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 1012 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 | 1043 * 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. | 1044 * alpha/colorfilter/imagefilter/xfermode to that buffer as it is drawn to the canvas. |
| 1044 * This is logically equivalent to | 1045 * This is logically equivalent to |
| 1045 * saveLayer(paint)/drawPicture/restore | 1046 * saveLayer(paint)/drawPicture/restore |
| 1046 */ | 1047 */ |
| 1047 void drawPicture(const SkPicture*, const SkMatrix* matrix, const SkPaint* pa int); | 1048 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) { | 1049 void drawPicture(const sk_sp<SkPicture>& picture, const SkMatrix* matrix, co nst SkPaint* paint) { |
| 1049 this->drawPicture(picture.get(), matrix, paint); | 1050 this->drawPicture(picture.get(), matrix, paint); |
| 1050 } | 1051 } |
| 1051 | 1052 |
| 1053 /** | |
| 1054 * Draw the picture into this canvas. | |
| 1055 * | |
| 1056 * However, this time, we will use the passed-in lights to generate shadows ! | |
| 1057 */ | |
| 1058 void drawShadowedPicture(const SkPicture*, const sk_sp<SkLights>); | |
| 1059 void drawShadowedPicture(const sk_sp<SkPicture>& picture, const sk_sp<SkLigh ts> lights) { | |
|
reed1
2016/07/14 14:25:13
api nit: don't use const on 2nd parameter.
vjiaoblack
2016/07/14 14:42:04
Done.
| |
| 1060 this->drawShadowedPicture(picture.get(), lights); | |
| 1061 } | |
| 1062 | |
| 1052 enum VertexMode { | 1063 enum VertexMode { |
| 1053 kTriangles_VertexMode, | 1064 kTriangles_VertexMode, |
| 1054 kTriangleStrip_VertexMode, | 1065 kTriangleStrip_VertexMode, |
| 1055 kTriangleFan_VertexMode | 1066 kTriangleFan_VertexMode |
| 1056 }; | 1067 }; |
| 1057 | 1068 |
| 1058 /** Draw the array of vertices, interpreted as triangles (based on mode). | 1069 /** Draw the array of vertices, interpreted as triangles (based on mode). |
| 1059 | 1070 |
| 1060 If both textures and vertex-colors are NULL, it strokes hairlines with | 1071 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 | 1072 the paint's color. This behavior is a useful debugging mode to visualize |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1395 }; | 1406 }; |
| 1396 | 1407 |
| 1397 virtual void onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle e dgeStyle); | 1408 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); | 1409 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); | 1410 virtual void onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle e dgeStyle); |
| 1400 virtual void onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op); | 1411 virtual void onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op); |
| 1401 | 1412 |
| 1402 virtual void onDiscard(); | 1413 virtual void onDiscard(); |
| 1403 | 1414 |
| 1404 virtual void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint* ); | 1415 virtual void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint* ); |
| 1416 virtual void onDrawShadowedPicture(const SkPicture*, const sk_sp<SkLights>); | |
| 1405 | 1417 |
| 1406 // Returns the canvas to be used by DrawIter. Default implementation | 1418 // Returns the canvas to be used by DrawIter. Default implementation |
| 1407 // returns this. Subclasses that encapsulate an indirect canvas may | 1419 // returns this. Subclasses that encapsulate an indirect canvas may |
| 1408 // need to overload this method. The impl must keep track of this, as it | 1420 // need to overload this method. The impl must keep track of this, as it |
| 1409 // is not released or deleted by the caller. | 1421 // is not released or deleted by the caller. |
| 1410 virtual SkCanvas* canvasForDrawIter(); | 1422 virtual SkCanvas* canvasForDrawIter(); |
| 1411 | 1423 |
| 1412 // Clip rectangle bounds. Called internally by saveLayer. | 1424 // Clip rectangle bounds. Called internally by saveLayer. |
| 1413 // returns false if the entire rectangle is entirely clipped out | 1425 // returns false if the entire rectangle is entirely clipped out |
| 1414 // If non-NULL, The imageFilter parameter will be used to expand the clip | 1426 // If non-NULL, The imageFilter parameter will be used to expand the clip |
| 1415 // and offscreen bounds for any margin required by the filter DAG. | 1427 // and offscreen bounds for any margin required by the filter DAG. |
| 1416 bool clipRectBounds(const SkRect* bounds, SaveLayerFlags, SkIRect* intersect ion, | 1428 bool clipRectBounds(const SkRect* bounds, SaveLayerFlags, SkIRect* intersect ion, |
| 1417 const SkImageFilter* imageFilter = NULL); | 1429 const SkImageFilter* imageFilter = NULL); |
| 1418 | 1430 |
| 1419 private: | 1431 private: |
| 1432 uint32_t curDrawDepth = 0; | |
| 1433 | |
| 1420 static bool BoundsAffectsClip(SaveLayerFlags); | 1434 static bool BoundsAffectsClip(SaveLayerFlags); |
| 1421 static SaveLayerFlags LegacySaveFlagsToSaveLayerFlags(uint32_t legacySaveFla gs); | 1435 static SaveLayerFlags LegacySaveFlagsToSaveLayerFlags(uint32_t legacySaveFla gs); |
| 1422 | 1436 |
| 1423 enum ShaderOverrideOpacity { | 1437 enum ShaderOverrideOpacity { |
| 1424 kNone_ShaderOverrideOpacity, //!< there is no overriding shader ( bitmap or image) | 1438 kNone_ShaderOverrideOpacity, //!< there is no overriding shader ( bitmap or image) |
| 1425 kOpaque_ShaderOverrideOpacity, //!< the overriding shader is opaque | 1439 kOpaque_ShaderOverrideOpacity, //!< the overriding shader is opaque |
| 1426 kNotOpaque_ShaderOverrideOpacity, //!< the overriding shader may not b e opaque | 1440 kNotOpaque_ShaderOverrideOpacity, //!< the overriding shader may not b e opaque |
| 1427 }; | 1441 }; |
| 1428 | 1442 |
| 1429 // notify our surface (if we have one) that we are about to draw, so it | 1443 // notify our surface (if we have one) that we are about to draw, so it |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1617 | 1631 |
| 1618 class SkCanvasClipVisitor { | 1632 class SkCanvasClipVisitor { |
| 1619 public: | 1633 public: |
| 1620 virtual ~SkCanvasClipVisitor(); | 1634 virtual ~SkCanvasClipVisitor(); |
| 1621 virtual void clipRect(const SkRect&, SkRegion::Op, bool antialias) = 0; | 1635 virtual void clipRect(const SkRect&, SkRegion::Op, bool antialias) = 0; |
| 1622 virtual void clipRRect(const SkRRect&, SkRegion::Op, bool antialias) = 0; | 1636 virtual void clipRRect(const SkRRect&, SkRegion::Op, bool antialias) = 0; |
| 1623 virtual void clipPath(const SkPath&, SkRegion::Op, bool antialias) = 0; | 1637 virtual void clipPath(const SkPath&, SkRegion::Op, bool antialias) = 0; |
| 1624 }; | 1638 }; |
| 1625 | 1639 |
| 1626 #endif | 1640 #endif |
| OLD | NEW |