Bug 1317430 - Avoid a unnecessary copy by passing a const & in gfx/ r=nical
authorSylvestre Ledru <sledru@mozilla.com>
Mon, 14 Nov 2016 23:16:18 +0100
changeset 322691 90f23af9f67bb2c84e51e7f6c61e8763e81b640f
parent 322690 0d8fa19c7fa9e228f1c79175911a8852f1d12b7d
child 322692 3e2bacaba5468e08c6548e757069c18ec885001e
push id21
push usermaklebus@msu.edu
push dateThu, 01 Dec 2016 06:22:08 +0000
reviewersnical
bugs1317430
milestone53.0a1
Bug 1317430 - Avoid a unnecessary copy by passing a const & in gfx/ r=nical MozReview-Commit-ID: 4AHG1queVe6
gfx/2d/DrawTargetSkia.cpp
gfx/2d/SourceSurfaceSkia.cpp
gfx/2d/SourceSurfaceSkia.h
gfx/layers/PersistentBufferProvider.cpp
gfx/layers/PersistentBufferProvider.h
--- a/gfx/2d/DrawTargetSkia.cpp
+++ b/gfx/2d/DrawTargetSkia.cpp
@@ -370,17 +370,17 @@ SkImageIsMask(const sk_sp<SkImage>& aIma
     return GrPixelConfigIsAlphaOnly(tex->config());
 #endif
   } else {
     return false;
   }
 }
 
 static bool
-ExtractAlphaBitmap(sk_sp<SkImage> aImage, SkBitmap* aResultBitmap)
+ExtractAlphaBitmap(const sk_sp<SkImage>& aImage, SkBitmap* aResultBitmap)
 {
   SkImageInfo info = SkImageInfo::MakeA8(aImage->width(), aImage->height());
   SkBitmap bitmap;
   if (!bitmap.tryAllocPixels(info, SkAlign4(info.minRowBytes())) ||
       !aImage->readPixels(bitmap.info(), bitmap.getPixels(), bitmap.rowBytes(), 0, 0)) {
     gfxWarning() << "Failed reading alpha pixels for Skia bitmap";
     return false;
   }
--- a/gfx/2d/SourceSurfaceSkia.cpp
+++ b/gfx/2d/SourceSurfaceSkia.cpp
@@ -54,17 +54,17 @@ SourceSurfaceSkia::InitFromData(unsigned
 
   mSize = aSize;
   mFormat = aFormat;
   mStride = aStride;
   return true;
 }
 
 bool
-SourceSurfaceSkia::InitFromImage(sk_sp<SkImage> aImage,
+SourceSurfaceSkia::InitFromImage(const sk_sp<SkImage>& aImage,
                                  SurfaceFormat aFormat,
                                  DrawTargetSkia* aOwner)
 {
   if (!aImage) {
     return false;
   }
 
   mSize = IntSize(aImage->width(), aImage->height());
--- a/gfx/2d/SourceSurfaceSkia.h
+++ b/gfx/2d/SourceSurfaceSkia.h
@@ -30,17 +30,17 @@ public:
 
   sk_sp<SkImage>& GetImage() { return mImage; }
 
   bool InitFromData(unsigned char* aData,
                     const IntSize &aSize,
                     int32_t aStride,
                     SurfaceFormat aFormat);
 
-  bool InitFromImage(sk_sp<SkImage> aImage,
+  bool InitFromImage(const sk_sp<SkImage>& aImage,
                      SurfaceFormat aFormat = SurfaceFormat::UNKNOWN,
                      DrawTargetSkia* aOwner = nullptr);
 
   virtual uint8_t* GetData();
 
   virtual int32_t Stride() { return mStride; }
 
 private:
--- a/gfx/layers/PersistentBufferProvider.cpp
+++ b/gfx/layers/PersistentBufferProvider.cpp
@@ -209,17 +209,17 @@ PersistentBufferProviderShared::SetForwa
   }
 
   mFwd = aFwd;
 
   return true;
 }
 
 TextureClient*
-PersistentBufferProviderShared::GetTexture(Maybe<uint32_t> aIndex)
+PersistentBufferProviderShared::GetTexture(const Maybe<uint32_t>& aIndex)
 {
   if (aIndex.isNothing() || !CheckIndex(aIndex.value())) {
     return nullptr;
   }
   return mTextures[aIndex.value()];
 }
 
 already_AddRefed<gfx::DrawTarget>
--- a/gfx/layers/PersistentBufferProvider.h
+++ b/gfx/layers/PersistentBufferProvider.h
@@ -140,17 +140,17 @@ public:
   virtual bool PreservesDrawingState() const override { return false; }
 protected:
   PersistentBufferProviderShared(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
                                  ShadowLayerForwarder* aFwd,
                                  RefPtr<TextureClient>& aTexture);
 
   ~PersistentBufferProviderShared();
 
-  TextureClient* GetTexture(Maybe<uint32_t> aIndex);
+  TextureClient* GetTexture(const Maybe<uint32_t>& aIndex);
   bool CheckIndex(uint32_t aIndex) { return aIndex < mTextures.length(); }
 
   void Destroy();
 
   gfx::IntSize mSize;
   gfx::SurfaceFormat mFormat;
   RefPtr<ShadowLayerForwarder> mFwd;
   Vector<RefPtr<TextureClient>, 4> mTextures;