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 |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 /** | 286 /** |
287 * Helper for calling writePixels(info, ...) by passing its pixels and rowb
ytes. If the bitmap | 287 * Helper for calling writePixels(info, ...) by passing its pixels and rowb
ytes. If the bitmap |
288 * is just wrapping a texture, returns false and does nothing. | 288 * is just wrapping a texture, returns false and does nothing. |
289 */ | 289 */ |
290 bool writePixels(const SkBitmap& bitmap, int x, int y); | 290 bool writePixels(const SkBitmap& bitmap, int x, int y); |
291 | 291 |
292 /////////////////////////////////////////////////////////////////////////// | 292 /////////////////////////////////////////////////////////////////////////// |
293 | 293 |
294 enum SaveFlags { | 294 enum SaveFlags { |
295 /** save the matrix state, restoring it on restore() */ | 295 /** save the matrix state, restoring it on restore() */ |
296 kMatrix_SaveFlag = 0x01, | 296 // [deprecated] kMatrix_SaveFlag = 0x01, |
297 /** save the clip state, restoring it on restore() */ | 297 /** save the clip state, restoring it on restore() */ |
298 kClip_SaveFlag = 0x02, | 298 // [deprecated] kClip_SaveFlag = 0x02, |
299 /** the layer needs to support per-pixel alpha */ | 299 /** the layer needs to support per-pixel alpha */ |
300 kHasAlphaLayer_SaveFlag = 0x04, | 300 kHasAlphaLayer_SaveFlag = 0x04, |
301 /** the layer needs to support 8-bits per color component */ | 301 /** the layer needs to support 8-bits per color component */ |
302 kFullColorLayer_SaveFlag = 0x08, | 302 kFullColorLayer_SaveFlag = 0x08, |
303 /** | 303 /** |
304 * the layer should clip against the bounds argument | 304 * the layer should clip against the bounds argument |
305 * | 305 * |
306 * if SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG is undefined, this is treated a
s always on. | 306 * if SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG is undefined, this is treated a
s always on. |
307 */ | 307 */ |
308 kClipToLayer_SaveFlag = 0x10, | 308 kClipToLayer_SaveFlag = 0x10, |
309 | 309 |
310 // helper masks for common choices | 310 // helper masks for common choices |
311 kMatrixClip_SaveFlag = 0x03, | 311 // [deprecated] kMatrixClip_SaveFlag = 0x03, |
312 #ifdef SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG | 312 #ifdef SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG |
313 kARGB_NoClipLayer_SaveFlag = 0x0F, | 313 kARGB_NoClipLayer_SaveFlag = 0x0F, |
314 #endif | 314 #endif |
315 kARGB_ClipLayer_SaveFlag = 0x1F | 315 kARGB_ClipLayer_SaveFlag = 0x1F |
316 }; | 316 }; |
317 | 317 |
318 /** This call saves the current matrix, clip, and drawFilter, and pushes a | 318 /** This call saves the current matrix, clip, and drawFilter, and pushes a |
319 copy onto a private stack. Subsequent calls to translate, scale, | 319 copy onto a private stack. Subsequent calls to translate, scale, |
320 rotate, skew, concat or clipRect, clipPath, and setDrawFilter all | 320 rotate, skew, concat or clipRect, clipPath, and setDrawFilter all |
321 operate on this copy. | 321 operate on this copy. |
322 When the balancing call to restore() is made, the previous matrix, clip, | 322 When the balancing call to restore() is made, the previous matrix, clip, |
323 and drawFilter are restored. | 323 and drawFilter are restored. |
324 | 324 |
325 @return The value to pass to restoreToCount() to balance this save() | 325 @return The value to pass to restoreToCount() to balance this save() |
326 */ | 326 */ |
327 int save(); | 327 int save(); |
328 | 328 |
329 /** DEPRECATED - use save() instead. | |
330 | |
331 This behaves the same as save(), but it allows fine-grained control of | |
332 which state bits to be saved (and subsequently restored). | |
333 | |
334 @param flags The flags govern what portion of the Matrix/Clip/drawFilter | |
335 state the save (and matching restore) effect. For example, | |
336 if only kMatrix is specified, then only the matrix state | |
337 will be pushed and popped. Likewise for the clip if kClip | |
338 is specified. However, the drawFilter is always affected | |
339 by calls to save/restore. | |
340 @return The value to pass to restoreToCount() to balance this save() | |
341 */ | |
342 SK_ATTR_EXTERNALLY_DEPRECATED("SaveFlags use is deprecated") | |
343 int save(SaveFlags flags); | |
344 | |
345 /** This behaves the same as save(), but in addition it allocates an | 329 /** This behaves the same as save(), but in addition it allocates an |
346 offscreen bitmap. All drawing calls are directed there, and only when | 330 offscreen bitmap. All drawing calls are directed there, and only when |
347 the balancing call to restore() is made is that offscreen transfered to | 331 the balancing call to restore() is made is that offscreen transfered to |
348 the canvas (or the previous layer). | 332 the canvas (or the previous layer). |
349 @param bounds (may be null) This rect, if non-null, is used as a hint to | 333 @param bounds (may be null) This rect, if non-null, is used as a hint to |
350 limit the size of the offscreen, and thus drawing may be | 334 limit the size of the offscreen, and thus drawing may be |
351 clipped to it, though that clipping is not guaranteed to | 335 clipped to it, though that clipping is not guaranteed to |
352 happen. If exact clipping is desired, use clipRect(). | 336 happen. If exact clipping is desired, use clipRect(). |
353 @param paint (may be null) This is copied, and is applied to the | 337 @param paint (may be null) This is copied, and is applied to the |
354 offscreen when restore() is called | 338 offscreen when restore() is called |
(...skipping 829 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1184 virtual void* onAccessTopLayerPixels(SkImageInfo*, size_t* rowBytes); | 1168 virtual void* onAccessTopLayerPixels(SkImageInfo*, size_t* rowBytes); |
1185 | 1169 |
1186 // Subclass save/restore notifiers. | 1170 // Subclass save/restore notifiers. |
1187 // Overriders should call the corresponding INHERITED method up the inherita
nce chain. | 1171 // Overriders should call the corresponding INHERITED method up the inherita
nce chain. |
1188 // willSaveLayer()'s return value may suppress full layer allocation. | 1172 // willSaveLayer()'s return value may suppress full layer allocation. |
1189 enum SaveLayerStrategy { | 1173 enum SaveLayerStrategy { |
1190 kFullLayer_SaveLayerStrategy, | 1174 kFullLayer_SaveLayerStrategy, |
1191 kNoLayer_SaveLayerStrategy | 1175 kNoLayer_SaveLayerStrategy |
1192 }; | 1176 }; |
1193 | 1177 |
1194 // Transitional, pending external clients cleanup. | |
1195 virtual void willSave(SaveFlags) { this->willSave(); } | |
1196 | |
1197 virtual void willSave() {} | 1178 virtual void willSave() {} |
1198 virtual SaveLayerStrategy willSaveLayer(const SkRect*, const SkPaint*, SaveF
lags) { | 1179 virtual SaveLayerStrategy willSaveLayer(const SkRect*, const SkPaint*, SaveF
lags) { |
1199 return kFullLayer_SaveLayerStrategy; | 1180 return kFullLayer_SaveLayerStrategy; |
1200 } | 1181 } |
1201 virtual void willRestore() {} | 1182 virtual void willRestore() {} |
1202 virtual void didConcat(const SkMatrix&) {} | 1183 virtual void didConcat(const SkMatrix&) {} |
1203 virtual void didSetMatrix(const SkMatrix&) {} | 1184 virtual void didSetMatrix(const SkMatrix&) {} |
1204 | 1185 |
1205 virtual void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&); | 1186 virtual void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&); |
1206 | 1187 |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1317 const SkRect& dst, const SkPaint* paint, | 1298 const SkRect& dst, const SkPaint* paint, |
1318 DrawBitmapRectFlags flags); | 1299 DrawBitmapRectFlags flags); |
1319 void internalDrawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, | 1300 void internalDrawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, |
1320 const SkRect& dst, const SkPaint* paint); | 1301 const SkRect& dst, const SkPaint* paint); |
1321 void internalDrawPaint(const SkPaint& paint); | 1302 void internalDrawPaint(const SkPaint& paint); |
1322 int internalSaveLayer(const SkRect* bounds, const SkPaint* paint, | 1303 int internalSaveLayer(const SkRect* bounds, const SkPaint* paint, |
1323 SaveFlags, bool justForImageFilter, SaveLayerStrategy
strategy); | 1304 SaveFlags, bool justForImageFilter, SaveLayerStrategy
strategy); |
1324 void internalDrawDevice(SkBaseDevice*, int x, int y, const SkPaint*); | 1305 void internalDrawDevice(SkBaseDevice*, int x, int y, const SkPaint*); |
1325 | 1306 |
1326 // shared by save() and saveLayer() | 1307 // shared by save() and saveLayer() |
1327 int internalSave(SaveFlags flags); | 1308 int internalSave(); |
1328 void internalRestore(); | 1309 void internalRestore(); |
1329 static void DrawRect(const SkDraw& draw, const SkPaint& paint, | 1310 static void DrawRect(const SkDraw& draw, const SkPaint& paint, |
1330 const SkRect& r, SkScalar textSize); | 1311 const SkRect& r, SkScalar textSize); |
1331 static void DrawTextDecorations(const SkDraw& draw, const SkPaint& paint, | 1312 static void DrawTextDecorations(const SkDraw& draw, const SkPaint& paint, |
1332 const char text[], size_t byteLength, | 1313 const char text[], size_t byteLength, |
1333 SkScalar x, SkScalar y); | 1314 SkScalar x, SkScalar y); |
1334 | 1315 |
1335 /* These maintain a cache of the clip bounds in local coordinates, | 1316 /* These maintain a cache of the clip bounds in local coordinates, |
1336 (converted to 2s-compliment if floats are slow). | 1317 (converted to 2s-compliment if floats are slow). |
1337 */ | 1318 */ |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1488 | 1469 |
1489 class SkCanvasClipVisitor { | 1470 class SkCanvasClipVisitor { |
1490 public: | 1471 public: |
1491 virtual ~SkCanvasClipVisitor(); | 1472 virtual ~SkCanvasClipVisitor(); |
1492 virtual void clipRect(const SkRect&, SkRegion::Op, bool antialias) = 0; | 1473 virtual void clipRect(const SkRect&, SkRegion::Op, bool antialias) = 0; |
1493 virtual void clipRRect(const SkRRect&, SkRegion::Op, bool antialias) = 0; | 1474 virtual void clipRRect(const SkRRect&, SkRegion::Op, bool antialias) = 0; |
1494 virtual void clipPath(const SkPath&, SkRegion::Op, bool antialias) = 0; | 1475 virtual void clipPath(const SkPath&, SkRegion::Op, bool antialias) = 0; |
1495 }; | 1476 }; |
1496 | 1477 |
1497 #endif | 1478 #endif |
OLD | NEW |