OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright 2015 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 SkAndroidSDKCanvas_DEFINED | |
9 #define SkAndroidSDKCanvas_DEFINED | |
10 | |
11 #include "SkBitmap.h" | |
12 #include "SkCanvas.h" | |
13 #include "SkPaint.h" | |
14 #include "SkPath.h" | |
15 #include "SkRect.h" | |
16 | |
17 /** SkDrawFilter is likely to be deprecated; this is a proxy | |
18 canvas that does the same thing: alter SkPaint fields. | |
19 | |
20 onDraw*() functions may have their SkPaint modified, and are then | |
21 passed on to the same function on proxyTarget. THIS BREAKS CONSTNESS! | |
22 | |
23 This still suffers one of the same architectural flaws as SkDrawFilter: | |
24 TextBlob paints are incomplete when filter is called. | |
25 */ | |
26 | |
27 class SkAndroidSDKCanvas : public SkCanvas { | |
28 public: | |
29 SkAndroidSDKCanvas(); | |
30 void reset(SkCanvas* newTarget); | |
31 | |
32 protected: | |
33 | |
34 // FILTERING | |
35 | |
36 void onDrawPaint(const SkPaint& paint) override; | |
37 void onDrawPoints(PointMode pMode, size_t count, const SkPoint pts[], | |
38 const SkPaint& paint) override; | |
39 void onDrawOval(const SkRect& r, const SkPaint& paint) override; | |
40 void onDrawRect(const SkRect& r, const SkPaint& paint) override; | |
41 void onDrawRRect(const SkRRect& r, const SkPaint& paint) override; | |
42 void onDrawPath(const SkPath& path, const SkPaint& paint) override; | |
43 void onDrawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top, | |
44 const SkPaint* paint) override; | |
45 void onDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src, const SkRec
t& dst, | |
46 const SkPaint* paint, SkCanvas::SrcRectConstraint) ove
rride; | |
47 void onDrawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, | |
48 const SkRect& dst, const SkPaint* paint) override; | |
49 void onDrawVertices(VertexMode vMode, int vertexCount, const SkPoint vertice
s[], | |
50 const SkPoint texs[], const SkColor colors[], SkXfermode
* xMode, | |
51 const uint16_t indices[], int indexCount, | |
52 const SkPaint& paint) override; | |
53 | |
54 void onDrawDRRect(const SkRRect& outer, const SkRRect& inner, | |
55 const SkPaint& paint) override; | |
56 | |
57 void onDrawText(const void* text, size_t byteLength, SkScalar x, SkScalar y, | |
58 const SkPaint& paint) override; | |
59 void onDrawPosText(const void* text, size_t byteLength, const SkPoint pos[], | |
60 const SkPaint& paint) override; | |
61 void onDrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos
[], | |
62 SkScalar constY, const SkPaint& paint) override; | |
63 void onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& pat
h, | |
64 const SkMatrix* matrix, const SkPaint& paint) override
; | |
65 void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y, | |
66 const SkPaint& paint) override; | |
67 | |
68 void onDrawPatch(const SkPoint cubics[12], const SkColor colors[4], | |
69 const SkPoint texCoords[4], SkXfermode* xmode, | |
70 const SkPaint& paint) override; | |
71 | |
72 void onDrawImage(const SkImage*, SkScalar, SkScalar, const SkPaint*) overrid
e; | |
73 void onDrawImageRect(const SkImage*, const SkRect*, const SkRect&, const SkP
aint*, | |
74 SrcRectConstraint) override; | |
75 void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*); | |
76 void onDrawAtlas(const SkImage*, const SkRSXform[], const SkRect[], | |
77 const SkColor[], int count, SkXfermode::Mode, | |
78 const SkRect* cull, const SkPaint*) override; | |
79 void onDrawImageNine(const SkImage*, const SkIRect& center, | |
80 const SkRect& dst, const SkPaint*) override; | |
81 | |
82 // PASS THROUGH | |
83 | |
84 void onDrawDrawable(SkDrawable*, const SkMatrix*) override; | |
85 SkISize getBaseLayerSize() const override; | |
86 bool getClipBounds(SkRect*) const override; | |
87 bool getClipDeviceBounds(SkIRect*) const override; | |
88 bool isClipEmpty() const override; | |
89 bool isClipRect() const override; | |
90 SkSurface* onNewSurface(const SkImageInfo&, const SkSurfaceProps&) override; | |
91 bool onPeekPixels(SkPixmap*) override; | |
92 bool onAccessTopLayerPixels(SkPixmap*) override; | |
93 void willSave() override; | |
94 SaveLayerStrategy getSaveLayerStrategy(const SaveLayerRec&) override; | |
95 void willRestore() override; | |
96 void didRestore() override; | |
97 void didConcat(const SkMatrix&) override; | |
98 void didSetMatrix(const SkMatrix&) override; | |
99 void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) override; | |
100 void onClipRRect(const SkRRect&, SkRegion::Op, ClipEdgeStyle) override; | |
101 void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) override; | |
102 void onClipRegion(const SkRegion&, SkRegion::Op) override; | |
103 void onDiscard() override; | |
104 | |
105 protected: | |
106 SkCanvas* fProxyTarget; | |
107 }; | |
108 | |
109 #endif // SkAndroidSDKCanvas_DEFINED | |
110 | |
OLD | NEW |