OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkCanvasStateUtils.h" | 8 #include "SkCanvasStateUtils.h" |
9 | 9 |
10 #include "SkBitmapDevice.h" | 10 #include "SkBitmapDevice.h" |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 | 216 |
217 SkCanvasLayerState* layerState = | 217 SkCanvasLayerState* layerState = |
218 (SkCanvasLayerState*) layerWriter.reserve(sizeof(SkCanvasLayerSt
ate)); | 218 (SkCanvasLayerState*) layerWriter.reserve(sizeof(SkCanvasLayerSt
ate)); |
219 layerState->type = kRaster_CanvasBackend; | 219 layerState->type = kRaster_CanvasBackend; |
220 layerState->x = layer.x(); | 220 layerState->x = layer.x(); |
221 layerState->y = layer.y(); | 221 layerState->y = layer.y(); |
222 layerState->width = bitmap.width(); | 222 layerState->width = bitmap.width(); |
223 layerState->height = bitmap.height(); | 223 layerState->height = bitmap.height(); |
224 | 224 |
225 switch (bitmap.colorType()) { | 225 switch (bitmap.colorType()) { |
226 case kN32_SkColorType: | 226 case kPMColor_SkColorType: |
227 layerState->raster.config = kARGB_8888_RasterConfig; | 227 layerState->raster.config = kARGB_8888_RasterConfig; |
228 break; | 228 break; |
229 case kRGB_565_SkColorType: | 229 case kRGB_565_SkColorType: |
230 layerState->raster.config = kRGB_565_RasterConfig; | 230 layerState->raster.config = kRGB_565_RasterConfig; |
231 break; | 231 break; |
232 default: | 232 default: |
233 return NULL; | 233 return NULL; |
234 } | 234 } |
235 layerState->raster.rowBytes = bitmap.rowBytes(); | 235 layerState->raster.rowBytes = bitmap.rowBytes(); |
236 layerState->raster.pixels = bitmap.getPixels(); | 236 layerState->raster.pixels = bitmap.getPixels(); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 | 274 |
275 canvas->setMatrix(matrix); | 275 canvas->setMatrix(matrix); |
276 canvas->setClipRegion(clip); | 276 canvas->setClipRegion(clip); |
277 } | 277 } |
278 | 278 |
279 static SkCanvas* create_canvas_from_canvas_layer(const SkCanvasLayerState& layer
State) { | 279 static SkCanvas* create_canvas_from_canvas_layer(const SkCanvasLayerState& layer
State) { |
280 SkASSERT(kRaster_CanvasBackend == layerState.type); | 280 SkASSERT(kRaster_CanvasBackend == layerState.type); |
281 | 281 |
282 SkBitmap bitmap; | 282 SkBitmap bitmap; |
283 SkColorType colorType = | 283 SkColorType colorType = |
284 layerState.raster.config == kARGB_8888_RasterConfig ? kN32_SkColorType : | 284 layerState.raster.config == kARGB_8888_RasterConfig ? kPMColor_SkColorTy
pe : |
285 layerState.raster.config == kRGB_565_RasterConfig ? kRGB_565_SkColorType
: | 285 layerState.raster.config == kRGB_565_RasterConfig ? kRGB_565_SkColorType
: |
286 kUnknown_SkColorType; | 286 kUnknown_SkColorType; |
287 | 287 |
288 if (colorType == kUnknown_SkColorType) { | 288 if (colorType == kUnknown_SkColorType) { |
289 return NULL; | 289 return NULL; |
290 } | 290 } |
291 | 291 |
292 bitmap.installPixels(SkImageInfo::Make(layerState.width, layerState.height, | 292 bitmap.installPixels(SkImageInfo::Make(layerState.width, layerState.height, |
293 colorType, kPremul_SkAlphaType), | 293 colorType, kPremul_SkAlphaType), |
294 layerState.raster.pixels, layerState.raster.rowBytes, | 294 layerState.raster.pixels, layerState.raster.rowBytes, |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 } | 334 } |
335 | 335 |
336 return canvas.detach(); | 336 return canvas.detach(); |
337 } | 337 } |
338 | 338 |
339 //////////////////////////////////////////////////////////////////////////////// | 339 //////////////////////////////////////////////////////////////////////////////// |
340 | 340 |
341 void SkCanvasStateUtils::ReleaseCanvasState(SkCanvasState* state) { | 341 void SkCanvasStateUtils::ReleaseCanvasState(SkCanvasState* state) { |
342 SkDELETE(state); | 342 SkDELETE(state); |
343 } | 343 } |
OLD | NEW |