import changes from `dev' branch of rmottola/Arctic-Fox:

- Bug 1167420 - Handle fallible AppendElement call in netwerk/base/Dashboard.cpp. r=valentin (a485b8990)
- Bug 968520 - Add mozilla::fallible to FallibleTArray::AppendElement calls. r=froydnj (12a529a0e)
- Bug 1172584 - Avoid coping FallibleTArray in SendRequestRunnable constructor. r=dragana (c3a4a4253)
- Bug 948466: Rename gfxPangoFonts to gfxFontconfigFonts. r=nical (43eed1f5f)
- Bug 968520 - Add mozilla::fallible to more FallibleTArray calls. r=froydnj (339968a1d)
- Bug 1166544 - Assume successful InsertElementAt calls in DOMSVG*List::MaybeInsertNullInAnimValListAt. r=dholbert (cf687dad7)
- Bug 968520 - Add mozilla::fallible to FallibleTArray::InsertElementAt calls. r=froydnj (cc5c68ff2)
- Bug 968520 - Add mozilla::fallible to more FallibleTArray::InsertElementsAt calls. r=froydnj (66df1d034)
- Bug 1165735 - Make ThreadSharedFloatArrayBufferList::mContents infallible. r=roc (eda2839db)
- Bug 1166544 - Use ReplaceElementAt instead of Clear and InsertElementAt in SVGMotionSMILType::Add. r=dholbert (474887a8c)
- Bug 1167418 - Check AppendElement call in MediaQueryList. r=heycam (b6ed6d153)
- Bug 1167418 - Use nsTArray instead of FallibleTArray in MediaQueryList. r=heycam (c9e3816d0)
- Bug 1167418 - Follow-up: Fix bustage (5015e91ce)
- Bug 1174220 - Part 1: Remove capacity constructor of MediaLargeByteBuffer. r=jya (66819d3e4)
- Bug 1179282 - Use nsTArray::Assign instead of the assignment operator in dom/svg/. r=dholbert (cb3d43c19)
- Bug 968520 - Add nsTArray::Assign. r=froydnj (e5eccf354)
- Bug 1182277, don't leak when using nsAutoTArray inside nsTArray, r=nfroyd (bba32394c)
- Bug 1143575. Avoid including Android's GraphicBuffer.h from LayersTypes.h. r=nical (99e4e2816)
- Bug 1143575. Avoid use of COMPARE macro which can clash with Android headers. r=bent (99cfc74c4)
- Bug 1143575. Add RefBase #include to stagefright stubs. r=cpearce (f9e327600)
- Bug 1143575. test_HaveMetadataUnbufferedSeek should not wait for canplay since preload='metadata' elements may not fire canplay. r=cpearce (f1b0eee27)
- Bug 1143575. Make GL context current before cleaning up programs. r=nical (d7b05b2bd)
- partial Bug 1143575. Android's screenshotting code should invalidate the LayrManagerComposite to ensure composition will actually happen. r=nical (58fb296ab)
- Bug 1143575. Remove unused Image::IsSentToCompositor tracking. r=nical (808d0b3f0)
- Bug 1143575. Remove unused CompositionNotifySink. r=nical (98a332305)
- Bug 1143575. Remove unused VideoFrameContainer::Reset. r=nical (e292bc722)
- Bug 1143575. Rename mAsyncTransactionTrackeres to mAsyncTransactionTrackers. r=nical (df71ebf4f)
- Bug 1143575. Remove unused ImageContainer::ResetPaintCount. r=nical (a92c5bf6e)
- Bug 1143575. Remove unused VideoFrameContainer::ClearCurrentFrame aResetSize parameter. r=nical (5d3c9b83a)
- Bug 1143575. Remove unused ReturnReleaseFence. r=nical (9d6ea92b5)
- Bug 1143575. LayerManagerComposite can't get END_NO_COMPOSITE. r=mattwoodrow (0c5c364b5)
- Bug 1143575. Remove unused AttachAsyncCompositable overload. r=nical (5fd3d4f6d)
- Bug 1143575. Rename ImageBridgeChild's AutoRemoteTextures to AutoRemoveTexturesFromImageBridge to avoid clashes with later work. r=nical (34d67fcc0)
- Bug 1143575. Fix some code formatting. r=nical (1d7f30f60)
- Bug 1143575. Move mLayer from ImageClientBridge up into its superclass ImageClient. r=nical (40c902a36)
- Bug 1127336 - Label HW-decoded frames with correct origin. - r=vlad (fd1580bcd)
- Bug 1167504 - Part 1: Remove BindableName - Framebuffer. r=jgilbert (b3133eee6)
- Bug 1167504 - Part 2: Remove BindableName - Renderbuffer. r=jgilbert (155a7e796)
- Bug 1167504 - Part 3: Remove BindableName - Sampler. r=jgilbert (8c5c68960)
- Bug 1167504 - Part 4: Remove BindableName - Texture. r=jgilbert (28077db04)
- Bug 1167504 - Part 5: Remove BindableName - Transform Feedback. r=jgilbert (4fd839598)
- Bug 1170454: Fix up instance type for VAOs. r=smaug,r=jgilbert (cc62d993a)
- Bug 1167504 - Part 6: Remove BindableName - Vertex Array. r=jgilbert (1d54d5bc1)
- Bug 1048724 - Implement GetBufferSubData. r=jgilbert, r=smaug (06570aa84)
- Bug 1167504 - Part 7: Remove BindableName - Buffer. r=jgilbert (b2ddf3fc6)
This commit is contained in:
2021-03-18 11:57:10 +08:00
parent 232a03e11f
commit cbff465051
155 changed files with 1151 additions and 724 deletions
+11 -11
View File
@@ -607,7 +607,7 @@ private:
return;
}
if (!arguments.AppendElement(value)) {
if (!arguments.AppendElement(value, fallible)) {
return;
}
}
@@ -768,7 +768,7 @@ Console::Time(JSContext* aCx, const JS::Handle<JS::Value> aTime)
Sequence<JS::Value> data;
SequenceRooter<JS::Value> rooter(aCx, &data);
if (!aTime.isUndefined() && !data.AppendElement(aTime)) {
if (!aTime.isUndefined() && !data.AppendElement(aTime, fallible)) {
return;
}
@@ -781,7 +781,7 @@ Console::TimeEnd(JSContext* aCx, const JS::Handle<JS::Value> aTime)
Sequence<JS::Value> data;
SequenceRooter<JS::Value> rooter(aCx, &data);
if (!aTime.isUndefined() && !data.AppendElement(aTime)) {
if (!aTime.isUndefined() && !data.AppendElement(aTime, fallible)) {
return;
}
@@ -794,7 +794,7 @@ Console::TimeStamp(JSContext* aCx, const JS::Handle<JS::Value> aData)
Sequence<JS::Value> data;
SequenceRooter<JS::Value> rooter(aCx, &data);
if (aData.isString() && !data.AppendElement(aData)) {
if (aData.isString() && !data.AppendElement(aData, fallible)) {
return;
}
@@ -834,7 +834,7 @@ Console::ProfileMethod(JSContext* aCx, const nsAString& aAction,
Sequence<JS::Value>& sequence = event.mArguments.Value();
for (uint32_t i = 0; i < aData.Length(); ++i) {
if (!sequence.AppendElement(aData[i])) {
if (!sequence.AppendElement(aData[i], fallible)) {
return;
}
}
@@ -1380,7 +1380,7 @@ FlushOutput(JSContext* aCx, Sequence<JS::Value>& aSequence, nsString &aOutput)
return false;
}
if (!aSequence.AppendElement(JS::StringValue(str))) {
if (!aSequence.AppendElement(JS::StringValue(str), fallible)) {
return false;
}
@@ -1511,7 +1511,7 @@ Console::ProcessArguments(JSContext* aCx,
v = aData[index++];
}
if (!aSequence.AppendElement(v)) {
if (!aSequence.AppendElement(v, fallible)) {
return false;
}
@@ -1534,13 +1534,13 @@ Console::ProcessArguments(JSContext* aCx,
int32_t diff = aSequence.Length() - aStyles.Length();
if (diff > 0) {
for (int32_t i = 0; i < diff; i++) {
if (!aStyles.AppendElement(JS::NullValue())) {
if (!aStyles.AppendElement(JS::NullValue(), fallible)) {
return false;
}
}
}
if (!aStyles.AppendElement(JS::StringValue(jsString))) {
if (!aStyles.AppendElement(JS::StringValue(jsString), fallible)) {
return false;
}
}
@@ -1612,7 +1612,7 @@ Console::ProcessArguments(JSContext* aCx,
// The rest of the array, if unused by the format string.
for (; index < aData.Length(); ++index) {
if (!aSequence.AppendElement(aData[index])) {
if (!aSequence.AppendElement(aData[index], fallible)) {
return false;
}
}
@@ -1748,7 +1748,7 @@ Console::ArgumentsToValueList(const nsTArray<JS::Heap<JS::Value>>& aData,
Sequence<JS::Value>& aSequence)
{
for (uint32_t i = 0; i < aData.Length(); ++i) {
if (!aSequence.AppendElement(aData[i])) {
if (!aSequence.AppendElement(aData[i], fallible)) {
return false;
}
}
+1 -1
View File
@@ -1004,7 +1004,7 @@ WebSocket::Constructor(const GlobalObject& aGlobal,
ErrorResult& aRv)
{
Sequence<nsString> protocols;
if (!protocols.AppendElement(aProtocol)) {
if (!protocols.AppendElement(aProtocol, fallible)) {
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
return nullptr;
}
+3 -2
View File
@@ -715,7 +715,8 @@ nsDOMMutationObserver::GetObservingInfo(
mozilla::dom::Sequence<nsString>& filtersAsStrings =
info.mAttributeFilter.Value();
for (int32_t j = 0; j < filters.Count(); ++j) {
if (!filtersAsStrings.AppendElement(nsDependentAtomString(filters[j]))) {
if (!filtersAsStrings.AppendElement(nsDependentAtomString(filters[j]),
mozilla::fallible)) {
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
return;
}
@@ -774,7 +775,7 @@ nsDOMMutationObserver::HandleMutation()
for (uint32_t i = 0; i < mPendingMutationCount; ++i) {
nsRefPtr<nsDOMMutationRecord> next;
current->mNext.swap(next);
*mutations.AppendElement() = current;
*mutations.AppendElement(mozilla::fallible) = current;
current.swap(next);
}
}
+1 -1
View File
@@ -368,7 +368,7 @@ nsJSScriptTimeoutHandler::Init(nsGlobalWindow *aWindow, bool *aIsInterval,
return NS_ERROR_OUT_OF_MEMORY;
}
for (uint32_t idx = 0; idx < argCount; ++idx) {
*args.AppendElement() = argv[idx + 2];
*args.AppendElement(fallible) = argv[idx + 2];
}
args.SwapElements(mArgs);
} else {
+1 -1
View File
@@ -247,7 +247,7 @@ nsScreen::MozLockOrientation(const nsAString& aOrientation, ErrorResult& aRv)
{
nsString orientation(aOrientation);
Sequence<nsString> orientations;
if (!orientations.AppendElement(orientation)) {
if (!orientations.AppendElement(orientation, fallible)) {
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
return false;
}
+2 -2
View File
@@ -4337,7 +4337,7 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None,
if (done${nestingLevel}) {
break;
}
${elementType}* slotPtr${nestingLevel} = arr${nestingLevel}.AppendElement();
${elementType}* slotPtr${nestingLevel} = arr${nestingLevel}.AppendElement(mozilla::fallible);
if (!slotPtr${nestingLevel}) {
JS_ReportOutOfMemory(cx);
$*{exceptionCode}
@@ -5632,7 +5632,7 @@ class CGArgumentConverter(CGThing):
return false;
}
for (uint32_t variadicArg = ${index}; variadicArg < ${argc}; ++variadicArg) {
${elemType}& slot = *${declName}.AppendElement();
${elemType}& slot = *${declName}.AppendElement(mozilla::fallible);
""")
).substitute(replacer)
+1 -1
View File
@@ -1374,7 +1374,7 @@ nsDOMCameraControl::OnFacesDetected(const nsTArray<ICameraControl::Face>& aFaces
if (faces.SetCapacity(len, fallible)) {
for (uint32_t i = 0; i < len; ++i) {
*faces.AppendElement() =
*faces.AppendElement(fallible) =
new DOMCameraDetectedFace(static_cast<DOMMediaStream*>(this), aFaces[i]);
}
}
+7 -4
View File
@@ -2799,7 +2799,7 @@ void CanvasRenderingContext2D::DrawFocusIfNeeded(mozilla::dom::Element& aElement
// set dashing for foreground
FallibleTArray<mozilla::gfx::Float>& dash = CurrentState().dash;
for (uint32_t i = 0; i < 2; ++i) {
if (!dash.AppendElement(1)) {
if (!dash.AppendElement(1, fallible)) {
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
return;
}
@@ -4108,14 +4108,14 @@ CanvasRenderingContext2D::SetLineDash(const Sequence<double>& aSegments,
return;
}
if (!dash.AppendElement(aSegments[x])) {
if (!dash.AppendElement(aSegments[x], fallible)) {
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
return;
}
}
if (aSegments.Length() % 2) { // If the number of elements is odd, concatenate again
for (uint32_t x = 0; x < aSegments.Length(); x++) {
if (!dash.AppendElement(aSegments[x])) {
if (!dash.AppendElement(aSegments[x], fallible)) {
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
return;
}
@@ -4429,7 +4429,10 @@ CanvasRenderingContext2D::DrawImage(const HTMLImageOrCanvasOrVideoElement& image
gl->fTexParameteri(LOCAL_GL_TEXTURE_2D, LOCAL_GL_TEXTURE_MAG_FILTER, LOCAL_GL_LINEAR);
gl->fTexParameteri(LOCAL_GL_TEXTURE_2D, LOCAL_GL_TEXTURE_MIN_FILTER, LOCAL_GL_LINEAR);
}
bool ok = gl->BlitHelper()->BlitImageToTexture(srcImage.get(), srcImage->GetSize(), mVideoTexture, LOCAL_GL_TEXTURE_2D, 1);
const gl::OriginPos destOrigin = gl::OriginPos::TopLeft;
bool ok = gl->BlitHelper()->BlitImageToTexture(srcImage.get(), srcImage->GetSize(),
mVideoTexture, LOCAL_GL_TEXTURE_2D,
destOrigin);
if (ok) {
NativeSurface texSurf;
texSurf.mType = NativeSurfaceType::OPENGL_TEXTURE;
+1 -1
View File
@@ -129,7 +129,7 @@ JSValToDashArray(JSContext* cx, const JS::Value& patternArray,
} else if (d > 0.0) {
haveNonzeroElement = true;
}
if (!dashes.AppendElement(d)) {
if (!dashes.AppendElement(d, mozilla::fallible)) {
return NS_ERROR_OUT_OF_MEMORY;
}
}
+5 -2
View File
@@ -45,8 +45,9 @@ public:
void CopyBufferSubData(GLenum readTarget, GLenum writeTarget,
GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);
void GetBufferSubData(GLenum target, GLintptr offset, const dom::ArrayBuffer& returnedData);
void GetBufferSubData(GLenum target, GLintptr offset, const dom::ArrayBufferView& returnedData);
void GetBufferSubData(GLenum target, GLintptr offset,
const dom::Nullable<dom::ArrayBuffer>& maybeData);
// -------------------------------------------------------------------------
// Framebuffer objects - WebGL2ContextFramebuffers.cpp
@@ -276,6 +277,8 @@ private:
GLsizei width, GLsizei height, GLsizei depth,
const char* info);
// CreateVertexArrayImpl is assumed to be infallible.
virtual WebGLVertexArray* CreateVertexArrayImpl() override;
virtual bool ValidateAttribPointerType(bool integerMode, GLenum type, GLsizei* alignment, const char* info) override;
virtual bool ValidateBufferTarget(GLenum target, const char* info) override;
virtual bool ValidateBufferIndexedTarget(GLenum target, const char* info) override;
+82 -9
View File
@@ -71,7 +71,7 @@ WebGL2Context::ValidateBufferForTarget(GLenum target, WebGLBuffer* buffer,
}
ErrorInvalidOperation("%s: buffer already bound to a incompatible target %s",
info, EnumName(buffer->Target().get()));
info, EnumName(buffer->Target()));
return false;
}
@@ -129,14 +129,87 @@ WebGL2Context::CopyBufferSubData(GLenum readTarget, GLenum writeTarget,
void
WebGL2Context::GetBufferSubData(GLenum target, GLintptr offset,
const dom::ArrayBuffer& returnedData)
const dom::Nullable<dom::ArrayBuffer>& maybeData)
{
MOZ_CRASH("Not Implemented.");
}
if (IsContextLost())
return;
void
WebGL2Context::GetBufferSubData(GLenum target, GLintptr offset,
const dom::ArrayBufferView& returnedData)
{
MOZ_CRASH("Not Implemented.");
// For the WebGLBuffer bound to the passed target, read
// returnedData.byteLength bytes from the buffer starting at byte
// offset offset and write them to returnedData.
// If zero is bound to target, an INVALID_OPERATION error is
// generated.
if (!ValidateBufferTarget(target, "getBufferSubData"))
return;
// If offset is less than zero, an INVALID_VALUE error is
// generated.
if (offset < 0)
return ErrorInvalidValue("getBufferSubData: negative offset");
// If returnedData is null then an INVALID_VALUE error is
// generated.
if (maybeData.IsNull())
return ErrorInvalidValue("getBufferSubData: returnedData is null");
WebGLRefPtr<WebGLBuffer>& bufferSlot = GetBufferSlotByTarget(target);
WebGLBuffer* boundBuffer = bufferSlot.get();
if (!boundBuffer)
return ErrorInvalidOperation("getBufferSubData: no buffer bound");
// If offset + returnedData.byteLength would extend beyond the end
// of the buffer an INVALID_VALUE error is generated.
const dom::ArrayBuffer& data = maybeData.Value();
data.ComputeLengthAndData();
CheckedInt<WebGLsizeiptr> neededByteLength = CheckedInt<WebGLsizeiptr>(offset) + data.Length();
if (!neededByteLength.isValid()) {
ErrorInvalidValue("getBufferSubData: Integer overflow computing the needed"
" byte length.");
return;
}
if (neededByteLength.value() > boundBuffer->ByteLength()) {
ErrorInvalidValue("getBufferSubData: Not enough data. Operation requires"
" %d bytes, but buffer only has %d bytes.",
neededByteLength.value(), boundBuffer->ByteLength());
return;
}
// If target is TRANSFORM_FEEDBACK_BUFFER, and any transform
// feedback object is currently active, an INVALID_OPERATION error
// is generated.
WebGLTransformFeedback* currentTF = mBoundTransformFeedback;
if (target == LOCAL_GL_TRANSFORM_FEEDBACK_BUFFER && currentTF) {
if (currentTF->mIsActive)
return ErrorInvalidOperation("getBufferSubData: Currently bound transform"
" feedback is active");
// https://github.com/NVIDIA/WebGL/commit/63aff5e58c1d79825a596f0f4aa46174b9a5f72c
// Performing reads and writes on a buffer that is currently
// bound for transform feedback causes undefined results in
// GLES3.0 and OpenGL 4.5. In practice results of reads and
// writes might be consistent as long as transform feedback
// objects are not active, but neither GLES3.0 nor OpenGL 4.5
// spec guarantees this - just being bound for transform
// feedback is sufficient to cause undefined results.
BindTransformFeedback(LOCAL_GL_TRANSFORM_FEEDBACK, nullptr);
}
/* If the buffer is written and read sequentially by other
* operations and getBufferSubData, it is the responsibility of
* the WebGL API to ensure that data are access
* consistently. This applies even if the buffer is currently
* bound to a transform feedback binding point.
*/
void* ptr = gl->fMapBufferRange(target, offset, data.Length(), LOCAL_GL_MAP_READ_BIT);
memcpy(data.Data(), ptr, data.Length());
gl->fUnmapBuffer(target);
if (target == LOCAL_GL_TRANSFORM_FEEDBACK_BUFFER && currentTF) {
BindTransformFeedback(LOCAL_GL_TRANSFORM_FEEDBACK, currentTF);
}
}
+3 -3
View File
@@ -349,19 +349,19 @@ TranslateDefaultAttachments(const dom::Sequence<GLenum>& in, dom::Sequence<GLenu
for (size_t i = 0; i < in.Length(); i++) {
switch (in[i]) {
case LOCAL_GL_COLOR:
if (!out->AppendElement(LOCAL_GL_COLOR_ATTACHMENT0)) {
if (!out->AppendElement(LOCAL_GL_COLOR_ATTACHMENT0, fallible)) {
return false;
}
break;
case LOCAL_GL_DEPTH:
if (!out->AppendElement(LOCAL_GL_DEPTH_ATTACHMENT)) {
if (!out->AppendElement(LOCAL_GL_DEPTH_ATTACHMENT, fallible)) {
return false;
}
break;
case LOCAL_GL_STENCIL:
if (!out->AppendElement(LOCAL_GL_STENCIL_ATTACHMENT)) {
if (!out->AppendElement(LOCAL_GL_STENCIL_ATTACHMENT, fallible)) {
return false;
}
break;
+2 -1
View File
@@ -54,7 +54,8 @@ WebGL2Context::IsSampler(WebGLSampler* sampler)
if (sampler->IsDeleted())
return false;
return !sampler->HasEverBeenBound();
MakeContextCurrent();
return gl->fIsSampler(sampler->mGLName);
}
void
@@ -60,7 +60,7 @@ WebGL2Context::IsTransformFeedback(WebGLTransformFeedback* tf)
return false;
MakeContextCurrent();
return gl->fIsTransformFeedback(tf->GLName());
return gl->fIsTransformFeedback(tf->mGLName);
}
void
@@ -84,11 +84,8 @@ WebGL2Context::BindTransformFeedback(GLenum target, WebGLTransformFeedback* tf)
if (tf && tf->IsDeleted())
return ErrorInvalidOperation("bindTransformFeedback: Attempt to bind deleted id");
if (tf)
tf->BindTo(LOCAL_GL_TRANSFORM_FEEDBACK);
MakeContextCurrent();
gl->fBindTransformFeedback(target, tf ? tf->GLName() : 0);
gl->fBindTransformFeedback(target, tf ? tf->mGLName : 0);
if (tf)
mBoundTransformFeedback = tf;
else
+10 -9
View File
@@ -5,16 +5,17 @@
#include "WebGL2Context.h"
#include "GLContext.h"
#include "WebGLVertexArrayObject.h"
using namespace mozilla;
using namespace mozilla::dom;
namespace mozilla {
// -------------------------------------------------------------------------
// Vertex Array Object
// TODO(djg): Implemented in WebGLContext
/*
already_AddRefed<WebGLVertexArrayObject> CreateVertexArray();
void DeleteVertexArray(WebGLVertexArrayObject* vertexArray);
bool IsVertexArray(WebGLVertexArrayObject* vertexArray);
void BindVertexArray(WebGLVertexArrayObject* vertexArray);
*/
WebGLVertexArray*
WebGL2Context::CreateVertexArrayImpl()
{
return dom::WebGLVertexArrayObject::Create(this);
}
} // namespace mozilla
+15 -2
View File
@@ -13,8 +13,9 @@
namespace mozilla {
WebGLBuffer::WebGLBuffer(WebGLContext* webgl, GLuint buf)
: WebGLBindableName<BufferBinding>(buf)
, WebGLContextBoundObject(webgl)
: WebGLContextBoundObject(webgl)
, mGLName(buf)
, mTarget(LOCAL_GL_NONE)
, mByteLength(0)
{
mContext->mBuffers.insertBack(this);
@@ -35,6 +36,18 @@ WebGLBuffer::Delete()
LinkedListElement<WebGLBuffer>::remove(); // remove from mContext->mBuffers
}
void
WebGLBuffer::BindTo(GLenum target)
{
MOZ_ASSERT(target != LOCAL_GL_NONE, "Can't bind to GL_NONE.");
MOZ_ASSERT(!HasEverBeenBound() || mTarget == target, "Rebinding is illegal.");
bool targetChanged = (target != mTarget);
mTarget = target;
if (targetChanged)
OnTargetChanged();
}
void
WebGLBuffer::OnTargetChanged()
{
+9 -3
View File
@@ -10,7 +10,6 @@
#include "mozilla/LinkedList.h"
#include "mozilla/MemoryReporting.h"
#include "nsWrapperCache.h"
#include "WebGLBindableName.h"
#include "WebGLObjectModel.h"
#include "WebGLStrongTypes.h"
#include "WebGLTypes.h"
@@ -21,7 +20,6 @@ class WebGLElementArrayCache;
class WebGLBuffer final
: public nsWrapperCache
, public WebGLBindableName<BufferBinding>
, public WebGLRefCountedObject<WebGLBuffer>
, public LinkedListElement<WebGLBuffer>
, public WebGLContextBoundObject
@@ -41,6 +39,10 @@ public:
void ElementArrayCacheBufferSubData(size_t pos, const void* ptr,
size_t updateSizeInBytes);
void BindTo(GLenum target);
bool HasEverBeenBound() const { return mTarget != LOCAL_GL_NONE; }
GLenum Target() const { return mTarget; }
bool Validate(GLenum type, uint32_t max_allowed, size_t first, size_t count,
uint32_t* const out_upperBound);
@@ -52,13 +54,17 @@ public:
virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> aGivenProto) override;
const GLenum mGLName;
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WebGLBuffer)
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WebGLBuffer)
protected:
~WebGLBuffer();
virtual void OnTargetChanged() override;
void OnTargetChanged();
GLenum mTarget;
WebGLsizeiptr mByteLength;
nsAutoPtr<WebGLElementArrayCache> mCache;
+4 -2
View File
@@ -1871,11 +1871,13 @@ WebGLContext::TexImageFromVideoElement(const TexImageTarget texImageTarget,
0, format, type, nullptr);
}
const gl::OriginPos destOrigin = mPixelStoreFlipY ? gl::OriginPos::BottomLeft
: gl::OriginPos::TopLeft;
bool ok = gl->BlitHelper()->BlitImageToTexture(srcImage.get(),
srcImage->GetSize(),
tex->GLName(),
tex->mGLName,
texImageTarget.get(),
mPixelStoreFlipY);
destOrigin);
if (ok) {
TexInternalFormat effectiveInternalFormat =
EffectiveInternalFormatFromInternalFormatAndType(internalFormat,
+2
View File
@@ -1385,6 +1385,8 @@ private:
private:
// -------------------------------------------------------------------------
// Context customization points
virtual WebGLVertexArray* CreateVertexArrayImpl();
virtual bool ValidateAttribPointerType(bool integerMode, GLenum type, GLsizei* alignment, const char* info) = 0;
virtual bool ValidateBufferTarget(GLenum target, const char* info) = 0;
virtual bool ValidateBufferIndexedTarget(GLenum target, const char* info) = 0;
+5 -5
View File
@@ -598,7 +598,7 @@ WebGLContext::DoFakeVertexAttrib0(GLuint vertexCount)
}
GLenum error = GetAndFlushUnderlyingGLErrors();
gl->fBindBuffer(LOCAL_GL_ARRAY_BUFFER, mBoundArrayBuffer ? mBoundArrayBuffer->GLName() : 0);
gl->fBindBuffer(LOCAL_GL_ARRAY_BUFFER, mBoundArrayBuffer ? mBoundArrayBuffer->mGLName : 0);
// note that we do this error checking and early return AFTER having restored the buffer binding above
if (error) {
@@ -624,7 +624,7 @@ WebGLContext::UndoFakeVertexAttrib0()
if (mBoundVertexArray->HasAttrib(0) && mBoundVertexArray->mAttribs[0].buf) {
const WebGLVertexAttribData& attrib0 = mBoundVertexArray->mAttribs[0];
gl->fBindBuffer(LOCAL_GL_ARRAY_BUFFER, attrib0.buf->GLName());
gl->fBindBuffer(LOCAL_GL_ARRAY_BUFFER, attrib0.buf->mGLName);
if (attrib0.integer) {
gl->fVertexAttribIPointer(0,
attrib0.size,
@@ -643,7 +643,7 @@ WebGLContext::UndoFakeVertexAttrib0()
gl->fBindBuffer(LOCAL_GL_ARRAY_BUFFER, 0);
}
gl->fBindBuffer(LOCAL_GL_ARRAY_BUFFER, mBoundArrayBuffer ? mBoundArrayBuffer->GLName() : 0);
gl->fBindBuffer(LOCAL_GL_ARRAY_BUFFER, mBoundArrayBuffer ? mBoundArrayBuffer->mGLName : 0);
}
WebGLContextFakeBlackStatus
@@ -735,11 +735,11 @@ WebGLContext::UnbindFakeBlackTextures()
for (int32_t i = 0; i < mGLMaxTextureUnits; ++i) {
if (mBound2DTextures[i] && mBound2DTextures[i]->ResolvedFakeBlackStatus() != WebGLTextureFakeBlackStatus::NotNeeded) {
gl->fActiveTexture(LOCAL_GL_TEXTURE0 + i);
gl->fBindTexture(LOCAL_GL_TEXTURE_2D, mBound2DTextures[i]->GLName());
gl->fBindTexture(LOCAL_GL_TEXTURE_2D, mBound2DTextures[i]->mGLName);
}
if (mBoundCubeMapTextures[i] && mBoundCubeMapTextures[i]->ResolvedFakeBlackStatus() != WebGLTextureFakeBlackStatus::NotNeeded) {
gl->fActiveTexture(LOCAL_GL_TEXTURE0 + i);
gl->fBindTexture(LOCAL_GL_TEXTURE_CUBE_MAP, mBoundCubeMapTextures[i]->GLName());
gl->fBindTexture(LOCAL_GL_TEXTURE_CUBE_MAP, mBoundCubeMapTextures[i]->mGLName);
}
}
+40 -12
View File
@@ -160,9 +160,11 @@ WebGLContext::BindFramebuffer(GLenum target, WebGLFramebuffer* wfb)
if (!wfb) {
gl->fBindFramebuffer(target, 0);
} else {
wfb->BindTo(target);
GLuint framebuffername = wfb->GLName();
GLuint framebuffername = wfb->mGLName;
gl->fBindFramebuffer(target, framebuffername);
#ifdef ANDROID
wfb->mIsFB = true;
#endif
}
switch (target) {
@@ -197,15 +199,15 @@ WebGLContext::BindRenderbuffer(GLenum target, WebGLRenderbuffer* wrb)
if (wrb && wrb->IsDeleted())
return;
if (wrb)
wrb->BindTo(target);
MakeContextCurrent();
// Sometimes we emulate renderbuffers (depth-stencil emu), so there's not
// always a 1-1 mapping from `wrb` to GL name. Just have `wrb` handle it.
if (wrb) {
wrb->BindRenderbuffer();
#ifdef ANDROID
wrb->mIsRB = true;
#endif
} else {
gl->fBindRenderbuffer(target, 0);
}
@@ -750,7 +752,7 @@ WebGLContext::DeleteTexture(WebGLTexture* tex)
(mBound3DTextures[i] == tex && tex->Target() == LOCAL_GL_TEXTURE_3D))
{
ActiveTexture(LOCAL_GL_TEXTURE0 + i);
BindTexture(tex->Target().get(), nullptr);
BindTexture(tex->Target(), nullptr);
}
}
ActiveTexture(LOCAL_GL_TEXTURE0 + activeTexture);
@@ -1704,9 +1706,22 @@ WebGLContext::IsFramebuffer(WebGLFramebuffer* fb)
if (IsContextLost())
return false;
return ValidateObjectAllowDeleted("isFramebuffer", fb) &&
!fb->IsDeleted() &&
fb->HasEverBeenBound();
if (!ValidateObjectAllowDeleted("isFramebuffer", fb))
return false;
if (fb->IsDeleted())
return false;
#ifdef ANDROID
if (gl->WorkAroundDriverBugs() &&
gl->Renderer() == GLRenderer::AndroidEmulator)
{
return fb->mIsFB;
}
#endif
MakeContextCurrent();
return gl->fIsFramebuffer(fb->mGLName);
}
bool
@@ -1724,9 +1739,22 @@ WebGLContext::IsRenderbuffer(WebGLRenderbuffer* rb)
if (IsContextLost())
return false;
return ValidateObjectAllowDeleted("isRenderBuffer", rb) &&
!rb->IsDeleted() &&
rb->HasEverBeenBound();
if (!ValidateObjectAllowDeleted("isRenderBuffer", rb))
return false;
if (rb->IsDeleted())
return false;
#ifdef ANDROID
if (gl->WorkAroundDriverBugs() &&
gl->Renderer() == GLRenderer::AndroidEmulator)
{
return rb->mIsRB;
}
#endif
MakeContextCurrent();
return gl->fIsRenderbuffer(rb->PrimaryGLName());
}
bool
+10 -12
View File
@@ -24,21 +24,21 @@ void
WebGLContextUnchecked::BindBuffer(GLenum target, WebGLBuffer* buffer)
{
gl->MakeCurrent();
gl->fBindBuffer(target, buffer ? buffer->GLName() : 0);
gl->fBindBuffer(target, buffer ? buffer->mGLName : 0);
}
void
WebGLContextUnchecked::BindBufferBase(GLenum target, GLuint index, WebGLBuffer* buffer)
{
gl->MakeCurrent();
gl->fBindBufferBase(target, index, buffer ? buffer->GLName() : 0);
gl->fBindBufferBase(target, index, buffer ? buffer->mGLName : 0);
}
void
WebGLContextUnchecked::BindBufferRange(GLenum target, GLuint index, WebGLBuffer* buffer, WebGLintptr offset, WebGLsizeiptr size)
{
gl->MakeCurrent();
gl->fBindBufferRange(target, index, buffer ? buffer->GLName() : 0, offset, size);
gl->fBindBufferRange(target, index, buffer ? buffer->mGLName : 0, offset, size);
}
void
@@ -56,9 +56,7 @@ void
WebGLContextUnchecked::BindSampler(GLuint unit, WebGLSampler* sampler)
{
gl->MakeCurrent();
gl->fBindSampler(unit, sampler ? sampler->GLName() : 0);
if (sampler)
sampler->BindTo(LOCAL_GL_SAMPLER_BINDING);
gl->fBindSampler(unit, sampler ? sampler->mGLName : 0);
}
GLint
@@ -69,7 +67,7 @@ WebGLContextUnchecked::GetSamplerParameteriv(WebGLSampler* sampler,
GLint param = 0;
gl->MakeCurrent();
gl->fGetSamplerParameteriv(sampler->GLName(), pname, &param);
gl->fGetSamplerParameteriv(sampler->mGLName, pname, &param);
return param;
}
@@ -82,7 +80,7 @@ WebGLContextUnchecked::GetSamplerParameterfv(WebGLSampler* sampler,
GLfloat param = 0.0f;
gl->MakeCurrent();
gl->fGetSamplerParameterfv(sampler->GLName(), pname, &param);
gl->fGetSamplerParameterfv(sampler->mGLName, pname, &param);
return param;
}
@@ -93,7 +91,7 @@ WebGLContextUnchecked::SamplerParameteri(WebGLSampler* sampler,
{
MOZ_ASSERT(sampler, "Did you validate?");
gl->MakeCurrent();
gl->fSamplerParameteri(sampler->GLName(), pname, param);
gl->fSamplerParameteri(sampler->mGLName, pname, param);
}
void
@@ -103,7 +101,7 @@ WebGLContextUnchecked::SamplerParameteriv(WebGLSampler* sampler,
{
MOZ_ASSERT(sampler, "Did you validate?");
gl->MakeCurrent();
gl->fSamplerParameteriv(sampler->GLName(), pname, param);
gl->fSamplerParameteriv(sampler->mGLName, pname, param);
}
void
@@ -113,7 +111,7 @@ WebGLContextUnchecked::SamplerParameterf(WebGLSampler* sampler,
{
MOZ_ASSERT(sampler, "Did you validate?");
gl->MakeCurrent();
gl->fSamplerParameterf(sampler->GLName(), pname, param);
gl->fSamplerParameterf(sampler->mGLName, pname, param);
}
void
@@ -123,7 +121,7 @@ WebGLContextUnchecked::SamplerParameterfv(WebGLSampler* sampler,
{
MOZ_ASSERT(sampler, "Did you validate?");
gl->MakeCurrent();
gl->fSamplerParameterfv(sampler->GLName(), pname, param);
gl->fSamplerParameterfv(sampler->mGLName, pname, param);
}
} // namespace mozilla
+7 -7
View File
@@ -1052,15 +1052,15 @@ WebGLContext::AssertCachedBindings()
// Bound object state
if (IsWebGL2()) {
GLuint bound = mBoundDrawFramebuffer ? mBoundDrawFramebuffer->GLName()
GLuint bound = mBoundDrawFramebuffer ? mBoundDrawFramebuffer->mGLName
: 0;
AssertUintParamCorrect(gl, LOCAL_GL_DRAW_FRAMEBUFFER_BINDING, bound);
bound = mBoundReadFramebuffer ? mBoundReadFramebuffer->GLName() : 0;
bound = mBoundReadFramebuffer ? mBoundReadFramebuffer->mGLName : 0;
AssertUintParamCorrect(gl, LOCAL_GL_READ_FRAMEBUFFER_BINDING, bound);
} else {
MOZ_ASSERT(mBoundDrawFramebuffer == mBoundReadFramebuffer);
GLuint bound = mBoundDrawFramebuffer ? mBoundDrawFramebuffer->GLName()
GLuint bound = mBoundDrawFramebuffer ? mBoundDrawFramebuffer->mGLName
: 0;
AssertUintParamCorrect(gl, LOCAL_GL_FRAMEBUFFER_BINDING, bound);
}
@@ -1073,20 +1073,20 @@ WebGLContext::AssertCachedBindings()
AssertUintParamCorrect(gl, LOCAL_GL_ACTIVE_TEXTURE, activeTexture);
WebGLTexture* curTex = ActiveBoundTextureForTarget(LOCAL_GL_TEXTURE_2D);
bound = curTex ? curTex->GLName() : 0;
bound = curTex ? curTex->mGLName : 0;
AssertUintParamCorrect(gl, LOCAL_GL_TEXTURE_BINDING_2D, bound);
curTex = ActiveBoundTextureForTarget(LOCAL_GL_TEXTURE_CUBE_MAP);
bound = curTex ? curTex->GLName() : 0;
bound = curTex ? curTex->mGLName : 0;
AssertUintParamCorrect(gl, LOCAL_GL_TEXTURE_BINDING_CUBE_MAP, bound);
// Buffers
bound = mBoundArrayBuffer ? mBoundArrayBuffer->GLName() : 0;
bound = mBoundArrayBuffer ? mBoundArrayBuffer->mGLName : 0;
AssertUintParamCorrect(gl, LOCAL_GL_ARRAY_BUFFER_BINDING, bound);
MOZ_ASSERT(mBoundVertexArray);
WebGLBuffer* curBuff = mBoundVertexArray->mElementArrayBuffer;
bound = curBuff ? curBuff->GLName() : 0;
bound = curBuff ? curBuff->mGLName : 0;
AssertUintParamCorrect(gl, LOCAL_GL_ELEMENT_ARRAY_BUFFER_BINDING, bound);
MOZ_ASSERT(!GetAndFlushUnderlyingGLErrors());
+15 -4
View File
@@ -51,7 +51,7 @@ WebGLContext::CreateVertexArray()
if (IsContextLost())
return nullptr;
nsRefPtr<WebGLVertexArray> globj = WebGLVertexArray::Create(this);
nsRefPtr<WebGLVertexArray> globj = CreateVertexArrayImpl();
MakeContextCurrent();
globj->GenVertexArray();
@@ -59,6 +59,12 @@ WebGLContext::CreateVertexArray()
return globj.forget();
}
WebGLVertexArray*
WebGLContext::CreateVertexArrayImpl()
{
return WebGLVertexArray::Create(this);
}
void
WebGLContext::DeleteVertexArray(WebGLVertexArray* array)
{
@@ -86,9 +92,14 @@ WebGLContext::IsVertexArray(WebGLVertexArray* array)
if (!array)
return false;
return ValidateObjectAllowDeleted("isVertexArray", array) &&
!array->IsDeleted() &&
array->HasEverBeenBound();
if (!ValidateObjectAllowDeleted("isVertexArray", array))
return false;
if (array->IsDeleted())
return false;
MakeContextCurrent();
return array->IsVertexArray();
}
} // namespace mozilla
+11 -3
View File
@@ -378,7 +378,7 @@ WebGLFramebuffer::AttachPoint::FinalizeAttachment(gl::GLContext* gl,
const GLenum imageTarget = ImageTarget().get();
const GLint mipLevel = MipLevel();
const GLuint glName = Texture()->GLName();
const GLuint glName = Texture()->mGLName;
if (attachmentLoc == LOCAL_GL_DEPTH_STENCIL_ATTACHMENT) {
gl->fFramebufferTexture2D(LOCAL_GL_FRAMEBUFFER, LOCAL_GL_DEPTH_ATTACHMENT,
@@ -404,14 +404,18 @@ WebGLFramebuffer::AttachPoint::FinalizeAttachment(gl::GLContext* gl,
// WebGLFramebuffer
WebGLFramebuffer::WebGLFramebuffer(WebGLContext* webgl, GLuint fbo)
: WebGLBindableName<FBTarget>(fbo)
, WebGLContextBoundObject(webgl)
: WebGLContextBoundObject(webgl)
, mGLName(fbo)
, mStatus(0)
, mReadBufferMode(LOCAL_GL_COLOR_ATTACHMENT0)
, mColorAttachment0(this, LOCAL_GL_COLOR_ATTACHMENT0)
, mDepthAttachment(this, LOCAL_GL_DEPTH_ATTACHMENT)
, mStencilAttachment(this, LOCAL_GL_STENCIL_ATTACHMENT)
, mDepthStencilAttachment(this, LOCAL_GL_DEPTH_STENCIL_ATTACHMENT)
#ifdef ANDROID
, mIsFB(false)
#endif
{
mContext->mFramebuffers.insertBack(this);
}
@@ -432,6 +436,10 @@ WebGLFramebuffer::Delete()
mContext->MakeContextCurrent();
mContext->gl->fDeleteFramebuffers(1, &mGLName);
LinkedListElement<WebGLFramebuffer>::removeFrom(mContext->mFramebuffers);
#ifdef ANDROID
mIsFB = false;
#endif
}
void
+13 -3
View File
@@ -8,7 +8,6 @@
#include "mozilla/LinkedList.h"
#include "nsWrapperCache.h"
#include "WebGLBindableName.h"
#include "WebGLObjectModel.h"
#include "WebGLStrongTypes.h"
@@ -23,12 +22,13 @@ namespace gl {
class WebGLFramebuffer final
: public nsWrapperCache
, public WebGLBindableName<FBTarget>
, public WebGLRefCountedObject<WebGLFramebuffer>
, public LinkedListElement<WebGLFramebuffer>
, public WebGLContextBoundObject
, public SupportsWeakPtr<WebGLFramebuffer>
{
friend class WebGLContext;
public:
MOZ_DECLARE_WEAKREFERENCE_TYPENAME(WebGLFramebuffer)
@@ -53,7 +53,6 @@ public:
}
bool IsDefined() const;
bool IsDeleteRequested() const;
TexInternalFormat EffectiveInternalFormat() const;
@@ -99,6 +98,8 @@ public:
FBAttachment attachmentLoc) const;
};
const GLuint mGLName;
private:
mutable GLenum mStatus;
@@ -111,6 +112,15 @@ private:
AttachPoint mDepthStencilAttachment;
nsTArray<AttachPoint> mMoreColorAttachments;
#ifdef ANDROID
// Bug 1140459: Some drivers (including our test slaves!) don't
// give reasonable answers for IsRenderbuffer, maybe others.
// This shows up on Android 2.3 emulator.
//
// So we track the `is a Framebuffer` state ourselves.
bool mIsFB;
#endif
public:
WebGLFramebuffer(WebGLContext* webgl, GLuint fbo);
+7 -2
View File
@@ -47,14 +47,16 @@ WebGLRenderbuffer::WrapObject(JSContext* cx, JS::Handle<JSObject*> aGivenProto)
}
WebGLRenderbuffer::WebGLRenderbuffer(WebGLContext* webgl)
: WebGLBindable<RBTarget>()
, WebGLContextBoundObject(webgl)
: WebGLContextBoundObject(webgl)
, mPrimaryRB(0)
, mSecondaryRB(0)
, mInternalFormat(0)
, mInternalFormatForGL(0)
, mImageDataStatus(WebGLImageDataStatus::NoImageData)
, mSamples(1)
#ifdef ANDROID
, mIsRB(false)
#endif
{
mContext->MakeContextCurrent();
@@ -75,6 +77,9 @@ WebGLRenderbuffer::Delete()
mContext->gl->fDeleteRenderbuffers(1, &mSecondaryRB);
LinkedListElement<WebGLRenderbuffer>::removeFrom(mContext->mRenderbuffers);
#ifdef ANDROID
mIsRB = false;
#endif
}
int64_t
+11 -2
View File
@@ -8,7 +8,6 @@
#include "mozilla/LinkedList.h"
#include "nsWrapperCache.h"
#include "WebGLBindableName.h"
#include "WebGLFramebufferAttachable.h"
#include "WebGLObjectModel.h"
@@ -16,7 +15,6 @@ namespace mozilla {
class WebGLRenderbuffer final
: public nsWrapperCache
, public WebGLBindable<RBTarget>
, public WebGLRefCountedObject<WebGLRenderbuffer>
, public LinkedListElement<WebGLRenderbuffer>
, public WebGLRectangleObject
@@ -41,6 +39,8 @@ public:
GLsizei Samples() const { return mSamples; }
void SetSamples(GLsizei samples) { mSamples = samples; }
GLuint PrimaryGLName() const { return mPrimaryRB; }
GLenum InternalFormat() const { return mInternalFormat; }
void SetInternalFormat(GLenum internalFormat) {
mInternalFormat = internalFormat;
@@ -80,7 +80,16 @@ protected:
GLenum mInternalFormatForGL;
WebGLImageDataStatus mImageDataStatus;
GLsizei mSamples;
#ifdef ANDROID
// Bug 1140459: Some drivers (including our test slaves!) don't
// give reasonable answers for IsRenderbuffer, maybe others.
// This shows up on Android 2.3 emulator.
//
// So we track the `is a Renderbuffer` state ourselves.
bool mIsRB;
#endif
friend class WebGLContext;
friend class WebGLFramebuffer;
};
+2 -2
View File
@@ -12,8 +12,8 @@
namespace mozilla {
WebGLSampler::WebGLSampler(WebGLContext* webgl, GLuint sampler)
: WebGLBindableName<GLenum>(sampler),
WebGLContextBoundObject(webgl)
: WebGLContextBoundObject(webgl)
, mGLName(sampler)
{
mContext->mSamplers.insertBack(this);
}
+2 -2
View File
@@ -8,14 +8,12 @@
#include "mozilla/LinkedList.h"
#include "nsWrapperCache.h"
#include "WebGLBindableName.h"
#include "WebGLObjectModel.h"
namespace mozilla {
class WebGLSampler final
: public nsWrapperCache
, public WebGLBindableName<GLenum>
, public WebGLRefCountedObject<WebGLSampler>
, public LinkedListElement<WebGLSampler>
, public WebGLContextBoundObject
@@ -25,6 +23,8 @@ class WebGLSampler final
public:
explicit WebGLSampler(WebGLContext* webgl, GLuint sampler);
const GLuint mGLName;
void Delete();
WebGLContext* GetParentObject() const;
+10 -11
View File
@@ -23,8 +23,9 @@ WebGLTexture::WrapObject(JSContext* cx, JS::Handle<JSObject*> aGivenProto) {
}
WebGLTexture::WebGLTexture(WebGLContext* webgl, GLuint tex)
: WebGLBindableName<TexTarget>(tex)
, WebGLContextBoundObject(webgl)
: WebGLContextBoundObject(webgl)
, mGLName(tex)
, mTarget(LOCAL_GL_NONE)
, mMinFilter(LOCAL_GL_NEAREST_MIPMAP_LINEAR)
, mMagFilter(LOCAL_GL_LINEAR)
, mWrapS(LOCAL_GL_REPEAT)
@@ -141,7 +142,7 @@ WebGLTexture::Bind(TexTarget texTarget)
bool firstTimeThisTextureIsBound = !HasEverBeenBound();
if (firstTimeThisTextureIsBound) {
BindTo(texTarget);
mTarget = texTarget.get();
} else if (texTarget != Target()) {
mContext->ErrorInvalidOperation("bindTexture: This texture has already"
" been bound to a different target.");
@@ -151,9 +152,7 @@ WebGLTexture::Bind(TexTarget texTarget)
return;
}
GLuint name = GLName();
mContext->gl->fBindTexture(texTarget.get(), name);
mContext->gl->fBindTexture(texTarget.get(), mGLName);
if (firstTimeThisTextureIsBound) {
mFacesCount = (texTarget == LOCAL_GL_TEXTURE_CUBE_MAP) ? 6 : 1;
@@ -228,7 +227,7 @@ WebGLTexture::SetCustomMipmap()
imageInfo.mWidth = std::max(imageInfo.mWidth / 2, 1);
imageInfo.mHeight = std::max(imageInfo.mHeight / 2, 1);
imageInfo.mDepth = std::max(imageInfo.mDepth / 2, 1);
for(size_t face = 0; face < mFacesCount; ++face) {
for (size_t face = 0; face < mFacesCount; ++face) {
ImageInfoAtFace(face, level) = imageInfo;
}
}
@@ -275,8 +274,8 @@ WebGLTexture::IsMipmapCubeComplete() const
return false;
for (int i = 0; i < 6; i++) {
const TexImageTarget face = TexImageTargetForTargetAndFace(LOCAL_GL_TEXTURE_CUBE_MAP,
i);
const TexImageTarget face =
TexImageTargetForTargetAndFace(LOCAL_GL_TEXTURE_CUBE_MAP, i);
if (!DoesMipmapHaveAllLevelsConsistentlyDefined(face))
return false;
}
@@ -625,7 +624,7 @@ WebGLTexture::EnsureNoUninitializedImageData(TexImageTarget imageTarget,
// Try to clear with glClear.
if (imageTarget == LOCAL_GL_TEXTURE_2D) {
bool cleared = ClearWithTempFB(mContext, GLName(), imageTarget, level,
bool cleared = ClearWithTempFB(mContext, mGLName, imageTarget, level,
imageInfo.mEffectiveInternalFormat,
imageInfo.mHeight, imageInfo.mWidth);
if (cleared) {
@@ -636,7 +635,7 @@ WebGLTexture::EnsureNoUninitializedImageData(TexImageTarget imageTarget,
}
// That didn't work. Try uploading zeros then.
gl::ScopedBindTexture autoBindTex(mContext->gl, GLName(), mTarget.get());
gl::ScopedBindTexture autoBindTex(mContext->gl, mGLName, mTarget);
size_t bitspertexel = GetBitsPerTexel(imageInfo.mEffectiveInternalFormat);
MOZ_ASSERT((bitspertexel % 8) == 0); // That would only happen for
+9 -2
View File
@@ -12,7 +12,6 @@
#include "mozilla/LinkedList.h"
#include "nsAlgorithm.h"
#include "nsWrapperCache.h"
#include "WebGLBindableName.h"
#include "WebGLFramebufferAttachable.h"
#include "WebGLObjectModel.h"
#include "WebGLStrongTypes.h"
@@ -31,7 +30,6 @@ IsPOTAssumingNonnegative(GLsizei x)
// WrapObject calls in GetParameter and GetFramebufferAttachmentParameter.
class WebGLTexture final
: public nsWrapperCache
, public WebGLBindableName<TexTarget>
, public WebGLRefCountedObject<WebGLTexture>
, public LinkedListElement<WebGLTexture>
, public WebGLContextBoundObject
@@ -42,6 +40,9 @@ public:
void Delete();
bool HasEverBeenBound() const { return mTarget != LOCAL_GL_NONE; }
GLenum Target() const { return mTarget; }
WebGLContext* GetParentObject() const {
return Context();
}
@@ -62,6 +63,12 @@ protected:
// We store information about the various images that are part of this
// texture. (cubemap faces, mipmap levels)
public:
const GLuint mGLName;
protected:
GLenum mTarget;
public:
class ImageInfo
: public WebGLRectangleObject
+2 -2
View File
@@ -13,8 +13,8 @@ namespace mozilla {
WebGLTransformFeedback::WebGLTransformFeedback(WebGLContext* webgl,
GLuint tf)
: WebGLBindableName<GLenum>(tf)
, WebGLContextBoundObject(webgl)
: WebGLContextBoundObject(webgl)
, mGLName(tf)
, mMode(LOCAL_GL_NONE)
, mIsActive(false)
, mIsPaused(false)
+3 -2
View File
@@ -8,14 +8,12 @@
#include "mozilla/LinkedList.h"
#include "nsWrapperCache.h"
#include "WebGLBindableName.h"
#include "WebGLObjectModel.h"
namespace mozilla {
class WebGLTransformFeedback final
: public nsWrapperCache
, public WebGLBindableName<GLenum>
, public WebGLRefCountedObject<WebGLTransformFeedback>
, public LinkedListElement<WebGLTransformFeedback>
, public WebGLContextBoundObject
@@ -30,11 +28,14 @@ public:
WebGLContext* GetParentObject() const;
virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> aGivenProto) override;
const GLuint mGLName;
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WebGLTransformFeedback)
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WebGLTransformFeedback)
private:
~WebGLTransformFeedback();
GLenum mMode;
bool mIsActive;
bool mIsPaused;
+7 -2
View File
@@ -21,8 +21,7 @@ WebGLVertexArray::WrapObject(JSContext* cx, JS::Handle<JSObject*> aGivenProto)
}
WebGLVertexArray::WebGLVertexArray(WebGLContext* webgl)
: WebGLBindable<VAOBinding>()
, WebGLContextBoundObject(webgl)
: WebGLContextBoundObject(webgl)
, mGLName(0)
{
mContext->mVertexArrays.insertBack(this);
@@ -50,6 +49,12 @@ WebGLVertexArray::Delete()
mAttribs.Clear();
}
bool
WebGLVertexArray::IsVertexArray()
{
return IsVertexArrayImpl();
}
void
WebGLVertexArray::EnsureAttrib(GLuint index)
{
+6 -7
View File
@@ -8,7 +8,6 @@
#include "mozilla/LinkedList.h"
#include "nsWrapperCache.h"
#include "WebGLBindableName.h"
#include "WebGLBuffer.h"
#include "WebGLObjectModel.h"
#include "WebGLStrongTypes.h"
@@ -20,7 +19,6 @@ class WebGLVertexArrayFake;
class WebGLVertexArray
: public nsWrapperCache
, public WebGLBindable<VAOBinding>
, public WebGLRefCountedObject<WebGLVertexArray>
, public LinkedListElement<WebGLVertexArray>
, public WebGLContextBoundObject
@@ -31,14 +29,9 @@ public:
void BindVertexArray() {
// Bind to dummy value to signal that this vertex array has ever been
// bound.
BindTo(LOCAL_GL_VERTEX_ARRAY_BINDING);
BindVertexArrayImpl();
};
virtual void GenVertexArray() = 0;
virtual void BindVertexArrayImpl() = 0;
virtual void DeleteImpl() = 0;
void EnsureAttrib(GLuint index);
bool HasAttrib(GLuint index) const {
return index < mAttribs.Length();
@@ -49,6 +42,7 @@ public:
// Implement parent classes:
void Delete();
bool IsVertexArray();
WebGLContext* GetParentObject() const {
return Context();
@@ -68,6 +62,11 @@ protected:
MOZ_ASSERT(IsDeleted());
}
virtual void GenVertexArray() = 0;
virtual void BindVertexArrayImpl() = 0;
virtual void DeleteImpl() = 0;
virtual bool IsVertexArrayImpl() = 0;
GLuint mGLName;
nsTArray<WebGLVertexAttribData> mAttribs;
WebGLRefPtr<WebGLBuffer> mElementArrayBuffer;
+18
View File
@@ -10,6 +10,11 @@
namespace mozilla {
WebGLVertexArrayFake::WebGLVertexArrayFake(WebGLContext* webgl)
: WebGLVertexArray(webgl)
, mIsVAO(false)
{ }
void
WebGLVertexArrayFake::BindVertexArrayImpl()
{
@@ -52,6 +57,19 @@ WebGLVertexArrayFake::BindVertexArrayImpl()
}
mContext->BindBuffer(LOCAL_GL_ARRAY_BUFFER, prevBuffer);
mIsVAO = true;
}
void
WebGLVertexArrayFake::DeleteImpl()
{
mIsVAO = false;
}
bool
WebGLVertexArrayFake::IsVertexArrayImpl()
{
return mIsVAO;
}
} // namespace mozilla
+7 -6
View File
@@ -13,21 +13,22 @@ namespace mozilla {
class WebGLVertexArrayFake final
: public WebGLVertexArray
{
public:
friend class WebGLVertexArray;
protected:
virtual void BindVertexArrayImpl() override;
virtual void DeleteImpl() override {};
virtual void DeleteImpl() override;
virtual void GenVertexArray() override {};
virtual bool IsVertexArrayImpl() override;
private:
explicit WebGLVertexArrayFake(WebGLContext* webgl)
: WebGLVertexArray(webgl)
{ }
explicit WebGLVertexArrayFake(WebGLContext* webgl);
~WebGLVertexArrayFake() {
DeleteOnce();
}
friend class WebGLVertexArray;
bool mIsVAO;
};
} // namespace mozilla
+37 -1
View File
@@ -10,6 +10,18 @@
namespace mozilla {
WebGLVertexArrayGL::WebGLVertexArrayGL(WebGLContext* webgl)
: WebGLVertexArray(webgl)
#if defined(XP_LINUX)
, mIsVAO(false)
#endif
{ }
WebGLVertexArrayGL::~WebGLVertexArrayGL()
{
DeleteOnce();
}
void
WebGLVertexArrayGL::DeleteImpl()
{
@@ -17,14 +29,21 @@ WebGLVertexArrayGL::DeleteImpl()
mContext->MakeContextCurrent();
mContext->gl->fDeleteVertexArrays(1, &mGLName);
#if defined(XP_LINUX)
mIsVAO = false;
#endif
}
void
WebGLVertexArrayGL::BindVertexArrayImpl()
{
mContext->mBoundVertexArray = this;
mContext->gl->fBindVertexArray(mGLName);
#if defined(XP_LINUX)
mIsVAO = true;
#endif
}
void
@@ -33,4 +52,21 @@ WebGLVertexArrayGL::GenVertexArray()
mContext->gl->fGenVertexArrays(1, &mGLName);
}
bool
WebGLVertexArrayGL::IsVertexArrayImpl()
{
#if defined(XP_LINUX)
gl::GLContext* gl = mContext->gl;
if (gl->WorkAroundDriverBugs() &&
gl->Vendor() == gl::GLVendor::VMware &&
gl->Renderer() == gl::GLRenderer::GalliumLlvmpipe)
{
return mIsVAO;
}
#endif
mContext->MakeContextCurrent();
return mContext->gl->fIsVertexArray(mGLName) != 0;
}
} // namespace mozilla
+14 -10
View File
@@ -10,24 +10,28 @@
namespace mozilla {
class WebGLVertexArrayGL final
class WebGLVertexArrayGL
: public WebGLVertexArray
{
friend class WebGLVertexArray;
public:
virtual void DeleteImpl() override;
virtual void BindVertexArrayImpl() override;
virtual void GenVertexArray() override;
virtual bool IsVertexArrayImpl() override;
private:
explicit WebGLVertexArrayGL(WebGLContext* webgl)
: WebGLVertexArray(webgl)
{ }
protected:
explicit WebGLVertexArrayGL(WebGLContext* webgl);
~WebGLVertexArrayGL();
~WebGLVertexArrayGL() {
DeleteOnce();
}
friend class WebGLVertexArray;
#if defined(XP_LINUX)
// Bug 1140459: Some drivers (including our test slaves!) don't
// give reasonable answers for IsRenderbuffer, maybe others.
//
// So we track the `is a VAO` state ourselves.
bool mIsVAO;
#endif
};
} // namespace mozilla
+35
View File
@@ -0,0 +1,35 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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 "WebGLVertexArrayObject.h"
#include "mozilla/dom/WebGL2RenderingContextBinding.h"
namespace mozilla {
namespace dom {
WebGLVertexArray*
WebGLVertexArrayObject::Create(WebGLContext* webgl)
{
// WebGL 2: This is core in GL ES 3. If support is missing something
// is very wrong.
bool vaoSupport = webgl->GL()->IsSupported(gl::GLFeature::vertex_array_object);
MOZ_RELEASE_ASSERT(vaoSupport, "Vertex Array Objects aren't supported.");
if (vaoSupport)
return new WebGLVertexArrayObject(webgl);
return nullptr;
}
JSObject*
WebGLVertexArrayObject::WrapObject(JSContext* cx,
JS::Handle<JSObject*> givenProto)
{
return dom::WebGLVertexArrayObjectBinding::Wrap(cx, this, givenProto);
}
} // namespace dom
} // namespace mozilla
+42
View File
@@ -0,0 +1,42 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */
#ifndef mozilla_dom_WebGLVertexArrayObject_h
#define mozilla_dom_WebGLVertexArrayObject_h
#include "WebGLVertexArrayGL.h"
namespace mozilla {
namespace dom {
/**
* This class implements the DOM bindings for WebGL 2 VAO.
*
* This exists to so the object returned from gl.createVertexArray()
* is an instance of WebGLVertexArrayObject (to match the WebGL 2
* spec.)
*/
class WebGLVertexArrayObject final
: public WebGLVertexArrayGL
{
public:
static WebGLVertexArray* Create(WebGLContext* webgl);
virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> givenProto) override;
private:
explicit WebGLVertexArrayObject(WebGLContext* webgl)
: WebGLVertexArrayGL(webgl)
{ }
~WebGLVertexArrayObject() {
DeleteOnce();
}
};
} // namespace dom
} // namespace mozilla
#endif // !mozilla_dom_WebGLVertexArrayObject_h
+2
View File
@@ -33,6 +33,7 @@ EXPORTS.mozilla.dom += [
'CanvasUtils.h',
'ImageData.h',
'TextMetrics.h',
'WebGLVertexArrayObject.h',
]
# http://support.microsoft.com/kb/143208
@@ -128,6 +129,7 @@ UNIFIED_SOURCES += [
'WebGLVertexArray.cpp',
'WebGLVertexArrayFake.cpp',
'WebGLVertexArrayGL.cpp',
'WebGLVertexArrayObject.cpp',
]
LOCAL_INCLUDES += [
'/js/xpconnect/wrappers',
+1 -1
View File
@@ -1325,7 +1325,7 @@ DataStoreService::CreateFirstRevisionId(uint32_t aAppId,
new FirstRevisionIdCallback(aAppId, aName, aManifestURL);
Sequence<nsString> dbs;
if (!dbs.AppendElement(NS_LITERAL_STRING(DATASTOREDB_REVISION))) {
if (!dbs.AppendElement(NS_LITERAL_STRING(DATASTOREDB_REVISION), fallible)) {
return NS_ERROR_OUT_OF_MEMORY;
}
+3 -3
View File
@@ -1872,7 +1872,7 @@ HTMLInputElement::SetValue(const nsAString& aValue, ErrorResult& aRv)
return;
}
Sequence<nsString> list;
if (!list.AppendElement(aValue)) {
if (!list.AppendElement(aValue, fallible)) {
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
return;
}
@@ -2462,7 +2462,7 @@ HTMLInputElement::MozSetFileNameArray(const char16_t** aFileNames, uint32_t aLen
Sequence<nsString> list;
for (uint32_t i = 0; i < aLength; ++i) {
if (!list.AppendElement(nsDependentString(aFileNames[i]))) {
if (!list.AppendElement(nsDependentString(aFileNames[i]), fallible)) {
return NS_ERROR_OUT_OF_MEMORY;
}
}
@@ -2515,7 +2515,7 @@ HTMLInputElement::SetUserInput(const nsAString& aValue)
if (mType == NS_FORM_INPUT_FILE)
{
Sequence<nsString> list;
if (!list.AppendElement(aValue)) {
if (!list.AppendElement(aValue, fallible)) {
return NS_ERROR_OUT_OF_MEMORY;
}
+10 -10
View File
@@ -8500,7 +8500,7 @@ ConvertBlobsToActors(PBackgroundParent* aBackgroundActor,
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
MOZ_ALWAYS_TRUE(aActors.AppendElement(actor));
MOZ_ALWAYS_TRUE(aActors.AppendElement(actor, fallible));
if (collectFileInfos) {
nsRefPtr<FileInfo> fileInfo = file.mFileInfo;
@@ -8508,7 +8508,7 @@ ConvertBlobsToActors(PBackgroundParent* aBackgroundActor,
// Transfer a reference to the receiver.
auto transferedFileInfo =
reinterpret_cast<intptr_t>(fileInfo.forget().take());
MOZ_ALWAYS_TRUE(aFileInfos.AppendElement(transferedFileInfo));
MOZ_ALWAYS_TRUE(aFileInfos.AppendElement(transferedFileInfo, fallible));
}
}
@@ -12359,7 +12359,7 @@ Database::Invalidate()
auto* array =
static_cast<FallibleTArray<nsRefPtr<TransactionBase>>*>(aUserData);
if (NS_WARN_IF(!array->AppendElement(aEntry->GetKey()))) {
if (NS_WARN_IF(!array->AppendElement(aEntry->GetKey(), fallible))) {
return PL_DHASH_STOP;
}
@@ -12626,7 +12626,7 @@ Database::AllocPBackgroundIDBTransactionParent(
if (closure->mName == aValue->mCommonMetadata.name() &&
!aValue->mDeleted) {
MOZ_ALWAYS_TRUE(closure->mObjectStores.AppendElement(aValue));
MOZ_ALWAYS_TRUE(closure->mObjectStores.AppendElement(aValue, fallible));
return PL_DHASH_STOP;
}
@@ -18566,7 +18566,7 @@ FactoryOp::SendVersionChangeMessages(DatabaseActorInfo* aDatabaseActorInfo,
Database* database = aDatabaseActorInfo->mLiveDatabases[index];
if ((!aOpeningDatabase || database != aOpeningDatabase) &&
!database->IsClosed() &&
NS_WARN_IF(!maybeBlockedDatabases.AppendElement(database))) {
NS_WARN_IF(!maybeBlockedDatabases.AppendElement(database, fallible))) {
return NS_ERROR_OUT_OF_MEMORY;
}
}
@@ -22848,7 +22848,7 @@ ObjectStoreAddOrPutRequestOp::Init(TransactionBase* aTransaction)
TPBackgroundIDBDatabaseFileParent ||
fileOrFileId.type() == DatabaseFileOrMutableFileId::Tint64_t);
StoredFileInfo* storedFileInfo = mStoredFileInfos.AppendElement();
StoredFileInfo* storedFileInfo = mStoredFileInfos.AppendElement(fallible);
MOZ_ASSERT(storedFileInfo);
switch (fileOrFileId.type()) {
@@ -23413,7 +23413,7 @@ ObjectStoreGetRequestOp::DoDatabaseWork(DatabaseConnection* aConnection)
bool hasResult;
while (NS_SUCCEEDED((rv = stmt->ExecuteStep(&hasResult))) && hasResult) {
StructuredCloneReadInfo* cloneInfo = mResponse.AppendElement();
StructuredCloneReadInfo* cloneInfo = mResponse.AppendElement(fallible);
if (NS_WARN_IF(!cloneInfo)) {
return NS_ERROR_OUT_OF_MEMORY;
}
@@ -23540,7 +23540,7 @@ ObjectStoreGetAllKeysRequestOp::DoDatabaseWork(DatabaseConnection* aConnection)
bool hasResult;
while(NS_SUCCEEDED((rv = stmt->ExecuteStep(&hasResult))) && hasResult) {
Key* key = mResponse.AppendElement();
Key* key = mResponse.AppendElement(fallible);
if (NS_WARN_IF(!key)) {
return NS_ERROR_OUT_OF_MEMORY;
}
@@ -23962,7 +23962,7 @@ IndexGetRequestOp::DoDatabaseWork(DatabaseConnection* aConnection)
bool hasResult;
while(NS_SUCCEEDED((rv = stmt->ExecuteStep(&hasResult))) && hasResult) {
StructuredCloneReadInfo* cloneInfo = mResponse.AppendElement();
StructuredCloneReadInfo* cloneInfo = mResponse.AppendElement(fallible);
if (NS_WARN_IF(!cloneInfo)) {
return NS_ERROR_OUT_OF_MEMORY;
}
@@ -24154,7 +24154,7 @@ IndexGetKeyRequestOp::DoDatabaseWork(DatabaseConnection* aConnection)
bool hasResult;
while(NS_SUCCEEDED((rv = stmt->ExecuteStep(&hasResult))) && hasResult) {
Key* key = mResponse.AppendElement();
Key* key = mResponse.AppendElement(fallible);
if (NS_WARN_IF(!key)) {
return NS_ERROR_OUT_OF_MEMORY;
}
+6 -3
View File
@@ -1245,14 +1245,17 @@ IDBObjectStore::AddOrPut(JSContext* aCx,
return nullptr;
}
MOZ_ALWAYS_TRUE(fileActorOrMutableFileIds.AppendElement(fileActor));
MOZ_ALWAYS_TRUE(fileActorOrMutableFileIds.AppendElement(fileActor,
fallible));
} else {
const int64_t fileId = blobOrFileInfo.mFileInfo->Id();
MOZ_ASSERT(fileId > 0);
MOZ_ALWAYS_TRUE(fileActorOrMutableFileIds.AppendElement(fileId));
MOZ_ALWAYS_TRUE(fileActorOrMutableFileIds.AppendElement(fileId,
fallible));
nsRefPtr<FileInfo>* newFileInfo = fileInfosToKeepAlive.AppendElement();
nsRefPtr<FileInfo>* newFileInfo =
fileInfosToKeepAlive.AppendElement(fallible);
if (NS_WARN_IF(!newFileInfo)) {
aRv = NS_ERROR_OUT_OF_MEMORY;
return nullptr;
+2
View File
@@ -612,9 +612,11 @@ MediaRawDataWriter::Prepend(const uint8_t* aData, size_t aSize)
if (!EnsureSize(aSize + mTarget->mSize)) {
return false;
}
// Shift the data to the right by aSize to leave room for the new data.
memmove(mTarget->mData + aSize, mTarget->mData, mTarget->mSize);
memcpy(mTarget->mData, aData, aSize);
mTarget->mSize += aSize;
return true;
}
-2
View File
@@ -420,8 +420,6 @@ private:
// It is designed to share potentially big byte arrays.
class MediaLargeByteBuffer : public FallibleTArray<uint8_t> {
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MediaLargeByteBuffer);
MediaLargeByteBuffer() = default;
explicit MediaLargeByteBuffer(size_t aCapacity) : FallibleTArray<uint8_t>(aCapacity) {}
private:
~MediaLargeByteBuffer() {}
+4
View File
@@ -661,6 +661,10 @@ MediaDecoderStateMachine::NeedToDecodeVideo()
{
MOZ_ASSERT(OnTaskQueue());
AssertCurrentThreadInMonitor();
SAMPLE_LOG("NeedToDecodeVideo() isDec=%d decToTar=%d minPrl=%d seek=%d enufVid=%d",
IsVideoDecoding(), mDecodeToSeekTarget, mMinimizePreroll,
mState == DECODER_STATE_SEEKING,
HaveEnoughDecodedVideo());
return IsVideoDecoding() &&
((mState == DECODER_STATE_SEEKING && mDecodeToSeekTarget) ||
(mState == DECODER_STATE_DECODING_FIRSTFRAME &&
+2 -12
View File
@@ -65,17 +65,7 @@ void VideoFrameContainer::SetCurrentFrame(const gfxIntSize& aIntrinsicSize,
mPaintTarget = aTargetTime;
}
void VideoFrameContainer::Reset()
{
ClearCurrentFrame(true);
Invalidate();
mIntrinsicSize = gfxIntSize(-1, -1);
mPaintDelay = mozilla::TimeDuration();
mPaintTarget = mozilla::TimeStamp();
mImageContainer->ResetPaintCount();
}
void VideoFrameContainer::ClearCurrentFrame(bool aResetSize)
void VideoFrameContainer::ClearCurrentFrame()
{
MutexAutoLock lock(mMutex);
@@ -86,7 +76,7 @@ void VideoFrameContainer::ClearCurrentFrame(bool aResetSize)
mImageContainer->UnlockCurrentImage();
mImageContainer->ClearAllImages();
mImageSizeChanged = aResetSize;
mImageSizeChanged = false;
}
ImageContainer* VideoFrameContainer::GetImageContainer() {
+1 -3
View File
@@ -48,9 +48,7 @@ public:
// Call on any thread
void SetCurrentFrame(const gfxIntSize& aIntrinsicSize, Image* aImage,
TimeStamp aTargetTime);
void ClearCurrentFrame(bool aResetSize = false);
// Reset the VideoFrameContainer
void Reset();
void ClearCurrentFrame();
// Time in seconds by which the last painted video frame was late by.
// E.g. if the last painted frame should have been painted at time t,
// but was actually painted at t+n, this returns n in seconds. Threadsafe.
@@ -22,9 +22,9 @@ runWithMSE(function (ms, v) {
var target = 2;
v.addEventListener("canplay", function oncanplay() {
v.removeEventListener("canplay", oncanplay);
ok(v.readyState >= v.HAVE_FUTURE_DATA, "readyState is >= FUTURE_DATA");
v.addEventListener("loadeddata", function onloadeddata() {
v.removeEventListener("loadeddata", onloadeddata);
ok(v.readyState >= v.HAVE_CURRENT_DATA, "readyState is >= CURRENT_DATA");
v.currentTime = target;
});
+1 -1
View File
@@ -110,7 +110,7 @@ public:
}
private:
AutoFallibleTArray<Storage,2> mContents;
nsAutoTArray<Storage, 2> mContents;
};
/**
+4 -4
View File
@@ -349,8 +349,8 @@ MobileMessageCursorChild::DoNotifyResult(const nsTArray<MobileMessageData>& aDat
for (uint32_t i = 0; i < length; i++) {
nsCOMPtr<nsISupports> message = CreateMessageFromMessageData(aDataArray[i]);
NS_ENSURE_TRUE_VOID(messages.AppendElement(message));
NS_ENSURE_TRUE_VOID(autoArray.AppendElement(message.get()));
NS_ENSURE_TRUE_VOID(messages.AppendElement(message, fallible));
NS_ENSURE_TRUE_VOID(autoArray.AppendElement(message.get(), fallible));
}
mCursorCallback->NotifyCursorResult(autoArray.Elements(), length);
@@ -370,8 +370,8 @@ MobileMessageCursorChild::DoNotifyResult(const nsTArray<ThreadData>& aDataArray)
for (uint32_t i = 0; i < length; i++) {
nsCOMPtr<nsISupports> thread = new MobileMessageThread(aDataArray[i]);
NS_ENSURE_TRUE_VOID(threads.AppendElement(thread));
NS_ENSURE_TRUE_VOID(autoArray.AppendElement(thread.get()));
NS_ENSURE_TRUE_VOID(threads.AppendElement(thread, fallible));
NS_ENSURE_TRUE_VOID(autoArray.AppendElement(thread.get(), fallible));
}
mCursorCallback->NotifyCursorResult(autoArray.Elements(), length);
+2 -1
View File
@@ -237,7 +237,8 @@ TCPSocketChild::SendSend(JS::Handle<JS::Value> aData,
if (!data) {
return NS_ERROR_OUT_OF_MEMORY;
}
if (!fallibleArr.InsertElementsAt(0, data + aByteOffset, nbytes)) {
if (!fallibleArr.InsertElementsAt(0, data + aByteOffset, nbytes,
fallible)) {
return NS_ERROR_OUT_OF_MEMORY;
}
}
+1 -1
View File
@@ -311,7 +311,7 @@ TCPSocketParent::SendEvent(const nsAString& aType, JS::Handle<JS::Value> aDataVa
errLine = __LINE__;
break;
}
if (!fallibleArr.InsertElementsAt(0, buffer, nbytes)) {
if (!fallibleArr.InsertElementsAt(0, buffer, nbytes, fallible)) {
errLine = __LINE__;
break;
}
+1 -1
View File
@@ -251,7 +251,7 @@ UDPSocketChild::SendDataInternal(const UDPSocketAddr& aAddr,
NS_ENSURE_ARG(aData);
FallibleTArray<uint8_t> fallibleArray;
if (!fallibleArray.InsertElementsAt(0, aData, aByteLength)) {
if (!fallibleArray.InsertElementsAt(0, aData, aByteLength, fallible)) {
return NS_ERROR_OUT_OF_MEMORY;
}
+1 -1
View File
@@ -459,7 +459,7 @@ UDPSocketParent::OnPacketReceived(nsIUDPSocket* aSocket, nsIUDPMessage* aMessage
}
FallibleTArray<uint8_t> fallibleArray;
if (!fallibleArray.InsertElementsAt(0, buffer, len)) {
if (!fallibleArray.InsertElementsAt(0, buffer, len, fallible)) {
FireInternalError(__LINE__);
return NS_ERROR_OUT_OF_MEMORY;
}
+7 -4
View File
@@ -161,14 +161,15 @@ public:
int length = mEvent.mTechList.Length();
event.mTechList.Construct();
if (!event.mTechList.Value().SetCapacity(length)) {
if (!event.mTechList.Value().SetCapacity(length, fallible)) {
return NS_ERROR_FAILURE;
}
for (int i = 0; i < length; i++) {
NFCTechType tech = static_cast<NFCTechType>(mEvent.mTechList[i]);
MOZ_ASSERT(tech < NFCTechType::EndGuard_);
*event.mTechList.Value().AppendElement() = tech;
// FIXME: Make this infallible after bug 968520 is done.
*event.mTechList.Value().AppendElement(fallible) = tech;
}
}
@@ -180,13 +181,15 @@ public:
if (mEvent.mRecords.Length() > 0) {
int length = mEvent.mRecords.Length();
event.mRecords.Construct();
if (!event.mRecords.Value().SetCapacity(length)) {
if (!event.mRecords.Value().SetCapacity(length, fallible)) {
return NS_ERROR_FAILURE;
}
for (int i = 0; i < length; i++) {
NDEFRecordStruct& recordStruct = mEvent.mRecords[i];
MozNDEFRecordOptions& record = *event.mRecords.Value().AppendElement();
// FIXME: Make this infallible after bug 968520 is done.
MozNDEFRecordOptions& record =
*event.mRecords.Value().AppendElement(fallible);
record.mTnf = recordStruct.mTnf;
MOZ_ASSERT(record.mTnf < TNF::EndGuard_);
+1 -1
View File
@@ -978,7 +978,7 @@ already_AddRefed<AndroidSurfaceTexture> nsNPAPIPluginInstance::CreateSurfaceText
void nsNPAPIPluginInstance::OnSurfaceTextureFrameAvailable()
{
if (mRunning == RUNNING && mOwner)
AndroidBridge::Bridge()->ScheduleComposite();
AndroidBridge::Bridge()->InvalidateAndScheduleComposite();
}
void* nsNPAPIPluginInstance::AcquireContentWindow()
-11
View File
@@ -393,17 +393,6 @@ PluginInstanceParent::AnswerNPN_SetValue_NPPVpluginUsesDOMForCursor(
return true;
}
class NotificationSink : public CompositionNotifySink
{
public:
explicit NotificationSink(PluginInstanceParent* aInstance) : mInstance(aInstance)
{ }
virtual void DidComposite() { mInstance->DidComposite(); }
private:
PluginInstanceParent *mInstance;
};
bool
PluginInstanceParent::AnswerNPN_SetValue_NPPVpluginDrawingModel(
const int& drawingModel, NPError* result)
-2
View File
@@ -33,7 +33,6 @@ class nsPluginInstanceOwner;
namespace mozilla {
namespace layers {
class ImageContainer;
class CompositionNotifySink;
}
namespace plugins {
@@ -343,7 +342,6 @@ private:
bool mIsWhitelistedForShumway;
NPWindowType mWindowType;
int16_t mDrawingModel;
nsAutoPtr<mozilla::layers::CompositionNotifySink> mNotifySink;
nsDataHashtable<nsPtrHashKey<NPObject>, PluginScriptableObjectParent*> mScriptableObjects;
+1 -1
View File
@@ -1212,7 +1212,7 @@ nsCSPContext::ToJSON(nsAString& outCSPinJSON)
for (uint32_t p = 0; p < mPolicies.Length(); p++) {
dom::CSP jsonCSP;
mPolicies[p]->toDomCSPStruct(jsonCSP);
jsonPolicies.mCsp_policies.Value().AppendElement(jsonCSP);
jsonPolicies.mCsp_policies.Value().AppendElement(jsonCSP, fallible);
}
// convert the gathered information to JSON
+2 -2
View File
@@ -801,7 +801,7 @@ nsCSPDirective::toDomCSPStruct(mozilla::dom::CSP& outCSP) const
for (uint32_t i = 0; i < mSrcs.Length(); i++) {
src.Truncate();
mSrcs[i]->toString(src);
srcs.AppendElement(src);
srcs.AppendElement(src, mozilla::fallible);
}
switch(mDirective) {
@@ -1055,7 +1055,7 @@ nsCSPPolicy::toDomCSPStruct(mozilla::dom::CSP& outCSP) const
for (uint32_t i = 0; i < mDirectives.Length(); ++i) {
if (mDirectives[i]->equals(nsIContentSecurityPolicy::REFERRER_DIRECTIVE)) {
mozilla::dom::Sequence<nsString> srcs;
srcs.AppendElement(mReferrerPolicy);
srcs.AppendElement(mReferrerPolicy, mozilla::fallible);
outCSP.mReferrer.Construct();
outCSP.mReferrer.Value() = srcs;
} else {
+5 -5
View File
@@ -787,20 +787,20 @@ nsSMILAnimationFunction::GetValues(const nsISMILAttr& aSMILAttr,
// AppendElement() below must succeed, because SetCapacity() succeeded.
if (!to.IsNull()) {
if (!from.IsNull()) {
MOZ_ALWAYS_TRUE(result.AppendElement(from));
MOZ_ALWAYS_TRUE(result.AppendElement(to));
MOZ_ALWAYS_TRUE(result.AppendElement(from, mozilla::fallible));
MOZ_ALWAYS_TRUE(result.AppendElement(to, mozilla::fallible));
} else {
MOZ_ALWAYS_TRUE(result.AppendElement(to));
MOZ_ALWAYS_TRUE(result.AppendElement(to, mozilla::fallible));
}
} else if (!by.IsNull()) {
nsSMILValue effectiveFrom(by.mType);
if (!from.IsNull())
effectiveFrom = from;
// Set values to 'from; from + by'
MOZ_ALWAYS_TRUE(result.AppendElement(effectiveFrom));
MOZ_ALWAYS_TRUE(result.AppendElement(effectiveFrom, mozilla::fallible));
nsSMILValue effectiveTo(effectiveFrom);
if (!effectiveTo.IsNull() && NS_SUCCEEDED(effectiveTo.Add(by))) {
MOZ_ALWAYS_TRUE(result.AppendElement(effectiveTo));
MOZ_ALWAYS_TRUE(result.AppendElement(effectiveTo, mozilla::fallible));
} else {
// Using by-animation with non-additive type or bad base-value
return NS_ERROR_FAILURE;
+4 -3
View File
@@ -535,7 +535,8 @@ nsSMILParserUtils::ParseKeySplines(const nsAString& aSpec,
!aKeySplines.AppendElement(nsSMILKeySpline(values[0],
values[1],
values[2],
values[3]))) {
values[3]),
fallible)) {
return false;
}
}
@@ -563,7 +564,7 @@ nsSMILParserUtils::ParseSemicolonDelimitedProgressList(const nsAString& aSpec,
return false;
}
if (!aArray.AppendElement(value)) {
if (!aArray.AppendElement(value, fallible)) {
return false;
}
previousValue = value;
@@ -594,7 +595,7 @@ public:
tmpPreventCachingOfSandwich)))
return false;
if (!mValuesArray->AppendElement(newValue)) {
if (!mValuesArray->AppendElement(newValue, fallible)) {
return false;
}
if (tmpPreventCachingOfSandwich) {
+2 -2
View File
@@ -266,7 +266,7 @@ DOMSVGLengthList::InsertItemBefore(DOMSVGLength& newItem,
MaybeInsertNullInAnimValListAt(index);
InternalList().InsertItem(index, domItem->ToSVGLength());
MOZ_ALWAYS_TRUE(mItems.InsertElementAt(index, domItem.get()));
MOZ_ALWAYS_TRUE(mItems.InsertElementAt(index, domItem.get(), fallible));
// This MUST come after the insertion into InternalList(), or else under the
// insertion into InternalList() the values read from domItem would be bad
@@ -380,7 +380,7 @@ DOMSVGLengthList::MaybeInsertNullInAnimValListAt(uint32_t aIndex)
MOZ_ASSERT(animVal->mItems.Length() == mItems.Length(),
"animVal list not in sync!");
animVal->mItems.InsertElementAt(aIndex, static_cast<DOMSVGLength*>(nullptr));
MOZ_ALWAYS_TRUE(animVal->mItems.InsertElementAt(aIndex, nullptr, fallible));
UpdateListIndicesFromIndex(animVal->mItems, aIndex + 1);
}
+2 -2
View File
@@ -250,7 +250,7 @@ DOMSVGNumberList::InsertItemBefore(DOMSVGNumber& aItem,
MaybeInsertNullInAnimValListAt(index);
InternalList().InsertItem(index, domItem->ToSVGNumber());
MOZ_ALWAYS_TRUE(mItems.InsertElementAt(index, domItem));
MOZ_ALWAYS_TRUE(mItems.InsertElementAt(index, domItem, fallible));
// This MUST come after the insertion into InternalList(), or else under the
// insertion into InternalList() the values read from domItem would be bad
@@ -359,7 +359,7 @@ DOMSVGNumberList::MaybeInsertNullInAnimValListAt(uint32_t aIndex)
MOZ_ASSERT(animVal->mItems.Length() == mItems.Length(),
"animVal list not in sync!");
animVal->mItems.InsertElementAt(aIndex, static_cast<DOMSVGNumber*>(nullptr));
MOZ_ALWAYS_TRUE(animVal->mItems.InsertElementAt(aIndex, nullptr, fallible));
UpdateListIndicesFromIndex(animVal->mItems, aIndex + 1);
}
+9 -4
View File
@@ -221,7 +221,7 @@ DOMSVGPathSegList::InternalListWillChangeTo(const SVGPathData& aNewValue)
// have FEWER items than it does.
return;
}
if (!mItems.AppendElement(ItemProxy(nullptr, dataIndex))) {
if (!mItems.AppendElement(ItemProxy(nullptr, dataIndex), fallible)) {
// OOM
ErrorResult rv;
Clear(rv);
@@ -385,10 +385,12 @@ DOMSVGPathSegList::InsertItemBefore(DOMSVGPathSeg& aNewItem,
MOZ_ALWAYS_TRUE(InternalList().mData.InsertElementsAt(internalIndex,
segAsRaw,
1 + argCount));
1 + argCount,
fallible));
MOZ_ALWAYS_TRUE(mItems.InsertElementAt(aIndex,
ItemProxy(domItem.get(),
internalIndex)));
internalIndex),
fallible));
// This MUST come after the insertion into InternalList(), or else under the
// insertion into InternalList() the values read from domItem would be bad
@@ -541,7 +543,10 @@ DOMSVGPathSegList::
MOZ_ASSERT(animVal->mItems.Length() == mItems.Length(),
"animVal list not in sync!");
animVal->mItems.InsertElementAt(aIndex, ItemProxy(nullptr, aInternalIndex));
MOZ_ALWAYS_TRUE(animVal->mItems.InsertElementAt(aIndex,
ItemProxy(nullptr,
aInternalIndex),
fallible));
animVal->UpdateListIndicesFromIndex(aIndex + 1, 1 + aArgCountForItem);
}
+2 -2
View File
@@ -317,7 +317,7 @@ DOMSVGPointList::InsertItemBefore(nsISVGPoint& aNewItem, uint32_t aIndex,
MaybeInsertNullInAnimValListAt(aIndex);
InternalList().InsertItem(aIndex, domItem->ToSVGPoint());
MOZ_ALWAYS_TRUE(mItems.InsertElementAt(aIndex, domItem));
MOZ_ALWAYS_TRUE(mItems.InsertElementAt(aIndex, domItem, fallible));
// This MUST come after the insertion into InternalList(), or else under the
// insertion into InternalList() the values read from domItem would be bad
@@ -433,7 +433,7 @@ DOMSVGPointList::MaybeInsertNullInAnimValListAt(uint32_t aIndex)
MOZ_ASSERT(animVal->mItems.Length() == mItems.Length(),
"animVal list not in sync!");
animVal->mItems.InsertElementAt(aIndex, static_cast<nsISVGPoint*>(nullptr));
MOZ_ALWAYS_TRUE(animVal->mItems.InsertElementAt(aIndex, nullptr, fallible));
UpdateListIndicesFromIndex(animVal->mItems, aIndex + 1);
}
+2 -3
View File
@@ -258,7 +258,7 @@ DOMSVGTransformList::InsertItemBefore(SVGTransform& newItem,
MaybeInsertNullInAnimValListAt(index);
InternalList().InsertItem(index, domItem->ToSVGTransform());
MOZ_ALWAYS_TRUE(mItems.InsertElementAt(index, domItem.get()));
MOZ_ALWAYS_TRUE(mItems.InsertElementAt(index, domItem.get(), fallible));
// This MUST come after the insertion into InternalList(), or else under the
// insertion into InternalList() the values read from domItem would be bad
@@ -406,8 +406,7 @@ DOMSVGTransformList::MaybeInsertNullInAnimValListAt(uint32_t aIndex)
MOZ_ASSERT(animVal->mItems.Length() == mItems.Length(),
"animVal list not in sync!");
animVal->mItems.InsertElementAt(aIndex,
static_cast<SVGTransform*>(nullptr));
MOZ_ALWAYS_TRUE(animVal->mItems.InsertElementAt(aIndex, nullptr, fallible));
UpdateListIndicesFromIndex(animVal->mItems, aIndex + 1);
}
+1 -3
View File
@@ -18,11 +18,9 @@ namespace mozilla {
nsresult
SVGLengthList::CopyFrom(const SVGLengthList& rhs)
{
if (!mLengths.SetCapacity(rhs.Length(), fallible)) {
// Yes, we do want fallible alloc here
if (!mLengths.Assign(rhs.mLengths, fallible)) {
return NS_ERROR_OUT_OF_MEMORY;
}
mLengths = rhs.mLengths;
return NS_OK;
}
+2 -2
View File
@@ -107,7 +107,7 @@ private:
bool InsertItem(uint32_t aIndex, const SVGLength &aLength) {
if (aIndex >= mLengths.Length()) aIndex = mLengths.Length();
return !!mLengths.InsertElementAt(aIndex, aLength);
return !!mLengths.InsertElementAt(aIndex, aLength, fallible);
}
void ReplaceItem(uint32_t aIndex, const SVGLength &aLength) {
@@ -123,7 +123,7 @@ private:
}
bool AppendItem(SVGLength aLength) {
return !!mLengths.AppendElement(aLength);
return !!mLengths.AppendElement(aLength, fallible);
}
protected:
+5 -4
View File
@@ -174,7 +174,7 @@ SVGMotionSMILAnimationFunction::
if (HasAttr(nsGkAtoms::from)) {
const nsAString& fromStr = GetAttr(nsGkAtoms::from)->GetStringValue();
success = pathGenerator.MoveToAbsolute(fromStr);
mPathVertices.AppendElement(0.0);
mPathVertices.AppendElement(0.0, fallible);
} else {
// Create dummy 'from' value at 0,0, if we're doing by-animation.
// (NOTE: We don't add the dummy 0-point to our list for *to-animation*,
@@ -182,7 +182,7 @@ SVGMotionSMILAnimationFunction::
// expect a dummy value. It only expects one value: the final 'to' value.)
pathGenerator.MoveToOrigin();
if (!HasAttr(nsGkAtoms::to)) {
mPathVertices.AppendElement(0.0);
mPathVertices.AppendElement(0.0, fallible);
}
success = true;
}
@@ -200,7 +200,7 @@ SVGMotionSMILAnimationFunction::
success = pathGenerator.LineToRelative(byStr, dist);
}
if (success) {
mPathVertices.AppendElement(dist);
mPathVertices.AppendElement(dist, fallible);
}
}
}
@@ -308,7 +308,8 @@ SVGMotionSMILAnimationFunction::
double curDist = aPointDistances[i] * distanceMultiplier;
if (!aResult.AppendElement(
SVGMotionSMILType::ConstructSMILValue(aPath, curDist,
mRotateType, mRotateAngle))) {
mRotateType, mRotateAngle),
fallible)) {
return false;
}
}
+2 -2
View File
@@ -136,14 +136,14 @@ SVGMotionSMILPathUtils::MotionValueParser::
// Interpret first value in "values" attribute as the path's initial MoveTo
success = mPathGenerator->MoveToAbsolute(aValueStr);
if (success) {
success = !!mPointDistances->AppendElement(0.0);
success = !!mPointDistances->AppendElement(0.0, fallible);
}
} else {
double dist;
success = mPathGenerator->LineToAbsolute(aValueStr, dist);
if (success) {
mDistanceSoFar += dist;
success = !!mPointDistances->AppendElement(mDistanceSoFar);
success = !!mPointDistances->AppendElement(mDistanceSoFar, fallible);
}
}
return success;
+7 -9
View File
@@ -195,13 +195,10 @@ SVGMotionSMILType::Assign(nsSMILValue& aDest, const nsSMILValue& aSrc) const
const MotionSegmentArray& srcArr = ExtractMotionSegmentArray(aSrc);
MotionSegmentArray& dstArr = ExtractMotionSegmentArray(aDest);
// Ensure we have sufficient memory.
if (!dstArr.SetCapacity(srcArr.Length(), fallible)) {
if (!dstArr.Assign(srcArr, fallible)) {
return NS_ERROR_OUT_OF_MEMORY;
}
dstArr = srcArr; // Do the assignment.
return NS_OK;
}
@@ -305,8 +302,7 @@ SVGMotionSMILType::Add(nsSMILValue& aDest, const nsSMILValue& aValueToAdd,
// Replace destination's current value -- a point-on-a-path -- with the
// translation that results from our addition.
dstArr.Clear();
dstArr.AppendElement(MotionSegment(newX, newY, rotateAngle));
dstArr.ReplaceElementAt(0, MotionSegment(newX, newY, rotateAngle));
return NS_OK;
}
@@ -324,7 +320,7 @@ SVGMotionSMILType::SandwichAdd(nsSMILValue& aDest,
MOZ_ASSERT(srcArr.Length() == 1,
"Trying to do sandwich add of more than one value");
if (!dstArr.AppendElement(srcArr[0])) {
if (!dstArr.AppendElement(srcArr[0], fallible)) {
return NS_ERROR_OUT_OF_MEMORY;
}
@@ -441,7 +437,8 @@ SVGMotionSMILType::Interpolate(const nsSMILValue& aStartVal,
// AppendElement has guaranteed success here, since Init() allocates 1 slot.
MOZ_ALWAYS_TRUE(resultArr.AppendElement(MotionSegment(path, resultDist,
rotateType,
rotateAngle)));
rotateAngle),
fallible));
return NS_OK;
}
@@ -484,7 +481,8 @@ SVGMotionSMILType::ConstructSMILValue(Path* aPath,
// AppendElement has guaranteed success here, since Init() allocates 1 slot.
MOZ_ALWAYS_TRUE(arr.AppendElement(MotionSegment(aPath, aDist,
aRotateType, aRotateAngle)));
aRotateType, aRotateAngle),
fallible));
return smilVal;
}
+1 -3
View File
@@ -17,11 +17,9 @@ namespace mozilla {
nsresult
SVGNumberList::CopyFrom(const SVGNumberList& rhs)
{
if (!mNumbers.SetCapacity(rhs.Length(), fallible)) {
// Yes, we do want fallible alloc here
if (!mNumbers.Assign(rhs.mNumbers, fallible)) {
return NS_ERROR_OUT_OF_MEMORY;
}
mNumbers = rhs.mNumbers;
return NS_OK;
}
+2 -2
View File
@@ -110,7 +110,7 @@ private:
if (aIndex >= mNumbers.Length()) {
aIndex = mNumbers.Length();
}
return !!mNumbers.InsertElementAt(aIndex, aNumber);
return !!mNumbers.InsertElementAt(aIndex, aNumber, fallible);
}
void ReplaceItem(uint32_t aIndex, const float &aNumber) {
@@ -126,7 +126,7 @@ private:
}
bool AppendItem(float aNumber) {
return !!mNumbers.AppendElement(aNumber);
return !!mNumbers.AppendElement(aNumber, fallible);
}
protected:
+2 -4
View File
@@ -34,11 +34,9 @@ static bool IsMoveto(uint16_t aSegType)
nsresult
SVGPathData::CopyFrom(const SVGPathData& rhs)
{
if (!mData.SetCapacity(rhs.mData.Length(), fallible)) {
// Yes, we do want fallible alloc here
if (!mData.Assign(rhs.mData, fallible)) {
return NS_ERROR_OUT_OF_MEMORY;
}
mData = rhs.mData;
return NS_OK;
}
@@ -175,7 +173,7 @@ SVGPathData::GetDistancesFromOriginToEndsOfVisibleSegments(FallibleTArray<double
if (i == 0 || (segType != PATHSEG_MOVETO_ABS &&
segType != PATHSEG_MOVETO_REL)) {
if (!aOutput->AppendElement(state.length)) {
if (!aOutput->AppendElement(state.length, fallible)) {
return false;
}
}
+1 -3
View File
@@ -16,11 +16,9 @@ namespace mozilla {
nsresult
SVGPointList::CopyFrom(const SVGPointList& rhs)
{
if (!SetCapacity(rhs.Length())) {
// Yes, we do want fallible alloc here
if (!mItems.Assign(rhs.mItems, fallible)) {
return NS_ERROR_OUT_OF_MEMORY;
}
mItems = rhs.mItems;
return NS_OK;
}
+2 -2
View File
@@ -118,7 +118,7 @@ private:
if (aIndex >= mItems.Length()) {
aIndex = mItems.Length();
}
return !!mItems.InsertElementAt(aIndex, aPoint);
return !!mItems.InsertElementAt(aIndex, aPoint, fallible);
}
void ReplaceItem(uint32_t aIndex, const SVGPoint &aPoint) {
@@ -134,7 +134,7 @@ private:
}
bool AppendItem(SVGPoint aPoint) {
return !!mItems.AppendElement(aPoint);
return !!mItems.AppendElement(aPoint, fallible);
}
protected:
+1 -3
View File
@@ -16,11 +16,9 @@ namespace mozilla {
nsresult
SVGStringList::CopyFrom(const SVGStringList& rhs)
{
if (!mStrings.SetCapacity(rhs.Length(), fallible)) {
// Yes, we do want fallible alloc here
if (!mStrings.Assign(rhs.mStrings, fallible)) {
return NS_ERROR_OUT_OF_MEMORY;
}
mStrings = rhs.mStrings;
mIsSet = true;
return NS_OK;
}
+2 -2
View File
@@ -105,7 +105,7 @@ private:
if (aIndex >= mStrings.Length()) {
aIndex = mStrings.Length();
}
if (mStrings.InsertElementAt(aIndex, aString)) {
if (mStrings.InsertElementAt(aIndex, aString, fallible)) {
mIsSet = true;
return true;
}
@@ -125,7 +125,7 @@ private:
}
bool AppendItem(const nsAString &aString) {
if (mStrings.AppendElement(aString)) {
if (mStrings.AppendElement(aString, fallible)) {
mIsSet = true;
return true;
}
+1 -3
View File
@@ -43,11 +43,9 @@ SVGTransformList::CopyFrom(const SVGTransformList& rhs)
nsresult
SVGTransformList::CopyFrom(const nsTArray<nsSVGTransform>& aTransformArray)
{
if (!mItems.SetCapacity(aTransformArray.Length(), fallible)) {
// Yes, we do want fallible alloc here
if (!mItems.Assign(aTransformArray, fallible)) {
return NS_ERROR_OUT_OF_MEMORY;
}
mItems = aTransformArray;
return NS_OK;
}
+2 -2
View File
@@ -113,7 +113,7 @@ private:
if (aIndex >= mItems.Length()) {
aIndex = mItems.Length();
}
return !!mItems.InsertElementAt(aIndex, aTransform);
return !!mItems.InsertElementAt(aIndex, aTransform, fallible);
}
void ReplaceItem(uint32_t aIndex, const nsSVGTransform& aTransform) {
@@ -129,7 +129,7 @@ private:
}
bool AppendItem(const nsSVGTransform& aTransform) {
return !!mItems.AppendElement(aTransform);
return !!mItems.AppendElement(aTransform, fallible);
}
protected:
+6 -6
View File
@@ -146,7 +146,7 @@ SVGTransformListParser::ParseTranslate()
// fall-through
case 2:
{
nsSVGTransform* transform = mTransforms.AppendElement();
nsSVGTransform* transform = mTransforms.AppendElement(fallible);
if (!transform) {
return false;
}
@@ -174,7 +174,7 @@ SVGTransformListParser::ParseScale()
// fall-through
case 2:
{
nsSVGTransform* transform = mTransforms.AppendElement();
nsSVGTransform* transform = mTransforms.AppendElement(fallible);
if (!transform) {
return false;
}
@@ -203,7 +203,7 @@ SVGTransformListParser::ParseRotate()
// fall-through
case 3:
{
nsSVGTransform* transform = mTransforms.AppendElement();
nsSVGTransform* transform = mTransforms.AppendElement(fallible);
if (!transform) {
return false;
}
@@ -225,7 +225,7 @@ SVGTransformListParser::ParseSkewX()
return false;
}
nsSVGTransform* transform = mTransforms.AppendElement();
nsSVGTransform* transform = mTransforms.AppendElement(fallible);
if (!transform) {
return false;
}
@@ -244,7 +244,7 @@ SVGTransformListParser::ParseSkewY()
return false;
}
nsSVGTransform* transform = mTransforms.AppendElement();
nsSVGTransform* transform = mTransforms.AppendElement(fallible);
if (!transform) {
return false;
}
@@ -263,7 +263,7 @@ SVGTransformListParser::ParseMatrix()
return false;
}
nsSVGTransform* transform = mTransforms.AppendElement();
nsSVGTransform* transform = mTransforms.AppendElement(fallible);
if (!transform) {
return false;
}
+11 -12
View File
@@ -48,12 +48,9 @@ SVGTransformListSMILType::Assign(nsSMILValue& aDest,
const TransformArray* srcTransforms =
static_cast<const TransformArray*>(aSrc.mU.mPtr);
TransformArray* dstTransforms = static_cast<TransformArray*>(aDest.mU.mPtr);
// Before we assign, ensure we have sufficient memory
bool result = dstTransforms->SetCapacity(srcTransforms->Length(), fallible);
NS_ENSURE_TRUE(result,NS_ERROR_OUT_OF_MEMORY);
*dstTransforms = *srcTransforms;
if (!dstTransforms->Assign(*srcTransforms, fallible)) {
return NS_ERROR_OUT_OF_MEMORY;
}
return NS_OK;
}
@@ -118,7 +115,7 @@ SVGTransformListSMILType::Add(nsSMILValue& aDest,
const SVGTransformSMILData& srcTransform = srcTransforms[0];
if (dstTransforms.IsEmpty()) {
SVGTransformSMILData* result = dstTransforms.AppendElement(
SVGTransformSMILData(srcTransform.mTransformType));
SVGTransformSMILData(srcTransform.mTransformType), fallible);
NS_ENSURE_TRUE(result,NS_ERROR_OUT_OF_MEMORY);
}
SVGTransformSMILData& dstTransform = dstTransforms[0];
@@ -170,7 +167,8 @@ SVGTransformListSMILType::SandwichAdd(nsSMILValue& aDest,
// Stick the src on the end of the array
const SVGTransformSMILData& srcTransform = srcTransforms[0];
SVGTransformSMILData* result = dstTransforms.AppendElement(srcTransform);
SVGTransformSMILData* result =
dstTransforms.AppendElement(srcTransform, fallible);
NS_ENSURE_TRUE(result,NS_ERROR_OUT_OF_MEMORY);
return NS_OK;
@@ -305,7 +303,7 @@ SVGTransformListSMILType::Interpolate(const nsSMILValue& aStartVal,
// Assign the result
SVGTransformSMILData* transform =
dstTransforms.AppendElement(resultTransform);
dstTransforms.AppendElement(resultTransform, fallible);
NS_ENSURE_TRUE(transform,NS_ERROR_OUT_OF_MEMORY);
return NS_OK;
@@ -323,7 +321,7 @@ SVGTransformListSMILType::AppendTransform(
NS_PRECONDITION(aValue.mType == Singleton(), "Unexpected SMIL value type");
TransformArray& transforms = *static_cast<TransformArray*>(aValue.mU.mPtr);
return transforms.AppendElement(aTransform) ?
return transforms.AppendElement(aTransform, fallible) ?
NS_OK : NS_ERROR_OUT_OF_MEMORY;
}
@@ -342,7 +340,8 @@ SVGTransformListSMILType::AppendTransforms(const SVGTransformList& aList,
for (uint32_t i = 0; i < aList.Length(); ++i) {
// No need to check the return value below since we have already allocated
// the necessary space
MOZ_ALWAYS_TRUE(transforms.AppendElement(SVGTransformSMILData(aList[i])));
MOZ_ALWAYS_TRUE(transforms.AppendElement(SVGTransformSMILData(aList[i]),
fallible));
}
return true;
}
@@ -364,7 +363,7 @@ SVGTransformListSMILType::GetTransforms(const nsSMILValue& aValue,
for (uint32_t i = 0; i < smilTransforms.Length(); ++i) {
// No need to check the return value below since we have already allocated
// the necessary space
aTransforms.AppendElement(smilTransforms[i].ToSVGTransform());
aTransforms.AppendElement(smilTransforms[i].ToSVGTransform(), fallible);
}
return true;
}
+1 -1
View File
@@ -349,7 +349,7 @@ TVSource::NotifyEITBroadcasted(nsITVChannelData* aChannelData,
for (uint32_t i = 0; i < aCount; i++) {
nsRefPtr<TVProgram> program =
new TVProgram(GetOwner(), channel, aProgramDataList[i]);
*programs.AppendElement() = program;
*programs.AppendElement(fallible) = program;
}
return DispatchEITBroadcastedEvent(programs);
}
+1 -6
View File
@@ -26,11 +26,9 @@ interface WebGLSync {
interface WebGLTransformFeedback {
};
/*
[Pref="webgl.enable-prototype-webgl2"]
interface WebGLVertexArrayObject {
};
*/
[Pref="webgl.enable-prototype-webgl2"]
interface WebGL2RenderingContext : WebGLRenderingContext
@@ -322,8 +320,7 @@ interface WebGL2RenderingContext : WebGLRenderingContext
/* Buffer objects */
void copyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset,
GLintptr writeOffset, GLsizeiptr size);
void getBufferSubData(GLenum target, GLintptr offset, ArrayBuffer returnedData);
void getBufferSubData(GLenum target, GLintptr offset, ArrayBufferView returnedData);
void getBufferSubData(GLenum target, GLintptr offset, ArrayBuffer? returnedData);
/* Framebuffer objects */
void blitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0,
@@ -472,10 +469,8 @@ interface WebGL2RenderingContext : WebGLRenderingContext
void uniformBlockBinding(WebGLProgram? program, GLuint uniformBlockIndex, GLuint uniformBlockBinding);
/* Vertex Array Objects */
/*
WebGLVertexArrayObject? createVertexArray();
void deleteVertexArray(WebGLVertexArrayObject? vertexArray);
[WebGLHandlesContextLoss] GLboolean isVertexArray(WebGLVertexArrayObject? vertexArray);
void bindVertexArray(WebGLVertexArrayObject? array);
*/
};
+54 -62
View File
@@ -690,7 +690,7 @@ GLBlitHelper::BindAndUploadEGLImage(EGLImage image, GLuint target)
#ifdef MOZ_WIDGET_GONK
bool
GLBlitHelper::BlitGrallocImage(layers::GrallocImage* grallocImage, bool yflip)
GLBlitHelper::BlitGrallocImage(layers::GrallocImage* grallocImage)
{
ScopedBindTextureUnit boundTU(mGL, LOCAL_GL_TEXTURE0);
mGL->fClear(LOCAL_GL_COLOR_BUFFER_BIT);
@@ -711,8 +711,6 @@ GLBlitHelper::BlitGrallocImage(layers::GrallocImage* grallocImage, bool yflip)
BindAndUploadEGLImage(image, LOCAL_GL_TEXTURE_EXTERNAL_OES);
mGL->fUniform1f(mYFlipLoc, yflip ? (float)1.0f : (float)0.0f);
mGL->fDrawArrays(LOCAL_GL_TRIANGLE_STRIP, 0, 4);
sEGLLibrary.fDestroyImage(sEGLLibrary.Display(), image);
@@ -726,7 +724,7 @@ GLBlitHelper::BlitGrallocImage(layers::GrallocImage* grallocImage, bool yflip)
#define ATTACH_WAIT_MS 50
bool
GLBlitHelper::BlitSurfaceTextureImage(layers::SurfaceTextureImage* stImage, bool yflip)
GLBlitHelper::BlitSurfaceTextureImage(layers::SurfaceTextureImage* stImage)
{
AndroidSurfaceTexture* surfaceTexture = stImage->GetData()->mSurfTex;
@@ -746,7 +744,6 @@ GLBlitHelper::BlitSurfaceTextureImage(layers::SurfaceTextureImage* stImage, bool
surfaceTexture->GetTransformMatrix(transform);
mGL->fUniformMatrix4fv(mTextureTransformLoc, 1, false, &transform._11);
mGL->fUniform1f(mYFlipLoc, yflip ? 1.0f : 0.0f);
mGL->fDrawArrays(LOCAL_GL_TRIANGLE_STRIP, 0, 4);
surfaceTexture->Detach();
@@ -756,7 +753,7 @@ GLBlitHelper::BlitSurfaceTextureImage(layers::SurfaceTextureImage* stImage, bool
}
bool
GLBlitHelper::BlitEGLImageImage(layers::EGLImageImage* image, bool yflip)
GLBlitHelper::BlitEGLImageImage(layers::EGLImageImage* image)
{
EGLImage eglImage = image->GetData()->mImage;
EGLSync eglSync = image->GetData()->mSync;
@@ -775,8 +772,6 @@ GLBlitHelper::BlitEGLImageImage(layers::EGLImageImage* image, bool yflip)
BindAndUploadEGLImage(eglImage, LOCAL_GL_TEXTURE_2D);
mGL->fUniform1f(mYFlipLoc, yflip ? 1.0f : 0.0f);
mGL->fDrawArrays(LOCAL_GL_TRIANGLE_STRIP, 0, 4);
mGL->fBindTexture(LOCAL_GL_TEXTURE_EXTERNAL_OES, oldBinding);
@@ -786,7 +781,7 @@ GLBlitHelper::BlitEGLImageImage(layers::EGLImageImage* image, bool yflip)
#endif
bool
GLBlitHelper::BlitPlanarYCbCrImage(layers::PlanarYCbCrImage* yuvImage, bool yflip)
GLBlitHelper::BlitPlanarYCbCrImage(layers::PlanarYCbCrImage* yuvImage)
{
ScopedBindTextureUnit boundTU(mGL, LOCAL_GL_TEXTURE0);
const PlanarYCbCrData* yuvData = yuvImage->GetData();
@@ -807,8 +802,6 @@ GLBlitHelper::BlitPlanarYCbCrImage(layers::PlanarYCbCrImage* yuvImage, bool yfli
BindAndUploadYUVTexture(Channel_Cb, yuvData->mCbCrStride, yuvData->mCbCrSize.height, yuvData->mCbChannel, needsAllocation);
BindAndUploadYUVTexture(Channel_Cr, yuvData->mCbCrStride, yuvData->mCbCrSize.height, yuvData->mCrChannel, needsAllocation);
mGL->fUniform1f(mYFlipLoc, yflip ? (float)1.0 : (float)0.0);
if (needsAllocation) {
mGL->fUniform2f(mYTexScaleLoc, (float)yuvData->mYSize.width/yuvData->mYStride, 1.0f);
mGL->fUniform2f(mCbCrTexScaleLoc, (float)yuvData->mCbCrSize.width/yuvData->mCbCrStride, 1.0f);
@@ -826,32 +819,39 @@ bool
GLBlitHelper::BlitImageToFramebuffer(layers::Image* srcImage,
const gfx::IntSize& destSize,
GLuint destFB,
bool yflip,
GLuint xoffset,
GLuint yoffset,
GLuint cropWidth,
GLuint cropHeight)
OriginPos destOrigin)
{
ScopedGLDrawState autoStates(mGL);
BlitType type;
OriginPos srcOrigin;
switch (srcImage->GetFormat()) {
case ImageFormat::PLANAR_YCBCR:
type = ConvertPlanarYCbCr;
srcOrigin = OriginPos::TopLeft;
break;
case ImageFormat::GRALLOC_PLANAR_YCBCR:
#ifdef MOZ_WIDGET_GONK
case ImageFormat::GRALLOC_PLANAR_YCBCR:
type = ConvertGralloc;
srcOrigin = OriginPos::TopLeft;
break;
#endif
#ifdef MOZ_WIDGET_ANDROID
case ImageFormat::SURFACE_TEXTURE:
type = ConvertSurfaceTexture;
srcOrigin = static_cast<layers::SurfaceTextureImage*>(srcImage)->GetData()
->mOriginPos;
break;
case ImageFormat::EGLIMAGE:
type = ConvertEGLImage;
srcOrigin = static_cast<layers::EGLImageImage*>(srcImage)->GetData()->mOriginPos;
break;
#endif
default:
return false;
}
@@ -861,37 +861,34 @@ GLBlitHelper::BlitImageToFramebuffer(layers::Image* srcImage,
return false;
}
const bool needsYFlip = (srcOrigin != destOrigin);
mGL->fUniform1f(mYFlipLoc, needsYFlip ? (float)1.0 : (float)0.0);
ScopedBindFramebuffer boundFB(mGL, destFB);
mGL->fColorMask(LOCAL_GL_TRUE, LOCAL_GL_TRUE, LOCAL_GL_TRUE, LOCAL_GL_TRUE);
mGL->fViewport(0, 0, destSize.width, destSize.height);
if (xoffset != 0 && yoffset != 0 && cropWidth != 0 && cropHeight != 0) {
mGL->fEnable(LOCAL_GL_SCISSOR_TEST);
mGL->fScissor(xoffset, yoffset, (GLsizei)cropWidth, (GLsizei)cropHeight);
}
switch (type) {
#ifdef MOZ_WIDGET_GONK
if (type == ConvertGralloc) {
layers::GrallocImage* grallocImage = static_cast<layers::GrallocImage*>(srcImage);
return BlitGrallocImage(grallocImage, yflip);
}
#endif
if (type == ConvertPlanarYCbCr) {
mGL->fPixelStorei(LOCAL_GL_UNPACK_ALIGNMENT, 1);
PlanarYCbCrImage* yuvImage = static_cast<PlanarYCbCrImage*>(srcImage);
return BlitPlanarYCbCrImage(yuvImage, yflip);
}
#ifdef MOZ_WIDGET_ANDROID
if (type == ConvertSurfaceTexture) {
layers::SurfaceTextureImage* stImage = static_cast<layers::SurfaceTextureImage*>(srcImage);
return BlitSurfaceTextureImage(stImage, yflip);
}
if (type == ConvertEGLImage) {
layers::EGLImageImage* eglImage = static_cast<layers::EGLImageImage*>(srcImage);
return BlitEGLImageImage(eglImage, yflip);
}
case ConvertGralloc:
return BlitGrallocImage(static_cast<layers::GrallocImage*>(srcImage));
#endif
return false;
case ConvertPlanarYCbCr:
mGL->fPixelStorei(LOCAL_GL_UNPACK_ALIGNMENT, 1);
return BlitPlanarYCbCrImage(static_cast<PlanarYCbCrImage*>(srcImage));
#ifdef MOZ_WIDGET_ANDROID
case ConvertSurfaceTexture:
return BlitSurfaceTextureImage(static_cast<layers::SurfaceTextureImage*>(srcImage));
case ConvertEGLImage:
return BlitEGLImageImage(static_cast<layers::EGLImageImage*>(srcImage));
#endif
default:
return false;
}
}
bool
@@ -899,22 +896,15 @@ GLBlitHelper::BlitImageToTexture(layers::Image* srcImage,
const gfx::IntSize& destSize,
GLuint destTex,
GLenum destTarget,
bool yflip,
GLuint xoffset,
GLuint yoffset,
GLuint cropWidth,
GLuint cropHeight)
OriginPos destOrigin)
{
ScopedGLDrawState autoStates(mGL);
ScopedFramebufferForTexture autoFBForTex(mGL, destTex, destTarget);
if (!mFBO)
mGL->fGenFramebuffers(1, &mFBO);
if (!autoFBForTex.IsComplete()) {
MOZ_CRASH("ScopedFramebufferForTexture failed.");
}
ScopedBindFramebuffer boundFB(mGL, mFBO);
mGL->fFramebufferTexture2D(LOCAL_GL_FRAMEBUFFER, LOCAL_GL_COLOR_ATTACHMENT0,
destTarget, destTex, 0);
return BlitImageToFramebuffer(srcImage, destSize, mFBO, yflip, xoffset, yoffset,
cropWidth, cropHeight);
return BlitImageToFramebuffer(srcImage, destSize, autoFBForTex.FB(), destOrigin);
}
void
@@ -929,7 +919,7 @@ GLBlitHelper::BlitTextureToFramebuffer(GLuint srcTex, GLuint destFB,
if (mGL->IsSupported(GLFeature::framebuffer_blit)) {
ScopedFramebufferForTexture srcWrapper(mGL, srcTex, srcTarget);
MOZ_ASSERT(srcWrapper.IsComplete());
MOZ_DIAGNOSTIC_ASSERT(srcWrapper.IsComplete());
BlitFramebufferToFramebuffer(srcWrapper.FB(), destFB,
srcSize, destSize,
@@ -938,8 +928,7 @@ GLBlitHelper::BlitTextureToFramebuffer(GLuint srcTex, GLuint destFB,
}
BlitType type;
switch (srcTarget)
{
switch (srcTarget) {
case LOCAL_GL_TEXTURE_2D:
type = BlitTex2D;
break;
@@ -947,8 +936,7 @@ GLBlitHelper::BlitTextureToFramebuffer(GLuint srcTex, GLuint destFB,
type = BlitTexRect;
break;
default:
printf_stderr("Fatal Error: Failed to prepare to blit texture->framebuffer.\n");
MOZ_CRASH();
MOZ_CRASH("Fatal Error: Bad `srcTarget`.");
break;
}
@@ -963,10 +951,14 @@ GLBlitHelper::BlitTextureToFramebuffer(GLuint srcTex, GLuint destFB,
bool good = UseTexQuadProgram(type, srcSize);
if (!good) {
// We're up against the wall, so bail.
// This should really be MOZ_CRASH(why) or MOZ_RUNTIME_ASSERT(good).
printf_stderr("Fatal Error: Failed to prepare to blit texture->framebuffer.\n");
MOZ_CRASH();
MOZ_DIAGNOSTIC_ASSERT(false,
"Error: Failed to prepare to blit texture->framebuffer.\n");
mGL->fScissor(0, 0, destSize.width, destSize.height);
mGL->fColorMask(1, 1, 1, 1);
mGL->fClear(LOCAL_GL_COLOR_BUFFER_BIT);
return;
}
mGL->fDrawArrays(LOCAL_GL_TRIANGLE_STRIP, 0, 4);
}
+10 -11
View File
@@ -145,18 +145,20 @@ class GLBlitHelper final
void BindAndUploadEGLImage(EGLImage image, GLuint target);
#ifdef MOZ_WIDGET_GONK
bool BlitGrallocImage(layers::GrallocImage* grallocImage, bool yflip);
bool BlitGrallocImage(layers::GrallocImage* grallocImage);
#endif
bool BlitPlanarYCbCrImage(layers::PlanarYCbCrImage* yuvImage, bool yflip);
bool BlitPlanarYCbCrImage(layers::PlanarYCbCrImage* yuvImage);
#ifdef MOZ_WIDGET_ANDROID
// Blit onto the current FB.
bool BlitSurfaceTextureImage(layers::SurfaceTextureImage* stImage, bool yflip);
bool BlitEGLImageImage(layers::EGLImageImage* eglImage, bool yflip);
bool BlitSurfaceTextureImage(layers::SurfaceTextureImage* stImage);
bool BlitEGLImageImage(layers::EGLImageImage* eglImage);
#endif
public:
explicit GLBlitHelper(GLContext* gl);
friend class GLContext;
public:
~GLBlitHelper();
// If you don't have |srcFormats| for the 2nd definition,
@@ -187,12 +189,9 @@ public:
GLenum srcTarget = LOCAL_GL_TEXTURE_2D,
GLenum destTarget = LOCAL_GL_TEXTURE_2D);
bool BlitImageToFramebuffer(layers::Image* srcImage, const gfx::IntSize& destSize,
GLuint destFB, bool yflip = false, GLuint xoffset = 0,
GLuint yoffset = 0, GLuint width = 0, GLuint height = 0);
GLuint destFB, OriginPos destOrigin);
bool BlitImageToTexture(layers::Image* srcImage, const gfx::IntSize& destSize,
GLuint destTex, GLenum destTarget, bool yflip = false,
GLuint xoffset = 0, GLuint yoffset = 0, GLuint width = 0,
GLuint height = 0);
GLuint destTex, GLenum destTarget, OriginPos destOrigin);
};
} // namespace gl
+1 -1
View File
@@ -2396,7 +2396,7 @@ GLBlitHelper*
GLContext::BlitHelper()
{
if (!mBlitHelper) {
mBlitHelper = MakeUnique<GLBlitHelper>(this);
mBlitHelper.reset(new GLBlitHelper(this));
}
return mBlitHelper.get();
+10 -4
View File
@@ -57,11 +57,17 @@ GLImage::GetAsSourceSurface()
LOCAL_GL_UNSIGNED_BYTE,
nullptr);
ScopedFramebufferForTexture fb(sSnapshotContext, scopedTex.Texture());
ScopedFramebufferForTexture autoFBForTex(sSnapshotContext, scopedTex.Texture());
if (!autoFBForTex.IsComplete()) {
MOZ_CRASH("ScopedFramebufferForTexture failed.");
}
GLBlitHelper helper(sSnapshotContext);
const gl::OriginPos destOrigin = gl::OriginPos::TopLeft;
if (!helper.BlitImageToFramebuffer(this, size, fb.FB(), true)) {
if (!sSnapshotContext->BlitHelper()->BlitImageToFramebuffer(this, size,
autoFBForTex.FB(),
destOrigin))
{
return nullptr;
}
@@ -71,7 +77,7 @@ GLImage::GetAsSourceSurface()
return nullptr;
}
ScopedBindFramebuffer bind(sSnapshotContext, fb.FB());
ScopedBindFramebuffer bind(sSnapshotContext, autoFBForTex.FB());
ReadPixelsIntoDataSurface(sSnapshotContext, source);
return source.forget();
}
-1
View File
@@ -145,7 +145,6 @@ ImageContainer::ImageContainer(ImageContainer::Mode flag)
mPreviousImagePainted(false),
mImageFactory(new ImageFactory()),
mRecycleBin(new BufferRecycleBin()),
mCompositionNotifySink(nullptr),
mImageClient(nullptr)
{
if (ImageBridgeChild::IsCreated()) {
+1 -31
View File
@@ -145,9 +145,6 @@ public:
int32_t GetSerial() { return mSerial; }
void MarkSent() { mSent = true; }
bool IsSentToCompositor() { return mSent; }
virtual already_AddRefed<gfx::SourceSurface> GetAsSourceSurface() = 0;
virtual GrallocImage* AsGrallocImage()
@@ -169,8 +166,7 @@ protected:
Image(void* aImplData, ImageFormat aFormat) :
mImplData(aImplData),
mSerial(++sSerialCounter),
mFormat(aFormat),
mSent(false)
mFormat(aFormat)
{}
// Protected destructor, to discourage deletion outside of Release():
@@ -226,13 +222,6 @@ private:
uint32_t mRecycledBufferSize;
};
class CompositionNotifySink
{
public:
virtual void DidComposite() = 0;
virtual ~CompositionNotifySink() {}
};
/**
* A class that manages Image creation for a LayerManager. The only reason
* we need a separate class here is that LayerManagers aren't threadsafe
@@ -479,15 +468,6 @@ public:
return mPaintCount;
}
/**
* Resets the paint count to zero.
* Can be called from any thread.
*/
void ResetPaintCount() {
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
mPaintCount = 0;
}
/**
* Increments mPaintCount if this is the first time aPainted has been
* painted, and sets mPaintTime if the painted image is the current image.
@@ -509,14 +489,6 @@ public:
mPaintCount++;
mPreviousImagePainted = true;
}
if (mCompositionNotifySink) {
mCompositionNotifySink->DidComposite();
}
}
void SetCompositionNotifySink(CompositionNotifySink *aSink) {
mCompositionNotifySink = aSink;
}
private:
@@ -569,8 +541,6 @@ private:
nsRefPtr<BufferRecycleBin> mRecycleBin;
CompositionNotifySink *mCompositionNotifySink;
// This member points to an ImageClient if this ImageContainer was
// sucessfully created with ENABLE_ASYNC, or points to null otherwise.
// 'unsuccessful' in this case only means that the ImageClient could not
+58
View File
@@ -0,0 +1,58 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* 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 "LayersTypes.h"
#ifdef MOZ_WIDGET_GONK
#include <ui/GraphicBuffer.h>
#endif
namespace mozilla {
namespace layers {
LayerRenderState::LayerRenderState()
: mFlags(LayerRenderStateFlags::LAYER_RENDER_STATE_DEFAULT)
, mHasOwnOffset(false)
#ifdef MOZ_WIDGET_GONK
, mSurface(nullptr)
, mOverlayId(INVALID_OVERLAY)
, mTexture(nullptr)
#endif
{
}
LayerRenderState::LayerRenderState(const LayerRenderState& aOther)
: mFlags(aOther.mFlags)
, mHasOwnOffset(aOther.mHasOwnOffset)
, mOffset(aOther.mOffset)
#ifdef MOZ_WIDGET_GONK
, mSurface(aOther.mSurface)
, mOverlayId(aOther.mOverlayId)
, mSize(aOther.mSize)
, mTexture(aOther.mTexture)
#endif
{
}
LayerRenderState::~LayerRenderState()
{
}
#ifdef MOZ_WIDGET_GONK
LayerRenderState::LayerRenderState(android::GraphicBuffer* aSurface,
const gfx::IntSize& aSize,
LayerRenderStateFlags aFlags,
TextureHost* aTexture)
: mFlags(aFlags)
, mHasOwnOffset(false)
, mSurface(aSurface)
, mOverlayId(INVALID_OVERLAY)
, mSize(aSize)
, mTexture(aTexture)
{}
#endif
} // namespace
} // namespace
+12 -19
View File
@@ -13,7 +13,7 @@
#include "mozilla/TypedEnumBits.h"
#ifdef MOZ_WIDGET_GONK
#include <ui/GraphicBuffer.h>
#include <utils/RefBase.h>
#endif
#include <stdio.h> // FILE
#include "mozilla/Logging.h" // for PR_LOG
@@ -28,7 +28,7 @@
#define INVALID_OVERLAY -1
namespace android {
class GraphicBuffer;
class MOZ_EXPORT GraphicBuffer;
}
namespace mozilla {
@@ -85,28 +85,19 @@ MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(LayerRenderStateFlags)
// The 'ifdef MOZ_WIDGET_GONK' sadness here is because we don't want to include
// android::sp unless we have to.
struct LayerRenderState {
LayerRenderState()
#ifdef MOZ_WIDGET_GONK
: mFlags(LayerRenderStateFlags::LAYER_RENDER_STATE_DEFAULT)
, mHasOwnOffset(false)
, mSurface(nullptr)
, mOverlayId(INVALID_OVERLAY)
, mTexture(nullptr)
#endif
{}
// Constructors and destructor are defined in LayersTypes.cpp so we don't
// have to pull in a definition for GraphicBuffer.h here. In KK at least,
// that results in nasty pollution such as libui's hardware.h #defining
// 'version_major' and 'version_minor' which conflict with Theora's codec.c...
LayerRenderState();
LayerRenderState(const LayerRenderState& aOther);
~LayerRenderState();
#ifdef MOZ_WIDGET_GONK
LayerRenderState(android::GraphicBuffer* aSurface,
const gfx::IntSize& aSize,
LayerRenderStateFlags aFlags,
TextureHost* aTexture)
: mFlags(aFlags)
, mHasOwnOffset(false)
, mSurface(aSurface)
, mOverlayId(INVALID_OVERLAY)
, mSize(aSize)
, mTexture(aTexture)
{}
TextureHost* aTexture);
bool OriginBottomLeft() const
{ return bool(mFlags & LayerRenderStateFlags::ORIGIN_BOTTOM_LEFT); }
@@ -133,6 +124,8 @@ struct LayerRenderState {
bool mHasOwnOffset;
// the location of the layer's origin on mSurface
nsIntPoint mOffset;
// The 'ifdef MOZ_WIDGET_GONK' sadness here is because we don't want to include
// android::sp unless we have to.
#ifdef MOZ_WIDGET_GONK
// surface to render
android::sp<android::GraphicBuffer> mSurface;
+1 -1
View File
@@ -17,7 +17,7 @@ struct APZTestDataToJSConverter {
dom::Sequence<KeyValuePair>& aOutTo,
void (*aElementConverter)(const Key&, const Value&, KeyValuePair&)) {
for (auto it = aFrom.begin(); it != aFrom.end(); ++it) {
aOutTo.AppendElement();
aOutTo.AppendElement(fallible);
aElementConverter(it->first, it->second, aOutTo.LastElement());
}
}
@@ -19,6 +19,9 @@
#include "nsIDOMWindow.h"
#include "nsRefreshDriver.h"
#include "nsView.h"
#include "mozilla/TouchEvents.h"
#include "mozilla/dom/Element.h"
#include "Layers.h"
#define APZCCH_LOG(...)
// #define APZCCH_LOG(...) printf_stderr("APZCCH: " __VA_ARGS__)

Some files were not shown because too many files have changed in this diff Show More