Bug 1066280 - Review fixes. - r=kamidphish,mattwoodrow
authorjdashg <jdashg+github@gmail.com>
Wed, 08 Oct 2014 13:04:19 -0700
changeset 233109 a3bc505ee94570005f01b41bed8082369bdbe7e6
parent 233108 49531b0af9b802c859cda9bd4241b611ed025c38
child 233110 216915390f9b50a2d1520a41bc9ff5b150c4ded2
push id4187
push userbhearsum@mozilla.com
push dateFri, 28 Nov 2014 15:29:12 +0000
treeherdermozilla-beta@f23cc6a30c11 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskamidphish, mattwoodrow
bugs1066280
milestone35.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1066280 - Review fixes. - r=kamidphish,mattwoodrow
dom/canvas/WebGLContext.cpp
gfx/2d/DrawTargetSkia.cpp
gfx/gl/GLScreenBuffer.cpp
gfx/gl/GLUploadHelpers.cpp
gfx/layers/CopyableCanvasLayer.cpp
gfx/layers/client/CanvasClient.cpp
gfx/layers/composite/TextureHost.cpp
gfx/layers/composite/TextureHost.h
gfx/layers/opengl/GrallocTextureClient.cpp
gfx/layers/opengl/GrallocTextureClient.h
--- a/dom/canvas/WebGLContext.cpp
+++ b/dom/canvas/WebGLContext.cpp
@@ -1424,21 +1424,20 @@ WebGLContext::PresentScreenBuffer()
 
     if (!mShouldPresent) {
         return false;
     }
     MOZ_ASSERT(!mBackbufferNeedsClear);
 
     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;
     }
 
     if (!mOptions.preserveDrawingBuffer) {
         mBackbufferNeedsClear = true;
     }
 
