| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
| 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 #ifndef SkCanvas_DEFINED | 8 #ifndef SkCanvas_DEFINED |
| 9 #define SkCanvas_DEFINED | 9 #define SkCanvas_DEFINED |
| 10 | 10 |
| 11 #include "SkTypes.h" | 11 #include "SkTypes.h" |
| 12 #include "SkBitmap.h" | 12 #include "SkBitmap.h" |
| 13 #include "SkDeque.h" | 13 #include "SkDeque.h" |
| 14 #include "SkClipStack.h" | 14 #include "SkClipStack.h" |
| 15 #include "SkPaint.h" | 15 #include "SkPaint.h" |
| 16 #include "SkRefCnt.h" | 16 #include "SkRefCnt.h" |
| 17 #include "SkPath.h" | 17 #include "SkPath.h" |
| 18 #include "SkRegion.h" | 18 #include "SkRegion.h" |
| 19 #include "SkXfermode.h" | 19 #include "SkXfermode.h" |
| 20 | 20 |
| 21 //#define SK_SUPPORT_LEGACY_READPIXELSCONFIG |
| 22 |
| 21 // if not defined, we always assume ClipToLayer for saveLayer() | 23 // if not defined, we always assume ClipToLayer for saveLayer() |
| 22 //#define SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG | 24 //#define SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG |
| 23 | 25 |
| 24 | 26 |
| 25 //#define SK_SUPPORT_LEGACY_GETCLIPTYPE | 27 //#define SK_SUPPORT_LEGACY_GETCLIPTYPE |
| 26 //#define SK_SUPPORT_LEGACY_GETTOTALCLIP | 28 //#define SK_SUPPORT_LEGACY_GETTOTALCLIP |
| 27 //#define SK_SUPPORT_LEGACY_GETTOPDEVICE | 29 //#define SK_SUPPORT_LEGACY_GETTOPDEVICE |
| 28 | 30 |
| 29 class SkBounder; | 31 class SkBounder; |
| 30 class SkBaseDevice; | 32 class SkBaseDevice; |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 */ | 259 */ |
| 258 kBGRA_Premul_Config8888, | 260 kBGRA_Premul_Config8888, |
| 259 kBGRA_Unpremul_Config8888, | 261 kBGRA_Unpremul_Config8888, |
| 260 /** | 262 /** |
| 261 * low byte to high byte: R, G, B, A. | 263 * low byte to high byte: R, G, B, A. |
| 262 */ | 264 */ |
| 263 kRGBA_Premul_Config8888, | 265 kRGBA_Premul_Config8888, |
| 264 kRGBA_Unpremul_Config8888 | 266 kRGBA_Unpremul_Config8888 |
| 265 }; | 267 }; |
| 266 | 268 |
| 269 #ifdef SK_SUPPORT_LEGACY_READPIXELSCONFIG |
| 267 /** | 270 /** |
| 268 * On success (returns true), copy the canvas pixels into the bitmap. | 271 * On success (returns true), copy the canvas pixels into the bitmap. |
| 269 * On failure, the bitmap parameter is left unchanged and false is | 272 * On failure, the bitmap parameter is left unchanged and false is |
| 270 * returned. | 273 * returned. |
| 271 * | 274 * |
| 272 * The canvas' pixels are converted to the bitmap's config. The only | 275 * The canvas' pixels are converted to the bitmap's config. The only |
| 273 * supported config is kARGB_8888_Config, though this is likely to be | 276 * supported config is kARGB_8888_Config, though this is likely to be |
| 274 * relaxed in the future. The meaning of config kARGB_8888_Config is | 277 * relaxed in the future. The meaning of config kARGB_8888_Config is |
| 275 * modified by the enum param config8888. The default value interprets | 278 * modified by the enum param config8888. The default value interprets |
| 276 * kARGB_8888_Config as SkPMColor | 279 * kARGB_8888_Config as SkPMColor |
| (...skipping 16 matching lines...) Expand all Loading... |
| 293 * | 296 * |
| 294 * Example that reads the entire canvas into a bitmap using the native | 297 * Example that reads the entire canvas into a bitmap using the native |
| 295 * SkPMColor: | 298 * SkPMColor: |
| 296 * SkISize size = canvas->getDeviceSize(); | 299 * SkISize size = canvas->getDeviceSize(); |
| 297 * bitmap->setConfig(SkBitmap::kARGB_8888_Config, size.fWidth, | 300 * bitmap->setConfig(SkBitmap::kARGB_8888_Config, size.fWidth, |
| 298 * size.fHeight); | 301 * size.fHeight); |
| 299 * if (canvas->readPixels(bitmap, 0, 0)) { | 302 * if (canvas->readPixels(bitmap, 0, 0)) { |
| 300 * // use the pixels | 303 * // use the pixels |
| 301 * } | 304 * } |
| 302 */ | 305 */ |
| 303 bool readPixels(SkBitmap* bitmap, | 306 bool readPixels(SkBitmap* bitmap, int x, int y, Config8888 config8888); |
| 304 int x, int y, | 307 #endif |
| 305 Config8888 config8888 = kNative_Premul_Config8888); | |
| 306 | 308 |
| 307 /** | 309 /** |
| 308 * DEPRECATED: This will be removed as soon as webkit is no longer relying | 310 * Copy the pixels from the base-layer into the specified buffer (pixels +
rowBytes), |
| 309 * on it. The bitmap is resized to the intersection of srcRect and the | 311 * converting them into the requested format (SkImageInfo). The base-layer
pixels are read |
| 310 * canvas bounds. New pixels are always allocated on success. Bitmap is | 312 * starting at the specified (x,y) location in the coordinate system of the
base-layer. |
| 311 * unmodified on failure. | 313 * |
| 314 * The specified ImageInfo and (x,y) offset specifies a source rectangle |
| 315 * |
| 316 * srcR(x, y, info.width(), info.height()); |
| 317 * |
| 318 * SrcR is intersected with the bounds of the base-layer. If this intersect
ion is not empty, |
| 319 * then we have two sets of pixels (of equal size), the "src" specified by
base-layer at (x,y) |
| 320 * and the "dst" by info+pixels+rowBytes. Replace the dst pixels with the c
orresponding src |
| 321 * pixels, performing any colortype/alphatype transformations needed (in th
e case where the |
| 322 * src and dst have different colortypes or alphatypes). |
| 323 * |
| 324 * This call can fail, returning false, for several reasons: |
| 325 * - If the requested colortype/alphatype cannot be converted from the base
-layer's types. |
| 326 * - If this canvas is not backed by pixels (e.g. picture or PDF) |
| 327 */ |
| 328 bool readPixels(const SkImageInfo&, void* pixels, size_t rowBytes, int x, in
t y); |
| 329 |
| 330 /** |
| 331 * Helper for calling readPixels(info, ...). This call will check if bitmap
has been allocated. |
| 332 * If not, it will attempt to call allocPixels(). If this fails, it will re
turn false. If not, |
| 333 * it calls through to readPixels(info, ...) and returns its result. |
| 334 */ |
| 335 bool readPixels(SkBitmap* bitmap, int x, int y); |
| 336 |
| 337 /** |
| 338 * Helper for allocating pixels and then calling readPixels(info, ...). The
bitmap is resized |
| 339 * to the intersection of srcRect and the base-layer bounds. On success, pi
xels will be |
| 340 * allocated in bitmap and true returned. On failure, false is returned and
bitmap will be |
| 341 * set to empty. |
| 312 */ | 342 */ |
| 313 bool readPixels(const SkIRect& srcRect, SkBitmap* bitmap); | 343 bool readPixels(const SkIRect& srcRect, SkBitmap* bitmap); |
| 314 | 344 |
| 315 /** | 345 /** |
| 316 * This method affects the pixels in the base-layer, and operates in pixel
coordinates, | 346 * This method affects the pixels in the base-layer, and operates in pixel
coordinates, |
| 317 * ignoring the matrix and clip. | 347 * ignoring the matrix and clip. |
| 318 * | 348 * |
| 319 * The specified ImageInfo and (x,y) offset specifies a rectangle: target. | 349 * The specified ImageInfo and (x,y) offset specifies a rectangle: target. |
| 320 * | 350 * |
| 321 * target.setXYWH(x, y, info.width(), info.height()); | 351 * target.setXYWH(x, y, info.width(), info.height()); |
| (...skipping 1151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1473 bool asROBitmap(SkBitmap*) const; | 1503 bool asROBitmap(SkBitmap*) const; |
| 1474 | 1504 |
| 1475 private: | 1505 private: |
| 1476 SkBitmap fBitmap; // used if peekPixels() fails | 1506 SkBitmap fBitmap; // used if peekPixels() fails |
| 1477 const void* fAddr; // NULL on failure | 1507 const void* fAddr; // NULL on failure |
| 1478 SkImageInfo fInfo; | 1508 SkImageInfo fInfo; |
| 1479 size_t fRowBytes; | 1509 size_t fRowBytes; |
| 1480 }; | 1510 }; |
| 1481 | 1511 |
| 1482 #endif | 1512 #endif |
| OLD | NEW |