Bug 1890793: Assert CallArgs::newTarget is not gray. r=spidermonkey-reviewers,sfink...
[gecko.git] / dom / canvas / WebGLObjectModel.h
blob951a8dc83b46e10149fedf6d23a22c214ef44173
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef WEBGLOBJECTMODEL_H_
7 #define WEBGLOBJECTMODEL_H_
9 #include "mozilla/RefCounted.h"
10 #include "mozilla/WeakPtr.h"
11 #include "WebGLTypes.h"
13 namespace mozilla {
15 class WebGLContext;
17 ////
19 // This class is a mixin for objects that are tied to a specific
20 // context (which is to say, all of them). They provide initialization
21 // as well as comparison with the current context.
22 class WebGLContextBoundObject : public VRefCounted {
23 public:
24 const WeakPtr<WebGLContext> mContext;
26 explicit WebGLContextBoundObject(WebGLContext* webgl);
28 private:
29 friend class HostWebGLContext;
32 ////
34 // this class is a mixin for GL objects that have dimensions
35 // that we need to track.
36 class WebGLRectangleObject {
37 public:
38 WebGLRectangleObject() : mWidth(0), mHeight(0) {}
40 WebGLRectangleObject(GLsizei width, GLsizei height)
41 : mWidth(width), mHeight(height) {}
43 GLsizei Width() const { return mWidth; }
44 void width(GLsizei value) { mWidth = value; }
46 GLsizei Height() const { return mHeight; }
47 void height(GLsizei value) { mHeight = value; }
49 void setDimensions(GLsizei width, GLsizei height) {
50 mWidth = width;
51 mHeight = height;
54 void setDimensions(WebGLRectangleObject* rect) {
55 if (rect) {
56 mWidth = rect->Width();
57 mHeight = rect->Height();
58 } else {
59 mWidth = 0;
60 mHeight = 0;
64 bool HasSameDimensionsAs(const WebGLRectangleObject& other) const {
65 return Width() == other.Width() && Height() == other.Height();
68 protected:
69 GLsizei mWidth;
70 GLsizei mHeight;
73 } // namespace mozilla
75 #endif