From ca85c239873141a3cca2eca7286d794156f42276 Mon Sep 17 00:00:00 2001 From: jdashg Date: Wed, 8 Oct 2014 13:04:19 -0700 Subject: [PATCH] Bug 1066280 - Review fixes. - r=kamidphish,mattwoodrow --- dom/canvas/WebGLContext.cpp | 5 +- gfx/2d/DrawTargetSkia.cpp | 24 +++--- gfx/gl/GLScreenBuffer.cpp | 2 +- gfx/gl/GLUploadHelpers.cpp | 2 + gfx/layers/CopyableCanvasLayer.cpp | 4 +- gfx/layers/client/CanvasClient.cpp | 87 +--------------------- gfx/layers/composite/TextureHost.cpp | 8 +- gfx/layers/composite/TextureHost.h | 7 +- gfx/layers/opengl/GrallocTextureClient.cpp | 8 +- gfx/layers/opengl/GrallocTextureClient.h | 4 +- 10 files changed, 34 insertions(+), 117 deletions(-) diff --git a/dom/canvas/WebGLContext.cpp b/dom/canvas/WebGLContext.cpp index e1ac54bd7098..9b7728335049 100644 --- a/dom/canvas/WebGLContext.cpp +++ b/dom/canvas/WebGLContext.cpp @@ -1429,11 +1429,10 @@ WebGLContext::PresentScreenBuffer() gl->MakeCurrent(); - auto screen = gl->Screen(); + GLScreenBuffer* screen = gl->Screen(); MOZ_ASSERT(screen); - auto size = screen->Size(); - if (!screen->PublishFrame(size)) { + if (!screen->PublishFrame(screen->Size())) { ForceLoseContext(); return false; } diff --git a/gfx/2d/DrawTargetSkia.cpp b/gfx/2d/DrawTargetSkia.cpp index 2cb2680a0a18..a72b7b54460a 100644 --- a/gfx/2d/DrawTargetSkia.cpp +++ b/gfx/2d/DrawTargetSkia.cpp @@ -705,18 +705,18 @@ DrawTargetSkia::CopySurface(SourceSurface *aSurface, // This is a fast path that is disabled for now to mimimize risk if (false && !bitmap.mBitmap.getTexture() && mCanvas->imageInfo() == bitmap.mBitmap.info()) { - SkBitmap bm(bitmap.mBitmap); - bm.lockPixels(); - if (bm.getPixels()) { - SkImageInfo info = bm.info(); - info.fWidth = aSourceRect.width; - info.fHeight = aSourceRect.height; - uint8_t* pixels = static_cast(bm.getPixels()); - // adjust pixels for the source offset - pixels += aSourceRect.x + aSourceRect.y*bm.rowBytes(); - mCanvas->writePixels(info, pixels, bm.rowBytes(), aDestination.x, aDestination.y); - return; - } + SkBitmap bm(bitmap.mBitmap); + bm.lockPixels(); + if (bm.getPixels()) { + SkImageInfo info = bm.info(); + info.fWidth = aSourceRect.width; + info.fHeight = aSourceRect.height; + uint8_t* pixels = static_cast(bm.getPixels()); + // adjust pixels for the source offset + pixels += aSourceRect.x + aSourceRect.y*bm.rowBytes(); + mCanvas->writePixels(info, pixels, bm.rowBytes(), aDestination.x, aDestination.y); + return; + } } mCanvas->save(); diff --git a/gfx/gl/GLScreenBuffer.cpp b/gfx/gl/GLScreenBuffer.cpp index 5edfe117df26..3c06a0f4a783 100755 --- a/gfx/gl/GLScreenBuffer.cpp +++ b/gfx/gl/GLScreenBuffer.cpp @@ -43,7 +43,7 @@ GLScreenBuffer::Create(GLContext* gl, #ifdef MOZ_WIDGET_GONK /* On B2G, we want a Gralloc factory, and we want one right at the start */ - auto allocator = caps.surfaceAllocator; + layers::ISurfaceAllocator* allocator = caps.surfaceAllocator; if (!factory && allocator && XRE_GetProcessType() != GeckoProcessType_Default) diff --git a/gfx/gl/GLUploadHelpers.cpp b/gfx/gl/GLUploadHelpers.cpp index 25b325a5afcf..8b1a3fcea06a 100644 --- a/gfx/gl/GLUploadHelpers.cpp +++ b/gfx/gl/GLUploadHelpers.cpp @@ -460,6 +460,8 @@ UploadImageDataToTexture(GLContext* gl, break; case SurfaceFormat::R8G8B8A8: if (gl->GetPreferredARGB32Format() == LOCAL_GL_BGRA) { + // Upload our RGBA as BGRA, but store that the uploaded format is + // BGRA. (sample from R to get B) format = LOCAL_GL_BGRA; type = LOCAL_GL_UNSIGNED_INT_8_8_8_8_REV; surfaceFormat = SurfaceFormat::B8G8R8A8; diff --git a/gfx/layers/CopyableCanvasLayer.cpp b/gfx/layers/CopyableCanvasLayer.cpp index 46cabab33484..bdf3f0672851 100644 --- a/gfx/layers/CopyableCanvasLayer.cpp +++ b/gfx/layers/CopyableCanvasLayer.cpp @@ -106,8 +106,8 @@ CopyableCanvasLayer::UpdateTarget(DrawTarget* aDestTarget) if (mGLFrontbuffer) { frontbuffer = mGLFrontbuffer.get(); } else { - auto screen = mGLContext->Screen(); - auto front = screen->Front(); + GLScreenBuffer* screen = mGLContext->Screen(); + ShSurfHandle* front = screen->Front(); if (front) { frontbuffer = front->Surf(); } diff --git a/gfx/layers/client/CanvasClient.cpp b/gfx/layers/client/CanvasClient.cpp index 59132bd0cf0d..938260d77d81 100644 --- a/gfx/layers/client/CanvasClient.cpp +++ b/gfx/layers/client/CanvasClient.cpp @@ -141,91 +141,6 @@ CanvasClient2D::CreateTextureClientForCanvas(gfx::SurfaceFormat aFormat, mTextureInfo.mTextureFlags | aFlags); #endif } -/* -void -CanvasClientSurfaceStream::Update(gfx::IntSize aSize, ClientCanvasLayer* aLayer) -{ - aLayer->mGLContext->MakeCurrent(); - - SurfaceStream* stream = aLayer->mStream; - MOZ_ASSERT(stream); - - // Copy our current surface to the current producer surface in our stream, then - // call SwapProducer to make a new buffer ready. - stream->CopySurfaceToProducer(aLayer->mTextureSurface.get(), - aLayer->mFactory.get()); - stream->SwapProducer(aLayer->mFactory.get(), - gfx::IntSize(aSize.width, aSize.height)); - -#ifdef MOZ_WIDGET_GONK - SharedSurface* surf = stream->SwapConsumer(); - if (!surf) { - printf_stderr("surf is null post-SwapConsumer!\n"); - return; - } - - if (surf->mType != SharedSurfaceType::Gralloc) { - printf_stderr("Unexpected non-Gralloc SharedSurface in IPC path!"); - MOZ_ASSERT(false); - return; - } - - SharedSurface_Gralloc* grallocSurf = SharedSurface_Gralloc::Cast(surf); - - RefPtr grallocTextureClient = - static_cast(grallocSurf->GetTextureClient()); - - // If IPDLActor is null means this TextureClient didn't AddTextureClient yet - if (!grallocTextureClient->GetIPDLActor()) { - grallocTextureClient->SetTextureFlags(mTextureInfo.mTextureFlags); - AddTextureClient(grallocTextureClient); - } - - if (grallocTextureClient->GetIPDLActor()) { - UseTexture(grallocTextureClient); - } - - if (mBuffer) { - // remove old buffer from CompositableHost - RefPtr tracker = new RemoveTextureFromCompositableTracker(); - // Hold TextureClient until transaction complete. - tracker->SetTextureClient(mBuffer); - mBuffer->SetRemoveFromCompositableTracker(tracker); - // RemoveTextureFromCompositableAsync() expects CompositorChild's presence. - GetForwarder()->RemoveTextureFromCompositableAsync(tracker, this, mBuffer); - } - mBuffer = grallocTextureClient; -#else - bool isCrossProcess = !(XRE_GetProcessType() == GeckoProcessType_Default); - if (isCrossProcess) { - printf_stderr("isCrossProcess, but not MOZ_WIDGET_GONK! Someone needs to write some code!"); - MOZ_ASSERT(false); - } else { - bool bufferCreated = false; - if (!mBuffer) { - // We need to dealloc in the client. - TextureFlags flags = GetTextureFlags() | - TextureFlags::DEALLOCATE_CLIENT; - StreamTextureClient* texClient = new StreamTextureClient(flags); - texClient->InitWith(stream); - mBuffer = texClient; - bufferCreated = true; - } - - if (bufferCreated && !AddTextureClient(mBuffer)) { - mBuffer = nullptr; - } - - if (mBuffer) { - GetForwarder()->UpdatedTexture(this, mBuffer, nullptr); - GetForwarder()->UseTexture(this, mBuffer); - } - } -#endif - - aLayer->Painted(); -} -*/ //////////////////////////////////////////////////////////////////////// @@ -247,7 +162,7 @@ TexClientFromShSurf(SharedSurface* surf, TextureFlags flags) #ifdef MOZ_WIDGET_GONK case SharedSurfaceType::Gralloc: - return GrallocTextureClientOGL::FromShSurf(surf, flags); + return GrallocTextureClientOGL::FromSharedSurface(surf, flags); #endif default: diff --git a/gfx/layers/composite/TextureHost.cpp b/gfx/layers/composite/TextureHost.cpp index c8e58977d631..1397c69f6c4e 100644 --- a/gfx/layers/composite/TextureHost.cpp +++ b/gfx/layers/composite/TextureHost.cpp @@ -797,8 +797,8 @@ TextureParent::ClearTextureHost() //////////////////////////////////////////////////////////////////////////////// -static RefPtr -ShSurfToTexSource(gl::SharedSurface* abstractSurf, Compositor* compositor) +static RefPtr +SharedSurfaceToTexSource(gl::SharedSurface* abstractSurf, Compositor* compositor) { MOZ_ASSERT(abstractSurf); MOZ_ASSERT(abstractSurf->mType != gl::SharedSurfaceType::Basic); @@ -811,7 +811,7 @@ ShSurfToTexSource(gl::SharedSurface* abstractSurf, Compositor* compositor) gfx::SurfaceFormat format = abstractSurf->mHasAlpha ? gfx::SurfaceFormat::R8G8B8A8 : gfx::SurfaceFormat::R8G8B8X8; - RefPtr texSource; + RefPtr texSource; switch (abstractSurf->mType) { #ifdef XP_WIN case gl::SharedSurfaceType::EGLSurfaceANGLE: { @@ -919,7 +919,7 @@ SharedSurfaceTextureHost::EnsureTexSource() return; mSurf->WaitSync(); - mTexSource = ShSurfToTexSource(mSurf, mCompositor); + mTexSource = SharedSurfaceToTexSource(mSurf, mCompositor); MOZ_ASSERT(mTexSource); } diff --git a/gfx/layers/composite/TextureHost.h b/gfx/layers/composite/TextureHost.h index 9fe2a1ff5281..279586891f82 100644 --- a/gfx/layers/composite/TextureHost.h +++ b/gfx/layers/composite/TextureHost.h @@ -577,7 +577,8 @@ protected: class SharedSurfaceTextureHost : public TextureHost { public: - SharedSurfaceTextureHost(TextureFlags aFlags, const ShSurfDescriptor& aDesc); + SharedSurfaceTextureHost(TextureFlags aFlags, + const SharedSurfaceDescriptor& aDesc); virtual ~SharedSurfaceTextureHost() {}; @@ -610,7 +611,7 @@ public: mIsLocked = false; } - virtual NewTextureSource* GetTextureSources() MOZ_OVERRIDE { + virtual TextureSource* GetTextureSources() MOZ_OVERRIDE { MOZ_ASSERT(mIsLocked); MOZ_ASSERT(mTexSource); return mTexSource; @@ -630,7 +631,7 @@ protected: bool mIsLocked; gl::SharedSurface* const mSurf; Compositor* mCompositor; - RefPtr mTexSource; + RefPtr mTexSource; }; class MOZ_STACK_CLASS AutoLockTextureHost diff --git a/gfx/layers/opengl/GrallocTextureClient.cpp b/gfx/layers/opengl/GrallocTextureClient.cpp index 5623ab8a6a8a..3624c97fce96 100644 --- a/gfx/layers/opengl/GrallocTextureClient.cpp +++ b/gfx/layers/opengl/GrallocTextureClient.cpp @@ -112,8 +112,8 @@ GrallocTextureClientOGL::WaitForBufferOwnership() android::sp fence = mReleaseFenceHandle.mFence; #if ANDROID_VERSION == 17 fence->waitForever(1000, "GrallocTextureClientOGL::Lock"); - // 1000 is what Android uses. It is warning timeout ms. - // This timeous is removed since ANDROID_VERSION 18. + // 1000 is what Android uses. It is a warning timeout in ms. + // This timeout was removed in ANDROID_VERSION 18. #else fence->waitForever("GrallocTextureClientOGL::Lock"); #endif @@ -348,8 +348,8 @@ GrallocTextureClientOGL::GetBufferSize() const } /*static*/ TemporaryRef -GrallocTextureClientOGL::FromShSurf(gl::SharedSurface* abstractSurf, - TextureFlags flags) +GrallocTextureClientOGL::FromSharedSurface(gl::SharedSurface* abstractSurf, + TextureFlags flags) { auto surf = gl::SharedSurface_Gralloc::Cast(abstractSurf); diff --git a/gfx/layers/opengl/GrallocTextureClient.h b/gfx/layers/opengl/GrallocTextureClient.h index 8d5cf2663105..d2cc06a8275e 100644 --- a/gfx/layers/opengl/GrallocTextureClient.h +++ b/gfx/layers/opengl/GrallocTextureClient.h @@ -118,8 +118,8 @@ public: CreateSimilar(TextureFlags aFlags = TextureFlags::DEFAULT, TextureAllocationFlags aAllocFlags = ALLOC_DEFAULT) const MOZ_OVERRIDE; - static TemporaryRef FromShSurf(gl::SharedSurface* surf, - TextureFlags flags); + static TemporaryRef FromSharedSurface(gl::SharedSurface* surf, + TextureFlags flags); protected: /**