Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(149)

Unified Diff: src/core/SkSpriteBlitter_RGB16.cpp

Issue 179343005: Add a class to allocate small objects w/o extra calls to new. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Rename the .h file Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/core/SkSpriteBlitter_RGB16.cpp
diff --git a/src/core/SkSpriteBlitter_RGB16.cpp b/src/core/SkSpriteBlitter_RGB16.cpp
index 7428c8a74a38b8cf525efbf7c73151eb4cb8a9f6..74c1961dbdf8516d28ac707c47c91664213360b7 100644
--- a/src/core/SkSpriteBlitter_RGB16.cpp
+++ b/src/core/SkSpriteBlitter_RGB16.cpp
@@ -306,11 +306,11 @@ private:
///////////////////////////////////////////////////////////////////////////////
-#include "SkTemplatesPriv.h"
+SkSpriteBlitter* SkSpriteBlitter::ChooseD16(const SkBitmap& source, const SkPaint& paint,
+ SkTBlitterAllocator* allocator) {
+
+ SkASSERT(allocator != NULL);
-SkSpriteBlitter* SkSpriteBlitter::ChooseD16(const SkBitmap& source,
- const SkPaint& paint,
- void* storage, size_t storageSize) {
if (paint.getMaskFilter() != NULL) { // may add cases for this
return NULL;
}
@@ -325,26 +325,22 @@ SkSpriteBlitter* SkSpriteBlitter::ChooseD16(const SkBitmap& source,
unsigned alpha = paint.getAlpha();
switch (source.colorType()) {
- case kPMColor_SkColorType:
- SK_PLACEMENT_NEW_ARGS(blitter, Sprite_D16_S32_BlitRowProc,
- storage, storageSize, (source));
+ case kPMColor_SkColorType: {
+ blitter = allocator->createT<Sprite_D16_S32_BlitRowProc>(source);
break;
+ }
case kARGB_4444_SkColorType:
if (255 == alpha) {
- SK_PLACEMENT_NEW_ARGS(blitter, Sprite_D16_S4444_Opaque,
- storage, storageSize, (source));
+ blitter = allocator->createT<Sprite_D16_S4444_Opaque>(source);
} else {
- SK_PLACEMENT_NEW_ARGS(blitter, Sprite_D16_S4444_Blend,
- storage, storageSize, (source, alpha >> 4));
+ blitter = allocator->createT<Sprite_D16_S4444_Blend>(source, alpha >> 4);
}
break;
case kRGB_565_SkColorType:
if (255 == alpha) {
- SK_PLACEMENT_NEW_ARGS(blitter, Sprite_D16_S16_Opaque,
- storage, storageSize, (source));
+ blitter = allocator->createT<Sprite_D16_S16_Opaque>(source);
} else {
- SK_PLACEMENT_NEW_ARGS(blitter, Sprite_D16_S16_Blend,
- storage, storageSize, (source, alpha));
+ blitter = allocator->createT<Sprite_D16_S16_Blend>(source, alpha);
}
break;
case kIndex_8_SkColorType:
@@ -354,19 +350,15 @@ SkSpriteBlitter* SkSpriteBlitter::ChooseD16(const SkBitmap& source,
}
if (source.isOpaque()) {
if (255 == alpha) {
- SK_PLACEMENT_NEW_ARGS(blitter, Sprite_D16_SIndex8_Opaque,
- storage, storageSize, (source));
+ blitter = allocator->createT<Sprite_D16_SIndex8_Opaque>(source);
} else {
- SK_PLACEMENT_NEW_ARGS(blitter, Sprite_D16_SIndex8_Blend,
- storage, storageSize, (source, alpha));
+ blitter = allocator->createT<Sprite_D16_SIndex8_Blend>(source, alpha);
}
} else {
if (255 == alpha) {
- SK_PLACEMENT_NEW_ARGS(blitter, Sprite_D16_SIndex8A_Opaque,
- storage, storageSize, (source));
+ blitter = allocator->createT<Sprite_D16_SIndex8A_Opaque>(source);
} else {
- SK_PLACEMENT_NEW_ARGS(blitter, Sprite_D16_SIndex8A_Blend,
- storage, storageSize, (source, alpha));
+ blitter = allocator->createT<Sprite_D16_SIndex8A_Blend>(source, alpha);
}
}
break;

Powered by Google App Engine
This is Rietveld 408576698