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

Unified Diff: src/utils/SkCanvasStateUtils.cpp

Issue 168843002: use SkColorType instead of SkBitmap::Config in views/effects (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 10 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
« no previous file with comments | « src/effects/gradients/SkGradientShader.cpp ('k') | src/utils/mac/SkCreateCGImageRef.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/utils/SkCanvasStateUtils.cpp
diff --git a/src/utils/SkCanvasStateUtils.cpp b/src/utils/SkCanvasStateUtils.cpp
index 77b0e20c2d46377a61df5148cb2c293738d8d76d..4b8868b02a62a7001c036974ce3a5bbfc09f1733 100644
--- a/src/utils/SkCanvasStateUtils.cpp
+++ b/src/utils/SkCanvasStateUtils.cpp
@@ -221,11 +221,11 @@ SkCanvasState* SkCanvasStateUtils::CaptureCanvasState(SkCanvas* canvas) {
layerState->width = bitmap.width();
layerState->height = bitmap.height();
- switch (bitmap.config()) {
- case SkBitmap::kARGB_8888_Config:
+ switch (bitmap.colorType()) {
+ case kPMColor_SkColorType:
layerState->raster.config = kARGB_8888_RasterConfig;
break;
- case SkBitmap::kRGB_565_Config:
+ case kRGB_565_SkColorType:
layerState->raster.config = kRGB_565_RasterConfig;
break;
default:
@@ -279,25 +279,24 @@ static SkCanvas* create_canvas_from_canvas_layer(const SkCanvasLayerState& layer
SkASSERT(kRaster_CanvasBackend == layerState.type);
SkBitmap bitmap;
- SkBitmap::Config config =
- layerState.raster.config == kARGB_8888_RasterConfig ? SkBitmap::kARGB_8888_Config :
- layerState.raster.config == kRGB_565_RasterConfig ? SkBitmap::kRGB_565_Config :
- SkBitmap::kNo_Config;
+ SkColorType colorType =
+ layerState.raster.config == kARGB_8888_RasterConfig ? kPMColor_SkColorType :
+ layerState.raster.config == kRGB_565_RasterConfig ? kRGB_565_SkColorType :
+ kUnknown_SkColorType;
- if (config == SkBitmap::kNo_Config) {
+ if (colorType == kUnknown_SkColorType) {
return NULL;
}
- bitmap.setConfig(config, layerState.width, layerState.height,
- layerState.raster.rowBytes);
- bitmap.setPixels(layerState.raster.pixels);
+ bitmap.installPixels(SkImageInfo::Make(layerState.width, layerState.height,
+ colorType, kPremul_SkAlphaType),
+ layerState.raster.pixels, layerState.raster.rowBytes,
+ NULL, NULL);
SkASSERT(!bitmap.empty());
SkASSERT(!bitmap.isNull());
- // create a device & canvas
- SkAutoTUnref<SkBitmapDevice> device(SkNEW_ARGS(SkBitmapDevice, (bitmap)));
- SkAutoTUnref<SkCanvas> canvas(SkNEW_ARGS(SkCanvas, (device.get())));
+ SkAutoTUnref<SkCanvas> canvas(SkNEW_ARGS(SkCanvas, (bitmap)));
// setup the matrix and clip
setup_canvas_from_MC_state(layerState.mcState, canvas.get());
« no previous file with comments | « src/effects/gradients/SkGradientShader.cpp ('k') | src/utils/mac/SkCreateCGImageRef.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698