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, |
f(malita)
2014/06/19 17:24:48
Should we leave this in for archeological reasons?
| |
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 838 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1193 virtual void* onAccessTopLayerPixels(SkImageInfo*, size_t* rowBytes); | 1177 virtual void* onAccessTopLayerPixels(SkImageInfo*, size_t* rowBytes); |
1194 | 1178 |
1195 // Subclass save/restore notifiers. | 1179 // Subclass save/restore notifiers. |
1196 // Overriders should call the corresponding INHERITED method up the inherita nce chain. | 1180 // Overriders should call the corresponding INHERITED method up the inherita nce chain. |
1197 // willSaveLayer()'s return value may suppress full layer allocation. | 1181 // willSaveLayer()'s return value may suppress full layer allocation. |
1198 enum SaveLayerStrategy { | 1182 enum SaveLayerStrategy { |
1199 kFullLayer_SaveLayerStrategy, | 1183 kFullLayer_SaveLayerStrategy, |
1200 kNoLayer_SaveLayerStrategy | 1184 kNoLayer_SaveLayerStrategy |
1201 }; | 1185 }; |
1202 | 1186 |
1203 // Transitional, pending external clients cleanup. | |
1204 virtual void willSave(SaveFlags) { this->willSave(); } | |
1205 | |
1206 virtual void willSave() {} | 1187 virtual void willSave() {} |
1207 virtual SaveLayerStrategy willSaveLayer(const SkRect*, const SkPaint*, SaveF lags) { | 1188 virtual SaveLayerStrategy willSaveLayer(const SkRect*, const SkPaint*, SaveF lags) { |
1208 return kFullLayer_SaveLayerStrategy; | 1189 return kFullLayer_SaveLayerStrategy; |
1209 } | 1190 } |
1210 virtual void willRestore() {} | 1191 virtual void willRestore() {} |
1211 virtual void didConcat(const SkMatrix&) {} | 1192 virtual void didConcat(const SkMatrix&) {} |
1212 virtual void didSetMatrix(const SkMatrix&) {} | 1193 virtual void didSetMatrix(const SkMatrix&) {} |
1213 | 1194 |
1214 virtual void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&); | 1195 virtual void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&); |
1215 | 1196 |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1326 const SkRect& dst, const SkPaint* paint, | 1307 const SkRect& dst, const SkPaint* paint, |
1327 DrawBitmapRectFlags flags); | 1308 DrawBitmapRectFlags flags); |
1328 void internalDrawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, | 1309 void internalDrawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, |
1329 const SkRect& dst, const SkPaint* paint); | 1310 const SkRect& dst, const SkPaint* paint); |
1330 void internalDrawPaint(const SkPaint& paint); | 1311 void internalDrawPaint(const SkPaint& paint); |
1331 int internalSaveLayer(const SkRect* bounds, const SkPaint* paint, | 1312 int internalSaveLayer(const SkRect* bounds, const SkPaint* paint, |
1332 SaveFlags, bool justForImageFilter, SaveLayerStrategy strategy); | 1313 SaveFlags, bool justForImageFilter, SaveLayerStrategy strategy); |
1333 void internalDrawDevice(SkBaseDevice*, int x, int y, const SkPaint*); | 1314 void internalDrawDevice(SkBaseDevice*, int x, int y, const SkPaint*); |
1334 | 1315 |
1335 // shared by save() and saveLayer() | 1316 // shared by save() and saveLayer() |
1336 int internalSave(SaveFlags flags); | 1317 int internalSave(); |
1337 void internalRestore(); | 1318 void internalRestore(); |
1338 static void DrawRect(const SkDraw& draw, const SkPaint& paint, | 1319 static void DrawRect(const SkDraw& draw, const SkPaint& paint, |
1339 const SkRect& r, SkScalar textSize); | 1320 const SkRect& r, SkScalar textSize); |
1340 static void DrawTextDecorations(const SkDraw& draw, const SkPaint& paint, | 1321 static void DrawTextDecorations(const SkDraw& draw, const SkPaint& paint, |
1341 const char text[], size_t byteLength, | 1322 const char text[], size_t byteLength, |
1342 SkScalar x, SkScalar y); | 1323 SkScalar x, SkScalar y); |
1343 | 1324 |
1344 /* These maintain a cache of the clip bounds in local coordinates, | 1325 /* These maintain a cache of the clip bounds in local coordinates, |
1345 (converted to 2s-compliment if floats are slow). | 1326 (converted to 2s-compliment if floats are slow). |
1346 */ | 1327 */ |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1497 | 1478 |
1498 class SkCanvasClipVisitor { | 1479 class SkCanvasClipVisitor { |
1499 public: | 1480 public: |
1500 virtual ~SkCanvasClipVisitor(); | 1481 virtual ~SkCanvasClipVisitor(); |
1501 virtual void clipRect(const SkRect&, SkRegion::Op, bool antialias) = 0; | 1482 virtual void clipRect(const SkRect&, SkRegion::Op, bool antialias) = 0; |
1502 virtual void clipRRect(const SkRRect&, SkRegion::Op, bool antialias) = 0; | 1483 virtual void clipRRect(const SkRRect&, SkRegion::Op, bool antialias) = 0; |
1503 virtual void clipPath(const SkPath&, SkRegion::Op, bool antialias) = 0; | 1484 virtual void clipPath(const SkPath&, SkRegion::Op, bool antialias) = 0; |
1504 }; | 1485 }; |
1505 | 1486 |
1506 #endif | 1487 #endif |
OLD | NEW |