| 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_WRITEPIXELSCONFIG |
| 22 |
| 21 class SkBounder; | 23 class SkBounder; |
| 22 class SkBaseDevice; | 24 class SkBaseDevice; |
| 23 class SkDraw; | 25 class SkDraw; |
| 24 class SkDrawFilter; | 26 class SkDrawFilter; |
| 25 class SkMetaData; | 27 class SkMetaData; |
| 26 class SkPicture; | 28 class SkPicture; |
| 27 class SkRRect; | 29 class SkRRect; |
| 28 class SkSurface; | 30 class SkSurface; |
| 29 class SkSurface_Base; | 31 class SkSurface_Base; |
| 30 class GrContext; | 32 class GrContext; |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 Config8888 config8888 = kNative_Premul_Config8888); | 259 Config8888 config8888 = kNative_Premul_Config8888); |
| 258 | 260 |
| 259 /** | 261 /** |
| 260 * DEPRECATED: This will be removed as soon as webkit is no longer relying | 262 * DEPRECATED: This will be removed as soon as webkit is no longer relying |
| 261 * on it. The bitmap is resized to the intersection of srcRect and the | 263 * on it. The bitmap is resized to the intersection of srcRect and the |
| 262 * canvas bounds. New pixels are always allocated on success. Bitmap is | 264 * canvas bounds. New pixels are always allocated on success. Bitmap is |
| 263 * unmodified on failure. | 265 * unmodified on failure. |
| 264 */ | 266 */ |
| 265 bool readPixels(const SkIRect& srcRect, SkBitmap* bitmap); | 267 bool readPixels(const SkIRect& srcRect, SkBitmap* bitmap); |
| 266 | 268 |
| 269 #ifdef SK_SUPPORT_LEGACY_WRITEPIXELSCONFIG |
| 267 /** | 270 /** |
| 271 * DEPRECATED |
| 268 * Similar to draw sprite, this method will copy the pixels in bitmap onto | 272 * Similar to draw sprite, this method will copy the pixels in bitmap onto |
| 269 * the canvas, with the top/left corner specified by (x, y). The canvas' | 273 * the canvas, with the top/left corner specified by (x, y). The canvas' |
| 270 * pixel values are completely replaced: there is no blending. | 274 * pixel values are completely replaced: there is no blending. |
| 271 * | 275 * |
| 272 * Currently if bitmap is backed by a texture this is a no-op. This may be | 276 * Currently if bitmap is backed by a texture this is a no-op. This may be |
| 273 * relaxed in the future. | 277 * relaxed in the future. |
| 274 * | 278 * |
| 275 * If the bitmap has config kARGB_8888_Config then the config8888 param | 279 * If the bitmap has config kARGB_8888_Config then the config8888 param |
| 276 * will determines how the pixel valuess are intepreted. If the bitmap is | 280 * will determines how the pixel valuess are intepreted. If the bitmap is |
| 277 * not kARGB_8888_Config then this parameter is ignored. | 281 * not kARGB_8888_Config then this parameter is ignored. |
| 278 * | 282 * |
| 279 * Note: If you are recording drawing commands on this canvas to | 283 * Note: If you are recording drawing commands on this canvas to |
| 280 * SkPicture, writePixels() is ignored! | 284 * SkPicture, writePixels() is ignored! |
| 281 */ | 285 */ |
| 282 void writePixels(const SkBitmap& bitmap, | 286 void writePixels(const SkBitmap& bitmap, int x, int y, Config8888 config8888
); |
| 283 int x, int y, | 287 #endif |
| 284 Config8888 config8888 = kNative_Premul_Config8888); | 288 |
| 289 /** |
| 290 * This method affects the pixels in the base-layer, and operates in pixel
coordinates, |
| 291 * ignoring the matrix and clip. |
| 292 * |
| 293 * The specified ImageInfo and (x,y) offset specifies a rectangle: target. |
| 294 * |
| 295 * target.setXYWH(x, y, info.width(), info.height()); |
| 296 * |
| 297 * Target is intersected with the bounds of the base-layer. If this interse
ction is not empty, |
| 298 * then we have two sets of pixels (of equal size), the "src" specified by
info+pixels+rowBytes |
| 299 * and the "dst" by the canvas' backend. Replace the dst pixels with the co
rresponding src |
| 300 * pixels, performing any colortype/alphatype transformations needed (in th
e case where the |
| 301 * src and dst have different colortypes or alphatypes). |
| 302 * |
| 303 * This call can fail, returning false, for several reasons: |
| 304 * - If the src colortype/alphatype cannot be converted to the canvas' type
s |
| 305 * - If this canvas is not backed by pixels (e.g. picture or PDF) |
| 306 */ |
| 307 bool writePixels(const SkImageInfo&, const void* pixels, size_t rowBytes, in
t x, int y); |
| 308 |
| 309 /** |
| 310 * Helper for calling writePixels(info, ...) by passing its pixels and rowb
ytes. If the bitmap |
| 311 * is just wrapping a texture, returns false and does nothing. |
| 312 */ |
| 313 bool writePixels(const SkBitmap& bitmap, int x, int y); |
| 285 | 314 |
| 286 /////////////////////////////////////////////////////////////////////////// | 315 /////////////////////////////////////////////////////////////////////////// |
| 287 | 316 |
| 288 enum SaveFlags { | 317 enum SaveFlags { |
| 289 /** save the matrix state, restoring it on restore() */ | 318 /** save the matrix state, restoring it on restore() */ |
| 290 kMatrix_SaveFlag = 0x01, | 319 kMatrix_SaveFlag = 0x01, |
| 291 /** save the clip state, restoring it on restore() */ | 320 /** save the clip state, restoring it on restore() */ |
| 292 kClip_SaveFlag = 0x02, | 321 kClip_SaveFlag = 0x02, |
| 293 /** the layer needs to support per-pixel alpha */ | 322 /** the layer needs to support per-pixel alpha */ |
| 294 kHasAlphaLayer_SaveFlag = 0x04, | 323 kHasAlphaLayer_SaveFlag = 0x04, |
| (...skipping 1077 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1372 bool asROBitmap(SkBitmap*) const; | 1401 bool asROBitmap(SkBitmap*) const; |
| 1373 | 1402 |
| 1374 private: | 1403 private: |
| 1375 SkBitmap fBitmap; // used if peekPixels() fails | 1404 SkBitmap fBitmap; // used if peekPixels() fails |
| 1376 const void* fAddr; // NULL on failure | 1405 const void* fAddr; // NULL on failure |
| 1377 SkImageInfo fInfo; | 1406 SkImageInfo fInfo; |
| 1378 size_t fRowBytes; | 1407 size_t fRowBytes; |
| 1379 }; | 1408 }; |
| 1380 | 1409 |
| 1381 #endif | 1410 #endif |
| OLD | NEW |