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

Unified Diff: src/core/SkBitmapProcShader.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/SkBitmapProcShader.cpp
diff --git a/src/core/SkBitmapProcShader.cpp b/src/core/SkBitmapProcShader.cpp
index 74b9e86669eead31a270822791558e2b2c2c0adc..55a772ec10ace94578a4be78cedbd508de1deb97 100644
--- a/src/core/SkBitmapProcShader.cpp
+++ b/src/core/SkBitmapProcShader.cpp
@@ -294,8 +294,6 @@ static bool canUseColorShader(const SkBitmap& bm, SkColor* color) {
return false;
}
-#include "SkTemplatesPriv.h"
-
static bool bitmapIsTooBig(const SkBitmap& bm) {
// SkBitmapProcShader stores bitmap coordinates in a 16bit buffer, as it
// communicates between its matrix-proc and its sampler-proc. Until we can
@@ -306,20 +304,29 @@ static bool bitmapIsTooBig(const SkBitmap& bm) {
return bm.width() > maxSize || bm.height() > maxSize;
}
-SkShader* SkShader::CreateBitmapShader(const SkBitmap& src,
- TileMode tmx, TileMode tmy,
- void* storage, size_t storageSize) {
+SkShader* CreateBitmapShader(const SkBitmap& src, SkShader::TileMode tmx,
+ SkShader::TileMode tmy, SkTBlitterAllocator* allocator) {
SkShader* shader;
SkColor color;
if (src.isNull() || bitmapIsTooBig(src)) {
- SK_PLACEMENT_NEW(shader, SkEmptyShader, storage, storageSize);
+ if (NULL == allocator) {
+ shader = SkNEW(SkEmptyShader);
+ } else {
+ shader = allocator->createT<SkEmptyShader>();
+ }
}
else if (canUseColorShader(src, &color)) {
- SK_PLACEMENT_NEW_ARGS(shader, SkColorShader, storage, storageSize,
- (color));
+ if (NULL == allocator) {
+ shader = SkNEW_ARGS(SkColorShader, (color));
+ } else {
+ shader = allocator->createT<SkColorShader>(color);
+ }
} else {
- SK_PLACEMENT_NEW_ARGS(shader, SkBitmapProcShader, storage,
- storageSize, (src, tmx, tmy));
+ if (NULL == allocator) {
+ shader = SkNEW_ARGS(SkBitmapProcShader, (src, tmx, tmy));
+ } else {
+ shader = allocator->createT<SkBitmapProcShader>(src, tmx, tmy);
+ }
}
return shader;
}
« no previous file with comments | « src/core/SkBitmapProcShader.h ('k') | src/core/SkBlitter.h » ('j') | src/core/SkSmallAllocator.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698