OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * Copyright 2016 Google Inc. | |
3 * | |
4 * Use of this source code is governed by a BSD-style license that can be | |
5 * found in the LICENSE file. | |
6 */ | |
7 | |
8 #ifndef SkShadowPaintFilterCanvas_DEFINED | |
9 #define SkShadowPaintFilterCanvas_DEFINED | |
10 | |
11 #include "SkPaintFilterCanvas.h" | |
12 | |
13 #ifdef SK_EXPERIMENTAL_SHADOWING | |
14 | |
15 /** \class SkShadowPaintFilterCanvas | |
16 * | |
17 * A utility proxy class for implementing shadow maps. | |
18 * | |
19 * We override the onFilter method to draw depths into the canvas | |
20 * depending on the current draw depth of the canvas, throwing out | |
21 * the actual draw color. | |
22 * | |
23 * Note that we can only do this for one light at a time! | |
24 * It is up to the user to set the 0th light in fLights to | |
25 * the light the want to render the depth map with. | |
26 */ | |
27 class SkShadowPaintFilterCanvas : public SkPaintFilterCanvas { | |
28 public: | |
29 | |
30 SkShadowPaintFilterCanvas(SkCanvas *canvas); | |
31 | |
32 // TODO use a shader instead | |
33 bool onFilter(SkTCopyOnFirstWrite<SkPaint>* paint, Type type) const override ; | |
34 | |
robertphillips
2016/08/04 18:16:06
This needs class-scope static syntax i.e., Compute
vjiaoblack
2016/08/04 18:55:49
Done.
| |
35 static SkISize computeDepthMapSize(const SkLights::Light& light, int maxDept h, | |
36 int width, int height); | |
37 | |
38 protected: | |
39 void onDrawPicture(const SkPicture *picture, const SkMatrix *matrix, | |
40 const SkPaint *paint) override; | |
41 | |
42 void updateMatrix(); | |
43 | |
44 void onDrawPaint(const SkPaint &paint) override; | |
45 | |
46 void onDrawPoints(PointMode mode, size_t count, const SkPoint pts[], | |
47 const SkPaint &paint) override; | |
48 | |
49 void onDrawRect(const SkRect &rect, const SkPaint &paint) override; | |
50 | |
51 void onDrawRRect(const SkRRect &rrect, const SkPaint &paint) override; | |
52 | |
53 void onDrawDRRect(const SkRRect &outer, const SkRRect &inner, | |
54 const SkPaint &paint) override; | |
55 | |
56 void onDrawOval(const SkRect &rect, const SkPaint &paint) override; | |
57 | |
58 void onDrawPath(const SkPath &path, const SkPaint &paint) override; | |
59 | |
60 void onDrawBitmap(const SkBitmap &bm, SkScalar left, SkScalar top, | |
61 const SkPaint *paint) override; | |
62 | |
63 void onDrawBitmapRect(const SkBitmap &bm, const SkRect *src, const SkRect &d st, | |
64 const SkPaint *paint, SrcRectConstraint constraint) ov erride; | |
65 | |
66 void onDrawBitmapNine(const SkBitmap &bm, const SkIRect ¢er, | |
67 const SkRect &dst, const SkPaint *paint) override; | |
68 | |
69 void onDrawImage(const SkImage *image, SkScalar left, SkScalar top, | |
70 const SkPaint *paint) override; | |
71 | |
72 void onDrawImageRect(const SkImage *image, const SkRect *src, | |
73 const SkRect &dst, const SkPaint *paint, | |
74 SrcRectConstraint constraint) override; | |
75 | |
76 void onDrawImageNine(const SkImage *image, const SkIRect ¢er, | |
77 const SkRect &dst, const SkPaint *paint) override; | |
78 | |
79 void onDrawVertices(VertexMode vmode, int vertexCount, | |
80 const SkPoint vertices[], const SkPoint texs[], | |
81 const SkColor colors[], SkXfermode *xmode, | |
82 const uint16_t indices[], int indexCount, | |
83 const SkPaint &paint) override; | |
84 | |
85 void onDrawPatch(const SkPoint cubics[], const SkColor colors[], | |
86 const SkPoint texCoords[], SkXfermode *xmode, | |
87 const SkPaint &paint) override; | |
88 | |
89 void onDrawText(const void *text, size_t byteLength, SkScalar x, SkScalar y, | |
90 const SkPaint &paint) override; | |
91 | |
92 void onDrawPosText(const void *text, size_t byteLength, const SkPoint pos[], | |
93 const SkPaint &paint) override; | |
94 | |
95 void onDrawPosTextH(const void *text, size_t byteLength, const SkScalar xpos [], | |
96 SkScalar constY, const SkPaint &paint) override; | |
97 | |
98 void onDrawTextOnPath(const void *text, size_t byteLength, const SkPath &pat h, | |
99 const SkMatrix *matrix, const SkPaint &paint) override ; | |
100 | |
101 void onDrawTextRSXform(const void *text, size_t byteLength, | |
102 const SkRSXform xform[], const SkRect *cull, | |
103 const SkPaint &paint) override; | |
104 | |
105 void onDrawTextBlob(const SkTextBlob *blob, SkScalar x, | |
106 SkScalar y, const SkPaint &paint) override; | |
107 private: | |
108 typedef SkPaintFilterCanvas INHERITED; | |
109 }; | |
110 | |
111 | |
112 #endif | |
113 #endif | |
OLD | NEW |