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

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

Issue 183533004: add SkCanvas::NewRaster factory -- a very common use-case in chrome (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
« no previous file with comments | « no previous file | src/core/SkCanvas.cpp » ('j') | src/core/SkCanvas.cpp » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 of the object being drawn is held by the Paint, which is provided as a 42 of the object being drawn is held by the Paint, which is provided as a
43 parameter to each of the draw() methods. The Paint holds attributes such as 43 parameter to each of the draw() methods. The Paint holds attributes such as
44 color, typeface, textSize, strokeWidth, shader (e.g. gradients, patterns), 44 color, typeface, textSize, strokeWidth, shader (e.g. gradients, patterns),
45 etc. 45 etc.
46 */ 46 */
47 class SK_API SkCanvas : public SkRefCnt { 47 class SK_API SkCanvas : public SkRefCnt {
48 public: 48 public:
49 SK_DECLARE_INST_COUNT(SkCanvas) 49 SK_DECLARE_INST_COUNT(SkCanvas)
50 50
51 /** 51 /**
52 * Attempt to allocate an offscreen raster canvas, matching the ImageInfo.
53 * On success, return a new canvas that will draw into that offscreen.
54 * The pixels will be uninitialized if the ImageInfo's alpha was kOpaque,
55 * else they will be initialized to 0. The caller can access the pixels
scroggo 2014/02/27 19:16:06 How about initializing them to SK_ColorTRANSPARENT
56 * after drawing into this canvas by calling readPixels() or peekPixels().
57 *
58 * If the offscreen cannot be allocated, or the requested ImageInfo is not
59 * supported, then NULL is returned.
60 */
61 static SkCanvas* NewRaster(const SkImageInfo&);
62
63 static SkCanvas* NewRasterN32(int width, int height) {
64 return NewRaster(SkImageInfo::MakeN32Premul(width, height));
65 }
66
67 /**
52 * Creates an empty canvas with no backing device/pixels, and zero 68 * Creates an empty canvas with no backing device/pixels, and zero
53 * dimensions. 69 * dimensions.
54 */ 70 */
55 SkCanvas(); 71 SkCanvas();
56 72
57 /** 73 /**
58 * Creates a canvas of the specified dimensions, but explicitly not backed 74 * Creates a canvas of the specified dimensions, but explicitly not backed
59 * by any device/pixels. Typically this use used by subclasses who handle 75 * by any device/pixels. Typically this use used by subclasses who handle
60 * the draw calls in some other way. 76 * the draw calls in some other way.
61 */ 77 */
(...skipping 1249 matching lines...) Expand 10 before | Expand all | Expand 10 after
1311 bool asROBitmap(SkBitmap*) const; 1327 bool asROBitmap(SkBitmap*) const;
1312 1328
1313 private: 1329 private:
1314 SkBitmap fBitmap; // used if peekPixels() fails 1330 SkBitmap fBitmap; // used if peekPixels() fails
1315 const void* fAddr; // NULL on failure 1331 const void* fAddr; // NULL on failure
1316 SkImageInfo fInfo; 1332 SkImageInfo fInfo;
1317 size_t fRowBytes; 1333 size_t fRowBytes;
1318 }; 1334 };
1319 1335
1320 #endif 1336 #endif
OLDNEW
« no previous file with comments | « no previous file | src/core/SkCanvas.cpp » ('j') | src/core/SkCanvas.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698