From bfdc87a62193aae20fac0bce37bed7b656f299bb Mon Sep 17 00:00:00 2001 From: Herb Derby Date: Tue, 14 Feb 2017 15:06:23 +0000 Subject: Revert "Revert "Always make SkImageShaders in heap."" This reverts commit 07f665efb918f68e406b76a78d0b76d5c714f16c. Reason for revert: Android code moved from priv api to real api Original change's description: > Revert "Always make SkImageShaders in heap." > > This reverts commit ff590a12441002d281254ec6a86070ac0a19263f. > > Reason for revert: This breaks the android roll because they are using > a private call. Updating android tests to use new api. > > Original change's description: > > Always make SkImageShaders in heap. > > > > I made a couple of measurments, and it looks like any differences is > > well below the noise threshold. > > > > Just for the record run1: .9991 of baseline and run2 .9988 of baseline. > > I was using top25 .skps as workload. > > > > TBR=mtklein@google.com > > > > Change-Id: If4fa06e5d5df72fb67dbb4bbb99c926f05765897 > > Reviewed-on: https://skia-review.googlesource.com/8341 > > Reviewed-by: Herb Derby > > Commit-Queue: Herb Derby > > > > TBR=mtklein@chromium.org,mtklein@google.com,herb@google.com,reviews@skia.org > NOPRESUBMIT=true > NOTREECHECKS=true > NOTRY=true > > Change-Id: Ibdaafc796702e250933b62e5f4abb5e2ce8d40c0 > Reviewed-on: https://skia-review.googlesource.com/8393 > Commit-Queue: Herb Derby > Reviewed-by: Herb Derby > TBR=mtklein@chromium.org,mtklein@google.com,herb@google.com,reviews@skia.org NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Change-Id: I320b5ebf707d74ffafd8b70d69646b74a30f0ae8 Reviewed-on: https://skia-review.googlesource.com/8407 Commit-Queue: Herb Derby Reviewed-by: Herb Derby --- src/core/SkBitmapDevice.cpp | 6 ++---- src/core/SkDraw.cpp | 19 ++----------------- src/core/SkImagePriv.h | 6 ++---- src/core/SkShader.cpp | 2 +- 4 files changed, 7 insertions(+), 26 deletions(-) (limited to 'src/core') diff --git a/src/core/SkBitmapDevice.cpp b/src/core/SkBitmapDevice.cpp index 2b5c37fa2e..45ec2b70ae 100644 --- a/src/core/SkBitmapDevice.cpp +++ b/src/core/SkBitmapDevice.cpp @@ -334,15 +334,13 @@ void SkBitmapDevice::drawBitmapRect(const SkDraw& draw, const SkBitmap& bitmap, // Since the shader need only live for our stack-frame, pass in a custom allocator. This // can save malloc calls, and signals to SkMakeBitmapShader to not try to copy the bitmap // if its mutable, since that precaution is not needed (give the short lifetime of the shader). - SkTBlitterAllocator allocator; + // construct a shader, so we can call drawRect with the dst auto s = SkMakeBitmapShader(*bitmapPtr, SkShader::kClamp_TileMode, SkShader::kClamp_TileMode, - &matrix, kNever_SkCopyPixelsMode, &allocator); + &matrix, kNever_SkCopyPixelsMode); if (!s) { return; } - // we deliberately add a ref, since the allocator wants to be the last owner - s.get()->ref(); SkPaint paintWithShader(paint); paintWithShader.setStyle(SkPaint::kFill_Style); diff --git a/src/core/SkDraw.cpp b/src/core/SkDraw.cpp index 4308000457..4d1c5a4998 100644 --- a/src/core/SkDraw.cpp +++ b/src/core/SkDraw.cpp @@ -85,23 +85,10 @@ public: SkAutoBitmapShaderInstall(const SkBitmap& src, const SkPaint& paint, const SkMatrix* localMatrix = nullptr) : fPaint(paint) /* makes a copy of the paint */ { - // TODO(herb): Move this over to SkArenaAlloc when arena alloc has a - // facility to return sk_sps. + fPaint.setShader(SkMakeBitmapShader(src, SkShader::kClamp_TileMode, SkShader::kClamp_TileMode, localMatrix, - kNever_SkCopyPixelsMode, - &fAllocator)); - // we deliberately left the shader with an owner-count of 2 - fPaint.getShader()->ref(); - SkASSERT(2 == fPaint.getShader()->getRefCnt()); - } - - ~SkAutoBitmapShaderInstall() { - // since fAllocator will destroy shader, we insist that owners == 2 - SkASSERT(2 == fPaint.getShader()->getRefCnt()); - - fPaint.setShader(nullptr); // unref the shader by 1 - + kNever_SkCopyPixelsMode)); } // return the new paint that has the shader applied @@ -110,8 +97,6 @@ public: private: // copy of caller's paint (which we then modify) SkPaint fPaint; - // Stores the shader. - SkTBlitterAllocator fAllocator; }; #define SkAutoBitmapShaderInstall(...) SK_REQUIRE_LOCAL_VAR(SkAutoBitmapShaderInstall) diff --git a/src/core/SkImagePriv.h b/src/core/SkImagePriv.h index 601108665d..d6e58d3c11 100644 --- a/src/core/SkImagePriv.h +++ b/src/core/SkImagePriv.h @@ -30,8 +30,7 @@ typedef SkSmallAllocator<3, kSkBlitterContextSize> SkTBlitterAllocator; // If alloc is non-nullptr, it will be used to allocate the returned SkShader, and MUST outlive // the SkShader. sk_sp SkMakeBitmapShader(const SkBitmap& src, SkShader::TileMode, SkShader::TileMode, - const SkMatrix* localMatrix, SkCopyPixelsMode, - SkTBlitterAllocator* alloc); + const SkMatrix* localMatrix, SkCopyPixelsMode); /** * Examines the bitmap to decide if it can share the existing pixelRef, or @@ -51,8 +50,7 @@ sk_sp SkMakeBitmapShader(const SkBitmap& src, SkShader::TileMode, SkSh * SkImageInfo, or the bitmap's pixels cannot be accessed, this will return * nullptr. */ -extern sk_sp SkMakeImageFromRasterBitmap(const SkBitmap&, SkCopyPixelsMode, - SkTBlitterAllocator* = nullptr); +extern sk_sp SkMakeImageFromRasterBitmap(const SkBitmap&, SkCopyPixelsMode); // Given an image created from SkNewImageFromBitmap, return its pixelref. This // may be called to see if the surface and the image share the same pixelref, diff --git a/src/core/SkShader.cpp b/src/core/SkShader.cpp index 81aae116d5..cfdd8b946e 100644 --- a/src/core/SkShader.cpp +++ b/src/core/SkShader.cpp @@ -232,7 +232,7 @@ sk_sp SkShader::MakeBitmapShader(const SkBitmap& src, TileMode tmx, Ti if (localMatrix && !localMatrix->invert(nullptr)) { return nullptr; } - return SkMakeBitmapShader(src, tmx, tmy, localMatrix, kIfMutable_SkCopyPixelsMode, nullptr); + return SkMakeBitmapShader(src, tmx, tmy, localMatrix, kIfMutable_SkCopyPixelsMode); } sk_sp SkShader::MakePictureShader(sk_sp src, TileMode tmx, TileMode tmy, -- cgit v1.2.3