Chromium Code Reviews| 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 |
| 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 "SkImage.h" | 14 #include "SkImage.h" |
| 15 #include "SkPaint.h" | 15 #include "SkPaint.h" |
| 16 #include "SkRefCnt.h" | 16 #include "SkRefCnt.h" |
| 17 #include "SkRegion.h" | 17 #include "SkRegion.h" |
| 18 #include "SkSurfaceProps.h" | 18 #include "SkSurfaceProps.h" |
| 19 #include "SkXfermode.h" | 19 #include "SkXfermode.h" |
| 20 #include "SkLights.h" | |
| 20 | 21 |
| 21 class GrContext; | 22 class GrContext; |
| 22 class GrDrawContext; | 23 class GrDrawContext; |
| 23 class SkBaseDevice; | 24 class SkBaseDevice; |
| 24 class SkCanvasClipVisitor; | 25 class SkCanvasClipVisitor; |
| 25 class SkClipStack; | 26 class SkClipStack; |
| 26 class SkData; | 27 class SkData; |
| 27 class SkDraw; | 28 class SkDraw; |
| 28 class SkDrawable; | 29 class SkDrawable; |
| 29 class SkDrawFilter; | 30 class SkDrawFilter; |
| (...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 449 | 450 |
| 450 /** Helper for setMatrix(identity). Sets the current matrix to identity. | 451 /** Helper for setMatrix(identity). Sets the current matrix to identity. |
| 451 */ | 452 */ |
| 452 void resetMatrix(); | 453 void resetMatrix(); |
| 453 | 454 |
| 454 /** Add the specified translation to the current draw depth of the canvas. | 455 /** Add the specified translation to the current draw depth of the canvas. |
| 455 @param z The distance to translate in Z. | 456 @param z The distance to translate in Z. |
| 456 Negative into screen, positive out of screen. | 457 Negative into screen, positive out of screen. |
| 457 Without translation, the draw depth defaults to 0. | 458 Without translation, the draw depth defaults to 0. |
| 458 */ | 459 */ |
| 459 void translateZ(SkScalar z); | 460 void translateZ(SkScalar z); |
|
jvanverth1
2016/07/18 15:02:26
Still need to put this behind SK_RELEASE.
vjiaoblack
2016/07/18 16:51:05
Done.
| |
| 460 | 461 |
| 462 #ifndef SK_RELEASE | |
| 463 /** Set the current set of lights in the canvas. | |
| 464 @param lights The lights that we want the canvas to have. | |
| 465 */ | |
| 466 void setLights(sk_sp<SkLights> lights); | |
| 467 | |
| 468 /** Returns the current set of lights the canvas uses | |
| 469 */ | |
| 470 sk_sp<SkLights> getLights() const; | |
| 471 #endif | |
| 472 | |
| 461 /** | 473 /** |
| 462 * Modify the current clip with the specified rectangle. | 474 * Modify the current clip with the specified rectangle. |
| 463 * @param rect The rect to combine with the current clip | 475 * @param rect The rect to combine with the current clip |
| 464 * @param op The region op to apply to the current clip | 476 * @param op The region op to apply to the current clip |
| 465 * @param doAntiAlias true if the clip should be antialiased | 477 * @param doAntiAlias true if the clip should be antialiased |
| 466 */ | 478 */ |
| 467 void clipRect(const SkRect& rect, | 479 void clipRect(const SkRect& rect, |
| 468 SkRegion::Op op = SkRegion::kIntersect_Op, | 480 SkRegion::Op op = SkRegion::kIntersect_Op, |
| 469 bool doAntiAlias = false); | 481 bool doAntiAlias = false); |
| 470 | 482 |
| (...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1042 * If paint is non-null, draw the picture into a temporary buffer, and then apply the paint's | 1054 * If paint is non-null, draw the picture into a temporary buffer, and then apply the paint's |
| 1043 * alpha/colorfilter/imagefilter/xfermode to that buffer as it is drawn to the canvas. | 1055 * alpha/colorfilter/imagefilter/xfermode to that buffer as it is drawn to the canvas. |
| 1044 * This is logically equivalent to | 1056 * This is logically equivalent to |
| 1045 * saveLayer(paint)/drawPicture/restore | 1057 * saveLayer(paint)/drawPicture/restore |
| 1046 */ | 1058 */ |
| 1047 void drawPicture(const SkPicture*, const SkMatrix* matrix, const SkPaint* pa int); | 1059 void drawPicture(const SkPicture*, const SkMatrix* matrix, const SkPaint* pa int); |
| 1048 void drawPicture(const sk_sp<SkPicture>& picture, const SkMatrix* matrix, co nst SkPaint* paint) { | 1060 void drawPicture(const sk_sp<SkPicture>& picture, const SkMatrix* matrix, co nst SkPaint* paint) { |
| 1049 this->drawPicture(picture.get(), matrix, paint); | 1061 this->drawPicture(picture.get(), matrix, paint); |
| 1050 } | 1062 } |
| 1051 | 1063 |
| 1064 #ifndef SK_RELEASE | |
| 1065 /** | |
| 1066 * Draw the picture into this canvas. | |
| 1067 * | |
| 1068 * We will use the canvas's lights along with the picture information (draw depths of | |
| 1069 * objects, etc) to first create a set of shadowmaps for the light-picture pairs, and | |
| 1070 * then use that set of shadowmaps to render the scene with shadows. | |
| 1071 * | |
| 1072 * If matrix is non-null, apply that matrix to the CTM when drawing this pi cture. This is | |
| 1073 * logically equivalent to | |
| 1074 * save/concat/drawPicture/restore | |
| 1075 * | |
| 1076 * If paint is non-null, draw the picture into a temporary buffer, and then apply the paint's | |
| 1077 * alpha/colorfilter/imagefilter/xfermode to that buffer as it is drawn to the canvas. | |
| 1078 * This is logically equivalent to | |
| 1079 * saveLayer(paint)/drawPicture/restore | |
| 1080 * | |
| 1081 */ | |
| 1082 void drawShadowedPicture(const SkPicture*, | |
| 1083 const SkMatrix* matrix, | |
| 1084 const SkPaint* paint); | |
| 1085 void drawShadowedPicture(const sk_sp<SkPicture>& picture, | |
| 1086 const SkMatrix* matrix, | |
| 1087 const SkPaint* paint) { | |
| 1088 this->drawShadowedPicture(picture.get(), matrix, paint); | |
| 1089 } | |
| 1090 #endif | |
| 1091 | |
| 1052 enum VertexMode { | 1092 enum VertexMode { |
| 1053 kTriangles_VertexMode, | 1093 kTriangles_VertexMode, |
| 1054 kTriangleStrip_VertexMode, | 1094 kTriangleStrip_VertexMode, |
| 1055 kTriangleFan_VertexMode | 1095 kTriangleFan_VertexMode |
| 1056 }; | 1096 }; |
| 1057 | 1097 |
| 1058 /** Draw the array of vertices, interpreted as triangles (based on mode). | 1098 /** Draw the array of vertices, interpreted as triangles (based on mode). |
| 1059 | 1099 |
| 1060 If both textures and vertex-colors are NULL, it strokes hairlines with | 1100 If both textures and vertex-colors are NULL, it strokes hairlines with |
| 1061 the paint's color. This behavior is a useful debugging mode to visualize | 1101 the paint's color. This behavior is a useful debugging mode to visualize |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1262 | 1302 |
| 1263 // expose minimum amount of information necessary for transitional refactori ng | 1303 // expose minimum amount of information necessary for transitional refactori ng |
| 1264 /** | 1304 /** |
| 1265 * Returns CTM and clip bounds, translated from canvas coordinates to top la yer coordinates. | 1305 * Returns CTM and clip bounds, translated from canvas coordinates to top la yer coordinates. |
| 1266 */ | 1306 */ |
| 1267 void temporary_internal_describeTopLayer(SkMatrix* matrix, SkIRect* clip_bou nds); | 1307 void temporary_internal_describeTopLayer(SkMatrix* matrix, SkIRect* clip_bou nds); |
| 1268 | 1308 |
| 1269 protected: | 1309 protected: |
| 1270 /** Returns the current (cumulative) draw depth of the canvas. | 1310 /** Returns the current (cumulative) draw depth of the canvas. |
| 1271 */ | 1311 */ |
| 1272 SkScalar getZ() const; | 1312 SkScalar getZ() const; |
|
jvanverth1
2016/07/18 15:02:26
This should be behind SK_RELEASE as well.
vjiaoblack
2016/07/18 16:51:05
Done.
| |
| 1273 | 1313 |
| 1314 #ifndef SK_RELEASE | |
| 1315 sk_sp<SkLights> fLights; | |
| 1316 #endif | |
| 1317 | |
| 1274 /** After calling saveLayer(), there can be any number of devices that make | 1318 /** After calling saveLayer(), there can be any number of devices that make |
| 1275 up the top-most drawing area. LayerIter can be used to iterate through | 1319 up the top-most drawing area. LayerIter can be used to iterate through |
| 1276 those devices. Note that the iterator is only valid until the next API | 1320 those devices. Note that the iterator is only valid until the next API |
| 1277 call made on the canvas. Ownership of all pointers in the iterator stays | 1321 call made on the canvas. Ownership of all pointers in the iterator stays |
| 1278 with the canvas, so none of them should be modified or deleted. | 1322 with the canvas, so none of them should be modified or deleted. |
| 1279 */ | 1323 */ |
| 1280 class LayerIter /*: SkNoncopyable*/ { | 1324 class LayerIter /*: SkNoncopyable*/ { |
| 1281 public: | 1325 public: |
| 1282 /** Initialize iterator with canvas, and set values for 1st device */ | 1326 /** Initialize iterator with canvas, and set values for 1st device */ |
| 1283 LayerIter(SkCanvas*, bool skipEmptyClips); | 1327 LayerIter(SkCanvas*, bool skipEmptyClips); |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1395 }; | 1439 }; |
| 1396 | 1440 |
| 1397 virtual void onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle e dgeStyle); | 1441 virtual void onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle e dgeStyle); |
| 1398 virtual void onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeStyl e edgeStyle); | 1442 virtual void onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeStyl e edgeStyle); |
| 1399 virtual void onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle e dgeStyle); | 1443 virtual void onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle e dgeStyle); |
| 1400 virtual void onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op); | 1444 virtual void onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op); |
| 1401 | 1445 |
| 1402 virtual void onDiscard(); | 1446 virtual void onDiscard(); |
| 1403 | 1447 |
| 1404 virtual void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint* ); | 1448 virtual void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint* ); |
| 1449 virtual void onDrawShadowedPicture(const SkPicture*, | |
| 1450 const SkMatrix*, | |
| 1451 const SkPaint*); | |
| 1405 | 1452 |
| 1406 // Returns the canvas to be used by DrawIter. Default implementation | 1453 // Returns the canvas to be used by DrawIter. Default implementation |
| 1407 // returns this. Subclasses that encapsulate an indirect canvas may | 1454 // returns this. Subclasses that encapsulate an indirect canvas may |
| 1408 // need to overload this method. The impl must keep track of this, as it | 1455 // need to overload this method. The impl must keep track of this, as it |
| 1409 // is not released or deleted by the caller. | 1456 // is not released or deleted by the caller. |
| 1410 virtual SkCanvas* canvasForDrawIter(); | 1457 virtual SkCanvas* canvasForDrawIter(); |
| 1411 | 1458 |
| 1412 // Clip rectangle bounds. Called internally by saveLayer. | 1459 // Clip rectangle bounds. Called internally by saveLayer. |
| 1413 // returns false if the entire rectangle is entirely clipped out | 1460 // returns false if the entire rectangle is entirely clipped out |
| 1414 // If non-NULL, The imageFilter parameter will be used to expand the clip | 1461 // If non-NULL, The imageFilter parameter will be used to expand the clip |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1617 | 1664 |
| 1618 class SkCanvasClipVisitor { | 1665 class SkCanvasClipVisitor { |
| 1619 public: | 1666 public: |
| 1620 virtual ~SkCanvasClipVisitor(); | 1667 virtual ~SkCanvasClipVisitor(); |
| 1621 virtual void clipRect(const SkRect&, SkRegion::Op, bool antialias) = 0; | 1668 virtual void clipRect(const SkRect&, SkRegion::Op, bool antialias) = 0; |
| 1622 virtual void clipRRect(const SkRRect&, SkRegion::Op, bool antialias) = 0; | 1669 virtual void clipRRect(const SkRRect&, SkRegion::Op, bool antialias) = 0; |
| 1623 virtual void clipPath(const SkPath&, SkRegion::Op, bool antialias) = 0; | 1670 virtual void clipPath(const SkPath&, SkRegion::Op, bool antialias) = 0; |
| 1624 }; | 1671 }; |
| 1625 | 1672 |
| 1626 #endif | 1673 #endif |
| OLD | NEW |