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"
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
{
24 const WeakPtr
<WebGLContext
> mContext
;
26 explicit WebGLContextBoundObject(WebGLContext
* webgl
);
29 friend class HostWebGLContext
;
34 // this class is a mixin for GL objects that have dimensions
35 // that we need to track.
36 class WebGLRectangleObject
{
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
) {
54 void setDimensions(WebGLRectangleObject
* rect
) {
56 mWidth
= rect
->Width();
57 mHeight
= rect
->Height();
64 bool HasSameDimensionsAs(const WebGLRectangleObject
& other
) const {
65 return Width() == other
.Width() && Height() == other
.Height();
73 } // namespace mozilla