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

Side by Side Diff: include/core/SkCanvas.h

Issue 180113010: Add SkCanvas::writePixels that takes info+pixels directly (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 * pixel values are completely replaced: there is no blending. 272 * pixel values are completely replaced: there is no blending.
271 * 273 *
272 * Currently if bitmap is backed by a texture this is a no-op. This may be 274 * Currently if bitmap is backed by a texture this is a no-op. This may be
273 * relaxed in the future. 275 * relaxed in the future.
274 * 276 *
275 * If the bitmap has config kARGB_8888_Config then the config8888 param 277 * 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 278 * will determines how the pixel valuess are intepreted. If the bitmap is
277 * not kARGB_8888_Config then this parameter is ignored. 279 * not kARGB_8888_Config then this parameter is ignored.
278 * 280 *
279 * Note: If you are recording drawing commands on this canvas to 281 * Note: If you are recording drawing commands on this canvas to
280 * SkPicture, writePixels() is ignored! 282 * SkPicture, writePixels() is ignored!
bsalomon 2014/03/06 17:48:12 DEPRECATED?
reed1 2014/03/06 20:21:29 Done.
281 */ 283 */
282 void writePixels(const SkBitmap& bitmap, 284 #ifdef SK_SUPPORT_LEGACY_WRITEPIXELSCONFIG
283 int x, int y, 285 void writePixels(const SkBitmap& bitmap, int x, int y, Config8888 config8888 );
284 Config8888 config8888 = kNative_Premul_Config8888); 286 #endif
287
288 /**
289 * This method affects the pixels in the base-layer, and operates in pixel coordinates,
290 * ignoring the matrix and clip.
291 *
292 * The specified ImageInfo and (x,y) offset specifies a rectangle: target.
293 *
294 * target.setXYWH(x, y, info.width(), info.height());
295 *
296 * Target is intersected with the bounds of the base-layer. If this interse ction is not empty,
297 * then we have two sets of pixels (of equal size), the "src" specified by info+pixels+rowBytes
298 * and the "dst" by the canvas' backend. Replace the dst pixels with the co rresponding src
299 * pixels, performing any colortype/alphatype transformations needed (in th e case where the
300 * src and dst have different colortypes or alphatypes).
301 *
302 * This call can fail, returning false, for several reasons:
303 * - If the src colortype/alphatype cannot be converted to the canvas' type s
304 * - If this canvas is not backed by pixels (e.g. picture or PDF)
305 */
306 bool writePixels(const SkImageInfo&, const void* pixels, size_t rowBytes, in t x, int y);
307
308 /**
309 * Helper for calling writePixels(info, ...)
310 */
311 bool writePixels(const SkBitmap& bitmap, int x, int y);
285 312
286 /////////////////////////////////////////////////////////////////////////// 313 ///////////////////////////////////////////////////////////////////////////
287 314
288 enum SaveFlags { 315 enum SaveFlags {
289 /** save the matrix state, restoring it on restore() */ 316 /** save the matrix state, restoring it on restore() */
290 kMatrix_SaveFlag = 0x01, 317 kMatrix_SaveFlag = 0x01,
291 /** save the clip state, restoring it on restore() */ 318 /** save the clip state, restoring it on restore() */
292 kClip_SaveFlag = 0x02, 319 kClip_SaveFlag = 0x02,
293 /** the layer needs to support per-pixel alpha */ 320 /** the layer needs to support per-pixel alpha */
294 kHasAlphaLayer_SaveFlag = 0x04, 321 kHasAlphaLayer_SaveFlag = 0x04,
(...skipping 1077 matching lines...) Expand 10 before | Expand all | Expand 10 after
1372 bool asROBitmap(SkBitmap*) const; 1399 bool asROBitmap(SkBitmap*) const;
1373 1400
1374 private: 1401 private:
1375 SkBitmap fBitmap; // used if peekPixels() fails 1402 SkBitmap fBitmap; // used if peekPixels() fails
1376 const void* fAddr; // NULL on failure 1403 const void* fAddr; // NULL on failure
1377 SkImageInfo fInfo; 1404 SkImageInfo fInfo;
1378 size_t fRowBytes; 1405 size_t fRowBytes;
1379 }; 1406 };
1380 1407
1381 #endif 1408 #endif
OLDNEW
« no previous file with comments | « include/core/SkBitmapDevice.h ('k') | include/core/SkDevice.h » ('j') | src/core/SkCanvas.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698