diff options
author | Herb Derby <herb@google.com> | 2017-02-09 17:25:43 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-02-10 15:29:43 +0000 |
commit | 57bfa0209e3379385b7ef6217cafb22ca83836c8 (patch) | |
tree | d6bd32772d2d3e7d4913224879354fef26f7625e /src/core | |
parent | f1d0ced9cbf99a9f1005e49127ec117aebc44978 (diff) |
Change the Sprite portion of SkBlitter use SkArenaAlloc.
The semantics of createT and make are the same with respect to
dtors, so it just a simple replacement of calls.
TBR=reed@google.com
Change-Id: Ib7d071d214edb44ea5c5466ce81252e9374b6eb7
Reviewed-on: https://skia-review.googlesource.com/8301
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Herb Derby <herb@google.com>
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/SkBlitter.h | 3 | ||||
-rw-r--r-- | src/core/SkBlitter_Sprite.cpp | 6 | ||||
-rw-r--r-- | src/core/SkDraw.cpp | 6 | ||||
-rw-r--r-- | src/core/SkSpriteBlitter.h | 8 | ||||
-rw-r--r-- | src/core/SkSpriteBlitter4f.cpp | 9 | ||||
-rw-r--r-- | src/core/SkSpriteBlitter_ARGB32.cpp | 13 | ||||
-rw-r--r-- | src/core/SkSpriteBlitter_RGB16.cpp | 21 |
7 files changed, 36 insertions, 30 deletions
diff --git a/src/core/SkBlitter.h b/src/core/SkBlitter.h index 4d34ce3e91..1fc49594c9 100644 --- a/src/core/SkBlitter.h +++ b/src/core/SkBlitter.h @@ -15,6 +15,7 @@ #include "SkRegion.h" #include "SkShader.h" +class SkArenaAlloc; class SkMatrix; class SkPaint; class SkPixmap; @@ -144,7 +145,7 @@ public: const SkPaint&, const SkPixmap& src, int left, int top, - SkTBlitterAllocator*); + SkArenaAlloc*); ///@} static SkShader::ContextRec::DstType PreferredShaderDest(const SkImageInfo&); diff --git a/src/core/SkBlitter_Sprite.cpp b/src/core/SkBlitter_Sprite.cpp index cef4cfaa2f..4c184bdb33 100644 --- a/src/core/SkBlitter_Sprite.cpp +++ b/src/core/SkBlitter_Sprite.cpp @@ -5,8 +5,8 @@ * found in the LICENSE file. */ +#include "SkArenaAlloc.h" #include "SkOpts.h" -#include "SkSmallAllocator.h" #include "SkSpriteBlitter.h" SkSpriteBlitter::SkSpriteBlitter(const SkPixmap& source) @@ -140,7 +140,7 @@ private: // returning null means the caller will call SkBlitter::Choose() and // have wrapped the source bitmap inside a shader SkBlitter* SkBlitter::ChooseSprite(const SkPixmap& dst, const SkPaint& paint, - const SkPixmap& source, int left, int top, SkTBlitterAllocator* allocator) { + const SkPixmap& source, int left, int top, SkArenaAlloc* allocator) { /* We currently ignore antialiasing and filtertype, meaning we will take our special blitters regardless of these settings. Ignoring filtertype seems fine since by definition there is no scale in the matrix. Ignoring antialiasing is @@ -161,7 +161,7 @@ SkBlitter* SkBlitter::ChooseSprite(const SkPixmap& dst, const SkPaint& paint, SkSpriteBlitter* blitter = nullptr; if (SkSpriteBlitter_Src_SrcOver::Supports(dst, source, paint)) { - blitter = allocator->createT<SkSpriteBlitter_Src_SrcOver>(source); + blitter = allocator->make<SkSpriteBlitter_Src_SrcOver>(source); } else { switch (dst.colorType()) { case kRGB_565_SkColorType: diff --git a/src/core/SkDraw.cpp b/src/core/SkDraw.cpp index 2891c95fdd..d11bcd2f9f 100644 --- a/src/core/SkDraw.cpp +++ b/src/core/SkDraw.cpp @@ -1331,7 +1331,8 @@ void SkDraw::drawBitmap(const SkBitmap& bitmap, const SkMatrix& prematrix, int ix = SkScalarRoundToInt(matrix.getTranslateX()); int iy = SkScalarRoundToInt(matrix.getTranslateY()); if (clipHandlesSprite(*fRC, ix, iy, pmap)) { - SkTBlitterAllocator allocator; + char storage[kSkBlitterContextSize]; + SkArenaAlloc allocator{storage}; // blitter will be owned by the allocator. SkBlitter* blitter = SkBlitter::ChooseSprite(fDst, *paint, pmap, ix, iy, &allocator); if (blitter) { @@ -1388,8 +1389,9 @@ void SkDraw::drawSprite(const SkBitmap& bitmap, int x, int y, const SkPaint& ori const SkPixmap& pmap = unlocker.pixmap(); if (nullptr == paint.getColorFilter() && clipHandlesSprite(*fRC, x, y, pmap)) { - SkTBlitterAllocator allocator; // blitter will be owned by the allocator. + char storage[kSkBlitterContextSize]; + SkArenaAlloc allocator{storage}; SkBlitter* blitter = SkBlitter::ChooseSprite(fDst, paint, pmap, x, y, &allocator); if (blitter) { SkScan::FillIRect(bounds, *fRC, blitter); diff --git a/src/core/SkSpriteBlitter.h b/src/core/SkSpriteBlitter.h index 3a62860867..3113d79766 100644 --- a/src/core/SkSpriteBlitter.h +++ b/src/core/SkSpriteBlitter.h @@ -33,10 +33,10 @@ public: // A SkSpriteBlitter must implement blitRect. void blitRect(int x, int y, int width, int height) override = 0; - static SkSpriteBlitter* ChooseD16(const SkPixmap& source, const SkPaint&, SkTBlitterAllocator*); - static SkSpriteBlitter* ChooseL32(const SkPixmap& source, const SkPaint&, SkTBlitterAllocator*); - static SkSpriteBlitter* ChooseS32(const SkPixmap& source, const SkPaint&, SkTBlitterAllocator*); - static SkSpriteBlitter* ChooseF16(const SkPixmap& source, const SkPaint&, SkTBlitterAllocator*); + static SkSpriteBlitter* ChooseD16(const SkPixmap& source, const SkPaint&, SkArenaAlloc*); + static SkSpriteBlitter* ChooseL32(const SkPixmap& source, const SkPaint&, SkArenaAlloc*); + static SkSpriteBlitter* ChooseS32(const SkPixmap& source, const SkPaint&, SkArenaAlloc*); + static SkSpriteBlitter* ChooseF16(const SkPixmap& source, const SkPaint&, SkArenaAlloc*); protected: SkPixmap fDst; diff --git a/src/core/SkSpriteBlitter4f.cpp b/src/core/SkSpriteBlitter4f.cpp index 977a2647a9..f893478c08 100644 --- a/src/core/SkSpriteBlitter4f.cpp +++ b/src/core/SkSpriteBlitter4f.cpp @@ -6,6 +6,7 @@ */ #include "SkSpriteBlitter.h" +#include "SkArenaAlloc.h" #include "SkSpanProcs.h" #include "SkTemplates.h" #include "SkXfermodePriv.h" @@ -62,7 +63,7 @@ private: SkSpriteBlitter* SkSpriteBlitter::ChooseF16(const SkPixmap& source, const SkPaint& paint, - SkTBlitterAllocator* allocator) { + SkArenaAlloc* allocator) { SkASSERT(allocator != nullptr); if (paint.getMaskFilter() != nullptr) { @@ -72,7 +73,7 @@ SkSpriteBlitter* SkSpriteBlitter::ChooseF16(const SkPixmap& source, const SkPain switch (source.colorType()) { case kN32_SkColorType: case kRGBA_F16_SkColorType: - return allocator->createT<Sprite_F16>(source, paint); + return allocator->make<Sprite_F16>(source, paint); default: return nullptr; } @@ -112,7 +113,7 @@ private: SkSpriteBlitter* SkSpriteBlitter::ChooseS32(const SkPixmap& source, const SkPaint& paint, - SkTBlitterAllocator* allocator) { + SkArenaAlloc* allocator) { SkASSERT(allocator != nullptr); if (paint.getMaskFilter() != nullptr) { @@ -122,7 +123,7 @@ SkSpriteBlitter* SkSpriteBlitter::ChooseS32(const SkPixmap& source, const SkPain switch (source.colorType()) { case kN32_SkColorType: case kRGBA_F16_SkColorType: - return allocator->createT<Sprite_sRGB>(source, paint); + return allocator->make<Sprite_sRGB>(source, paint); default: return nullptr; } diff --git a/src/core/SkSpriteBlitter_ARGB32.cpp b/src/core/SkSpriteBlitter_ARGB32.cpp index 99856a14f9..6b6d8b10d7 100644 --- a/src/core/SkSpriteBlitter_ARGB32.cpp +++ b/src/core/SkSpriteBlitter_ARGB32.cpp @@ -6,6 +6,7 @@ */ #include "SkSpriteBlitter.h" +#include "SkArenaAlloc.h" #include "SkBlitRow.h" #include "SkColorFilter.h" #include "SkColorPriv.h" @@ -253,7 +254,7 @@ public: /////////////////////////////////////////////////////////////////////////////// SkSpriteBlitter* SkSpriteBlitter::ChooseL32(const SkPixmap& source, const SkPaint& paint, - SkTBlitterAllocator* allocator) { + SkArenaAlloc* allocator) { SkASSERT(allocator != nullptr); if (paint.getMaskFilter() != nullptr) { @@ -271,22 +272,22 @@ SkSpriteBlitter* SkSpriteBlitter::ChooseL32(const SkPixmap& source, const SkPain return nullptr; // we only have opaque sprites } if (!isSrcOver || filter) { - blitter = allocator->createT<Sprite_D32_S4444_XferFilter>(source, paint); + blitter = allocator->make<Sprite_D32_S4444_XferFilter>(source, paint); } else if (source.isOpaque()) { - blitter = allocator->createT<Sprite_D32_S4444_Opaque>(source); + blitter = allocator->make<Sprite_D32_S4444_Opaque>(source); } else { - blitter = allocator->createT<Sprite_D32_S4444>(source); + blitter = allocator->make<Sprite_D32_S4444>(source); } break; case kN32_SkColorType: if (!isSrcOver || filter) { if (255 == alpha) { // this can handle xfermode or filter, but not alpha - blitter = allocator->createT<Sprite_D32_S32A_XferFilter>(source, paint); + blitter = allocator->make<Sprite_D32_S32A_XferFilter>(source, paint); } } else { // this can handle alpha, but not xfermode or filter - blitter = allocator->createT<Sprite_D32_S32>(source, alpha); + blitter = allocator->make<Sprite_D32_S32>(source, alpha); } break; default: diff --git a/src/core/SkSpriteBlitter_RGB16.cpp b/src/core/SkSpriteBlitter_RGB16.cpp index 9df7dab48c..6d9375d12b 100644 --- a/src/core/SkSpriteBlitter_RGB16.cpp +++ b/src/core/SkSpriteBlitter_RGB16.cpp @@ -7,6 +7,7 @@ #include "SkSpriteBlitter.h" +#include "SkArenaAlloc.h" #include "SkBlitRow.h" #include "SkTemplates.h" #include "SkUtils.h" @@ -300,7 +301,7 @@ private: /////////////////////////////////////////////////////////////////////////////// SkSpriteBlitter* SkSpriteBlitter::ChooseD16(const SkPixmap& source, const SkPaint& paint, - SkTBlitterAllocator* allocator) { + SkArenaAlloc* allocator) { SkASSERT(allocator != nullptr); @@ -324,7 +325,7 @@ SkSpriteBlitter* SkSpriteBlitter::ChooseD16(const SkPixmap& source, const SkPain if (kPremul_SkAlphaType != at && kOpaque_SkAlphaType != at) { break; } - blitter = allocator->createT<Sprite_D16_S32_BlitRowProc>(source); + blitter = allocator->make<Sprite_D16_S32_BlitRowProc>(source); break; } case kARGB_4444_SkColorType: @@ -332,16 +333,16 @@ SkSpriteBlitter* SkSpriteBlitter::ChooseD16(const SkPixmap& source, const SkPain break; } if (255 == alpha) { - blitter = allocator->createT<Sprite_D16_S4444_Opaque>(source); + blitter = allocator->make<Sprite_D16_S4444_Opaque>(source); } else { - blitter = allocator->createT<Sprite_D16_S4444_Blend>(source, alpha >> 4); + blitter = allocator->make<Sprite_D16_S4444_Blend>(source, alpha >> 4); } break; case kRGB_565_SkColorType: if (255 == alpha) { - blitter = allocator->createT<Sprite_D16_S16_Opaque>(source); + blitter = allocator->make<Sprite_D16_S16_Opaque>(source); } else { - blitter = allocator->createT<Sprite_D16_S16_Blend>(source, alpha); + blitter = allocator->make<Sprite_D16_S16_Blend>(source, alpha); } break; case kIndex_8_SkColorType: @@ -354,15 +355,15 @@ SkSpriteBlitter* SkSpriteBlitter::ChooseD16(const SkPixmap& source, const SkPain } if (source.isOpaque()) { if (255 == alpha) { - blitter = allocator->createT<Sprite_D16_SIndex8_Opaque>(source); + blitter = allocator->make<Sprite_D16_SIndex8_Opaque>(source); } else { - blitter = allocator->createT<Sprite_D16_SIndex8_Blend>(source, alpha); + blitter = allocator->make<Sprite_D16_SIndex8_Blend>(source, alpha); } } else { if (255 == alpha) { - blitter = allocator->createT<Sprite_D16_SIndex8A_Opaque>(source); + blitter = allocator->make<Sprite_D16_SIndex8A_Opaque>(source); } else { - blitter = allocator->createT<Sprite_D16_SIndex8A_Blend>(source, alpha); + blitter = allocator->make<Sprite_D16_SIndex8A_Blend>(source, alpha); } } break; |