diff options
author | Yuqian Li <liyuqian@google.com> | 2018-05-04 14:19:56 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-05-07 16:40:29 +0000 |
commit | 5c91fa4d84ca597f6f07c5ffb6cf9b115fe1aa87 (patch) | |
tree | 84b841544115d3391d90033086e08291638681e8 /src/core | |
parent | ad67c66a5849fa53b0e286ae8a78ada4661c964a (diff) |
Respect SkBitmapDeviceFilteredSurfaceProps in SkThreadedBMPDevice
Bug: skia:7909
Change-Id: I13ccfbdc883f764f60701383b90537d3175a8126
Reviewed-on: https://skia-review.googlesource.com/126100
Commit-Queue: Ben Wagner <bungeman@google.com>
Commit-Queue: Yuqian Li <liyuqian@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
Auto-Submit: Yuqian Li <liyuqian@google.com>
Reviewed-on: https://skia-review.googlesource.com/126463
Reviewed-by: Greg Daniel <egdaniel@google.com>
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/SkBitmapDevice.cpp | 19 | ||||
-rw-r--r-- | src/core/SkBitmapDevice.h | 21 | ||||
-rw-r--r-- | src/core/SkThreadedBMPDevice.cpp | 7 |
3 files changed, 25 insertions, 22 deletions
diff --git a/src/core/SkBitmapDevice.cpp b/src/core/SkBitmapDevice.cpp index b49818c2a1..522f016a2d 100644 --- a/src/core/SkBitmapDevice.cpp +++ b/src/core/SkBitmapDevice.cpp @@ -567,25 +567,6 @@ void SkBitmapDevice::drawSprite(const SkBitmap& bitmap, int x, int y, const SkPa BDDraw(this).drawSprite(bitmap, x, y, paint); } -class SkBitmapDeviceFilteredSurfaceProps { -public: - SkBitmapDeviceFilteredSurfaceProps(const SkBitmap& bitmap, const SkPaint& paint, - const SkSurfaceProps& surfaceProps) { - if (kN32_SkColorType != bitmap.colorType() || !paint.isSrcOver()) { - SkSurfaceProps* newPaint = fLazy.init(surfaceProps.flags(), kUnknown_SkPixelGeometry); - fSurfaceProps = newPaint; - } else { - fSurfaceProps = &surfaceProps; - } - } - - const SkSurfaceProps& operator()() const { return *fSurfaceProps; } - -private: - const SkSurfaceProps* fSurfaceProps; - SkTLazy<SkSurfaceProps> fLazy; -}; - void SkBitmapDevice::drawText(const void* text, size_t len, SkScalar x, SkScalar y, const SkPaint& paint) { SkBitmapDeviceFilteredSurfaceProps props(fBitmap, paint, fSurfaceProps); diff --git a/src/core/SkBitmapDevice.h b/src/core/SkBitmapDevice.h index f80cba6ee4..c36bc28713 100644 --- a/src/core/SkBitmapDevice.h +++ b/src/core/SkBitmapDevice.h @@ -179,4 +179,25 @@ private: typedef SkBaseDevice INHERITED; }; +class SkBitmapDeviceFilteredSurfaceProps { +public: + SkBitmapDeviceFilteredSurfaceProps(const SkBitmap& bitmap, const SkPaint& paint, + const SkSurfaceProps& surfaceProps) + : fSurfaceProps((kN32_SkColorType != bitmap.colorType() || !paint.isSrcOver()) + ? fLazy.init(surfaceProps.flags(), kUnknown_SkPixelGeometry) + : &surfaceProps) + { } + + SkBitmapDeviceFilteredSurfaceProps(const SkBitmapDeviceFilteredSurfaceProps&) = delete; + SkBitmapDeviceFilteredSurfaceProps& operator=(const SkBitmapDeviceFilteredSurfaceProps&) = delete; + SkBitmapDeviceFilteredSurfaceProps(SkBitmapDeviceFilteredSurfaceProps&&) = delete; + SkBitmapDeviceFilteredSurfaceProps& operator=(SkBitmapDeviceFilteredSurfaceProps&&) = delete; + + const SkSurfaceProps& operator()() const { return *fSurfaceProps; } + +private: + SkTLazy<SkSurfaceProps> fLazy; + SkSurfaceProps const * const fSurfaceProps; +}; + #endif // SkBitmapDevice_DEFINED diff --git a/src/core/SkThreadedBMPDevice.cpp b/src/core/SkThreadedBMPDevice.cpp index 83ed614263..b75e90d5e4 100644 --- a/src/core/SkThreadedBMPDevice.cpp +++ b/src/core/SkThreadedBMPDevice.cpp @@ -214,9 +214,9 @@ void SkThreadedBMPDevice::drawText(const void* text, size_t len, SkScalar x, SkS const SkPaint& paint) { char* clonedText = this->cloneArray((const char*)text, len); SkRect drawBounds = SkRectPriv::MakeLargest(); // TODO tighter drawBounds + SkSurfaceProps prop(SkBitmapDeviceFilteredSurfaceProps(fBitmap, paint, this->surfaceProps())()); fQueue.push(drawBounds, [=](SkArenaAlloc*, const DrawState& ds, const SkIRect& tileBounds){ - TileDraw(ds, tileBounds).drawText(clonedText, len, x, y, paint, - &this->surfaceProps()); + TileDraw(ds, tileBounds).drawText(clonedText, len, x, y, paint, &prop); }); } @@ -225,9 +225,10 @@ void SkThreadedBMPDevice::drawPosText(const void* text, size_t len, const SkScal char* clonedText = this->cloneArray((const char*)text, len); SkScalar* clonedXpos = this->cloneArray(xpos, paint.countText(text, len) * scalarsPerPos); SkRect drawBounds = SkRectPriv::MakeLargest(); // TODO tighter drawBounds + SkSurfaceProps prop(SkBitmapDeviceFilteredSurfaceProps(fBitmap, paint, this->surfaceProps())()); fQueue.push(drawBounds, [=](SkArenaAlloc*, const DrawState& ds, const SkIRect& tileBounds){ TileDraw(ds, tileBounds).drawPosText(clonedText, len, clonedXpos, scalarsPerPos, offset, - paint, &surfaceProps()); + paint, &prop); }); } |