Bug 1182371 - Misc WebGL cleanup. - r=kamidphish

This commit is contained in:
Jeff Gilbert 2015-07-14 17:37:28 -07:00
Родитель 902feca0b9
Коммит 2e4a1c88ee
77 изменённых файлов: 1082 добавлений и 743 удалений

Просмотреть файл

@ -116,6 +116,7 @@
#include "nsDeviceContext.h"
#include "nsFontMetrics.h"
#include "Units.h"
#include "CanvasUtils.h"
#undef free // apparently defined by some windows header, clashing with a free()
// method in SkTypes.h
@ -5277,12 +5278,12 @@ CanvasRenderingContext2D::PutImageData_explicit(int32_t x, int32_t y, uint32_t w
//uint8_t *src = aArray->Data();
uint8_t *dst = imgsurf->Data();
uint8_t* srcLine = aArray->Data() + copyY * (w * 4) + copyX * 4;
#if 0
#if 0
printf("PutImageData_explicit: dirty x=%d y=%d w=%d h=%d copy x=%d y=%d w=%d h=%d ext x=%d y=%d w=%d h=%d\n",
dirtyRect.x, dirtyRect.y, copyWidth, copyHeight,
copyX, copyY, copyWidth, copyHeight,
x, y, w, h);
#endif
#endif
for (uint32_t j = 0; j < copyHeight; j++) {
uint8_t *src = srcLine;
for (uint32_t i = 0; i < copyWidth; i++) {

Просмотреть файл

@ -13,7 +13,6 @@
#include "nsColor.h"
#include "mozilla/dom/HTMLCanvasElement.h"
#include "mozilla/dom/HTMLVideoElement.h"
#include "CanvasUtils.h"
#include "gfxTextRun.h"
#include "mozilla/ErrorResult.h"
#include "mozilla/dom/CanvasGradient.h"

Просмотреть файл

@ -28,9 +28,9 @@ WebGL1Context::~WebGL1Context()
}
JSObject*
WebGL1Context::WrapObject(JSContext* cx, JS::Handle<JSObject*> aGivenProto)
WebGL1Context::WrapObject(JSContext* cx, JS::Handle<JSObject*> givenProto)
{
return dom::WebGLRenderingContextBinding::Wrap(cx, this, aGivenProto);
return dom::WebGLRenderingContextBinding::Wrap(cx, this, givenProto);
}
bool

Просмотреть файл

@ -27,7 +27,7 @@ public:
}
// nsWrapperCache
virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> aGivenProto) override;
virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> givenProto) override;
private:
virtual bool ValidateAttribPointerType(bool integerMode, GLenum type, GLsizei* alignment, const char* info) override;

Просмотреть файл

@ -4,11 +4,8 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "WebGL1Context.h"
#include "WebGLBuffer.h"
#include "GLContext.h"
using namespace mozilla;
using namespace mozilla::dom;
namespace mozilla {
// -------------------------------------------------------------------------
// Buffer objects
@ -50,3 +47,5 @@ WebGL1Context::ValidateBufferUsageEnum(GLenum usage, const char* info)
ErrorInvalidEnumInfo(info, usage);
return false;
}
} // namespace mozilla

Просмотреть файл

@ -43,9 +43,9 @@ WebGL2Context::Create()
}
JSObject*
WebGL2Context::WrapObject(JSContext* cx, JS::Handle<JSObject*> aGivenProto)
WebGL2Context::WrapObject(JSContext* cx, JS::Handle<JSObject*> givenProto)
{
return dom::WebGL2RenderingContextBinding::Wrap(cx, this, aGivenProto);
return dom::WebGL2RenderingContextBinding::Wrap(cx, this, givenProto);
}
////////////////////////////////////////////////////////////////////////////////

Просмотреть файл

@ -38,7 +38,7 @@ public:
// -------------------------------------------------------------------------
// IMPLEMENT nsWrapperCache
virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> aGivenProto) override;
virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> givenProto) override;
// -------------------------------------------------------------------------
// Buffer objects - WebGL2ContextBuffers.cpp
@ -58,9 +58,9 @@ public:
void FramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer);
void GetInternalformatParameter(JSContext*, GLenum target, GLenum internalformat, GLenum pname, JS::MutableHandleValue retval);
void InvalidateFramebuffer(GLenum target, const dom::Sequence<GLenum>& attachments,
ErrorResult& aRv);
ErrorResult& rv);
void InvalidateSubFramebuffer (GLenum target, const dom::Sequence<GLenum>& attachments, GLint x, GLint y,
GLsizei width, GLsizei height, ErrorResult& aRv);
GLsizei width, GLsizei height, ErrorResult& rv);
void ReadBuffer(GLenum mode);
void RenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat,
GLsizei width, GLsizei height);
@ -75,12 +75,12 @@ public:
void TexImage3D(GLenum target, GLint level, GLenum internalformat,
GLsizei width, GLsizei height, GLsizei depth,
GLint border, GLenum format, GLenum type,
const Nullable<dom::ArrayBufferView> &pixels,
const dom::Nullable<dom::ArrayBufferView>& pixels,
ErrorResult& rv);
void TexSubImage3D(GLenum target, GLint level,
GLint xoffset, GLint yoffset, GLint zoffset,
GLsizei width, GLsizei height, GLsizei depth,
GLenum format, GLenum type, const Nullable<dom::ArrayBufferView>& pixels,
GLenum format, GLenum type, const dom::Nullable<dom::ArrayBufferView>& pixels,
ErrorResult& rv);
void TexSubImage3D(GLenum target, GLint level,
GLint xoffset, GLint yoffset, GLint zoffset,

Просмотреть файл

@ -7,9 +7,9 @@
#include "GLContext.h"
#include "WebGLBuffer.h"
#include "WebGLTransformFeedback.h"
using namespace mozilla;
using namespace mozilla::dom;
namespace mozilla {
bool
WebGL2Context::ValidateBufferTarget(GLenum target, const char* info)
@ -224,3 +224,5 @@ WebGL2Context::GetBufferSubData(GLenum target, GLintptr offset,
BindTransformFeedback(LOCAL_GL_TRANSFORM_FEEDBACK, currentTF);
}
}
} // namespace mozilla

Просмотреть файл

@ -4,10 +4,8 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "WebGL2Context.h"
#include "GLContext.h"
using namespace mozilla;
using namespace mozilla::dom;
namespace mozilla {
// -------------------------------------------------------------------------
// Writing to the drawing buffer
@ -17,3 +15,5 @@ WebGL2Context::DrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei
{
MOZ_CRASH("Not Implemented.");
}
} // namespace mozilla

Просмотреть файл

