blob: 4322fcf5edf58b8ee34749c75bfe9e3a2f96e0fc [file] [log] [blame]
Derek Sollenberger1db141f2014-12-16 08:37:20 -05001/*
2 * Copyright (C) 2015 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef SkiaCanvasProxy_DEFINED
18#define SkiaCanvasProxy_DEFINED
19
20#include <cutils/compiler.h>
21#include <SkCanvas.h>
22
23#include "Canvas.h"
24
25namespace android {
26namespace uirenderer {
27
28/**
29 * This class serves as a proxy between Skia's SkCanvas and Android Framework's
30 * Canvas. The class does not maintain any state and will pass through any request
31 * directly to the Canvas provided in the constructor.
32 *
33 * Upon construction it is expected that the provided Canvas has already been
34 * prepared for recording and will continue to be in the recording state while
35 * this proxy class is being used.
36 */
37class ANDROID_API SkiaCanvasProxy : public SkCanvas {
38public:
39 SkiaCanvasProxy(Canvas* canvas);
40 virtual ~SkiaCanvasProxy() {}
41
42protected:
43
44 virtual SkSurface* onNewSurface(const SkImageInfo&, const SkSurfaceProps&) override;
45
46 virtual void willSave() override;
47 virtual SaveLayerStrategy willSaveLayer(const SkRect*, const SkPaint*, SaveFlags) override;
48 virtual void willRestore() override;
49
50 virtual void didConcat(const SkMatrix&) override;
51 virtual void didSetMatrix(const SkMatrix&) override;
52
53 virtual void onDrawPaint(const SkPaint& paint) override;
54 virtual void onDrawPoints(PointMode, size_t count, const SkPoint pts[],
55 const SkPaint&) override;
56 virtual void onDrawOval(const SkRect&, const SkPaint&) override;
57 virtual void onDrawRect(const SkRect&, const SkPaint&) override;
58 virtual void onDrawRRect(const SkRRect&, const SkPaint&) override;
59 virtual void onDrawPath(const SkPath& path, const SkPaint&) override;
60 virtual void onDrawBitmap(const SkBitmap&, SkScalar left, SkScalar top,
61 const SkPaint*) override;
62 virtual void onDrawBitmapRect(const SkBitmap&, const SkRect* src, const SkRect& dst,
63 const SkPaint* paint, DrawBitmapRectFlags flags) override;
64 virtual void onDrawBitmapNine(const SkBitmap& bitmap, const SkIRect& center,
65 const SkRect& dst, const SkPaint*) override;
66 virtual void onDrawSprite(const SkBitmap&, int left, int top,
67 const SkPaint*) override;
68 virtual void onDrawVertices(VertexMode, int vertexCount, const SkPoint vertices[],
69 const SkPoint texs[], const SkColor colors[], SkXfermode*,
70 const uint16_t indices[], int indexCount,
71 const SkPaint&) override;
72
73 virtual void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) override;
74
75 virtual void onDrawText(const void* text, size_t byteLength, SkScalar x, SkScalar y,
76 const SkPaint&) override;
77 virtual void onDrawPosText(const void* text, size_t byteLength, const SkPoint pos[],
78 const SkPaint&) override;
79 virtual void onDrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[],
80 SkScalar constY, const SkPaint&) override;
81 virtual void onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path,
82 const SkMatrix* matrix, const SkPaint&) override;
83 virtual void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
84 const SkPaint& paint) override;
85
86 virtual void onDrawPatch(const SkPoint cubics[12], const SkColor colors[4],
87 const SkPoint texCoords[4], SkXfermode* xmode,
88 const SkPaint& paint) override;
89
90 virtual void onClipRect(const SkRect&, SkRegion::Op, ClipEdgeStyle) override;
91 virtual void onClipRRect(const SkRRect&, SkRegion::Op, ClipEdgeStyle) override;
92 virtual void onClipPath(const SkPath&, SkRegion::Op, ClipEdgeStyle) override;
93 virtual void onClipRegion(const SkRegion&, SkRegion::Op) override;
94
95private:
96 Canvas* mCanvas;
97
98 typedef SkCanvas INHERITED;
99};
100
101}; // namespace uirenderer
102}; // namespace android
103
104#endif // SkiaCanvasProxy_DEFINED