blob: d8ee0ed216728376289bdaf1e85d4680d3e67b0c [file] [log] [blame]
tomhudsonf7edcde2015-03-23 12:51:20 -07001/*
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
27class SkAndroidSDKCanvas : public SkCanvas {
28public:
29 SkAndroidSDKCanvas();
30 void reset(SkCanvas* newTarget);
31
32protected:
33
34 // FILTERING
35
mtklein36352bf2015-03-25 18:17:31 -070036 void onDrawPaint(const SkPaint& paint) override;
tomhudsonf7edcde2015-03-23 12:51:20 -070037 void onDrawPoints(PointMode pMode, size_t count, const SkPoint pts[],
mtklein36352bf2015-03-25 18:17:31 -070038 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;
tomhudsonf7edcde2015-03-23 12:51:20 -070043 void onDrawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top,
mtklein36352bf2015-03-25 18:17:31 -070044 const SkPaint* paint) override;
tomhudsonf7edcde2015-03-23 12:51:20 -070045 void onDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src, const SkRect& dst,
scroggoaa80e422015-07-31 14:29:26 -070046 const SkPaint* paint, SkCanvas::SrcRectConstraint) override;
tomhudsonf7edcde2015-03-23 12:51:20 -070047 void onDrawBitmapNine(const SkBitmap& bitmap, const SkIRect& center,
mtklein36352bf2015-03-25 18:17:31 -070048 const SkRect& dst, const SkPaint* paint) override;
tomhudsonf7edcde2015-03-23 12:51:20 -070049 void onDrawVertices(VertexMode vMode, int vertexCount, const SkPoint vertices[],
50 const SkPoint texs[], const SkColor colors[], SkXfermode* xMode,
51 const uint16_t indices[], int indexCount,
mtklein36352bf2015-03-25 18:17:31 -070052 const SkPaint& paint) override;
tomhudsonf7edcde2015-03-23 12:51:20 -070053
54 void onDrawDRRect(const SkRRect& outer, const SkRRect& inner,
mtklein36352bf2015-03-25 18:17:31 -070055 const SkPaint& paint) override;
tomhudsonf7edcde2015-03-23 12:51:20 -070056
57 void onDrawText(const void* text, size_t byteLength, SkScalar x, SkScalar y,
mtklein36352bf2015-03-25 18:17:31 -070058 const SkPaint& paint) override;
tomhudsonf7edcde2015-03-23 12:51:20 -070059 void onDrawPosText(const void* text, size_t byteLength, const SkPoint pos[],
mtklein36352bf2015-03-25 18:17:31 -070060 const SkPaint& paint) override;
tomhudsonf7edcde2015-03-23 12:51:20 -070061 void onDrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[],
mtklein36352bf2015-03-25 18:17:31 -070062 SkScalar constY, const SkPaint& paint) override;
tomhudsonf7edcde2015-03-23 12:51:20 -070063 void onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path,
mtklein36352bf2015-03-25 18:17:31 -070064 const SkMatrix* matrix, const SkPaint& paint) override;
tomhudsonf7edcde2015-03-23 12:51:20 -070065 void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
mtklein36352bf2015-03-25 18:17:31 -070066 const SkPaint& paint) override;
tomhudsonf7edcde2015-03-23 12:51:20 -070067
68 void onDrawPatch(const SkPoint cubics[12], const SkColor colors[4],
69 const SkPoint texCoords[4], SkXfermode* xmode,
mtklein36352bf2015-03-25 18:17:31 -070070 const SkPaint& paint) override;
tomhudsonf7edcde2015-03-23 12:51:20 -070071
mtklein36352bf2015-03-25 18:17:31 -070072 void onDrawImage(const SkImage*, SkScalar, SkScalar, const SkPaint*) override;
djsollend8ea6b42015-08-03 06:03:06 -070073 void onDrawImageRect(const SkImage*, const SkRect*, const SkRect&, const SkPaint*,
74 SrcRectConstraint) override;
tomhudsonf7edcde2015-03-23 12:51:20 -070075 void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*);
tomhudson45863342015-10-01 08:02:22 -070076 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;
tomhudsonf7edcde2015-03-23 12:51:20 -070081
82 // PASS THROUGH
83
reeda8db7282015-07-07 10:22:31 -070084 void onDrawDrawable(SkDrawable*, const SkMatrix*) override;
mtklein36352bf2015-03-25 18:17:31 -070085 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;
tomhudsonb97e9092015-05-26 14:12:24 -070091 bool onPeekPixels(SkPixmap*) override;
92 bool onAccessTopLayerPixels(SkPixmap*) override;
mtklein36352bf2015-03-25 18:17:31 -070093 void willSave() override;
reeda2b6fdd2015-12-18 07:38:26 -080094 SaveLayerStrategy getSaveLayerStrategy(const SaveLayerRec&) override;
mtklein36352bf2015-03-25 18:17:31 -070095 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;
tomhudsonf7edcde2015-03-23 12:51:20 -0700104
105protected:
106 SkCanvas* fProxyTarget;
107};
108
109#endif // SkAndroidSDKCanvas_DEFINED
110