diff options
author | Herb Derby <herb@google.com> | 2017-02-13 11:36:14 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-02-13 17:37:17 +0000 |
commit | ff590a12441002d281254ec6a86070ac0a19263f (patch) | |
tree | 29bff6f7da116c8691448bca204593e1a25c3ba3 /src/core | |
parent | fbd6cfbf8401ad645d66842a947e6f1e4edd790f (diff) |
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 <herb@google.com>
Commit-Queue: Herb Derby <herb@google.com>
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/SkBitmapDevice.cpp | 6 | ||||
-rw-r--r-- | src/core/SkDraw.cpp | 19 | ||||
-rw-r--r-- | src/core/SkImagePriv.h | 6 | ||||
-rw-r--r-- | src/core/SkShader.cpp | 2 |
4 files changed, 7 insertions, 26 deletions
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<SkShader> 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<SkShader> SkMakeBitmapShader(const SkBitmap& src, SkShader::TileMode, SkSh * SkImageInfo, or the bitmap's pixels cannot be accessed, this will return * nullptr. */ -extern sk_sp<SkImage> SkMakeImageFromRasterBitmap(const SkBitmap&, SkCopyPixelsMode, - SkTBlitterAllocator* = nullptr); +extern sk_sp<SkImage> 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> 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> SkShader::MakePictureShader(sk_sp<SkPicture> src, TileMode tmx, TileMode tmy, |