blob: 773fd201ab20496422eda82d55d9daa0556c3f6e [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001
2/*
3 * Copyright 2011 Google Inc.
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
reed@android.com8a1c16f2008-12-17 15:59:43 +00008#include "SkProxyCanvas.h"
9
10SkProxyCanvas::SkProxyCanvas(SkCanvas* proxy) : fProxy(proxy) {
reed@google.com82065d62011-02-07 15:30:46 +000011 SkSafeRef(fProxy);
reed@android.com8a1c16f2008-12-17 15:59:43 +000012}
13
14SkProxyCanvas::~SkProxyCanvas() {
reed@google.com82065d62011-02-07 15:30:46 +000015 SkSafeUnref(fProxy);
reed@android.com8a1c16f2008-12-17 15:59:43 +000016}
reed@google.com82065d62011-02-07 15:30:46 +000017
reed@android.com8a1c16f2008-12-17 15:59:43 +000018void SkProxyCanvas::setProxy(SkCanvas* proxy) {
19 SkRefCnt_SafeAssign(fProxy, proxy);
20}
21
22///////////////////////////////// Overrides ///////////
23
Florin Malita5f6102d2014-06-30 10:13:28 -040024void SkProxyCanvas::willSave() {
25 fProxy->save();
26 this->INHERITED::willSave();
reed@android.com8a1c16f2008-12-17 15:59:43 +000027}
28
commit-bot@chromium.orge54a23f2014-03-12 20:21:48 +000029SkCanvas::SaveLayerStrategy SkProxyCanvas::willSaveLayer(const SkRect* bounds, const SkPaint* paint,
30 SaveFlags flags) {
31 fProxy->saveLayer(bounds, paint, flags);
32 this->INHERITED::willSaveLayer(bounds, paint, flags);
33 // No need for a layer.
34 return kNoLayer_SaveLayerStrategy;
reed@android.com8a1c16f2008-12-17 15:59:43 +000035}
36
commit-bot@chromium.orge54a23f2014-03-12 20:21:48 +000037void SkProxyCanvas::willRestore() {
reed@android.com8a1c16f2008-12-17 15:59:43 +000038 fProxy->restore();
commit-bot@chromium.orge54a23f2014-03-12 20:21:48 +000039 this->INHERITED::willRestore();
reed@android.com8a1c16f2008-12-17 15:59:43 +000040}
41
commit-bot@chromium.org44c48d02014-03-13 20:03:58 +000042void SkProxyCanvas::didConcat(const SkMatrix& matrix) {
43 fProxy->concat(matrix);
44 this->INHERITED::didConcat(matrix);
reed@android.com8a1c16f2008-12-17 15:59:43 +000045}
46
commit-bot@chromium.org44c48d02014-03-13 20:03:58 +000047void SkProxyCanvas::didSetMatrix(const SkMatrix& matrix) {
reed@android.com8a1c16f2008-12-17 15:59:43 +000048 fProxy->setMatrix(matrix);
commit-bot@chromium.org44c48d02014-03-13 20:03:58 +000049 this->INHERITED::didSetMatrix(matrix);
reed@android.com8a1c16f2008-12-17 15:59:43 +000050}
51
robertphillips@google.com8f90a892014-02-28 18:19:39 +000052void SkProxyCanvas::onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle edgeStyle) {
53 fProxy->clipRect(rect, op, kSoft_ClipEdgeStyle == edgeStyle);
reed@android.com8a1c16f2008-12-17 15:59:43 +000054}
55
robertphillips@google.com8f90a892014-02-28 18:19:39 +000056void SkProxyCanvas::onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeStyle edgeStyle) {
57 fProxy->clipRRect(rrect, op, kSoft_ClipEdgeStyle == edgeStyle);
reed@google.com4ed0fb72012-12-12 20:48:18 +000058}
59
robertphillips@google.com8f90a892014-02-28 18:19:39 +000060void SkProxyCanvas::onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle edgeStyle) {
61 fProxy->clipPath(path, op, kSoft_ClipEdgeStyle == edgeStyle);
reed@android.com8a1c16f2008-12-17 15:59:43 +000062}
63
robertphillips@google.com8f90a892014-02-28 18:19:39 +000064void SkProxyCanvas::onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op) {
65 fProxy->clipRegion(deviceRgn, op);
reed@android.com8a1c16f2008-12-17 15:59:43 +000066}
67
68void SkProxyCanvas::drawPaint(const SkPaint& paint) {
69 fProxy->drawPaint(paint);
70}
71
72void SkProxyCanvas::drawPoints(PointMode mode, size_t count,
73 const SkPoint pts[], const SkPaint& paint) {
74 fProxy->drawPoints(mode, count, pts, paint);
75}
76
reed@google.com4ed0fb72012-12-12 20:48:18 +000077void SkProxyCanvas::drawOval(const SkRect& rect, const SkPaint& paint) {
78 fProxy->drawOval(rect, paint);
79}
80
bsalomon@google.com7ce564c2013-10-22 16:54:15 +000081void SkProxyCanvas::drawRect(const SkRect& rect, const SkPaint& paint) {
reed@android.com8a1c16f2008-12-17 15:59:43 +000082 fProxy->drawRect(rect, paint);
83}
84
reed@google.com4ed0fb72012-12-12 20:48:18 +000085void SkProxyCanvas::drawRRect(const SkRRect& rrect, const SkPaint& paint) {
86 fProxy->drawRRect(rrect, paint);
87}
88
commit-bot@chromium.orgab582732014-02-21 12:20:45 +000089void SkProxyCanvas::onDrawDRRect(const SkRRect& outer, const SkRRect& inner,
90 const SkPaint& paint) {
91 fProxy->drawDRRect(outer, inner, paint);
92}
93
bsalomon@google.com7ce564c2013-10-22 16:54:15 +000094void SkProxyCanvas::drawPath(const SkPath& path, const SkPaint& paint) {
reed@android.com8a1c16f2008-12-17 15:59:43 +000095 fProxy->drawPath(path, paint);
96}
97
98void SkProxyCanvas::drawBitmap(const SkBitmap& bitmap, SkScalar x, SkScalar y,
99 const SkPaint* paint) {
100 fProxy->drawBitmap(bitmap, x, y, paint);
101}
102
reed@google.com71121732012-09-18 15:14:33 +0000103void SkProxyCanvas::drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src,
commit-bot@chromium.orgeed779d2013-08-16 10:24:37 +0000104 const SkRect& dst, const SkPaint* paint,
105 DrawBitmapRectFlags flags) {
106 fProxy->drawBitmapRectToRect(bitmap, src, dst, paint, flags);
reed@android.com8a1c16f2008-12-17 15:59:43 +0000107}
108
109void SkProxyCanvas::drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m,
110 const SkPaint* paint) {
111 fProxy->drawBitmapMatrix(bitmap, m, paint);
112}
113
114void SkProxyCanvas::drawSprite(const SkBitmap& bitmap, int x, int y,
115 const SkPaint* paint) {
116 fProxy->drawSprite(bitmap, x, y, paint);
117}
118
reed@google.come0d9ce82014-04-23 04:00:17 +0000119void SkProxyCanvas::onDrawText(const void* text, size_t byteLength, SkScalar x, SkScalar y,
120 const SkPaint& paint) {
reed@android.com8a1c16f2008-12-17 15:59:43 +0000121 fProxy->drawText(text, byteLength, x, y, paint);
122}
123
reed@google.come0d9ce82014-04-23 04:00:17 +0000124void SkProxyCanvas::onDrawPosText(const void* text, size_t byteLength, const SkPoint pos[],
125 const SkPaint& paint) {
reed@android.com8a1c16f2008-12-17 15:59:43 +0000126 fProxy->drawPosText(text, byteLength, pos, paint);
127}
128
reed@google.come0d9ce82014-04-23 04:00:17 +0000129void SkProxyCanvas::onDrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[],
130 SkScalar constY, const SkPaint& paint) {
reed@android.com8a1c16f2008-12-17 15:59:43 +0000131 fProxy->drawPosTextH(text, byteLength, xpos, constY, paint);
132}
133
reed@google.come0d9ce82014-04-23 04:00:17 +0000134void SkProxyCanvas::onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path,
135 const SkMatrix* matrix, const SkPaint& paint) {
reed@android.com8a1c16f2008-12-17 15:59:43 +0000136 fProxy->drawTextOnPath(text, byteLength, path, matrix, paint);
137}
138
reedd5fa1a42014-08-09 11:08:05 -0700139void SkProxyCanvas::onDrawPicture(const SkPicture* picture, const SkMatrix* matrix,
140 const SkPaint* paint) {
141 fProxy->drawPicture(picture, matrix, paint);
reed@android.comed0bfb02009-05-13 21:01:21 +0000142}
143
reed@android.com8a1c16f2008-12-17 15:59:43 +0000144void SkProxyCanvas::drawVertices(VertexMode vmode, int vertexCount,
145 const SkPoint vertices[], const SkPoint texs[],
146 const SkColor colors[], SkXfermode* xmode,
147 const uint16_t indices[], int indexCount,
148 const SkPaint& paint) {
149 fProxy->drawVertices(vmode, vertexCount, vertices, texs, colors,
150 xmode, indices, indexCount, paint);
151}
152
dandov963137b2014-08-07 07:49:53 -0700153void SkProxyCanvas::drawPatch(const SkPatch& patch, const SkPaint& paint) {
154 fProxy->drawPatch(patch, paint);
155}
156
reed@android.comcb608442009-12-04 21:32:27 +0000157void SkProxyCanvas::drawData(const void* data, size_t length) {
158 fProxy->drawData(data, length);
159}
160
robertphillips@google.com0a4805e2013-05-29 13:24:23 +0000161void SkProxyCanvas::beginCommentGroup(const char* description) {
162 fProxy->beginCommentGroup(description);
163}
164
165void SkProxyCanvas::addComment(const char* kywd, const char* value) {
166 fProxy->addComment(kywd, value);
167}
168
169void SkProxyCanvas::endCommentGroup() {
170 fProxy->endCommentGroup();
171}
172
reed@android.com8a1c16f2008-12-17 15:59:43 +0000173SkDrawFilter* SkProxyCanvas::setDrawFilter(SkDrawFilter* filter) {
174 return fProxy->setDrawFilter(filter);
175}