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

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

Issue 196923004: add NewRasterDirect for creating a canvas drawing to pre-allocated pixels (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') | no next file with comments »
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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 * Note: it is valid to request a supported ImageInfo, but with zero 81 * Note: it is valid to request a supported ImageInfo, but with zero
82 * dimensions. 82 * dimensions.
83 */ 83 */
84 static SkCanvas* NewRaster(const SkImageInfo&); 84 static SkCanvas* NewRaster(const SkImageInfo&);
85 85
86 static SkCanvas* NewRasterN32(int width, int height) { 86 static SkCanvas* NewRasterN32(int width, int height) {
87 return NewRaster(SkImageInfo::MakeN32Premul(width, height)); 87 return NewRaster(SkImageInfo::MakeN32Premul(width, height));
88 } 88 }
89 89
90 /** 90 /**
91 * Attempt to allocate raster canvas, matching the ImageInfo, that will dra w directly into the
92 * specified pixels. To access the pixels after drawing to them, the caller should call
93 * flush() or call peekPixels(...).
94 *
95 * On failure, return NULL. This can fail for several reasons:
96 * 1. invalid ImageInfo (e.g. negative dimensions)
97 * 2. unsupported ImageInfo for a canvas
98 * - kUnknown_SkColorType, kIndex_8_SkColorType
99 * - kIgnore_SkAlphaType
100 * - this list is not complete, so others may also be unsupported
101 *
102 * Note: it is valid to request a supported ImageInfo, but with zero
103 * dimensions.
104 */
105 static SkCanvas* NewRasterDirect(const SkImageInfo&, void*, size_t);
106
107 static SkCanvas* NewRasterDirectN32(int width, int height, SkPMColor* pixels , size_t rowBytes) {
108 return NewRasterDirect(SkImageInfo::MakeN32Premul(width, height), pixels , rowBytes);
109 }
110
111 /**
91 * Creates an empty canvas with no backing device/pixels, and zero 112 * Creates an empty canvas with no backing device/pixels, and zero
92 * dimensions. 113 * dimensions.
93 */ 114 */
94 SkCanvas(); 115 SkCanvas();
95 116
96 /** 117 /**
97 * Creates a canvas of the specified dimensions, but explicitly not backed 118 * Creates a canvas of the specified dimensions, but explicitly not backed
98 * by any device/pixels. Typically this use used by subclasses who handle 119 * by any device/pixels. Typically this use used by subclasses who handle
99 * the draw calls in some other way. 120 * the draw calls in some other way.
100 */ 121 */
(...skipping 1364 matching lines...) Expand 10 before | Expand all | Expand 10 after
1465 bool asROBitmap(SkBitmap*) const; 1486 bool asROBitmap(SkBitmap*) const;
1466 1487
1467 private: 1488 private:
1468 SkBitmap fBitmap; // used if peekPixels() fails 1489 SkBitmap fBitmap; // used if peekPixels() fails
1469 const void* fAddr; // NULL on failure 1490 const void* fAddr; // NULL on failure
1470 SkImageInfo fInfo; 1491 SkImageInfo fInfo;
1471 size_t fRowBytes; 1492 size_t fRowBytes;
1472 }; 1493 };
1473 1494
1474 #endif 1495 #endif
OLDNEW
« no previous file with comments | « no previous file | src/core/SkCanvas.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698