--- a/gfx/2d/DrawTargetSkia.cpp
+++ b/gfx/2d/DrawTargetSkia.cpp
@@ -700,28 +700,28 @@ DrawTargetSkia::CopySurface(SourceSurfac
   }
 
   MarkChanged();
 
   TempBitmap bitmap = GetBitmapForSurface(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<uint8_t*>(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<uint8_t*>(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();
   mCanvas->resetMatrix();
   SkRect dest = IntRectToSkRect(IntRect(aDestination.x, aDestination.y, aSourceRect.width, aSourceRect.height));
   SkIRect source = IntRectToSkIRect(aSourceRect);
   mCanvas->clipRect(dest, SkRegion::kReplace_Op);
   SkPaint paint;
--- a/gfx/gl/GLScreenBuffer.cpp
+++ b/gfx/gl/GLScreenBuffer.cpp
@@ -38,17 +38,17 @@ GLScreenBuffer::Create(GLContext* gl,
     {
         return Move(ret);
     }
 
     UniquePtr<SurfaceFactory> factory;
 
 #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)
     {
         layers::TextureFlags flags = TextureFlags::DEALLOCATE_CLIENT |
                                      TextureFlags::NEEDS_Y_FLIP;
         if (!caps.premultAlpha) {
             flags |= TextureFlags::NON_PREMULTIPLIED;
--- a/gfx/gl/GLUploadHelpers.cpp
+++ b/gfx/gl/GLUploadHelpers.cpp
@@ -455,16 +455,18 @@ UploadImageDataToTexture(GLContext* gl,
               format = LOCAL_GL_RGBA;
               surfaceFormat = SurfaceFormat::B8G8R8X8;
               type = LOCAL_GL_UNSIGNED_BYTE;
             }
             internalFormat = LOCAL_GL_RGBA;
             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;
             } else {
               format = LOCAL_GL_RGBA;
               type = LOCAL_GL_UNSIGNED_BYTE;
               surfaceFormat = SurfaceFormat::R8G8B8A8;
             }
--- a/gfx/layers/CopyableCanvasLayer.cpp
+++ b/gfx/layers/CopyableCanvasLayer.cpp
@@ -101,18 +101,18 @@ CopyableCanvasLayer::UpdateTarget(DrawTa
   }
 
   MOZ_ASSERT(mGLContext);
 
   SharedSurface* frontbuffer = nullptr;
   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();
     }
   }
 
   if (!frontbuffer) {
     NS_WARNING("Null frame received.");
     return;
--- a/gfx/layers/client/CanvasClient.cpp
+++ b/gfx/layers/client/CanvasClient.cpp
@@ -136,101 +136,16 @@ CanvasClient2D::CreateTextureClientForCa
 #else
   // XXX - We should use CreateTextureClientForDrawing, but we first need
   // to use double buffering.
   return TextureClient::CreateForRawBufferAccess(GetForwarder(),
                                                  aFormat, aSize, backend,
                                                  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<GrallocTextureClientOGL> grallocTextureClient =
-    static_cast<GrallocTextureClientOGL*>(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<AsyncTransactionTracker> 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();
-}
-*/
 
 ////////////////////////////////////////////////////////////////////////
 
 CanvasClientSharedSurface::CanvasClientSharedSurface(CompositableForwarder* aLayerForwarder,
                                                      TextureFlags aFlags)
   : CanvasClient(aLayerForwarder, aFlags)
 {
 }
@@ -242,17 +157,17 @@ static TemporaryRef<TextureClient>
 TexClientFromShSurf(SharedSurface* surf, TextureFlags flags)
 {
   switch (surf->mType) {
     case SharedSurfaceType::Basic:
       return nullptr;
 
 #ifdef MOZ_WIDGET_GONK
     case SharedSurfaceType::Gralloc:
-      return GrallocTextureClientOGL::FromShSurf(surf, flags);
+      return GrallocTextureClientOGL::FromSharedSurface(surf, flags);
 #endif
 
     default:
       return new SharedSurfaceTextureClient(flags, surf);
   }
 }
 
 ////////////////////////////////////////
--- a/gfx/layers/composite/TextureHost.cpp
+++ b/gfx/layers/composite/TextureHost.cpp
@@ -792,31 +792,31 @@ TextureParent::ClearTextureHost()
   mWaitForClientRecycle = nullptr;
 
   mTextureHost->mActor = nullptr;
   mTextureHost = nullptr;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 
-static RefPtr<NewTextureSource>
-ShSurfToTexSource(gl::SharedSurface* abstractSurf, Compositor* compositor)
+static RefPtr<TextureSource>
+SharedSurfaceToTexSource(gl::SharedSurface* abstractSurf, Compositor* compositor)
 {
   MOZ_ASSERT(abstractSurf);
   MOZ_ASSERT(abstractSurf->mType != gl::SharedSurfaceType::Basic);
   MOZ_ASSERT(abstractSurf->mType != gl::SharedSurfaceType::Gralloc);
 
   if (!compositor) {
     return nullptr;
   }
 
   gfx::SurfaceFormat format = abstractSurf->mHasAlpha ? gfx::SurfaceFormat::R8G8B8A8
                                                       : gfx::SurfaceFormat::R8G8B8X8;
 
-  RefPtr<NewTextureSource> texSource;
+  RefPtr<TextureSource> texSource;
   switch (abstractSurf->mType) {
 #ifdef XP_WIN
     case gl::SharedSurfaceType::EGLSurfaceANGLE: {
       auto surf = gl::SharedSurface_ANGLEShareHandle::Cast(abstractSurf);
       HANDLE shareHandle = surf->GetShareHandle();
 
       MOZ_ASSERT(compositor->GetBackendType() == LayersBackend::LAYERS_D3D11);
       CompositorD3D11* compositorD3D11 = static_cast<CompositorD3D11*>(compositor);
@@ -914,16 +914,16 @@ void
 SharedSurfaceTextureHost::EnsureTexSource()
 {
   MOZ_ASSERT(mIsLocked);
 
   if (mTexSource)
     return;
 
   mSurf->WaitSync();
-  mTexSource = ShSurfToTexSource(mSurf, mCompositor);
+  mTexSource = SharedSurfaceToTexSource(mSurf, mCompositor);
   MOZ_ASSERT(mTexSource);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 
 } // namespace
 } // namespace
--- a/gfx/layers/composite/TextureHost.h
+++ b/gfx/layers/composite/TextureHost.h
@@ -572,17 +572,18 @@ protected:
 };
 
 /**
  * A TextureHost for SharedSurfaces
  */
 class SharedSurfaceTextureHost : public TextureHost
 {
 public:
-  SharedSurfaceTextureHost(TextureFlags aFlags, const ShSurfDescriptor& aDesc);
+  SharedSurfaceTextureHost(TextureFlags aFlags,
+                           const SharedSurfaceDescriptor& aDesc);
 
   virtual ~SharedSurfaceTextureHost() {};
 
   virtual void DeallocateDeviceData() MOZ_OVERRIDE {};
 
   virtual TemporaryRef<gfx::DataSourceSurface> GetAsSurface() MOZ_OVERRIDE {
     return nullptr; // XXX - implement this (for MOZ_DUMP_PAINTING)
   }
@@ -605,17 +606,17 @@ public:
     return true;
   }
 
   virtual void Unlock() MOZ_OVERRIDE {
     MOZ_ASSERT(mIsLocked);
     mIsLocked = false;
   }
 
-  virtual NewTextureSource* GetTextureSources() MOZ_OVERRIDE {
+  virtual TextureSource* GetTextureSources() MOZ_OVERRIDE {
     MOZ_ASSERT(mIsLocked);
     MOZ_ASSERT(mTexSource);
     return mTexSource;
   }
 
   virtual gfx::SurfaceFormat GetFormat() const MOZ_OVERRIDE;
 
   virtual gfx::IntSize GetSize() const MOZ_OVERRIDE;
@@ -625,17 +626,17 @@ public:
 #endif
 
 protected:
   void EnsureTexSource();
 
   bool mIsLocked;
   gl::SharedSurface* const mSurf;
   Compositor* mCompositor;
-  RefPtr<NewTextureSource> mTexSource;
+  RefPtr<TextureSource> mTexSource;
 };
 
 class MOZ_STACK_CLASS AutoLockTextureHost
 {
 public:
   explicit AutoLockTextureHost(TextureHost* aTexture)
     : mTexture(aTexture)
   {
--- a/gfx/layers/opengl/GrallocTextureClient.cpp
+++ b/gfx/layers/opengl/GrallocTextureClient.cpp
@@ -107,18 +107,18 @@ GrallocTextureClientOGL::WaitForBufferOw
     mRemoveFromCompositableTracker = nullptr;
   }
 
 #if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
    if (mReleaseFenceHandle.IsValid()) {
      android::sp<Fence> 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
      mReleaseFenceHandle = FenceHandle();
    }
 #endif
 }
 
@@ -343,18 +343,18 @@ size_t
 GrallocTextureClientOGL::GetBufferSize() const
 {
   // see Bug 908196
   MOZ_CRASH("This method should never be called.");
   return 0;
 }
 
 /*static*/ TemporaryRef<TextureClient>
-GrallocTextureClientOGL::FromShSurf(gl::SharedSurface* abstractSurf,
-                                    TextureFlags flags)
+GrallocTextureClientOGL::FromSharedSurface(gl::SharedSurface* abstractSurf,
+                                           TextureFlags flags)
 {
   auto surf = gl::SharedSurface_Gralloc::Cast(abstractSurf);
 
   RefPtr<TextureClient> ret = surf->GetTextureClient();
 
   TextureFlags mask = TextureFlags::NEEDS_Y_FLIP |
                       TextureFlags::RB_SWAPPED |
                       TextureFlags::NON_PREMULTIPLIED;
--- a/gfx/layers/opengl/GrallocTextureClient.h
+++ b/gfx/layers/opengl/GrallocTextureClient.h
@@ -113,18 +113,18 @@ public:
   {
     return mMediaBuffer;
   }
 
   virtual TemporaryRef<TextureClient>
   CreateSimilar(TextureFlags aFlags = TextureFlags::DEFAULT,
                 TextureAllocationFlags aAllocFlags = ALLOC_DEFAULT) const MOZ_OVERRIDE;
 
-  static TemporaryRef<TextureClient> FromShSurf(gl::SharedSurface* surf,
-                                                TextureFlags flags);
+  static TemporaryRef<TextureClient> FromSharedSurface(gl::SharedSurface* surf,
+                                                       TextureFlags flags);
 
 protected:
   /**
    * Unfortunately, until bug 879681 is fixed we need to use a GrallocBufferActor.
    */
   MaybeMagicGrallocBufferHandle mGrallocHandle;
 
   RefPtr<AsyncTransactionTracker> mRemoveFromCompositableTracker;