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

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

Issue 211043002: remove all references to legacy Config8888 (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 | « include/core/SkBitmapDevice.h ('k') | include/core/SkDevice.h » ('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
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
23 #ifdef SK_SUPPORT_LEGACY_READPIXELSCONFIG
24 #ifndef SK_SUPPORT_LEGACY_CONFIG8888
25 #define SK_SUPPORT_LEGACY_CONFIG8888
26 #endif
27 #endif
28
29 // if not defined, we always assume ClipToLayer for saveLayer() 21 // if not defined, we always assume ClipToLayer for saveLayer()
30 //#define SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG 22 //#define SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG
31 23
32 24
33 //#define SK_SUPPORT_LEGACY_GETCLIPTYPE 25 //#define SK_SUPPORT_LEGACY_GETCLIPTYPE
34 //#define SK_SUPPORT_LEGACY_GETTOTALCLIP 26 //#define SK_SUPPORT_LEGACY_GETTOTALCLIP
35 //#define SK_SUPPORT_LEGACY_GETTOPDEVICE 27 //#define SK_SUPPORT_LEGACY_GETTOPDEVICE
36 28
37 class SkBounder; 29 class SkBounder;
38 class SkBaseDevice; 30 class SkBaseDevice;
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 * return the ImageInfo and rowBytes. The returned address is only valid 222 * return the ImageInfo and rowBytes. The returned address is only valid
231 * while the canvas object is in scope and unchanged. Any API calls made on 223 * while the canvas object is in scope and unchanged. Any API calls made on
232 * canvas (or its parent surface if any) will invalidate the 224 * canvas (or its parent surface if any) will invalidate the
233 * returned address (and associated information). 225 * returned address (and associated information).
234 * 226 *
235 * On failure, returns NULL and the info and rowBytes parameters are 227 * On failure, returns NULL and the info and rowBytes parameters are
236 * ignored. 228 * ignored.
237 */ 229 */
238 const void* peekPixels(SkImageInfo* info, size_t* rowBytes); 230 const void* peekPixels(SkImageInfo* info, size_t* rowBytes);
239 231
240 #ifdef SK_SUPPORT_LEGACY_CONFIG8888
241 /**
242 * This enum can be used with read/writePixels to perform a pixel ops to or
243 * from an 8888 config other than Skia's native config (SkPMColor). There
244 * are three byte orders supported: native, BGRA, and RGBA. Each has a
245 * premultiplied and unpremultiplied variant.
246 *
247 * Components of a 8888 pixel can be packed/unpacked from a 32bit word using
248 * either byte offsets or shift values. Byte offsets are endian-invariant
249 * while shifts are not. BGRA and RGBA configs are defined by byte
250 * orderings. The native config is defined by shift values (SK_A32_SHIFT,
251 * ..., SK_B32_SHIFT).
252 */
253 enum Config8888 {
254 /**
255 * Skia's native order specified by:
256 * SK_A32_SHIFT, SK_R32_SHIFT, SK_G32_SHIFT, and SK_B32_SHIFT
257 *
258 * kNative_Premul_Config8888 is equivalent to SkPMColor
259 * kNative_Unpremul_Config8888 has the same component order as SkPMColor
260 * but is not premultiplied.
261 */
262 kNative_Premul_Config8888,
263 kNative_Unpremul_Config8888,
264 /**
265 * low byte to high byte: B, G, R, A.
266 */
267 kBGRA_Premul_Config8888,
268 kBGRA_Unpremul_Config8888,
269 /**
270 * low byte to high byte: R, G, B, A.
271 */
272 kRGBA_Premul_Config8888,
273 kRGBA_Unpremul_Config8888
274 };
275 #endif
276
277 #ifdef SK_SUPPORT_LEGACY_READPIXELSCONFIG
278 /**
279 * On success (returns true), copy the canvas pixels into the bitmap.
280 * On failure, the bitmap parameter is left unchanged and false is
281 * returned.
282 *
283 * The canvas' pixels are converted to the bitmap's config. The only
284 * supported config is kARGB_8888_Config, though this is likely to be
285 * relaxed in the future. The meaning of config kARGB_8888_Config is
286 * modified by the enum param config8888. The default value interprets
287 * kARGB_8888_Config as SkPMColor
288 *
289 * If the bitmap has pixels already allocated, the canvas pixels will be
290 * written there. If not, bitmap->allocPixels() will be called
291 * automatically. If the bitmap is backed by a texture readPixels will
292 * fail.
293 *
294 * The actual pixels written is the intersection of the canvas' bounds, and
295 * the rectangle formed by the bitmap's width,height and the specified x,y.
296 * If bitmap pixels extend outside of that intersection, they will not be
297 * modified.
298 *
299 * Other failure conditions:
300 * * If the canvas is backed by a non-raster device (e.g. PDF) then
301 * readPixels will fail.
302 * * If bitmap is texture-backed then readPixels will fail. (This may be
303 * relaxed in the future.)
304 *
305 * Example that reads the entire canvas into a bitmap using the native
306 * SkPMColor:
307 * SkISize size = canvas->getDeviceSize();
308 * bitmap->setConfig(SkBitmap::kARGB_8888_Config, size.fWidth,
309 * size.fHeight);
310 * if (canvas->readPixels(bitmap, 0, 0)) {
311 * // use the pixels
312 * }
313 */
314 bool readPixels(SkBitmap* bitmap, int x, int y, Config8888 config8888);
315 #endif
316
317 /** 232 /**
318 * Copy the pixels from the base-layer into the specified buffer (pixels + rowBytes), 233 * Copy the pixels from the base-layer into the specified buffer (pixels + rowBytes),
319 * converting them into the requested format (SkImageInfo). The base-layer pixels are read 234 * converting them into the requested format (SkImageInfo). The base-layer pixels are read
320 * starting at the specified (x,y) location in the coordinate system of the base-layer. 235 * starting at the specified (x,y) location in the coordinate system of the base-layer.
321 * 236 *
322 * The specified ImageInfo and (x,y) offset specifies a source rectangle 237 * The specified ImageInfo and (x,y) offset specifies a source rectangle
323 * 238 *
324 * srcR(x, y, info.width(), info.height()); 239 * srcR(x, y, info.width(), info.height());
325 * 240 *
326 * SrcR is intersected with the bounds of the base-layer. If this intersect ion is not empty, 241 * SrcR is intersected with the bounds of the base-layer. If this intersect ion is not empty,
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after
839 virtual void drawPath(const SkPath& path, const SkPaint& paint); 754 virtual void drawPath(const SkPath& path, const SkPaint& paint);
840 755
841 /** Draw the specified bitmap, with its top/left corner at (x,y), using the 756 /** Draw the specified bitmap, with its top/left corner at (x,y), using the
842 specified paint, transformed by the current matrix. Note: if the paint 757 specified paint, transformed by the current matrix. Note: if the paint
843 contains a maskfilter that generates a mask which extends beyond the 758 contains a maskfilter that generates a mask which extends beyond the
844 bitmap's original width/height, then the bitmap will be drawn as if it 759 bitmap's original width/height, then the bitmap will be drawn as if it
845 were in a Shader with CLAMP mode. Thus the color outside of the original 760 were in a Shader with CLAMP mode. Thus the color outside of the original
846 width/height will be the edge color replicated. 761 width/height will be the edge color replicated.
847 762
848 If a shader is present on the paint it will be ignored, except in the 763 If a shader is present on the paint it will be ignored, except in the
849 case where the bitmap is kA8_Config. In that case, the color is 764 case where the bitmap is kAlpha_8_SkColorType. In that case, the color i s
850 generated by the shader. 765 generated by the shader.
851 766
852 @param bitmap The bitmap to be drawn 767 @param bitmap The bitmap to be drawn
853 @param left The position of the left side of the bitmap being drawn 768 @param left The position of the left side of the bitmap being drawn
854 @param top The position of the top side of the bitmap being drawn 769 @param top The position of the top side of the bitmap being drawn
855 @param paint The paint used to draw the bitmap, or NULL 770 @param paint The paint used to draw the bitmap, or NULL
856 */ 771 */
857 virtual void drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top, 772 virtual void drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top,
858 const SkPaint* paint = NULL); 773 const SkPaint* paint = NULL);
859 774
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after
1502 bool asROBitmap(SkBitmap*) const; 1417 bool asROBitmap(SkBitmap*) const;
1503 1418
1504 private: 1419 private:
1505 SkBitmap fBitmap; // used if peekPixels() fails 1420 SkBitmap fBitmap; // used if peekPixels() fails
1506 const void* fAddr; // NULL on failure 1421 const void* fAddr; // NULL on failure
1507 SkImageInfo fInfo; 1422 SkImageInfo fInfo;
1508 size_t fRowBytes; 1423 size_t fRowBytes;
1509 }; 1424 };
1510 1425
1511 #endif 1426 #endif
OLDNEW
« no previous file with comments | « include/core/SkBitmapDevice.h ('k') | include/core/SkDevice.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698