SkShader* CreateBitmapShader(const SkBitmap& src, SkShader::TileMode tmx, SkShader::TileMode tmy, const SkMatrix* localMatrix, SkTBlitterAllocator* allocator) { SkShader* shader; SkColor color; if (src.isNull() || bitmapIsTooBig(src)) { if (NULL == allocator) { shader = SkNEW(SkEmptyShader); } else { shader = allocator->createT<SkEmptyShader>(); } } else if (canUseColorShader(src, &color)) { if (NULL == allocator) { shader = SkNEW_ARGS(SkColorShader, (color)); } else { shader = allocator->createT<SkColorShader>(color); } } else { if (NULL == allocator) { shader = SkNEW_ARGS(SkBitmapProcShader, (src, tmx, tmy, localMatrix)); } else { shader = allocator->createT<SkBitmapProcShader>(src, tmx, tmy, localMatrix); } } return shader; }
SkShader* SkShader::CreateBitmapShader(const SkBitmap& src, TileMode tmx, TileMode tmy, void* storage, size_t storageSize) { SkShader* shader; SkColor color; if (src.isNull() || bitmapIsTooBig(src)) { SK_PLACEMENT_NEW(shader, SkEmptyShader, storage, storageSize); } else if (canUseColorShader(src, &color)) { SK_PLACEMENT_NEW_ARGS(shader, SkColorShader, storage, storageSize, (color)); } else { SK_PLACEMENT_NEW_ARGS(shader, SkBitmapProcShader, storage, storageSize, (src, tmx, tmy)); } return shader; }