@ -6,10 +6,11 @@
#include "WebGL2Context.h"
#include "GLContext.h"
#include "GLScreenBuffer.h"
#include "WebGLContextUtils.h"
#include "WebGLFramebuffer.h"
using namespace mozilla;
using namespace mozilla::dom;
namespace mozilla {
// Returns one of FLOAT, INT, UNSIGNED_INT.
// Fixed-points (normalized ints) are considered FLOAT.
@ -374,7 +375,7 @@ TranslateDefaultAttachments(const dom::Sequence<GLenum>& in, dom::Sequence<GLenu
void
WebGL2Context::InvalidateFramebuffer(GLenum target,
const dom::Sequence<GLenum>& attachments,
ErrorResult& aRv)
ErrorResult& rv)
{
if (IsContextLost())
return;
@ -420,7 +421,7 @@ WebGL2Context::InvalidateFramebuffer(GLenum target,
if (!fb && !isDefaultFB) {
dom::Sequence<GLenum> tmpAttachments;
if (!TranslateDefaultAttachments(attachments, &tmpAttachments)) {
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
rv.Throw(NS_ERROR_OUT_OF_MEMORY);
return;
}
@ -433,7 +434,7 @@ WebGL2Context::InvalidateFramebuffer(GLenum target,
void
WebGL2Context::InvalidateSubFramebuffer(GLenum target, const dom::Sequence<GLenum>& attachments,
GLint x, GLint y, GLsizei width, GLsizei height,
ErrorResult& aRv)
ErrorResult& rv)
{
if (IsContextLost())
return;
@ -479,7 +480,7 @@ WebGL2Context::InvalidateSubFramebuffer(GLenum target, const dom::Sequence<GLenu
if (!fb && !isDefaultFB) {
dom::Sequence<GLenum> tmpAttachments;
if (!TranslateDefaultAttachments(attachments, &tmpAttachments)) {
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
rv.Throw(NS_ERROR_OUT_OF_MEMORY);
return;
}
@ -536,3 +537,5 @@ WebGL2Context::RenderbufferStorageMultisample(GLenum target, GLsizei samples,
RenderbufferStorage_base("renderbufferStorageMultisample", target, samples,
internalFormat, width, height);
}
} // namespace mozilla

Просмотреть файл

@ -6,8 +6,7 @@
#include "WebGL2Context.h"
#include "GLContext.h"
using namespace mozilla;
using namespace mozilla::dom;
namespace mozilla {
bool WebGL2Context::ValidateClearBuffer(const char* info, GLenum buffer, GLint drawbuffer, size_t elemCount)
{
@ -140,3 +139,5 @@ WebGL2Context::ClearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLi
MakeContextCurrent();
gl->fClearBufferfi(buffer, drawbuffer, depth, stencil);
}
} // namespace mozilla

Просмотреть файл

@ -7,8 +7,7 @@
#include "WebGLSampler.h"
#include "GLContext.h"
using namespace mozilla;
using namespace mozilla::dom;
namespace mozilla {
already_AddRefed<WebGLSampler>
WebGL2Context::CreateSampler()
@ -225,3 +224,5 @@ WebGL2Context::GetSamplerParameter(JSContext*, WebGLSampler* sampler, GLenum pna
return;
}
}
} // namespace mozilla

Просмотреть файл

@ -5,7 +5,14 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "WebGL2Context.h"
#include "GLContext.h"
#include "WebGLBuffer.h"
#include "WebGLContextUtils.h"
#include "WebGLFramebuffer.h"
#include "WebGLSampler.h"
#include "WebGLTransformFeedback.h"
#include "WebGLVertexArray.h"
namespace mozilla {

Просмотреть файл

@ -8,8 +8,7 @@
#include "GLContext.h"
#include "WebGLSync.h"
using namespace mozilla;
using namespace mozilla::dom;
namespace mozilla {
// -------------------------------------------------------------------------
// Sync objects
@ -131,3 +130,5 @@ WebGL2Context::GetSyncParameter(JSContext*, WebGLSync* sync, GLenum pname, JS::M
ErrorInvalidEnum("getSyncParameter: Invalid pname 0x%04x", pname);
}
} // namespace mozilla

Просмотреть файл

@ -3,12 +3,12 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "GLContext.h"
#include "WebGL2Context.h"
#include "WebGLContextUtils.h"
#include "GLContext.h"
#include "WebGLTexture.h"
using namespace mozilla;
using namespace mozilla::dom;
namespace mozilla {
bool
WebGL2Context::ValidateSizedInternalFormat(GLenum internalformat, const char* info)
@ -205,7 +205,7 @@ void
WebGL2Context::TexImage3D(GLenum target, GLint level, GLenum internalformat,
GLsizei width, GLsizei height, GLsizei depth,
GLint border, GLenum format, GLenum type,
const Nullable<dom::ArrayBufferView> &pixels,
const dom::Nullable<dom::ArrayBufferView> &pixels,
ErrorResult& rv)
{
if (IsContextLost())
@ -219,7 +219,7 @@ WebGL2Context::TexImage3D(GLenum target, GLint level, GLenum internalformat,
dataLength = 0;
jsArrayType = js::Scalar::MaxTypedArrayViewType;
} else {
const ArrayBufferView& view = pixels.Value();
const dom::ArrayBufferView& view = pixels.Value();
view.ComputeLengthAndData();
data = view.Data();
@ -318,7 +318,8 @@ void
WebGL2Context::TexSubImage3D(GLenum rawTarget, GLint level,
GLint xoffset, GLint yoffset, GLint zoffset,
GLsizei width, GLsizei height, GLsizei depth,
GLenum format, GLenum type, const Nullable<dom::ArrayBufferView>& pixels,
GLenum format, GLenum type,
const dom::Nullable<dom::ArrayBufferView>& pixels,
ErrorResult& rv)
{
if (IsContextLost())
@ -327,7 +328,7 @@ WebGL2Context::TexSubImage3D(GLenum rawTarget, GLint level,
if (pixels.IsNull())
return ErrorInvalidValue("texSubImage3D: pixels must not be null!");
const ArrayBufferView& view = pixels.Value();
const dom::ArrayBufferView& view = pixels.Value();
view.ComputeLengthAndData();
const WebGLTexImageFunc func = WebGLTexImageFunc::TexSubImage;
@ -489,3 +490,5 @@ WebGL2Context::GetTexParameterInternal(const TexTarget& target, GLenum pname)
return WebGLContext::GetTexParameterInternal(target, pname);
}
} // namespace mozilla

Просмотреть файл

@ -9,8 +9,7 @@
#include "WebGLTransformFeedback.h"
#include "GLContext.h"
using namespace mozilla;
using namespace mozilla::dom;
namespace mozilla {
// -------------------------------------------------------------------------
// Transform Feedback
@ -216,3 +215,5 @@ WebGL2Context::GetTransformFeedbackVarying(WebGLProgram* program, GLuint index)
return program->GetTransformFeedbackVarying(index);
}
} // namespace mozilla

Просмотреть файл

@ -4,12 +4,15 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "WebGL2Context.h"
#include "GLContext.h"
#include "mozilla/dom/WebGL2RenderingContextBinding.h"
#include "nsRefPtr.h"
#include "WebGLBuffer.h"
#include "WebGLContext.h"
#include "WebGLProgram.h"
#include "WebGLVertexArray.h"
#include "WebGLVertexAttribData.h"
#include "mozilla/dom/WebGL2RenderingContextBinding.h"
namespace mozilla {
@ -543,7 +546,7 @@ WebGL2Context::GetUniformBlockIndex(WebGLProgram* program,
void
WebGL2Context::GetActiveUniformBlockParameter(JSContext* cx, WebGLProgram* program,
GLuint uniformBlockIndex, GLenum pname,
Nullable<dom::OwningUnsignedLongOrUint32ArrayOrBoolean>& retval,
dom::Nullable<dom::OwningUnsignedLongOrUint32ArrayOrBoolean>& retval,
ErrorResult& rv)
{
retval.SetNull();

Просмотреть файл

@ -91,9 +91,9 @@ WebGLActiveInfo::WebGLActiveInfo(WebGLContext* webgl, GLint elemCount, GLenum el
////////////////////////////////////////////////////////////////////////////////
JSObject*
WebGLActiveInfo::WrapObject(JSContext* js, JS::Handle<JSObject*> aGivenProto)
WebGLActiveInfo::WrapObject(JSContext* js, JS::Handle<JSObject*> givenProto)
{
return dom::WebGLActiveInfoBinding::Wrap(js, this, aGivenProto);
return dom::WebGLActiveInfoBinding::Wrap(js, this, givenProto);
}
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_0(WebGLActiveInfo)

Просмотреть файл

@ -7,7 +7,6 @@
#define WEBGL_ACTIVE_INFO_H_
#include "GLDefs.h"
#include "js/TypeDecls.h"
#include "mozilla/Attributes.h"
#include "nsCycleCollectionParticipant.h" // NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS
#include "nsISupportsImpl.h" // NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING
@ -25,7 +24,7 @@ public:
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WebGLActiveInfo)
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WebGLActiveInfo)
virtual JSObject* WrapObject(JSContext* js, JS::Handle<JSObject*> aGivenProto) override;
virtual JSObject* WrapObject(JSContext* js, JS::Handle<JSObject*> givenProto) override;
WebGLContext* GetParentObject() const {
return mWebGL;

Просмотреть файл

@ -104,9 +104,9 @@ WebGLBuffer::IsElementArrayUsedWithMultipleTypes() const
}
JSObject*
WebGLBuffer::WrapObject(JSContext* cx, JS::Handle<JSObject*> aGivenProto)
WebGLBuffer::WrapObject(JSContext* cx, JS::Handle<JSObject*> givenProto)
{
return dom::WebGLBufferBinding::Wrap(cx, this, aGivenProto);
return dom::WebGLBufferBinding::Wrap(cx, this, givenProto);
}
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_0(WebGLBuffer)

Просмотреть файл

@ -8,10 +8,10 @@
#include "GLDefs.h"
#include "mozilla/LinkedList.h"
#include "mozilla/MemoryReporting.h"
#include "nsAutoPtr.h"
#include "nsWrapperCache.h"
#include "WebGLObjectModel.h"
#include "WebGLStrongTypes.h"
#include "WebGLTypes.h"
namespace mozilla {
@ -58,7 +58,7 @@ public:
return Context();
}
virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> aGivenProto) override;
virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> givenProto) override;
const GLenum mGLName;

Просмотреть файл

@ -5,8 +5,9 @@
#include "WebGLContext.h"
#include <queue>
#include "AccessCheck.h"
#include "CanvasUtils.h"
#include "gfxContext.h"
#include "gfxCrashReporterUtils.h"
#include "gfxPattern.h"
@ -16,13 +17,13 @@
#include "GLContext.h"
#include "GLContextProvider.h"
#include "GLReadTexImageHelper.h"
#include "GLScreenBuffer.h"
#include "ImageContainer.h"
#include "ImageEncoder.h"
#include "Layers.h"
#include "mozilla/dom/BindingUtils.h"
#include "mozilla/dom/HTMLVideoElement.h"
#include "mozilla/dom/ImageData.h"
#include "mozilla/dom/WebGLRenderingContextBinding.h"
#include "mozilla/EnumeratedArrayCycleCollection.h"
#include "mozilla/Preferences.h"
#include "mozilla/ProcessPriorityManager.h"
@ -33,18 +34,25 @@
#include "nsError.h"
#include "nsIClassInfoImpl.h"
#include "nsIConsoleService.h"
#include "nsIDOMEvent.h"
#include "nsIGfxInfo.h"
#include "nsIObserverService.h"
#include "nsIDOMEvent.h"
#include "nsIVariant.h"
#include "nsIWidget.h"
#include "nsIXPConnect.h"
#include "nsServiceManagerUtils.h"
#include "nsSVGEffects.h"
#include "prenv.h"
#include <queue>
#include "ScopedGLHelpers.h"
#ifdef MOZ_WIDGET_GONK
#include "mozilla/layers/ShadowLayers.h"
#endif
// Local
#include "CanvasUtils.h"
#include "WebGL1Context.h"
#include "WebGLActiveInfo.h"
#include "WebGLBuffer.h"
#include "WebGLContextLossHandler.h"
#include "WebGLContextUtils.h"
@ -52,17 +60,20 @@
#include "WebGLFramebuffer.h"
#include "WebGLMemoryTracker.h"
#include "WebGLObjectModel.h"
#include "WebGLProgram.h"
#include "WebGLQuery.h"
#include "WebGLSampler.h"
#include "WebGLShader.h"
#include "WebGLTransformFeedback.h"
#include "WebGLVertexArray.h"
#include "WebGLVertexAttribData.h"
#ifdef MOZ_WIDGET_GONK
#include "mozilla/layers/ShadowLayers.h"
#endif
// Generated
#include "mozilla/dom/WebGLRenderingContextBinding.h"
namespace mozilla {
using namespace mozilla;
using namespace mozilla::dom;
using namespace mozilla::gfx;
using namespace mozilla::gl;
@ -908,7 +919,7 @@ WebGLContext::SetDimensions(int32_t signedWidth, int32_t signedHeight)
!gfxPrefs::WebGLDisableFailIfMajorPerformanceCaveat() &&
!HasAcceleratedLayers(gfxInfo);
if (failIfMajorPerformanceCaveat) {
Nullable<dom::WebGLContextAttributes> contextAttributes;
dom::Nullable<dom::WebGLContextAttributes> contextAttributes;
this->GetContextAttributes(contextAttributes);
if (contextAttributes.Value().mFailIfMajorPerformanceCaveat) {
return NS_ERROR_FAILURE;
@ -1182,8 +1193,6 @@ WebGLContext::UpdateLastUseIndex()
static uint8_t gWebGLLayerUserData;
namespace mozilla {
class WebGLContextUserData : public LayerUserData
{
public:
@ -1222,8 +1231,6 @@ private:
nsRefPtr<HTMLCanvasElement> mCanvas;
};
} // end namespace mozilla
already_AddRefed<layers::CanvasLayer>
WebGLContext::GetCanvasLayer(nsDisplayListBuilder* builder,
CanvasLayer* oldLayer,
@ -1283,7 +1290,7 @@ WebGLContext::GetCanvasLayer(nsDisplayListBuilder* builder,
}
void
WebGLContext::GetContextAttributes(Nullable<dom::WebGLContextAttributes>& retval)
WebGLContext::GetContextAttributes(dom::Nullable<dom::WebGLContextAttributes>& retval)
{
retval.SetNull();
if (IsContextLost())
@ -1902,7 +1909,69 @@ WebGLContext::TexImageFromVideoElement(const TexImageTarget texImageTarget,
return ok;
}
size_t mozilla::RoundUpToMultipleOf(size_t value, size_t multiple)
void
WebGLContext::TexSubImage2D(GLenum rawTexImageTarget, GLint level, GLint xoffset,
GLint yoffset, GLenum format, GLenum type,
dom::Element* elt, ErrorResult* const out_rv)
{
// TODO: Consolidate all the parameter validation
// checks. Instead of spreading out the cheks in multple
// places, consolidate into one spot.
if (IsContextLost())
return;
if (!ValidateTexImageTarget(rawTexImageTarget,
WebGLTexImageFunc::TexSubImage,
WebGLTexDimensions::Tex2D))
{
ErrorInvalidEnumInfo("texSubImage2D: target", rawTexImageTarget);
return;
}
const TexImageTarget texImageTarget(rawTexImageTarget);
if (level < 0)
return ErrorInvalidValue("texSubImage2D: level is negative");
const int32_t maxLevel = MaxTextureLevelForTexImageTarget(texImageTarget);
if (level > maxLevel) {
ErrorInvalidValue("texSubImage2D: level %d is too large, max is %d",
level, maxLevel);
return;
}
WebGLTexture* tex = ActiveBoundTextureForTexImageTarget(texImageTarget);
if (!tex)
return ErrorInvalidOperation("texSubImage2D: no texture bound on active texture unit");
const WebGLTexture::ImageInfo& imageInfo = tex->ImageInfoAt(texImageTarget, level);
const TexInternalFormat internalFormat = imageInfo.EffectiveInternalFormat();
// Trying to handle the video by GPU directly first
if (TexImageFromVideoElement(texImageTarget, level,
internalFormat.get(), format, type, *elt))
{
return;
}
RefPtr<gfx::DataSourceSurface> data;
WebGLTexelFormat srcFormat;
nsLayoutUtils::SurfaceFromElementResult res = SurfaceFromElement(*elt);
*out_rv = SurfaceFromElementResultToImageSurface(res, data, &srcFormat);
if (out_rv->Failed() || !data)
return;
gfx::IntSize size = data->GetSize();
uint32_t byteLength = data->Stride() * size.height;
TexSubImage2D_base(texImageTarget.get(), level, xoffset, yoffset, size.width,
size.height, data->Stride(), format, type, data->GetData(),
byteLength, js::Scalar::MaxTypedArrayViewType, srcFormat,
mPixelStorePremultiplyAlpha);
}
size_t
RoundUpToMultipleOf(size_t value, size_t multiple)
{
size_t overshoot = value + multiple - 1;
return overshoot - (overshoot % multiple);
@ -1977,3 +2046,5 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(WebGLContext)
// ToSupports() method.
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMWebGLRenderingContext)
NS_INTERFACE_MAP_END
} // namespace mozilla

Просмотреть файл

@ -6,45 +6,40 @@
#ifndef WEBGLCONTEXT_H_
#define WEBGLCONTEXT_H_
#include <stdarg.h>
#include "GLDefs.h"
#include "mozilla/Attributes.h"
#include "mozilla/CheckedInt.h"
#include "mozilla/dom/HTMLCanvasElement.h"
#include "mozilla/dom/TypedArray.h"
#include "mozilla/EnumeratedArray.h"
#include "mozilla/ErrorResult.h"
#include "mozilla/gfx/2D.h"
#include "mozilla/LinkedList.h"
#include "mozilla/UniquePtr.h"
#include "mozilla/WeakPtr.h"
#include "GLDefs.h"
#include "WebGLActiveInfo.h"
#include "WebGLContextUnchecked.h"
#include "WebGLFormats.h"
#include "WebGLObjectModel.h"
#include "WebGLRenderbuffer.h"
#include "WebGLTexture.h"
#include "WebGLShaderValidator.h"
#include "WebGLStrongTypes.h"
#include <stdarg.h>
#include "nsTArray.h"
#include "nsCycleCollectionNoteChild.h"
#include "nsIDOMWebGLRenderingContext.h"
#include "nsICanvasRenderingContextInternal.h"
#include "mozilla/dom/HTMLCanvasElement.h"
#include "nsWrapperCache.h"
#include "nsIObserver.h"
#include "nsIDOMEventListener.h"
#include "nsLayoutUtils.h"
#include "GLContextProvider.h"
#include "mozilla/gfx/2D.h"
#include "nsTArray.h"
#include "nsWrapperCache.h"
#ifdef XP_MACOSX
#include "ForceDiscreteGPUHelperCGL.h"
#endif
#include "mozilla/dom/TypedArray.h"
#include "mozilla/ErrorResult.h"
// Local
#include "WebGLContextUnchecked.h"
#include "WebGLFormats.h"
#include "WebGLObjectModel.h"
#include "WebGLStrongTypes.h"
// Generated
#include "nsIDOMEventListener.h"
#include "nsIDOMWebGLRenderingContext.h"
#include "nsIObserver.h"
class nsIDocShell;
@ -108,6 +103,7 @@ class SourceSurface;
namespace webgl {
struct LinkedProgramInfo;
class ShaderValidator;
} // namespace webgl
WebGLTexelFormat GetWebGLTexelFormat(TexInternalFormat format);
@ -201,6 +197,10 @@ class WebGLContext
public:
WebGLContext();
protected:
virtual ~WebGLContext();
public:
MOZ_DECLARE_WEAKREFERENCE_TYPENAME(WebGLContext)
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
@ -208,7 +208,7 @@ public:
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(WebGLContext,
nsIDOMWebGLRenderingContext)
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override = 0;
virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> givenProto) override = 0;
NS_DECL_NSIDOMWEBGLRENDERINGCONTEXT
@ -542,7 +542,7 @@ public:
void PolygonOffset(GLfloat factor, GLfloat units);
void ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height,
GLenum format, GLenum type,
const Nullable<dom::ArrayBufferView>& pixels,
const dom::Nullable<dom::ArrayBufferView>& pixels,
ErrorResult& rv);
void RenderbufferStorage(GLenum target, GLenum internalFormat,
GLsizei width, GLsizei height);
@ -563,7 +563,7 @@ public:
GLenum dppass);
void TexImage2D(GLenum texImageTarget, GLint level, GLenum internalFormat,
GLsizei width, GLsizei height, GLint border, GLenum format,
GLenum type, const Nullable<dom::ArrayBufferView>& pixels,
GLenum type, const dom::Nullable<dom::ArrayBufferView>& pixels,
ErrorResult& rv);
void TexImage2D(GLenum texImageTarget, GLint level, GLenum internalFormat,
GLenum format, GLenum type, dom::ImageData* pixels,
@ -640,73 +640,25 @@ public:
void TexSubImage2D(GLenum texImageTarget, GLint level, GLint xoffset,
GLint yoffset, GLsizei width, GLsizei height,
GLenum format, GLenum type,
const Nullable<dom::ArrayBufferView>& pixels,
const dom::Nullable<dom::ArrayBufferView>& pixels,
ErrorResult& rv);
void TexSubImage2D(GLenum texImageTarget, GLint level, GLint xoffset,
GLint yoffset, GLenum format, GLenum type,
dom::ImageData* pixels, ErrorResult& rv);
void TexSubImage2D(GLenum rawTexImageTarget, GLint level, GLint xoffset,
GLint yoffset, GLenum format, GLenum type,
dom::Element* elt, ErrorResult* const out_rv);
// Allow whatever element types the bindings are willing to pass
// us in TexSubImage2D
template<class ElementType>
void TexSubImage2D(GLenum rawTexImageTarget, GLint level, GLint xoffset,
GLint yoffset, GLenum format, GLenum type,
ElementType& elt, ErrorResult& rv)
ElementType& elt, ErrorResult& out_rv)
{
// TODO: Consolidate all the parameter validation
// checks. Instead of spreading out the cheks in multple
// places, consolidate into one spot.
if (IsContextLost())
return;
if (!ValidateTexImageTarget(rawTexImageTarget,
WebGLTexImageFunc::TexSubImage,
WebGLTexDimensions::Tex2D))
{
ErrorInvalidEnumInfo("texSubImage2D: target", rawTexImageTarget);
return;
}
const TexImageTarget texImageTarget(rawTexImageTarget);
if (level < 0)
return ErrorInvalidValue("texSubImage2D: level is negative");
const int32_t maxLevel = MaxTextureLevelForTexImageTarget(texImageTarget);
if (level > maxLevel) {
ErrorInvalidValue("texSubImage2D: level %d is too large, max is %d",
level, maxLevel);
return;
}
WebGLTexture* tex = ActiveBoundTextureForTexImageTarget(texImageTarget);
if (!tex)
return ErrorInvalidOperation("texSubImage2D: no texture bound on active texture unit");
const WebGLTexture::ImageInfo& imageInfo = tex->ImageInfoAt(texImageTarget, level);
const TexInternalFormat internalFormat = imageInfo.EffectiveInternalFormat();
// Trying to handle the video by GPU directly first
if (TexImageFromVideoElement(texImageTarget, level,
internalFormat.get(), format, type, elt))
{
return;
}
RefPtr<gfx::DataSourceSurface> data;
WebGLTexelFormat srcFormat;
nsLayoutUtils::SurfaceFromElementResult res = SurfaceFromElement(elt);
rv = SurfaceFromElementResultToImageSurface(res, data, &srcFormat);
if (rv.Failed() || !data)
return;
gfx::IntSize size = data->GetSize();
uint32_t byteLength = data->Stride() * size.height;
return TexSubImage2D_base(texImageTarget.get(), level, xoffset, yoffset,
size.width, size.height, data->Stride(),
format, type, data->GetData(), byteLength,
js::Scalar::MaxTypedArrayViewType, srcFormat,
mPixelStorePremultiplyAlpha);
TexSubImage2D(rawTexImageTarget, level, xoffset, yoffset, format, type, &elt,
&out_rv);
}
void Uniform1i(WebGLUniformLocation* loc, GLint x);
@ -917,7 +869,7 @@ public:
void BufferData(GLenum target, WebGLsizeiptr size, GLenum usage);
void BufferData(GLenum target, const dom::ArrayBufferView& data,
GLenum usage);
void BufferData(GLenum target, const Nullable<dom::ArrayBuffer>& maybeData,
void BufferData(GLenum target, const dom::Nullable<dom::ArrayBuffer>& maybeData,
GLenum usage);
private:
@ -928,7 +880,7 @@ public:
void BufferSubData(GLenum target, WebGLsizeiptr byteOffset,
const dom::ArrayBufferView& data);
void BufferSubData(GLenum target, WebGLsizeiptr byteOffset,
const Nullable<dom::ArrayBuffer>& maybeData);
const dom::Nullable<dom::ArrayBuffer>& maybeData);
already_AddRefed<WebGLBuffer> CreateBuffer();
void DeleteBuffer(WebGLBuffer* buf);
bool IsBuffer(WebGLBuffer* buf);
@ -1087,8 +1039,6 @@ private:
// -----------------------------------------------------------------------------
// PROTECTED
protected:
virtual ~WebGLContext();
void SetFakeBlackStatus(WebGLContextFakeBlackStatus x) {
mFakeBlackStatus = x;
}

Просмотреть файл

@ -17,9 +17,7 @@
#include "WebGLVertexArray.h"
#include "WebGLVertexAttribData.h"
using namespace mozilla;
using namespace mozilla::dom;
using namespace mozilla::gl;
namespace mozilla {
// For a Tegra workaround.
static const int MAX_DRAW_CALLS_SINCE_FLUSH = 100;
@ -748,7 +746,7 @@ WebGLContext::UnbindFakeBlackTextures()
gl->fActiveTexture(LOCAL_GL_TEXTURE0 + mActiveTexture);
}
WebGLContext::FakeBlackTexture::FakeBlackTexture(GLContext* gl, TexTarget target, GLenum format)
WebGLContext::FakeBlackTexture::FakeBlackTexture(gl::GLContext* gl, TexTarget target, GLenum format)
: mGL(gl)
, mGLName(0)
{
@ -788,3 +786,5 @@ WebGLContext::FakeBlackTexture::~FakeBlackTexture()
mGL->fDeleteTextures(1, &mGLName);
}
}
} // namespace mozilla

Просмотреть файл

@ -393,7 +393,7 @@ WebGLContext::EnableExtension(WebGLExtensionID ext)
void
WebGLContext::GetSupportedExtensions(JSContext* cx,
Nullable< nsTArray<nsString> >& retval)
dom::Nullable< nsTArray<nsString> >& retval)
{
retval.SetNull();
if (IsContextLost())

Просмотреть файл

@ -9,7 +9,7 @@
#include "WebGLFramebuffer.h"
#include "GLContext.h"
using namespace mozilla;
namespace mozilla {
void
WebGLContext::Clear(GLbitfield mask)
@ -250,6 +250,4 @@ WebGLContext::StencilMaskSeparate(GLenum face, GLuint mask)
gl->fStencilMaskSeparate(face, mask);
}
} // namespace mozilla

Просмотреть файл

@ -4,6 +4,8 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "WebGLContext.h"
#include "WebGLActiveInfo.h"
#include "WebGLContextUtils.h"
#include "WebGLBuffer.h"
#include "WebGLVertexAttribData.h"
@ -17,9 +19,10 @@
#include "WebGLExtensions.h"
#include "WebGLVertexArray.h"
#include "nsString.h"
#include "nsDebug.h"
#include "nsReadableUtils.h"
#include "../../xpcom/base/nsRefPtr.h"
#include "nsString.h"
#include "gfxContext.h"
#include "gfxPlatform.h"
@ -49,7 +52,8 @@
#include "mozilla/dom/ToJSValue.h"
#include "mozilla/Endian.h"
using namespace mozilla;
namespace mozilla {
using namespace mozilla::dom;
using namespace mozilla::gfx;
using namespace mozilla::gl;
@ -1023,7 +1027,7 @@ WebGLContext::GetActiveUniform(WebGLProgram* prog, GLuint index)
void
WebGLContext::GetAttachedShaders(WebGLProgram* prog,
Nullable<nsTArray<nsRefPtr<WebGLShader>>>& retval)
dom::Nullable<nsTArray<nsRefPtr<WebGLShader>>>& retval)
{
retval.SetNull();
if (IsContextLost())
@ -1140,7 +1144,7 @@ WebGLContext::GetFramebufferAttachmentParameter(JSContext* cx,
MakeContextCurrent();
const WebGLFramebuffer::AttachPoint& fba = fb->GetAttachPoint(attachment);
const WebGLFBAttachPoint& fba = fb->GetAttachPoint(attachment);
if (fba.Renderbuffer()) {
switch (pname) {
@ -1972,7 +1976,7 @@ IsFormatAndTypeUnpackable(GLenum format, GLenum type)
void
WebGLContext::ReadPixels(GLint x, GLint y, GLsizei width,
GLsizei height, GLenum format,
GLenum type, const Nullable<ArrayBufferView> &pixels,
GLenum type, const dom::Nullable<ArrayBufferView>& pixels,
ErrorResult& rv)
{
if (IsContextLost())
@ -2087,9 +2091,9 @@ WebGLContext::ReadPixels(GLint x, GLint y, GLsizei width,
return;
MOZ_ASSERT(srcFormat != LOCAL_GL_NONE);
TexType type = TypeFromInternalFormat(srcFormat);
isSourceTypeFloat = (type == LOCAL_GL_FLOAT ||
type == LOCAL_GL_HALF_FLOAT);
TexType texType = TypeFromInternalFormat(srcFormat);
isSourceTypeFloat = (texType == LOCAL_GL_FLOAT ||
texType == LOCAL_GL_HALF_FLOAT);
} else {
ClearBackbufferIfNeeded();
@ -3407,7 +3411,8 @@ void
WebGLContext::TexImage2D(GLenum rawTarget, GLint level,
GLenum internalformat, GLsizei width,
GLsizei height, GLint border, GLenum format,
GLenum type, const Nullable<ArrayBufferView> &pixels, ErrorResult& rv)
GLenum type, const dom::Nullable<ArrayBufferView>& pixels,
ErrorResult& rv)
{
if (IsContextLost())
return;
@ -3608,7 +3613,7 @@ WebGLContext::TexSubImage2D(GLenum rawTarget, GLint level,
GLint xoffset, GLint yoffset,
GLsizei width, GLsizei height,
GLenum format, GLenum type,
const Nullable<ArrayBufferView> &pixels,
const dom::Nullable<ArrayBufferView>& pixels,
ErrorResult& rv)
{
if (IsContextLost())
@ -3684,7 +3689,7 @@ WebGLContext::RestoreContext()
}
WebGLTexelFormat
mozilla::GetWebGLTexelFormat(TexInternalFormat effectiveInternalFormat)
GetWebGLTexelFormat(TexInternalFormat effectiveInternalFormat)
{
switch (effectiveInternalFormat.get()) {
case LOCAL_GL_RGBA8: return WebGLTexelFormat::RGBA8;
@ -3768,3 +3773,5 @@ WebGLContext::SampleCoverage(GLclampf value, WebGLboolean invert) {
MakeContextCurrent();
gl->fSampleCoverage(value, invert);
}
} // namespace mozilla

Просмотреть файл

@ -3,10 +3,11 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "WebGLBuffer.h"
#include "WebGLContext.h"
#include "WebGLMemoryTracker.h"
using namespace mozilla;
namespace mozilla {
NS_IMPL_ISUPPORTS(WebGLObserver, nsIObserver)
@ -151,3 +152,5 @@ WebGLMemoryTracker::GetShaderSize()
}
return result;
}
} // namespace mozilla

Просмотреть файл

@ -15,8 +15,7 @@
#include "GLContext.h"
#include "mozilla/dom/ToJSValue.h"
using namespace mozilla;
using namespace dom;
namespace mozilla {
void
WebGLContext::Disable(GLenum cap)
@ -353,7 +352,8 @@ WebGLContext::GetParameter(JSContext* cx, GLenum pname, ErrorResult& rv)
return JS::Int32Value(0);
case LOCAL_GL_COMPRESSED_TEXTURE_FORMATS: {
uint32_t length = mCompressedTextureFormats.Length();
JSObject* obj = Uint32Array::Create(cx, this, length, mCompressedTextureFormats.Elements());
JSObject* obj = dom::Uint32Array::Create(cx, this, length,
mCompressedTextureFormats.Elements());
if (!obj) {
rv = NS_ERROR_OUT_OF_MEMORY;
}
@ -419,7 +419,7 @@ WebGLContext::GetParameter(JSContext* cx, GLenum pname, ErrorResult& rv)
case LOCAL_GL_ALIASED_LINE_WIDTH_RANGE: {
GLfloat fv[2] = { 0 };
gl->fGetFloatv(pname, fv);
JSObject* obj = Float32Array::Create(cx, this, 2, fv);
JSObject* obj = dom::Float32Array::Create(cx, this, 2, fv);
if (!obj) {
rv = NS_ERROR_OUT_OF_MEMORY;
}
@ -431,7 +431,7 @@ WebGLContext::GetParameter(JSContext* cx, GLenum pname, ErrorResult& rv)
case LOCAL_GL_BLEND_COLOR: {
GLfloat fv[4] = { 0 };
gl->fGetFloatv(pname, fv);
JSObject* obj = Float32Array::Create(cx, this, 4, fv);
JSObject* obj = dom::Float32Array::Create(cx, this, 4, fv);
if (!obj) {
rv = NS_ERROR_OUT_OF_MEMORY;
}
@ -442,7 +442,7 @@ WebGLContext::GetParameter(JSContext* cx, GLenum pname, ErrorResult& rv)
case LOCAL_GL_MAX_VIEWPORT_DIMS: {
GLint iv[2] = { 0 };
gl->fGetIntegerv(pname, iv);
JSObject* obj = Int32Array::Create(cx, this, 2, iv);
JSObject* obj = dom::Int32Array::Create(cx, this, 2, iv);
if (!obj) {
rv = NS_ERROR_OUT_OF_MEMORY;
}
@ -454,7 +454,7 @@ WebGLContext::GetParameter(JSContext* cx, GLenum pname, ErrorResult& rv)
case LOCAL_GL_VIEWPORT: {
GLint iv[4] = { 0 };
gl->fGetIntegerv(pname, iv);
JSObject* obj = Int32Array::Create(cx, this, 4, iv);
JSObject* obj = dom::Int32Array::Create(cx, this, 4, iv);
if (!obj) {
rv = NS_ERROR_OUT_OF_MEMORY;
}
@ -468,7 +468,7 @@ WebGLContext::GetParameter(JSContext* cx, GLenum pname, ErrorResult& rv)
bool vals[4] = { bool(gl_bv[0]), bool(gl_bv[1]),
bool(gl_bv[2]), bool(gl_bv[3]) };
JS::Rooted<JS::Value> arr(cx);
if (!ToJSValue(cx, vals, &arr)) {
if (!dom::ToJSValue(cx, vals, &arr)) {
rv = NS_ERROR_OUT_OF_MEMORY;
}
return arr;
@ -593,3 +593,5 @@ WebGLContext::GetStateTrackingSlot(GLenum cap)
return nullptr;
}
} // namespace mozilla

Просмотреть файл

@ -27,8 +27,6 @@
namespace mozilla {
using namespace gl;
bool
IsGLDepthFormat(TexInternalFormat internalformat)
{
@ -496,7 +494,7 @@ WebGLContext::GenerateWarning(const char* fmt, va_list ap)
return;
}
AutoJSAPI api;
dom::AutoJSAPI api;
if (!api.Init(mCanvasElement->OwnerDoc()->GetScopeObject())) {
return;
}

Просмотреть файл

@ -7,10 +7,12 @@
#define WEBGL_CONTEXT_UTILS_H_
#include "WebGLContext.h"
#include "WebGLStrongTypes.h"
#include "mozilla/Assertions.h"
#include "mozilla/dom/BindingUtils.h"
#include "WebGLStrongTypes.h"
namespace mozilla {
bool IsGLDepthFormat(TexInternalFormat webGLFormat);

Просмотреть файл

@ -14,11 +14,13 @@
#include "mozilla/Preferences.h"
#include "mozilla/Services.h"
#include "nsIObserverService.h"
#include "WebGLActiveInfo.h"
#include "WebGLBuffer.h"
#include "WebGLContextUtils.h"
#include "WebGLFramebuffer.h"
#include "WebGLProgram.h"
#include "WebGLRenderbuffer.h"
#include "WebGLSampler.h"
#include "WebGLShader.h"
#include "WebGLTexture.h"
#include "WebGLUniformLocation.h"

Просмотреть файл

@ -16,8 +16,7 @@
#include "WebGLVertexArray.h"
#include "WebGLVertexAttribData.h"
using namespace mozilla;
using namespace dom;
namespace mozilla {
void
WebGLContext::VertexAttrib1f(GLuint index, GLfloat x0)
@ -306,7 +305,7 @@ WebGLContext::GetVertexAttrib(JSContext* cx, GLuint index, GLenum pname,
vec[2] = mVertexAttrib0Vector[2];
vec[3] = mVertexAttrib0Vector[3];
}
JSObject* obj = Float32Array::Create(cx, this, 4, vec);
JSObject* obj = dom::Float32Array::Create(cx, this, 4, vec);
if (!obj) {
rv.Throw(NS_ERROR_OUT_OF_MEMORY);
}
@ -410,3 +409,5 @@ WebGLContext::VertexAttribDivisor(GLuint index, GLuint divisor)
gl->fVertexAttribDivisor(index, divisor);
}
} // namespace mozilla

Просмотреть файл

@ -3,10 +3,9 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "WebGLContext.h"
#include "WebGLExtensions.h"
using namespace mozilla;
namespace mozilla {
WebGLExtensionBase::WebGLExtensionBase(WebGLContext* context)
: WebGLContextBoundObject(context)
@ -28,3 +27,5 @@ NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_0(WebGLExtensionBase)
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(WebGLExtensionBase, AddRef)
NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(WebGLExtensionBase, Release)
} // namespace mozilla

Просмотреть файл

@ -6,14 +6,20 @@
#ifndef WEBGL_EXTENSIONS_H_
#define WEBGL_EXTENSIONS_H_
#include "jsapi.h"
#include "mozilla/AlreadyAddRefed.h"
#include "mozilla/Attributes.h"
#include "nsWrapperCache.h"
#include "WebGLObjectModel.h"
#include "WebGLTypes.h"
namespace mozilla {
namespace dom {
template<typename T>
class Sequence;
} // namespace dom
class WebGLContext;
class WebGLShader;
class WebGLQuery;
@ -43,12 +49,12 @@ protected:
};
#define DECL_WEBGL_EXTENSION_GOOP \
virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> aGivenProto) override;
virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> givenProto) override;
#define IMPL_WEBGL_EXTENSION_GOOP(WebGLExtensionType, WebGLBindingType)\
JSObject* \
WebGLExtensionType::WrapObject(JSContext* cx, JS::Handle<JSObject*> aGivenProto) { \
return dom::WebGLBindingType##Binding::Wrap(cx, this, aGivenProto); \
WebGLExtensionType::WrapObject(JSContext* cx, JS::Handle<JSObject*> givenProto) { \
return dom::WebGLBindingType##Binding::Wrap(cx, this, givenProto); \
}
class WebGLExtensionCompressedTextureATC

Просмотреть файл

@ -5,6 +5,7 @@
#include "WebGLFormats.h"
#include "GLDefs.h"
#include "mozilla/StaticMutex.h"
namespace mozilla {

Просмотреть файл

@ -15,21 +15,21 @@
namespace mozilla {
WebGLFramebuffer::AttachPoint::AttachPoint(WebGLFramebuffer* fb,
FBAttachment attachmentPoint)
WebGLFBAttachPoint::WebGLFBAttachPoint(WebGLFramebuffer* fb,
FBAttachment attachmentPoint)
: mFB(fb)
, mAttachmentPoint(attachmentPoint)
, mTexImageTarget(LOCAL_GL_NONE)
{ }
WebGLFramebuffer::AttachPoint::~AttachPoint()
WebGLFBAttachPoint::~WebGLFBAttachPoint()
{
MOZ_ASSERT(!mRenderbufferPtr);
MOZ_ASSERT(!mTexturePtr);
}
bool
WebGLFramebuffer::AttachPoint::IsDeleteRequested() const
WebGLFBAttachPoint::IsDeleteRequested() const
{
return Texture() ? Texture()->IsDeleteRequested()
: Renderbuffer() ? Renderbuffer()->IsDeleteRequested()
@ -37,14 +37,14 @@ WebGLFramebuffer::AttachPoint::IsDeleteRequested() const
}
bool
WebGLFramebuffer::AttachPoint::IsDefined() const
WebGLFBAttachPoint::IsDefined() const
{
return Renderbuffer() ||
(Texture() && Texture()->HasImageInfoAt(ImageTarget(), 0));
}
bool
WebGLFramebuffer::AttachPoint::HasAlpha() const
WebGLFBAttachPoint::HasAlpha() const
{
MOZ_ASSERT(HasImage());
@ -62,7 +62,7 @@ WebGLFramebuffer::AttachPoint::HasAlpha() const
}
GLenum
WebGLFramebuffer::GetFormatForAttachment(const WebGLFramebuffer::AttachPoint& attachment) const
WebGLFramebuffer::GetFormatForAttachment(const WebGLFBAttachPoint& attachment) const
{
MOZ_ASSERT(attachment.IsDefined());
MOZ_ASSERT(attachment.Texture() || attachment.Renderbuffer());
@ -83,7 +83,7 @@ WebGLFramebuffer::GetFormatForAttachment(const WebGLFramebuffer::AttachPoint& at
}
TexInternalFormat
WebGLFramebuffer::AttachPoint::EffectiveInternalFormat() const
WebGLFBAttachPoint::EffectiveInternalFormat() const
{
const WebGLTexture* tex = Texture();
if (tex && tex->HasImageInfoAt(mTexImageTarget, mTexImageLevel)) {
@ -99,7 +99,7 @@ WebGLFramebuffer::AttachPoint::EffectiveInternalFormat() const
}
bool
WebGLFramebuffer::AttachPoint::IsReadableFloat() const
WebGLFBAttachPoint::IsReadableFloat() const
{
TexInternalFormat internalformat = EffectiveInternalFormat();
MOZ_ASSERT(internalformat != LOCAL_GL_NONE);
@ -110,7 +110,7 @@ WebGLFramebuffer::AttachPoint::IsReadableFloat() const
}
static void
UnmarkAttachment(WebGLFramebuffer::AttachPoint& attachment)
UnmarkAttachment(WebGLFBAttachPoint& attachment)
{
WebGLFramebufferAttachable* maybe = attachment.Texture();
if (!maybe)
@ -121,7 +121,7 @@ UnmarkAttachment(WebGLFramebuffer::AttachPoint& attachment)
}
void
WebGLFramebuffer::AttachPoint::SetTexImage(WebGLTexture* tex, TexImageTarget target,
WebGLFBAttachPoint::SetTexImage(WebGLTexture* tex, TexImageTarget target,
GLint level)
{
mFB->InvalidateFramebufferStatus();
@ -138,7 +138,7 @@ WebGLFramebuffer::AttachPoint::SetTexImage(WebGLTexture* tex, TexImageTarget tar
}
void
WebGLFramebuffer::AttachPoint::SetRenderbuffer(WebGLRenderbuffer* rb)
WebGLFBAttachPoint::SetRenderbuffer(WebGLRenderbuffer* rb)
{
mFB->InvalidateFramebufferStatus();
@ -152,7 +152,7 @@ WebGLFramebuffer::AttachPoint::SetRenderbuffer(WebGLRenderbuffer* rb)
}
bool
WebGLFramebuffer::AttachPoint::HasUninitializedImageData() const
WebGLFBAttachPoint::HasUninitializedImageData() const
{
if (!HasImage())
return false;
@ -171,7 +171,7 @@ WebGLFramebuffer::AttachPoint::HasUninitializedImageData() const
}
void
WebGLFramebuffer::AttachPoint::SetImageDataStatus(WebGLImageDataStatus newStatus)
WebGLFBAttachPoint::SetImageDataStatus(WebGLImageDataStatus newStatus)
{
if (!HasImage())
return;
@ -191,7 +191,7 @@ WebGLFramebuffer::AttachPoint::SetImageDataStatus(WebGLImageDataStatus newStatus
}
bool
WebGLFramebuffer::AttachPoint::HasImage() const
WebGLFBAttachPoint::HasImage() const
{
if (Texture() && Texture()->HasImageInfoAt(mTexImageTarget, mTexImageLevel))
return true;
@ -203,7 +203,7 @@ WebGLFramebuffer::AttachPoint::HasImage() const
}
const WebGLRectangleObject&
WebGLFramebuffer::AttachPoint::RectangleObject() const
WebGLFBAttachPoint::RectangleObject() const
{
MOZ_ASSERT(HasImage(),
"Make sure it has an image before requesting the rectangle.");
@ -285,7 +285,7 @@ WebGLContext::IsFormatValidForFB(GLenum sizedFormat) const
}
bool
WebGLFramebuffer::AttachPoint::IsComplete() const
WebGLFBAttachPoint::IsComplete() const
{
if (!HasImage())
return false;
@ -353,7 +353,7 @@ WebGLFramebuffer::AttachPoint::IsComplete() const
}
void
WebGLFramebuffer::AttachPoint::FinalizeAttachment(gl::GLContext* gl,
WebGLFBAttachPoint::FinalizeAttachment(gl::GLContext* gl,
FBAttachment attachmentLoc) const
{
if (!HasImage()) {
@ -454,7 +454,7 @@ WebGLFramebuffer::FramebufferRenderbuffer(FBAttachment attachPointEnum,
return;
// `attachPoint` is validated by ValidateFramebufferAttachment().
AttachPoint& attachPoint = GetAttachPoint(attachPointEnum);
WebGLFBAttachPoint& attachPoint = GetAttachPoint(attachPointEnum);
attachPoint.SetRenderbuffer(rb);
InvalidateFramebufferStatus();
@ -481,13 +481,13 @@ WebGLFramebuffer::FramebufferTexture2D(FBAttachment attachPointEnum,
}
}
AttachPoint& attachPoint = GetAttachPoint(attachPointEnum);
WebGLFBAttachPoint& attachPoint = GetAttachPoint(attachPointEnum);
attachPoint.SetTexImage(tex, texImageTarget, level);
InvalidateFramebufferStatus();
}
WebGLFramebuffer::AttachPoint&
WebGLFBAttachPoint&
WebGLFramebuffer::GetAttachPoint(FBAttachment attachPoint)
{
switch (attachPoint.get()) {
@ -581,7 +581,7 @@ WebGLFramebuffer::HasDefinedAttachments() const
}
static bool
IsIncomplete(const WebGLFramebuffer::AttachPoint& cur)
IsIncomplete(const WebGLFBAttachPoint& cur)
{
return cur.IsDefined() && !cur.IsComplete();
}
@ -631,7 +631,7 @@ WebGLFramebuffer::GetAnyRectObject() const
}
static bool
RectsMatch(const WebGLFramebuffer::AttachPoint& attachment,
RectsMatch(const WebGLFBAttachPoint& attachment,
const WebGLRectangleObject& rect)
{
return attachment.RectangleObject().HasSameDimensionsAs(rect);
@ -839,7 +839,7 @@ void WebGLFramebuffer::EnsureColorAttachPoints(size_t colorAttachmentId)
while (ColorAttachmentCount() < WebGLContext::kMaxColorAttachments) {
GLenum nextAttachPoint = LOCAL_GL_COLOR_ATTACHMENT0 + ColorAttachmentCount();
mMoreColorAttachments.AppendElement(AttachPoint(this, nextAttachPoint));
mMoreColorAttachments.AppendElement(WebGLFBAttachPoint(this, nextAttachPoint));
}
MOZ_ASSERT(ColorAttachmentCount() == WebGLContext::kMaxColorAttachments);
@ -941,20 +941,20 @@ WebGLFramebuffer::ValidateForRead(const char* info, TexInternalFormat* const out
// Goop.
JSObject*
WebGLFramebuffer::WrapObject(JSContext* cx, JS::Handle<JSObject*> aGivenProto)
WebGLFramebuffer::WrapObject(JSContext* cx, JS::Handle<JSObject*> givenProto)
{
return dom::WebGLFramebufferBinding::Wrap(cx, this, aGivenProto);
return dom::WebGLFramebufferBinding::Wrap(cx, this, givenProto);
}
inline void
ImplCycleCollectionUnlink(mozilla::WebGLFramebuffer::AttachPoint& field)
ImplCycleCollectionUnlink(mozilla::WebGLFBAttachPoint& field)
{
field.Unlink();
}
inline void
ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& callback,
mozilla::WebGLFramebuffer::AttachPoint& field,
mozilla::WebGLFBAttachPoint& field,
const char* name,
uint32_t flags = 0)
{

Просмотреть файл

@ -7,12 +7,17 @@
#define WEBGL_FRAMEBUFFER_H_
#include "mozilla/LinkedList.h"
#include "mozilla/WeakPtr.h"
#include "nsWrapperCache.h"
#include "WebGLObjectModel.h"
#include "WebGLStrongTypes.h"
#include "WebGLRenderbuffer.h"
#include "WebGLTexture.h"
namespace mozilla {
class WebGLFramebuffer;
class WebGLRenderbuffer;
class WebGLTexture;
@ -20,6 +25,72 @@ namespace gl {
class GLContext;
} // namespace gl
class WebGLFBAttachPoint
{
public:
WebGLFramebuffer* const mFB;
private:
WebGLRefPtr<WebGLTexture> mTexturePtr;
WebGLRefPtr<WebGLRenderbuffer> mRenderbufferPtr;
FBAttachment mAttachmentPoint;
TexImageTarget mTexImageTarget;
GLint mTexImageLevel;
public:
WebGLFBAttachPoint(WebGLFramebuffer* fb, FBAttachment attachmentPoint);
~WebGLFBAttachPoint();
void Unlink() {
mRenderbufferPtr = nullptr;
mTexturePtr = nullptr;
}
bool IsDefined() const;
bool IsDeleteRequested() const;
TexInternalFormat EffectiveInternalFormat() const;
bool HasAlpha() const;
bool IsReadableFloat() const;
void Clear() {
SetRenderbuffer(nullptr);
}
void SetTexImage(WebGLTexture* tex, TexImageTarget target, GLint level);
void SetRenderbuffer(WebGLRenderbuffer* rb);
const WebGLTexture* Texture() const {
return mTexturePtr;
}
WebGLTexture* Texture() {
return mTexturePtr;
}
const WebGLRenderbuffer* Renderbuffer() const {
return mRenderbufferPtr;
}
WebGLRenderbuffer* Renderbuffer() {
return mRenderbufferPtr;
}
TexImageTarget ImageTarget() const {
return mTexImageTarget;
}
GLint MipLevel() const {
return mTexImageLevel;
}
bool HasUninitializedImageData() const;
void SetImageDataStatus(WebGLImageDataStatus x);
const WebGLRectangleObject& RectangleObject() const;
bool HasImage() const;
bool IsComplete() const;
void FinalizeAttachment(gl::GLContext* gl,
FBAttachment attachmentLoc) const;
};
class WebGLFramebuffer final
: public nsWrapperCache
, public WebGLRefCountedObject<WebGLFramebuffer>
@ -32,72 +103,6 @@ class WebGLFramebuffer final
public:
MOZ_DECLARE_WEAKREFERENCE_TYPENAME(WebGLFramebuffer)
class AttachPoint
{
public:
WebGLFramebuffer* const mFB;
private:
WebGLRefPtr<WebGLTexture> mTexturePtr;
WebGLRefPtr<WebGLRenderbuffer> mRenderbufferPtr;
FBAttachment mAttachmentPoint;
TexImageTarget mTexImageTarget;
GLint mTexImageLevel;
public:
AttachPoint(WebGLFramebuffer* fb, FBAttachment attachmentPoint);
~AttachPoint();
void Unlink() {
mRenderbufferPtr = nullptr;
mTexturePtr = nullptr;
}
bool IsDefined() const;
bool IsDeleteRequested() const;
TexInternalFormat EffectiveInternalFormat() const;
bool HasAlpha() const;
bool IsReadableFloat() const;
void Clear() {
SetRenderbuffer(nullptr);
}
void SetTexImage(WebGLTexture* tex, TexImageTarget target, GLint level);
void SetRenderbuffer(WebGLRenderbuffer* rb);
const WebGLTexture* Texture() const {
return mTexturePtr;
}
WebGLTexture* Texture() {
return mTexturePtr;
}
const WebGLRenderbuffer* Renderbuffer() const {
return mRenderbufferPtr;
}
WebGLRenderbuffer* Renderbuffer() {
return mRenderbufferPtr;
}
TexImageTarget ImageTarget() const {
return mTexImageTarget;
}
GLint MipLevel() const {
return mTexImageLevel;
}
bool HasUninitializedImageData() const;
void SetImageDataStatus(WebGLImageDataStatus x);
const WebGLRectangleObject& RectangleObject() const;
bool HasImage() const;
bool IsComplete() const;
void FinalizeAttachment(gl::GLContext* gl,
FBAttachment attachmentLoc) const;
};
const GLuint mGLName;
private:
@ -106,11 +111,11 @@ private:
GLenum mReadBufferMode;
// No need to chase pointers for the oft-used color0.
AttachPoint mColorAttachment0;
AttachPoint mDepthAttachment;
AttachPoint mStencilAttachment;
AttachPoint mDepthStencilAttachment;
nsTArray<AttachPoint> mMoreColorAttachments;
WebGLFBAttachPoint mColorAttachment0;
WebGLFBAttachPoint mDepthAttachment;
WebGLFBAttachPoint mStencilAttachment;
WebGLFBAttachPoint mDepthStencilAttachment;
nsTArray<WebGLFBAttachPoint> mMoreColorAttachments;
#ifdef ANDROID
// Bug 1140459: Some drivers (including our test slaves!) don't
@ -148,7 +153,7 @@ public:
FBStatus CheckFramebufferStatus() const;
GLenum
GetFormatForAttachment(const WebGLFramebuffer::AttachPoint& attachment) const;
GetFormatForAttachment(const WebGLFBAttachPoint& attachment) const;
bool HasDepthStencilConflict() const {
return int(mDepthAttachment.IsDefined()) +
@ -159,25 +164,25 @@ public:
size_t ColorAttachmentCount() const {
return 1 + mMoreColorAttachments.Length();
}
const AttachPoint& ColorAttachment(size_t colorAttachmentId) const {
const WebGLFBAttachPoint& ColorAttachment(size_t colorAttachmentId) const {
MOZ_ASSERT(colorAttachmentId < ColorAttachmentCount());
return colorAttachmentId ? mMoreColorAttachments[colorAttachmentId - 1]
: mColorAttachment0;
}
const AttachPoint& DepthAttachment() const {
const WebGLFBAttachPoint& DepthAttachment() const {
return mDepthAttachment;
}
const AttachPoint& StencilAttachment() const {
const WebGLFBAttachPoint& StencilAttachment() const {
return mStencilAttachment;
}
const AttachPoint& DepthStencilAttachment() const {
const WebGLFBAttachPoint& DepthStencilAttachment() const {
return mDepthStencilAttachment;
}
AttachPoint& GetAttachPoint(FBAttachment attachPointEnum);
WebGLFBAttachPoint& GetAttachPoint(FBAttachment attachPointEnum);
void DetachTexture(const WebGLTexture* tex);
@ -191,7 +196,7 @@ public:
void FinalizeAttachments() const;
virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> aGivenProto) override;
virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> givenProto) override;
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WebGLFramebuffer)
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WebGLFramebuffer)

Просмотреть файл

@ -5,15 +5,12 @@
#include "WebGLFramebufferAttachable.h"
#include "WebGLContext.h"
#include "WebGLFramebuffer.h"
#include "WebGLRenderbuffer.h"
#include "WebGLTexture.h"
namespace mozilla {
void
WebGLFramebufferAttachable::MarkAttachment(const WebGLFramebuffer::AttachPoint& attachment)
WebGLFramebufferAttachable::MarkAttachment(const WebGLFBAttachPoint& attachment)
{
if (mAttachmentPoints.Contains(&attachment))
return; // Already attached. Ignore.
@ -22,7 +19,7 @@ WebGLFramebufferAttachable::MarkAttachment(const WebGLFramebuffer::AttachPoint&
}
void
WebGLFramebufferAttachable::UnmarkAttachment(const WebGLFramebuffer::AttachPoint& attachment)
WebGLFramebufferAttachable::UnmarkAttachment(const WebGLFBAttachPoint& attachment)
{
const size_t i = mAttachmentPoints.IndexOf(&attachment);
if (i == mAttachmentPoints.NoIndex) {

Просмотреть файл

@ -6,22 +6,19 @@
#ifndef WEBGL_FRAMEBUFFER_ATTACHABLE_H_
#define WEBGL_FRAMEBUFFER_ATTACHABLE_H_
#include "GLDefs.h"
#include "mozilla/WeakPtr.h"
#include "nsTArray.h"
#include "WebGLFramebuffer.h"
#include "WebGLStrongTypes.h"
namespace mozilla {
class WebGLFBAttachPoint;
class WebGLFramebufferAttachable
{
nsTArray<const WebGLFramebuffer::AttachPoint*> mAttachmentPoints;
nsTArray<const WebGLFBAttachPoint*> mAttachmentPoints;
public:
// Track FBO/Attachment combinations
void MarkAttachment(const WebGLFramebuffer::AttachPoint& attachment);
void UnmarkAttachment(const WebGLFramebuffer::AttachPoint& attachment);
void MarkAttachment(const WebGLFBAttachPoint& attachment);
void UnmarkAttachment(const WebGLFBAttachPoint& attachment);
void InvalidateStatusOfAttachedFBs() const;
};

Просмотреть файл

@ -0,0 +1,275 @@
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "WebGLMemoryTracker.h"
#include "WebGLBuffer.h"
#include "WebGLContext.h"
#include "WebGLVertexAttribData.h"
#include "WebGLProgram.h"
#include "WebGLRenderbuffer.h"
#include "WebGLShader.h"
#include "WebGLTexture.h"
#include "WebGLUniformLocation.h"
namespace mozilla {
NS_IMPL_ISUPPORTS(WebGLObserver, nsIObserver)
NS_IMETHODIMP
WebGLMemoryTracker::CollectReports(nsIHandleReportCallback* handleReport,
nsISupports* data, bool)
{
#define REPORT(_path, _kind, _units, _amount, _desc) \
do { \
nsresult rv; \
rv = handleReport->Callback(EmptyCString(), NS_LITERAL_CSTRING(_path), \
_kind, _units, _amount, \
NS_LITERAL_CSTRING(_desc), data); \
NS_ENSURE_SUCCESS(rv, rv); \
} while (0)
REPORT("webgl-texture-memory",
KIND_OTHER, UNITS_BYTES, GetTextureMemoryUsed(),
"Memory used by WebGL textures.The OpenGL"
" implementation is free to store these textures in either video"
" memory or main memory. This measurement is only a lower bound,"
" actual memory usage may be higher for example if the storage"
" is strided.");
REPORT("webgl-texture-count",
KIND_OTHER, UNITS_COUNT, GetTextureCount(),
"Number of WebGL textures.");
REPORT("webgl-buffer-memory",
KIND_OTHER, UNITS_BYTES, GetBufferMemoryUsed(),
"Memory used by WebGL buffers. The OpenGL"
" implementation is free to store these buffers in either video"
" memory or main memory. This measurement is only a lower bound,"
" actual memory usage may be higher for example if the storage"
" is strided.");
REPORT("explicit/webgl/buffer-cache-memory",
KIND_HEAP, UNITS_BYTES, GetBufferCacheMemoryUsed(),
"Memory used by WebGL buffer caches. The WebGL"
" implementation caches the contents of element array buffers"
" only.This adds up with the webgl-buffer-memory value, but"
" contrary to it, this one represents bytes on the heap,"
" not managed by OpenGL.");
REPORT("webgl-buffer-count",
KIND_OTHER, UNITS_COUNT, GetBufferCount(),
"Number of WebGL buffers.");
REPORT("webgl-renderbuffer-memory",
KIND_OTHER, UNITS_BYTES, GetRenderbufferMemoryUsed(),
"Memory used by WebGL renderbuffers. The OpenGL"
" implementation is free to store these renderbuffers in either"
" video memory or main memory. This measurement is only a lower"
" bound, actual memory usage may be higher for example if the"
" storage is strided.");
REPORT("webgl-renderbuffer-count",
KIND_OTHER, UNITS_COUNT, GetRenderbufferCount(),
"Number of WebGL renderbuffers.");
REPORT("explicit/webgl/shader",
KIND_HEAP, UNITS_BYTES, GetShaderSize(),
"Combined size of WebGL shader ASCII sources and translation"
" logs cached on the heap.");
REPORT("webgl-shader-count",
KIND_OTHER, UNITS_COUNT, GetShaderCount(),
"Number of WebGL shaders.");
REPORT("webgl-context-count",
KIND_OTHER, UNITS_COUNT, GetContextCount(),
"Number of WebGL contexts.");
#undef REPORT
return NS_OK;
}
NS_IMPL_ISUPPORTS(WebGLMemoryTracker, nsIMemoryReporter)
StaticRefPtr<WebGLMemoryTracker> WebGLMemoryTracker::sUniqueInstance;
WebGLMemoryTracker*
WebGLMemoryTracker::UniqueInstance()
{
if (!sUniqueInstance) {
sUniqueInstance = new WebGLMemoryTracker;
sUniqueInstance->InitMemoryReporter();
}
return sUniqueInstance;
}
WebGLMemoryTracker::WebGLMemoryTracker()
{
}
void
WebGLMemoryTracker::InitMemoryReporter()
{
RegisterWeakMemoryReporter(this);
}
WebGLMemoryTracker::~WebGLMemoryTracker()
{
UnregisterWeakMemoryReporter(this);
}
MOZ_DEFINE_MALLOC_SIZE_OF(WebGLBufferMallocSizeOf)
int64_t
WebGLMemoryTracker::GetBufferCacheMemoryUsed()
{
const ContextsArrayType& contexts = Contexts();
int64_t result = 0;
for(size_t i = 0; i < contexts.Length(); ++i) {
for (const WebGLBuffer* buffer = contexts[i]->mBuffers.getFirst();
buffer;
buffer = buffer->getNext())
{
if (buffer->Content() == WebGLBuffer::Kind::ElementArray) {
result += buffer->SizeOfIncludingThis(WebGLBufferMallocSizeOf);
}
}
}
return result;
}
MOZ_DEFINE_MALLOC_SIZE_OF(WebGLShaderMallocSizeOf)
int64_t
WebGLMemoryTracker::GetShaderSize()
{
const ContextsArrayType& contexts = Contexts();
int64_t result = 0;
for(size_t i = 0; i < contexts.Length(); ++i) {
for (const WebGLShader* shader = contexts[i]->mShaders.getFirst();
shader;
shader = shader->getNext())
{
result += shader->SizeOfIncludingThis(WebGLShaderMallocSizeOf);
}
}
return result;
}
/*static*/ int64_t
WebGLMemoryTracker::GetTextureMemoryUsed()
{
const ContextsArrayType & contexts = Contexts();
int64_t result = 0;
for(size_t i = 0; i < contexts.Length(); ++i) {
for (const WebGLTexture* texture = contexts[i]->mTextures.getFirst();
texture;
texture = texture->getNext())
{
result += texture->MemoryUsage();
}
}
return result;
}
/*static*/ int64_t
WebGLMemoryTracker::GetTextureCount()
{
const ContextsArrayType & contexts = Contexts();
int64_t result = 0;
for(size_t i = 0; i < contexts.Length(); ++i) {
for (const WebGLTexture* texture = contexts[i]->mTextures.getFirst();
texture;
texture = texture->getNext())
{
result++;
}
}
return result;
}
/*static*/ int64_t
WebGLMemoryTracker::GetBufferMemoryUsed()
{
const ContextsArrayType & contexts = Contexts();
int64_t result = 0;
for(size_t i = 0; i < contexts.Length(); ++i) {
for (const WebGLBuffer* buffer = contexts[i]->mBuffers.getFirst();
buffer;
buffer = buffer->getNext())
{
result += buffer->ByteLength();
}
}
return result;
}
/*static*/ int64_t
WebGLMemoryTracker::GetBufferCount()
{
const ContextsArrayType & contexts = Contexts();
int64_t result = 0;
for(size_t i = 0; i < contexts.Length(); ++i) {
for (const WebGLBuffer* buffer = contexts[i]->mBuffers.getFirst();
buffer;
buffer = buffer->getNext())
{
result++;
}
}
return result;
}
/*static*/ int64_t
WebGLMemoryTracker::GetRenderbufferMemoryUsed()
{
const ContextsArrayType & contexts = Contexts();
int64_t result = 0;
for(size_t i = 0; i < contexts.Length(); ++i) {
for (const WebGLRenderbuffer* rb = contexts[i]->mRenderbuffers.getFirst();
rb;
rb = rb->getNext())
{
result += rb->MemoryUsage();
}
}
return result;
}
/*static*/ int64_t
WebGLMemoryTracker::GetRenderbufferCount()
{
const ContextsArrayType & contexts = Contexts();
int64_t result = 0;
for(size_t i = 0; i < contexts.Length(); ++i) {
for (const WebGLRenderbuffer* rb = contexts[i]->mRenderbuffers.getFirst();
rb;
rb = rb->getNext())
{
result++;
}
}
return result;
}
/*static*/ int64_t
WebGLMemoryTracker::GetShaderCount()
{
const ContextsArrayType & contexts = Contexts();
int64_t result = 0;
for(size_t i = 0; i < contexts.Length(); ++i) {
for (const WebGLShader* shader = contexts[i]->mShaders.getFirst();
shader;
shader = shader->getNext())
{
result++;
}
}
return result;
}
} // namespace mozilla

Просмотреть файл

@ -8,17 +8,11 @@
#include "mozilla/StaticPtr.h"
#include "nsIMemoryReporter.h"
#include "WebGLBuffer.h"
#include "WebGLContext.h"
#include "WebGLVertexAttribData.h"
#include "WebGLProgram.h"
#include "WebGLRenderbuffer.h"
#include "WebGLShader.h"
#include "WebGLTexture.h"
#include "WebGLUniformLocation.h"
namespace mozilla {
class WebGLContext;
class WebGLMemoryTracker : public nsIMemoryReporter
{
NS_DECL_THREADSAFE_ISUPPORTS
@ -58,107 +52,23 @@ class WebGLMemoryTracker : public nsIMemoryReporter
private:
virtual ~WebGLMemoryTracker();
static int64_t GetTextureMemoryUsed() {
const ContextsArrayType & contexts = Contexts();
int64_t result = 0;
for(size_t i = 0; i < contexts.Length(); ++i) {
for (const WebGLTexture* texture = contexts[i]->mTextures.getFirst();
texture;
texture = texture->getNext())
{
result += texture->MemoryUsage();
}
}
return result;
}
static int64_t GetTextureMemoryUsed();
static int64_t GetTextureCount() {
const ContextsArrayType & contexts = Contexts();
int64_t result = 0;
for(size_t i = 0; i < contexts.Length(); ++i) {
for (const WebGLTexture* texture = contexts[i]->mTextures.getFirst();
texture;
texture = texture->getNext())
{
result++;
}
}
return result;
}
static int64_t GetTextureCount();
static int64_t GetBufferMemoryUsed() {
const ContextsArrayType & contexts = Contexts();
int64_t result = 0;
for(size_t i = 0; i < contexts.Length(); ++i) {
for (const WebGLBuffer* buffer = contexts[i]->mBuffers.getFirst();
buffer;
buffer = buffer->getNext())
{
result += buffer->ByteLength();
}
}
return result;
}
static int64_t GetBufferMemoryUsed();
static int64_t GetBufferCacheMemoryUsed();
static int64_t GetBufferCount() {
const ContextsArrayType & contexts = Contexts();
int64_t result = 0;
for(size_t i = 0; i < contexts.Length(); ++i) {
for (const WebGLBuffer* buffer = contexts[i]->mBuffers.getFirst();
buffer;
buffer = buffer->getNext())
{
result++;
}
}
return result;
}
static int64_t GetBufferCount();
static int64_t GetRenderbufferMemoryUsed() {
const ContextsArrayType & contexts = Contexts();
int64_t result = 0;
for(size_t i = 0; i < contexts.Length(); ++i) {
for (const WebGLRenderbuffer* rb = contexts[i]->mRenderbuffers.getFirst();
rb;
rb = rb->getNext())
{
result += rb->MemoryUsage();
}
}
return result;
}
static int64_t GetRenderbufferMemoryUsed();
static int64_t GetRenderbufferCount() {
const ContextsArrayType & contexts = Contexts();
int64_t result = 0;
for(size_t i = 0; i < contexts.Length(); ++i) {
for (const WebGLRenderbuffer* rb = contexts[i]->mRenderbuffers.getFirst();
rb;
rb = rb->getNext())
{
result++;
}
}
return result;
}
static int64_t GetRenderbufferCount();
static int64_t GetShaderSize();
static int64_t GetShaderCount() {
const ContextsArrayType & contexts = Contexts();
int64_t result = 0;
for(size_t i = 0; i < contexts.Length(); ++i) {
for (const WebGLShader* shader = contexts[i]->mShaders.getFirst();
shader;
shader = shader->getNext())
{
result++;
}
}
return result;
}
static int64_t GetShaderCount();
static int64_t GetContextCount() {
return Contexts().Length();

Просмотреть файл

@ -7,7 +7,7 @@
#define WEBGLOBJECTMODEL_H_
#include "nsCycleCollectionNoteChild.h"
#include "nsICanvasRenderingContextInternal.h"
#include "WebGLTypes.h"
namespace mozilla {

Просмотреть файл

@ -6,7 +6,11 @@
#include "WebGLProgram.h"
#include "GLContext.h"
#include "mozilla/CheckedInt.h"
#include "mozilla/dom/WebGL2RenderingContextBinding.h"
#include "mozilla/dom/WebGLRenderingContextBinding.h"
#include "nsRefPtr.h"
#include "WebGLActiveInfo.h"
#include "WebGLContext.h"
#include "WebGLShader.h"
#include "WebGLUniformLocation.h"
@ -67,12 +71,12 @@ ParseName(const nsCString& name, nsCString* const out_baseName,
static void
AddActiveInfo(WebGLContext* webgl, GLint elemCount, GLenum elemType, bool isArray,
const nsACString& baseUserName, const nsACString& baseMappedName,
std::vector<nsRefPtr<WebGLActiveInfo>>* activeInfoList,
std::vector<RefPtr<WebGLActiveInfo>>* activeInfoList,
std::map<nsCString, const WebGLActiveInfo*>* infoLocMap)
{
nsRefPtr<WebGLActiveInfo> info = new WebGLActiveInfo(webgl, elemCount, elemType,
isArray, baseUserName,
baseMappedName);
RefPtr<WebGLActiveInfo> info = new WebGLActiveInfo(webgl, elemCount, elemType,
isArray, baseUserName,
baseMappedName);
activeInfoList->push_back(info);
infoLocMap->insert(std::make_pair(info->mBaseUserName, info.get()));
@ -202,10 +206,10 @@ QueryProgramInfo(WebGLProgram* prog, gl::GLContext* gl)
// By GLES 3, GetUniformLocation("foo[0]") should return -1 if `foo` is
// not an array. Our current linux Try slaves return the location of `foo`
// anyways, though.
std::string mappedName = baseMappedName.BeginReading();
mappedName += "[0]";
std::string mappedNameStr = baseMappedName.BeginReading();
mappedNameStr += "[0]";
GLint loc = gl->fGetUniformLocation(prog->mGLName, mappedName.c_str());
GLint loc = gl->fGetUniformLocation(prog->mGLName, mappedNameStr.c_str());
if (loc != -1)
isArray = true;
}
@ -246,14 +250,17 @@ QueryProgramInfo(WebGLProgram* prog, gl::GLContext* gl)
MOZ_CRASH("Failed to parse `mappedName` received from driver.");
nsAutoCString baseUserName;
if (!prog->FindUniformBlockByMappedName(baseMappedName, &baseUserName, &isArray)) {
if (!prog->FindUniformBlockByMappedName(baseMappedName, &baseUserName,
&isArray))
{
baseUserName = baseMappedName;
if (needsCheckForArrays && !isArray) {
std::string mappedName = baseMappedName.BeginReading();
mappedName += "[0]";
std::string mappedNameStr = baseMappedName.BeginReading();
mappedNameStr += "[0]";
GLuint loc = gl->fGetUniformBlockIndex(prog->mGLName, mappedName.c_str());
GLuint loc = gl->fGetUniformBlockIndex(prog->mGLName,
mappedNameStr.c_str());
if (loc != LOCAL_GL_INVALID_INDEX)
isArray = true;
}
@ -277,8 +284,8 @@ QueryProgramInfo(WebGLProgram* prog, gl::GLContext* gl)
////////////////////////////////////////////////////////////////////////////////
webgl::LinkedProgramInfo::LinkedProgramInfo(WebGLProgram* aProg)
: prog(aProg)
webgl::LinkedProgramInfo::LinkedProgramInfo(WebGLProgram* prog)
: prog(prog)
, fragDataMap(nullptr)
{ }
@ -300,6 +307,11 @@ WebGLProgram::WebGLProgram(WebGLContext* webgl)
mContext->mPrograms.insertBack(this);
}
WebGLProgram::~WebGLProgram()
{
DeleteOnce();
}
void
WebGLProgram::Delete()
{
@ -425,7 +437,7 @@ WebGLProgram::GetActiveAttrib(GLuint index) const
return nullptr;
}
nsRefPtr<WebGLActiveInfo> ret = activeList[index];
RefPtr<WebGLActiveInfo> ret = activeList[index];
return ret.forget();
}
@ -446,7 +458,7 @@ WebGLProgram::GetActiveUniform(GLuint index) const
return nullptr;
}
nsRefPtr<WebGLActiveInfo> ret = activeList[index];
RefPtr<WebGLActiveInfo> ret = activeList[index];
return ret.forget();
}
@ -627,7 +639,7 @@ WebGLProgram::GetActiveUniformBlockName(GLuint uniformBlockIndex, nsAString& ret
void
WebGLProgram::GetActiveUniformBlockParam(GLuint uniformBlockIndex, GLenum pname,
Nullable<dom::OwningUnsignedLongOrUint32ArrayOrBoolean>& retval) const
dom::Nullable<dom::OwningUnsignedLongOrUint32ArrayOrBoolean>& retval) const
{
retval.SetNull();
if (!IsLinked()) {
@ -663,7 +675,7 @@ WebGLProgram::GetActiveUniformBlockParam(GLuint uniformBlockIndex, GLenum pname,
void
WebGLProgram::GetActiveUniformBlockActiveUniforms(JSContext* cx, GLuint uniformBlockIndex,
Nullable<dom::OwningUnsignedLongOrUint32ArrayOrBoolean>& retval,
dom::Nullable<dom::OwningUnsignedLongOrUint32ArrayOrBoolean>& retval,
ErrorResult& rv) const
{
if (!IsLinked()) {
@ -1013,7 +1025,7 @@ WebGLProgram::GetTransformFeedbackVarying(GLuint index)
LinkInfo()->FindAttrib(varyingUserName, (const WebGLActiveInfo**) &info);
MOZ_ASSERT(info);
nsRefPtr<WebGLActiveInfo> ret(info);
RefPtr<WebGLActiveInfo> ret(info);
return ret.forget();
}
@ -1034,9 +1046,9 @@ WebGLProgram::FindUniformBlockByMappedName(const nsACString& mappedName,
////////////////////////////////////////////////////////////////////////////////
JSObject*
WebGLProgram::WrapObject(JSContext* js, JS::Handle<JSObject*> aGivenProto)
WebGLProgram::WrapObject(JSContext* js, JS::Handle<JSObject*> givenProto)
{
return dom::WebGLProgramBinding::Wrap(js, this, aGivenProto);
return dom::WebGLProgramBinding::Wrap(js, this, givenProto);
}
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(WebGLProgram, mVertShader, mFragShader)

Просмотреть файл

@ -7,22 +7,33 @@
#define WEBGL_PROGRAM_H_
#include <map>
#include "mozilla/CheckedInt.h"
#include "mozilla/LinkedList.h"
#include "mozilla/dom/WebGL2RenderingContextBinding.h"
#include "nsString.h"
#include "nsWrapperCache.h"
#include <set>
#include <vector>
#include "mozilla/LinkedList.h"
#include "mozilla/RefPtr.h"
#include "mozilla/WeakPtr.h"
#include "nsString.h"
#include "nsWrapperCache.h"
#include "WebGLObjectModel.h"
#include "WebGLShader.h"
template<class> class nsRefPtr;
namespace mozilla {
class ErrorResult;
class WebGLActiveInfo;
class WebGLProgram;
class WebGLShader;
class WebGLUniformLocation;
namespace dom {
template<typename> struct Nullable;
class OwningUnsignedLongOrUint32ArrayOrBoolean;
template<typename> class Sequence;
} // namespace dom
namespace webgl {
struct UniformBlockInfo final
@ -48,8 +59,8 @@ struct LinkedProgramInfo final
MOZ_DECLARE_WEAKREFERENCE_TYPENAME(LinkedProgramInfo)
WebGLProgram* const prog;
std::vector<nsRefPtr<WebGLActiveInfo>> activeAttribs;
std::vector<nsRefPtr<WebGLActiveInfo>> activeUniforms;
std::vector<RefPtr<WebGLActiveInfo>> activeAttribs;
std::vector<RefPtr<WebGLActiveInfo>> activeUniforms;
// Needed for Get{Attrib,Uniform}Location. The keys for these are non-mapped
// user-facing `GLActiveInfo::name`s, without any final "[0]".
@ -62,7 +73,7 @@ struct LinkedProgramInfo final
// Needed for draw call validation.
std::set<GLuint> activeAttribLocs;
explicit LinkedProgramInfo(WebGLProgram* aProg);
explicit LinkedProgramInfo(WebGLProgram* prog);
bool FindAttrib(const nsCString& baseUserName,
const WebGLActiveInfo** const out_activeInfo) const
@ -119,10 +130,6 @@ struct LinkedProgramInfo final
} // namespace webgl
class WebGLShader;
typedef nsDataHashtable<nsCStringHashKey, nsCString> CStringMap;
class WebGLProgram final
: public nsWrapperCache
, public WebGLRefCountedObject<WebGLProgram>
@ -151,9 +158,9 @@ public:
GLuint GetUniformBlockIndex(const nsAString& name) const;
void GetActiveUniformBlockName(GLuint uniformBlockIndex, nsAString& name) const;
void GetActiveUniformBlockParam(GLuint uniformBlockIndex, GLenum pname,
Nullable<dom::OwningUnsignedLongOrUint32ArrayOrBoolean>& retval) const;
dom::Nullable<dom::OwningUnsignedLongOrUint32ArrayOrBoolean>& retval) const;
void GetActiveUniformBlockActiveUniforms(JSContext* cx, GLuint uniformBlockIndex,
Nullable<dom::OwningUnsignedLongOrUint32ArrayOrBoolean>& retval,
dom::Nullable<dom::OwningUnsignedLongOrUint32ArrayOrBoolean>& retval,
ErrorResult& rv) const;
already_AddRefed<WebGLUniformLocation> GetUniformLocation(const nsAString& name) const;
void UniformBlockBinding(GLuint uniformBlockIndex, GLuint uniformBlockBinding) const;
@ -187,12 +194,10 @@ public:
return Context();
}
virtual JSObject* WrapObject(JSContext* js, JS::Handle<JSObject*> aGivenProto) override;
virtual JSObject* WrapObject(JSContext* js, JS::Handle<JSObject*> givenProto) override;
private:
~WebGLProgram() {
DeleteOnce();
}
~WebGLProgram();
bool LinkAndUpdate();

Просмотреть файл

@ -13,9 +13,9 @@
namespace mozilla {
JSObject*
WebGLQuery::WrapObject(JSContext* cx, JS::Handle<JSObject*> aGivenProto)
WebGLQuery::WrapObject(JSContext* cx, JS::Handle<JSObject*> givenProto)
{
return dom::WebGLQueryBinding::Wrap(cx, this, aGivenProto);
return dom::WebGLQueryBinding::Wrap(cx, this, givenProto);
}
WebGLQuery::WebGLQuery(WebGLContext* webgl)

Просмотреть файл

@ -8,6 +8,7 @@
#include "mozilla/LinkedList.h"
#include "nsWrapperCache.h"
#include "WebGLObjectModel.h"
namespace mozilla {
@ -36,7 +37,7 @@ public:
}
// NS
virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> aGivenProto) override;
virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> givenProto) override;
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WebGLQuery)
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WebGLQuery)

Просмотреть файл

@ -9,6 +9,7 @@
#include "mozilla/dom/WebGLRenderingContextBinding.h"
#include "ScopedGLHelpers.h"
#include "WebGLContext.h"
#include "WebGLStrongTypes.h"
#include "WebGLTexture.h"
namespace mozilla {
@ -41,9 +42,9 @@ NeedsDepthStencilEmu(gl::GLContext* gl, GLenum internalFormat)
}
JSObject*
WebGLRenderbuffer::WrapObject(JSContext* cx, JS::Handle<JSObject*> aGivenProto)
WebGLRenderbuffer::WrapObject(JSContext* cx, JS::Handle<JSObject*> givenProto)
{
return dom::WebGLRenderbufferBinding::Wrap(cx, this, aGivenProto);
return dom::WebGLRenderbufferBinding::Wrap(cx, this, givenProto);
}
WebGLRenderbuffer::WebGLRenderbuffer(WebGLContext* webgl)

Просмотреть файл

@ -8,8 +8,10 @@
#include "mozilla/LinkedList.h"
#include "nsWrapperCache.h"
#include "WebGLFramebufferAttachable.h"
#include "WebGLObjectModel.h"
#include "WebGLStrongTypes.h"
namespace mozilla {
@ -64,7 +66,7 @@ public:
// Only handles a subset of `pname`s.
GLint GetRenderbufferParameter(RBTarget target, RBParam pname) const;
virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> aGivenProto) override;
virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> givenProto) override;
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WebGLRenderbuffer)
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WebGLRenderbuffer)

Просмотреть файл

@ -39,9 +39,9 @@ WebGLSampler::GetParentObject() const
}
JSObject*
WebGLSampler::WrapObject(JSContext* cx, JS::Handle<JSObject*> aGivenProto)
WebGLSampler::WrapObject(JSContext* cx, JS::Handle<JSObject*> givenProto)
{
return dom::WebGLSamplerBinding::Wrap(cx, this, aGivenProto);
return dom::WebGLSamplerBinding::Wrap(cx, this, givenProto);
}

Просмотреть файл

@ -28,7 +28,7 @@ public:
void Delete();
WebGLContext* GetParentObject() const;
virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> aGivenProto) override;
virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> givenProto) override;
private:

Просмотреть файл

@ -403,9 +403,9 @@ WebGLShader::ApplyTransformFeedbackVaryings(GLuint prog,
// Boilerplate
JSObject*
WebGLShader::WrapObject(JSContext* js, JS::Handle<JSObject*> aGivenProto)
WebGLShader::WrapObject(JSContext* js, JS::Handle<JSObject*> givenProto)
{
return dom::WebGLShaderBinding::Wrap(js, this, aGivenProto);
return dom::WebGLShaderBinding::Wrap(js, this, givenProto);
}
size_t

Просмотреть файл

@ -6,10 +6,15 @@
#ifndef WEBGL_SHADER_H_
#define WEBGL_SHADER_H_
#include <string>
#include <vector>
#include "GLDefs.h"
#include "mozilla/LinkedList.h"
#include "mozilla/MemoryReporting.h"
#include "nsString.h"
#include "nsWrapperCache.h"
#include "WebGLObjectModel.h"
namespace mozilla {
@ -65,12 +70,12 @@ public:
std::vector<std::string>* out_mappedVaryings) const;
// Other funcs
size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
size_t SizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const;
void Delete();
WebGLContext* GetParentObject() const { return Context(); }
virtual JSObject* WrapObject(JSContext* js, JS::Handle<JSObject*> aGivenProto) override;
virtual JSObject* WrapObject(JSContext* js, JS::Handle<JSObject*> givenProto) override;
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WebGLShader)
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WebGLShader)

Просмотреть файл

@ -11,11 +11,11 @@
namespace mozilla {
bool
WebGLShaderPrecisionFormat::WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto,
JS::MutableHandle<JSObject*> aReflector)
WebGLShaderPrecisionFormat::WrapObject(JSContext* cx,
JS::Handle<JSObject*> givenProto,
JS::MutableHandle<JSObject*> reflector)
{
return dom::WebGLShaderPrecisionFormatBinding::Wrap(aCx, this, aGivenProto, aReflector);
return dom::WebGLShaderPrecisionFormatBinding::Wrap(cx, this, givenProto, reflector);
}
} // namespace mozilla

Просмотреть файл

@ -22,7 +22,7 @@ public:
, mPrecision(precision)
{ }
bool WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector);
bool WrapObject(JSContext* cx, JS::Handle<JSObject*> givenProto, JS::MutableHandle<JSObject*> reflector);
// WebIDL WebGLShaderPrecisionFormat API
GLint RangeMin() const {

Просмотреть файл

@ -6,6 +6,8 @@
#ifndef WEBGL_STRONG_TYPES_H_
#define WEBGL_STRONG_TYPES_H_
#include <algorithm>
#include "GLDefs.h"
#include "mozilla/ArrayUtils.h"
#include "mozilla/Assertions.h"

Просмотреть файл

@ -5,7 +5,9 @@
#include "WebGLSync.h"
#include "GLContext.h"
#include "mozilla/dom/WebGL2RenderingContextBinding.h"
#include "WebGLContext.h"
namespace mozilla {
@ -38,9 +40,9 @@ WebGLSync::GetParentObject() const
// -------------------------------------------------------------------------
// IMPLEMENT NS
JSObject*
WebGLSync::WrapObject(JSContext* cx, JS::Handle<JSObject*> aGivenProto)
WebGLSync::WrapObject(JSContext* cx, JS::Handle<JSObject*> givenProto)
{
return dom::WebGLSyncBinding::Wrap(cx, this, aGivenProto);
return dom::WebGLSyncBinding::Wrap(cx, this, givenProto);
}
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_0(WebGLSync)

Просмотреть файл

@ -26,7 +26,7 @@ public:
void Delete();
WebGLContext* GetParentObject() const;
virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> aGivenProto) override;
virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> givenProto) override;
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WebGLSync)
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WebGLSync)

Просмотреть файл

@ -19,8 +19,8 @@
namespace mozilla {
JSObject*
WebGLTexture::WrapObject(JSContext* cx, JS::Handle<JSObject*> aGivenProto) {
return dom::WebGLTextureBinding::Wrap(cx, this, aGivenProto);
WebGLTexture::WrapObject(JSContext* cx, JS::Handle<JSObject*> givenProto) {
return dom::WebGLTextureBinding::Wrap(cx, this, givenProto);
}
WebGLTexture::WebGLTexture(WebGLContext* webgl, GLuint tex)

Просмотреть файл

@ -7,11 +7,12 @@
#define WEBGL_TEXTURE_H_
#include <algorithm>
#include "mozilla/Assertions.h"
#include "mozilla/CheckedInt.h"
#include "mozilla/LinkedList.h"
#include "nsAlgorithm.h"
#include "nsWrapperCache.h"
#include "WebGLFramebufferAttachable.h"
#include "WebGLObjectModel.h"
#include "WebGLStrongTypes.h"
@ -47,7 +48,7 @@ public:
return Context();
}
virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> aGivenProto) override;
virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> givenProto) override;
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WebGLTexture)
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WebGLTexture)

Просмотреть файл

@ -14,14 +14,14 @@
namespace mozilla {
JSObject*
WebGLTimerQuery::WrapObject(JSContext* cx, JS::Handle<JSObject*> aGivenProto)
WebGLTimerQuery::WrapObject(JSContext* cx, JS::Handle<JSObject*> givenProto)
{
return dom::WebGLTimerQueryEXTBinding::Wrap(cx, this, aGivenProto);
return dom::WebGLTimerQueryEXTBinding::Wrap(cx, this, givenProto);
}
WebGLTimerQuery::WebGLTimerQuery(WebGLContext* webgl, GLuint aName)
WebGLTimerQuery::WebGLTimerQuery(WebGLContext* webgl, GLuint name)
: WebGLContextBoundObject(webgl)
, mGLName(aName)
, mGLName(name)
, mTarget(LOCAL_GL_NONE)
{
}

Просмотреть файл

@ -29,7 +29,7 @@ public:
WebGLContext* GetParentObject() const;
// NS
virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> aGivenProto) override;
virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> givenProto) override;
const GLenum mGLName;
@ -37,7 +37,7 @@ public:
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WebGLTimerQuery)
private:
explicit WebGLTimerQuery(WebGLContext* webgl, GLuint aName);
explicit WebGLTimerQuery(WebGLContext* webgl, GLuint name);
~WebGLTimerQuery();
GLenum mTarget;

Просмотреть файл

@ -45,9 +45,9 @@ WebGLTransformFeedback::GetParentObject() const
}
JSObject*
WebGLTransformFeedback::WrapObject(JSContext* cx, JS::Handle<JSObject*> aGivenProto)
WebGLTransformFeedback::WrapObject(JSContext* cx, JS::Handle<JSObject*> givenProto)
{
return dom::WebGLTransformFeedbackBinding::Wrap(cx, this, aGivenProto);
return dom::WebGLTransformFeedbackBinding::Wrap(cx, this, givenProto);
}

Просмотреть файл

@ -26,7 +26,7 @@ public:
void Delete();
WebGLContext* GetParentObject() const;
virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> aGivenProto) override;
virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> givenProto) override;
const GLuint mGLName;

Просмотреть файл

@ -321,9 +321,9 @@ WebGLUniformLocation::GetUniform(JSContext* js, WebGLContext* webgl) const
////////////////////////////////////////////////////////////////////////////////
JSObject*
WebGLUniformLocation::WrapObject(JSContext* js, JS::Handle<JSObject*> aGivenProto)
WebGLUniformLocation::WrapObject(JSContext* js, JS::Handle<JSObject*> givenProto)
{
return dom::WebGLUniformLocationBinding::Wrap(js, this, aGivenProto);
return dom::WebGLUniformLocationBinding::Wrap(js, this, givenProto);
}
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_0(WebGLUniformLocation)

Просмотреть файл

@ -11,6 +11,7 @@
#include "nsCycleCollectionParticipant.h" // NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS
#include "nsISupportsImpl.h" // NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING
#include "nsWrapperCache.h"
#include "WebGLObjectModel.h"
struct JSContext;
@ -32,13 +33,12 @@ public:
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WebGLUniformLocation)
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WebGLUniformLocation)
virtual JSObject* WrapObject(JSContext* js, JS::Handle<JSObject*> aGivenProto) override;
virtual JSObject* WrapObject(JSContext* js, JS::Handle<JSObject*> givenProto) override;
WebGLContext* GetParentObject() const {
return mContext;
}
const WeakPtr<const webgl::LinkedProgramInfo> mLinkInfo;
const GLuint mLoc;
const WebGLActiveInfo* const mActiveInfo;

Просмотреть файл

@ -15,9 +15,9 @@
namespace mozilla {
JSObject*
WebGLVertexArray::WrapObject(JSContext* cx, JS::Handle<JSObject*> aGivenProto)
WebGLVertexArray::WrapObject(JSContext* cx, JS::Handle<JSObject*> givenProto)
{
return dom::WebGLVertexArrayObjectOESBinding::Wrap(cx, this, aGivenProto);
return dom::WebGLVertexArrayObjectOESBinding::Wrap(cx, this, givenProto);
}
WebGLVertexArray::WebGLVertexArray(WebGLContext* webgl)

Просмотреть файл

@ -6,8 +6,10 @@
#ifndef WEBGL_VERTEX_ARRAY_H_
#define WEBGL_VERTEX_ARRAY_H_
#include "nsTArray.h"
#include "mozilla/LinkedList.h"
#include "nsWrapperCache.h"
#include "WebGLBuffer.h"
#include "WebGLObjectModel.h"
#include "WebGLStrongTypes.h"
@ -48,7 +50,7 @@ public:
return Context();
}
virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> aGivenProto) override;
virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> givenProto) override;
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WebGLVertexArray)
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WebGLVertexArray)

Просмотреть файл

@ -6,7 +6,9 @@
#include "WebGLVertexArrayObject.h"
#include "GLContext.h"
#include "mozilla/dom/WebGL2RenderingContextBinding.h"
#include "WebGLContext.h"
namespace mozilla {
namespace dom {

Просмотреть файл

@ -13,8 +13,6 @@
#include "nscore.h"
#include "nsTArray.h"
using namespace mozilla;
int gTestsPassed = 0;
void
@ -65,7 +63,7 @@ GLType()
}
void
CheckValidate(bool expectSuccess, WebGLElementArrayCache& c, GLenum type,
CheckValidate(bool expectSuccess, mozilla::WebGLElementArrayCache& c, GLenum type,
uint32_t maxAllowed, size_t first, size_t count)
{
uint32_t out_upperBound = 0;
@ -80,7 +78,8 @@ CheckValidate(bool expectSuccess, WebGLElementArrayCache& c, GLenum type,
template<typename T>
void
CheckValidateOneTypeVariousBounds(WebGLElementArrayCache& c, size_t firstByte, size_t countBytes)
CheckValidateOneTypeVariousBounds(mozilla::WebGLElementArrayCache& c, size_t firstByte,
size_t countBytes)
{
size_t first = firstByte / sizeof(T);
size_t count = countBytes / sizeof(T);
@ -101,7 +100,8 @@ CheckValidateOneTypeVariousBounds(WebGLElementArrayCache& c, size_t firstByte, s
}
}
void CheckValidateAllTypes(WebGLElementArrayCache& c, size_t firstByte, size_t countBytes)
void CheckValidateAllTypes(mozilla::WebGLElementArrayCache& c, size_t firstByte,
size_t countBytes)
{
CheckValidateOneTypeVariousBounds<uint8_t>(c, firstByte, countBytes);
CheckValidateOneTypeVariousBounds<uint16_t>(c, firstByte, countBytes);
@ -120,7 +120,7 @@ CheckSanity()
GLenum type = GLType<T>();
WebGLElementArrayCache c;
mozilla::WebGLElementArrayCache c;
c.BufferData(data, numBytes);
CheckValidate(true, c, type, 6, 0, 8);
CheckValidate(false, c, type, 5, 0, 8);
@ -161,7 +161,7 @@ CheckUintOverflow()
GLenum type = GLType<T>();
WebGLElementArrayCache c;
mozilla::WebGLElementArrayCache c;
for(size_t i = 0; i < numElems; i++)
data[i] = numElems - i;
@ -187,7 +187,7 @@ main(int argc, char* argv[])
CheckUintOverflow<uint16_t>();
nsTArray<uint8_t> v, vsub;
WebGLElementArrayCache b;
mozilla::WebGLElementArrayCache b;
for (int maxBufferSize = 1; maxBufferSize <= 4096; maxBufferSize *= 2) {
// See bug 800612. We originally had | repeat = min(maxBufferSize, 20) |
@ -229,3 +229,4 @@ main(int argc, char* argv[])
std::cerr << argv[0] << ": all " << gTestsPassed << " tests passed" << std::endl;
return 0;
}

Просмотреть файл

@ -76,7 +76,6 @@ UNIFIED_SOURCES += [
'WebGLContextFramebufferOperations.cpp',
'WebGLContextGL.cpp',
'WebGLContextLossHandler.cpp',
'WebGLContextReporter.cpp',
'WebGLContextState.cpp',
'WebGLContextUnchecked.cpp',
'WebGLContextUtils.cpp',
@ -113,6 +112,7 @@ UNIFIED_SOURCES += [
'WebGLFormats.cpp',
'WebGLFramebuffer.cpp',
'WebGLFramebufferAttachable.cpp',
'WebGLMemoryTracker.cpp',
'WebGLObjectModel.cpp',
'WebGLProgram.cpp',
'WebGLQuery.cpp',
@ -133,7 +133,9 @@ UNIFIED_SOURCES += [
'WebGLVertexArrayGL.cpp',
'WebGLVertexArrayObject.cpp',
]
LOCAL_INCLUDES += [
'../..', # Support `#include "mfbt/RefPtr.h"`
'/js/xpconnect/wrappers',
]

Просмотреть файл

@ -42,10 +42,10 @@ public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICANVASRENDERINGCONTEXTINTERNAL_IID)
void SetCanvasElement(mozilla::dom::HTMLCanvasElement* aParentCanvas)
void SetCanvasElement(mozilla::dom::HTMLCanvasElement* parentCanvas)
{
RemovePostRefreshObserver();
mCanvasElement = aParentCanvas;
mCanvasElement = parentCanvas;
AddPostRefreshObserverIfNecessary();
}
@ -93,24 +93,24 @@ public:
NS_IMETHOD InitializeWithSurface(nsIDocShell *docShell, gfxASurface *surface, int32_t width, int32_t height) = 0;
// Creates an image buffer. Returns null on failure.
virtual void GetImageBuffer(uint8_t** aImageBuffer, int32_t* aFormat) = 0;
virtual void GetImageBuffer(uint8_t** imageBuffer, int32_t* format) = 0;
// Gives you a stream containing the image represented by this context.
// The format is given in aMimeTime, for example "image/png".
// The format is given in mimeTime, for example "image/png".
//
// If the image format does not support transparency or aIncludeTransparency
// If the image format does not support transparency or includeTransparency
// is false, alpha will be discarded and the result will be the image
// composited on black.
NS_IMETHOD GetInputStream(const char *aMimeType,
const char16_t *aEncoderOptions,
nsIInputStream **aStream) = 0;
NS_IMETHOD GetInputStream(const char *mimeType,
const char16_t *encoderOptions,
nsIInputStream **stream) = 0;
// This gets an Azure SourceSurface for the canvas, this will be a snapshot
// of the canvas at the time it was called.
// If aPremultAlpha is provided, then it assumed the callee can handle
// un-premultiplied surfaces, and *aPremultAlpha will be set to false
// If premultAlpha is provided, then it assumed the callee can handle
// un-premultiplied surfaces, and *premultAlpha will be set to false
// if one is returned.
virtual already_AddRefed<mozilla::gfx::SourceSurface> GetSurfaceSnapshot(bool* aPremultAlpha = nullptr) = 0;
virtual already_AddRefed<mozilla::gfx::SourceSurface> GetSurfaceSnapshot(bool* premultAlpha = nullptr) = 0;
// If this context is opaque, the backing store of the canvas should
// be created as opaque; all compositing operators should assume the
@ -125,27 +125,27 @@ public:
// Return the CanvasLayer for this context, creating
// one for the given layer manager if not available.
virtual already_AddRefed<CanvasLayer> GetCanvasLayer(nsDisplayListBuilder* aBuilder,
CanvasLayer *aOldLayer,
LayerManager *aManager) = 0;
virtual already_AddRefed<CanvasLayer> GetCanvasLayer(nsDisplayListBuilder* builder,
CanvasLayer *oldLayer,
LayerManager *manager) = 0;
// Return true if the canvas should be forced to be "inactive" to ensure
// it can be drawn to the screen even if it's too large to be blitted by
// an accelerated CanvasLayer.
virtual bool ShouldForceInactiveLayer(LayerManager *aManager) { return false; }
virtual bool ShouldForceInactiveLayer(LayerManager *manager) { return false; }
virtual void MarkContextClean() = 0;
// Redraw the dirty rectangle of this canvas.
NS_IMETHOD Redraw(const gfxRect &dirty) = 0;
NS_IMETHOD SetContextOptions(JSContext* aCx, JS::Handle<JS::Value> aOptions) { return NS_OK; }
NS_IMETHOD SetContextOptions(JSContext* cx, JS::Handle<JS::Value> options) { return NS_OK; }
// return true and fills in the bounding rect if elementis a child and has a hit region.
virtual bool GetHitRegionRect(mozilla::dom::Element* aElement, nsRect& aRect) { return false; }
virtual bool GetHitRegionRect(mozilla::dom::Element* element, nsRect& rect) { return false; }
// Given a point, return hit region ID if it exists or an empty string if it doesn't
virtual nsString GetHitRegion(const mozilla::gfx::Point& aPoint) { return nsString(); }
virtual nsString GetHitRegion(const mozilla::gfx::Point& point) { return nsString(); }
//
// shmem support

Просмотреть файл

@ -6,6 +6,7 @@
#include "GLBlitHelper.h"
#include "GLContext.h"
#include "GLScreenBuffer.h"
#include "ScopedGLHelpers.h"
#include "mozilla/Preferences.h"
#include "ImageContainer.h"

Просмотреть файл

@ -4,15 +4,17 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "GLContext.h"
#include <algorithm>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <vector>
#include "GLContext.h"
#include "GLBlitHelper.h"
#include "GLReadTexImageHelper.h"
#include "GLScreenBuffer.h"
#include "gfxCrashReporterUtils.h"
#include "gfxUtils.h"
@ -2607,5 +2609,241 @@ GLContext::Readback(SharedSurface* src, gfx::DataSourceSurface* dest)
}
}
// Do whatever tear-down is necessary after drawing to our offscreen FBO,
// if it's bound.
void
GLContext::AfterGLDrawCall()
{
if (mScreen) {
mScreen->AfterDrawCall();
}
mHeavyGLCallsSinceLastFlush = true;
}
// Do whatever setup is necessary to read from our offscreen FBO, if it's
// bound.
void
GLContext::BeforeGLReadCall()
{
if (mScreen)
mScreen->BeforeReadCall();
}
void
GLContext::fBindFramebuffer(GLenum target, GLuint framebuffer)
{
if (!mScreen) {
raw_fBindFramebuffer(target, framebuffer);
return;
}
switch (target) {
case LOCAL_GL_DRAW_FRAMEBUFFER_EXT:
mScreen->BindDrawFB(framebuffer);
return;
case LOCAL_GL_READ_FRAMEBUFFER_EXT:
mScreen->BindReadFB(framebuffer);
return;
case LOCAL_GL_FRAMEBUFFER:
mScreen->BindFB(framebuffer);
return;
default:
// Nothing we care about, likely an error.
break;
}
raw_fBindFramebuffer(target, framebuffer);
}
void
GLContext::fCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x,
GLint y, GLsizei width, GLsizei height, GLint border)
{
if (!IsTextureSizeSafeToPassToDriver(target, width, height)) {
// pass wrong values to cause the GL to generate GL_INVALID_VALUE.
// See bug 737182 and the comment in IsTextureSizeSafeToPassToDriver.
level = -1;
width = -1;
height = -1;
border = -1;
}
BeforeGLReadCall();
bool didCopyTexImage2D = false;
if (mScreen) {
didCopyTexImage2D = mScreen->CopyTexImage2D(target, level, internalformat, x,
y, width, height, border);
}
if (!didCopyTexImage2D) {
raw_fCopyTexImage2D(target, level, internalformat, x, y, width, height,
border);
}
AfterGLReadCall();
}
void
GLContext::fGetIntegerv(GLenum pname, GLint* params)
{
switch (pname) {
// LOCAL_GL_FRAMEBUFFER_BINDING is equal to
// LOCAL_GL_DRAW_FRAMEBUFFER_BINDING_EXT,
// so we don't need two cases.
case LOCAL_GL_DRAW_FRAMEBUFFER_BINDING_EXT:
if (mScreen) {
*params = mScreen->GetDrawFB();
} else {
raw_fGetIntegerv(pname, params);
}
break;
case LOCAL_GL_READ_FRAMEBUFFER_BINDING_EXT:
if (mScreen) {
*params = mScreen->GetReadFB();
} else {
raw_fGetIntegerv(pname, params);
}
break;
case LOCAL_GL_MAX_TEXTURE_SIZE:
MOZ_ASSERT(mMaxTextureSize>0);
*params = mMaxTextureSize;
break;
case LOCAL_GL_MAX_CUBE_MAP_TEXTURE_SIZE:
MOZ_ASSERT(mMaxCubeMapTextureSize>0);
*params = mMaxCubeMapTextureSize;
break;
case LOCAL_GL_MAX_RENDERBUFFER_SIZE:
MOZ_ASSERT(mMaxRenderbufferSize>0);
*params = mMaxRenderbufferSize;
break;
case LOCAL_GL_VIEWPORT:
for (size_t i = 0; i < 4; i++) {
params[i] = mViewportRect[i];
}
break;
case LOCAL_GL_SCISSOR_BOX:
for (size_t i = 0; i < 4; i++) {
params[i] = mScissorRect[i];
}
break;
default:
raw_fGetIntegerv(pname, params);
break;
}
}
void
GLContext::fReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format,
GLenum type, GLvoid* pixels)
{
BeforeGLReadCall();
bool didReadPixels = false;
if (mScreen) {
didReadPixels = mScreen->ReadPixels(x, y, width, height, format, type, pixels);
}
if (!didReadPixels) {
raw_fReadPixels(x, y, width, height, format, type, pixels);
}
AfterGLReadCall();
}
void
GLContext::fDeleteFramebuffers(GLsizei n, const GLuint* names)
{
if (mScreen) {
// Notify mScreen which framebuffers we're deleting.
// Otherwise, we will get framebuffer binding mispredictions.
for (int i = 0; i < n; i++) {
mScreen->DeletingFB(names[i]);
}
}
if (n == 1 && *names == 0) {
// Deleting framebuffer 0 causes hangs on the DROID. See bug 623228.
} else {
raw_fDeleteFramebuffers(n, names);
}
TRACKING_CONTEXT(DeletedFramebuffers(this, n, names));
}
GLuint
GLContext::GetDrawFB()
{
if (mScreen)
return mScreen->GetDrawFB();
GLuint ret = 0;
GetUIntegerv(LOCAL_GL_DRAW_FRAMEBUFFER_BINDING_EXT, &ret);
return ret;
}
GLuint
GLContext::GetReadFB()
{
if (mScreen)
return mScreen->GetReadFB();
GLenum bindEnum = IsSupported(GLFeature::framebuffer_blit)
? LOCAL_GL_READ_FRAMEBUFFER_BINDING_EXT
: LOCAL_GL_FRAMEBUFFER_BINDING;
GLuint ret = 0;
GetUIntegerv(bindEnum, &ret);
return ret;
}
GLuint
GLContext::GetFB()
{
if (mScreen) {
// This has a very important extra assert that checks that we're
// not accidentally ignoring a situation where the draw and read
// FBs differ.
return mScreen->GetFB();
}
GLuint ret = 0;
GetUIntegerv(LOCAL_GL_FRAMEBUFFER_BINDING, &ret);
return ret;
}
bool
GLContext::InitOffscreen(const gfx::IntSize& size, const SurfaceCaps& caps)
{
if (!CreateScreenBuffer(size, caps))
return false;
MakeCurrent();
fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, 0);
fScissor(0, 0, size.width, size.height);
fViewport(0, 0, size.width, size.height);
mCaps = mScreen->mCaps;
MOZ_ASSERT(!mCaps.any);
UpdateGLFormats(mCaps);
return true;
}
bool
GLContext::IsDrawingToDefaultFramebuffer()
{
return Screen()->IsDrawFramebufferDefault();
}
} /* namespace gl */
} /* namespace mozilla */

Просмотреть файл

@ -32,19 +32,17 @@
#define MOZ_GL_DEBUG 1
#endif
#include "mozilla/UniquePtr.h"
#include "../../mfbt/RefPtr.h"
#include "../../mfbt/UniquePtr.h"
#include "GLDefs.h"
#include "GLLibraryLoader.h"
#include "nsISupportsImpl.h"
#include "plstr.h"
#include "nsDataHashtable.h"
#include "nsHashKeys.h"
#include "nsAutoPtr.h"
#include "GLContextTypes.h"
#include "GLTextureImage.h"
//#include "GLTextureImage.h"
#include "SurfaceTypes.h"
#include "GLScreenBuffer.h"
#include "GLContextSymbols.h"
#include "base/platform_thread.h" // for PlatformThreadId
#include "mozilla/GenericRefCounted.h"
@ -62,13 +60,14 @@ namespace mozilla {
} // namespace gfx
namespace gl {
class GLContext;
class GLLibraryEGL;
class GLScreenBuffer;
class TextureGarbageBin;
class GLBlitHelper;
class GLBlitTextureImageHelper;
class GLContext;
class GLLibraryEGL;
class GLReadTexImageHelper;
class GLScreenBuffer;
class SharedSurface;
class TextureGarbageBin;
struct SurfaceCaps;
} // namespace gl
@ -792,31 +791,19 @@ private:
// Do whatever setup is necessary to draw to our offscreen FBO, if it's
// bound.
void BeforeGLDrawCall() {
}
void BeforeGLDrawCall() { }
// Do whatever tear-down is necessary after drawing to our offscreen FBO,
// if it's bound.
void AfterGLDrawCall()
{
if (mScreen) {
mScreen->AfterDrawCall();
}
mHeavyGLCallsSinceLastFlush = true;
}
void AfterGLDrawCall();
// Do whatever setup is necessary to read from our offscreen FBO, if it's
// bound.
void BeforeGLReadCall()
{
if (mScreen)
mScreen->BeforeReadCall();
}
void BeforeGLReadCall();
// Do whatever tear-down is necessary after reading from our offscreen FBO,
// if it's bound.
void AfterGLReadCall() {
}
void AfterGLReadCall() { }
// -----------------------------------------------------------------------------
@ -854,32 +841,7 @@ public:
AFTER_GL_CALL;
}
void fBindFramebuffer(GLenum target, GLuint framebuffer) {
if (!mScreen) {
raw_fBindFramebuffer(target, framebuffer);
return;
}
switch (target) {
case LOCAL_GL_DRAW_FRAMEBUFFER_EXT:
mScreen->BindDrawFB(framebuffer);
return;
case LOCAL_GL_READ_FRAMEBUFFER_EXT:
mScreen->BindReadFB(framebuffer);
return;
case LOCAL_GL_FRAMEBUFFER:
mScreen->BindFB(framebuffer);
return;
default:
// Nothing we care about, likely an error.
break;
}
raw_fBindFramebuffer(target, framebuffer);
}
void fBindFramebuffer(GLenum target, GLuint framebuffer);
void fInvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments) {
BEFORE_GL_CALL;
@ -1041,29 +1003,8 @@ public:
mHeavyGLCallsSinceLastFlush = true;
}
void fCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) {
if (!IsTextureSizeSafeToPassToDriver(target, width, height)) {
// pass wrong values to cause the GL to generate GL_INVALID_VALUE.
// See bug 737182 and the comment in IsTextureSizeSafeToPassToDriver.
level = -1;
width = -1;
height = -1;
border = -1;
}
BeforeGLReadCall();
bool didCopyTexImage2D = false;
if (mScreen) {
didCopyTexImage2D = mScreen->CopyTexImage2D(target, level, internalformat, x,
y, width, height, border);
}
if (!didCopyTexImage2D) {
raw_fCopyTexImage2D(target, level, internalformat, x, y, width, height,
border);
}
AfterGLReadCall();
}
void fCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x,
GLint y, GLsizei width, GLsizei height, GLint border);
void fCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) {
BeforeGLReadCall();
@ -1238,7 +1179,7 @@ public:
}
private:
void raw_fGetIntegerv(GLenum pname, GLint *params) {
void raw_fGetIntegerv(GLenum pname, GLint* params) {
BEFORE_GL_CALL;
mSymbols.fGetIntegerv(pname, params);
AFTER_GL_CALL;
@ -1246,72 +1187,19 @@ private:
public:
void fGetIntegerv(GLenum pname, GLint *params) {
switch (pname)
{
// LOCAL_GL_FRAMEBUFFER_BINDING is equal to
// LOCAL_GL_DRAW_FRAMEBUFFER_BINDING_EXT,
// so we don't need two cases.
case LOCAL_GL_DRAW_FRAMEBUFFER_BINDING_EXT:
if (mScreen) {
*params = mScreen->GetDrawFB();
} else {
raw_fGetIntegerv(pname, params);
}
break;
case LOCAL_GL_READ_FRAMEBUFFER_BINDING_EXT:
if (mScreen) {
*params = mScreen->GetReadFB();
} else {
raw_fGetIntegerv(pname, params);
}
break;
case LOCAL_GL_MAX_TEXTURE_SIZE:
MOZ_ASSERT(mMaxTextureSize>0);
*params = mMaxTextureSize;
break;
case LOCAL_GL_MAX_CUBE_MAP_TEXTURE_SIZE:
MOZ_ASSERT(mMaxCubeMapTextureSize>0);
*params = mMaxCubeMapTextureSize;
break;
case LOCAL_GL_MAX_RENDERBUFFER_SIZE:
MOZ_ASSERT(mMaxRenderbufferSize>0);
*params = mMaxRenderbufferSize;
break;
case LOCAL_GL_VIEWPORT:
for (size_t i = 0; i < 4; i++) {
params[i] = mViewportRect[i];
}
break;
case LOCAL_GL_SCISSOR_BOX:
for (size_t i = 0; i < 4; i++) {
params[i] = mScissorRect[i];
}
break;
default:
raw_fGetIntegerv(pname, params);
break;
}
}
void fGetIntegerv(GLenum pname, GLint* params);
void GetUIntegerv(GLenum pname, GLuint *params) {
fGetIntegerv(pname, reinterpret_cast<GLint*>(params));
}
void fGetFloatv(GLenum pname, GLfloat *params) {
void fGetFloatv(GLenum pname, GLfloat* params) {
BEFORE_GL_CALL;
mSymbols.fGetFloatv(pname, params);
AFTER_GL_CALL;
}
void fGetBooleanv(GLenum pname, realGLboolean *params) {
void fGetBooleanv(GLenum pname, realGLboolean* params) {
BEFORE_GL_CALL;
mSymbols.fGetBooleanv(pname, params);
AFTER_GL_CALL;
@ -1604,20 +1492,8 @@ public:
mHeavyGLCallsSinceLastFlush = true;
}
void fReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels) {
BeforeGLReadCall();
bool didReadPixels = false;
if (mScreen) {
didReadPixels = mScreen->ReadPixels(x, y, width, height, format, type, pixels);
}
if (!didReadPixels) {
raw_fReadPixels(x, y, width, height, format, type, pixels);
}
AfterGLReadCall();
}
void fReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format,
GLenum type, GLvoid* pixels);
public:
void fSampleCoverage(GLclampf value, realGLboolean invert) {
@ -2289,22 +2165,7 @@ public:
TRACKING_CONTEXT(DeletedBuffers(this, n, names));
}
void fDeleteFramebuffers(GLsizei n, const GLuint* names) {
if (mScreen) {
// Notify mScreen which framebuffers we're deleting.
// Otherwise, we will get framebuffer binding mispredictions.
for (int i = 0; i < n; i++) {
mScreen->DeletingFB(names[i]);
}
}
if (n == 1 && *names == 0) {
// Deleting framebuffer 0 causes hangs on the DROID. See bug 623228.
} else {
raw_fDeleteFramebuffers(n, names);
}
TRACKING_CONTEXT(DeletedFramebuffers(this, n, names));
}
void fDeleteFramebuffers(GLsizei n, const GLuint* names);
void fDeleteRenderbuffers(GLsizei n, const GLuint* names) {
raw_fDeleteRenderbuffers(n, names);
@ -3359,40 +3220,11 @@ public:
fBindFramebuffer(LOCAL_GL_READ_FRAMEBUFFER_EXT, fb);
}
GLuint GetDrawFB() {
if (mScreen)
return mScreen->GetDrawFB();
GLuint GetDrawFB();
GLuint ret = 0;
GetUIntegerv(LOCAL_GL_DRAW_FRAMEBUFFER_BINDING_EXT, &ret);
return ret;
}
GLuint GetReadFB();
GLuint GetReadFB() {
if (mScreen)
return mScreen->GetReadFB();
GLenum bindEnum = IsSupported(GLFeature::framebuffer_blit)
? LOCAL_GL_READ_FRAMEBUFFER_BINDING_EXT
: LOCAL_GL_FRAMEBUFFER_BINDING;
GLuint ret = 0;
GetUIntegerv(bindEnum, &ret);
return ret;
}
GLuint GetFB() {
if (mScreen) {
// This has a very important extra assert that checks that we're
// not accidentally ignoring a situation where the draw and read
// FBs differ.
return mScreen->GetFB();
}
GLuint ret = 0;
GetUIntegerv(LOCAL_GL_FRAMEBUFFER_BINDING, &ret);
return ret;
}
GLuint GetFB();
private:
void GetShaderPrecisionFormatNonES2(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) {
@ -3452,7 +3284,7 @@ public:
}
protected:
nsRefPtr<GLContext> mSharedContext;
RefPtr<GLContext> mSharedContext;
// The thread id which this context was created.
PlatformThreadId mOwningThreadId;
@ -3492,22 +3324,7 @@ public:
return thisShared == otherShared;
}
bool InitOffscreen(const gfx::IntSize& size, const SurfaceCaps& caps) {
if (!CreateScreenBuffer(size, caps))
return false;
MakeCurrent();
fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, 0);
fScissor(0, 0, size.width, size.height);
fViewport(0, 0, size.width, size.height);
mCaps = mScreen->mCaps;
MOZ_ASSERT(!mCaps.any);
UpdateGLFormats(mCaps);
return true;
}
bool InitOffscreen(const gfx::IntSize& size, const SurfaceCaps& caps);
protected:
// Note that it does -not- clear the resized buffers.
@ -3598,12 +3415,10 @@ public:
bool WorkAroundDriverBugs() const { return mWorkAroundDriverBugs; }
bool IsDrawingToDefaultFramebuffer() {
return Screen()->IsDrawFramebufferDefault();
}
bool IsDrawingToDefaultFramebuffer();
protected:
nsRefPtr<TextureGarbageBin> mTexGarbageBin;
RefPtr<TextureGarbageBin> mTexGarbageBin;
public:
TextureGarbageBin* TexGarbageBin() {

Просмотреть файл

@ -9,6 +9,7 @@
#include "GLBlitHelper.h"
#include "GLContext.h"
#include "GLReadTexImageHelper.h"
#include "GLScreenBuffer.h"
#include "nsThreadUtils.h"
#include "ScopedGLHelpers.h"
#include "SharedSurfaceGL.h"

Просмотреть файл

@ -22,7 +22,7 @@ namespace HangMonitor {
} // namespace HangMonitor
namespace Telemetry {
#include "TelemetryHistogramEnums.h"
#include "mozilla/TelemetryHistogramEnums.h"
enum TimerResolution {
Millisecond,