epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 1 | |
| 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.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 8 | #include "SkProxyCanvas.h" |
| 9 | |
| 10 | SkProxyCanvas::SkProxyCanvas(SkCanvas* proxy) : fProxy(proxy) { |
reed@google.com | 82065d6 | 2011-02-07 15:30:46 +0000 | [diff] [blame] | 11 | SkSafeRef(fProxy); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 12 | } |
| 13 | |
| 14 | SkProxyCanvas::~SkProxyCanvas() { |
reed@google.com | 82065d6 | 2011-02-07 15:30:46 +0000 | [diff] [blame] | 15 | SkSafeUnref(fProxy); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 16 | } |
reed@google.com | 82065d6 | 2011-02-07 15:30:46 +0000 | [diff] [blame] | 17 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 18 | void SkProxyCanvas::setProxy(SkCanvas* proxy) { |
| 19 | SkRefCnt_SafeAssign(fProxy, proxy); |
| 20 | } |
| 21 | |
| 22 | ///////////////////////////////// Overrides /////////// |
| 23 | |
Florin Malita | 5f6102d | 2014-06-30 10:13:28 -0400 | [diff] [blame] | 24 | void SkProxyCanvas::willSave() { |
| 25 | fProxy->save(); |
| 26 | this->INHERITED::willSave(); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 27 | } |
| 28 | |
commit-bot@chromium.org | e54a23f | 2014-03-12 20:21:48 +0000 | [diff] [blame] | 29 | SkCanvas::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.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 35 | } |
| 36 | |
commit-bot@chromium.org | e54a23f | 2014-03-12 20:21:48 +0000 | [diff] [blame] | 37 | void SkProxyCanvas::willRestore() { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 38 | fProxy->restore(); |
commit-bot@chromium.org | e54a23f | 2014-03-12 20:21:48 +0000 | [diff] [blame] | 39 | this->INHERITED::willRestore(); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 40 | } |
| 41 | |
commit-bot@chromium.org | 44c48d0 | 2014-03-13 20:03:58 +0000 | [diff] [blame] | 42 | void SkProxyCanvas::didConcat(const SkMatrix& matrix) { |
| 43 | fProxy->concat(matrix); |
| 44 | this->INHERITED::didConcat(matrix); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 45 | } |
| 46 | |
commit-bot@chromium.org | 44c48d0 | 2014-03-13 20:03:58 +0000 | [diff] [blame] | 47 | void SkProxyCanvas::didSetMatrix(const SkMatrix& matrix) { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 48 | fProxy->setMatrix(matrix); |
commit-bot@chromium.org | 44c48d0 | 2014-03-13 20:03:58 +0000 | [diff] [blame] | 49 | this->INHERITED::didSetMatrix(matrix); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 50 | } |
| 51 | |
robertphillips@google.com | 8f90a89 | 2014-02-28 18:19:39 +0000 | [diff] [blame] | 52 | void SkProxyCanvas::onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle edgeStyle) { |
| 53 | fProxy->clipRect(rect, op, kSoft_ClipEdgeStyle == edgeStyle); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 54 | } |
| 55 | |
robertphillips@google.com | 8f90a89 | 2014-02-28 18:19:39 +0000 | [diff] [blame] | 56 | void SkProxyCanvas::onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeStyle edgeStyle) { |
| 57 | fProxy->clipRRect(rrect, op, kSoft_ClipEdgeStyle == edgeStyle); |
reed@google.com | 4ed0fb7 | 2012-12-12 20:48:18 +0000 | [diff] [blame] | 58 | } |
| 59 | |
robertphillips@google.com | 8f90a89 | 2014-02-28 18:19:39 +0000 | [diff] [blame] | 60 | void SkProxyCanvas::onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle edgeStyle) { |
| 61 | fProxy->clipPath(path, op, kSoft_ClipEdgeStyle == edgeStyle); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 62 | } |
| 63 | |
robertphillips@google.com | 8f90a89 | 2014-02-28 18:19:39 +0000 | [diff] [blame] | 64 | void SkProxyCanvas::onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op) { |
| 65 | fProxy->clipRegion(deviceRgn, op); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 66 | } |
| 67 | |
| 68 | void SkProxyCanvas::drawPaint(const SkPaint& paint) { |
| 69 | fProxy->drawPaint(paint); |
| 70 | } |
| 71 | |
| 72 | void 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.com | 4ed0fb7 | 2012-12-12 20:48:18 +0000 | [diff] [blame] | 77 | void SkProxyCanvas::drawOval(const SkRect& rect, const SkPaint& paint) { |
| 78 | fProxy->drawOval(rect, paint); |
| 79 | } |
| 80 | |
bsalomon@google.com | 7ce564c | 2013-10-22 16:54:15 +0000 | [diff] [blame] | 81 | void SkProxyCanvas::drawRect(const SkRect& rect, const SkPaint& paint) { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 82 | fProxy->drawRect(rect, paint); |
| 83 | } |
| 84 | |
reed@google.com | 4ed0fb7 | 2012-12-12 20:48:18 +0000 | [diff] [blame] | 85 | void SkProxyCanvas::drawRRect(const SkRRect& rrect, const SkPaint& paint) { |
| 86 | fProxy->drawRRect(rrect, paint); |
| 87 | } |
| 88 | |
commit-bot@chromium.org | ab58273 | 2014-02-21 12:20:45 +0000 | [diff] [blame] | 89 | void SkProxyCanvas::onDrawDRRect(const SkRRect& outer, const SkRRect& inner, |
| 90 | const SkPaint& paint) { |
| 91 | fProxy->drawDRRect(outer, inner, paint); |
| 92 | } |
| 93 | |
bsalomon@google.com | 7ce564c | 2013-10-22 16:54:15 +0000 | [diff] [blame] | 94 | void SkProxyCanvas::drawPath(const SkPath& path, const SkPaint& paint) { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 95 | fProxy->drawPath(path, paint); |
| 96 | } |
| 97 | |
| 98 | void SkProxyCanvas::drawBitmap(const SkBitmap& bitmap, SkScalar x, SkScalar y, |
| 99 | const SkPaint* paint) { |
| 100 | fProxy->drawBitmap(bitmap, x, y, paint); |
| 101 | } |
| 102 | |
reed@google.com | 7112173 | 2012-09-18 15:14:33 +0000 | [diff] [blame] | 103 | void SkProxyCanvas::drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src, |
commit-bot@chromium.org | eed779d | 2013-08-16 10:24:37 +0000 | [diff] [blame] | 104 | const SkRect& dst, const SkPaint* paint, |
| 105 | DrawBitmapRectFlags flags) { |
| 106 | fProxy->drawBitmapRectToRect(bitmap, src, dst, paint, flags); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 107 | } |
| 108 | |
| 109 | void SkProxyCanvas::drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m, |
| 110 | const SkPaint* paint) { |
| 111 | fProxy->drawBitmapMatrix(bitmap, m, paint); |
| 112 | } |
| 113 | |
| 114 | void SkProxyCanvas::drawSprite(const SkBitmap& bitmap, int x, int y, |
| 115 | const SkPaint* paint) { |
| 116 | fProxy->drawSprite(bitmap, x, y, paint); |
| 117 | } |
| 118 | |
reed@google.com | e0d9ce8 | 2014-04-23 04:00:17 +0000 | [diff] [blame] | 119 | void SkProxyCanvas::onDrawText(const void* text, size_t byteLength, SkScalar x, SkScalar y, |
| 120 | const SkPaint& paint) { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 121 | fProxy->drawText(text, byteLength, x, y, paint); |
| 122 | } |
| 123 | |
reed@google.com | e0d9ce8 | 2014-04-23 04:00:17 +0000 | [diff] [blame] | 124 | void SkProxyCanvas::onDrawPosText(const void* text, size_t byteLength, const SkPoint pos[], |
| 125 | const SkPaint& paint) { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 126 | fProxy->drawPosText(text, byteLength, pos, paint); |
| 127 | } |
| 128 | |
reed@google.com | e0d9ce8 | 2014-04-23 04:00:17 +0000 | [diff] [blame] | 129 | void SkProxyCanvas::onDrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[], |
| 130 | SkScalar constY, const SkPaint& paint) { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 131 | fProxy->drawPosTextH(text, byteLength, xpos, constY, paint); |
| 132 | } |
| 133 | |
reed@google.com | e0d9ce8 | 2014-04-23 04:00:17 +0000 | [diff] [blame] | 134 | void SkProxyCanvas::onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path, |
| 135 | const SkMatrix* matrix, const SkPaint& paint) { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 136 | fProxy->drawTextOnPath(text, byteLength, path, matrix, paint); |
| 137 | } |
| 138 | |
fmalita | b742517 | 2014-08-26 07:56:44 -0700 | [diff] [blame] | 139 | void SkProxyCanvas::onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y, |
| 140 | const SkPaint& paint) { |
| 141 | fProxy->drawTextBlob(blob, x, y, paint); |
| 142 | } |
| 143 | |
reed | d5fa1a4 | 2014-08-09 11:08:05 -0700 | [diff] [blame] | 144 | void SkProxyCanvas::onDrawPicture(const SkPicture* picture, const SkMatrix* matrix, |
| 145 | const SkPaint* paint) { |
| 146 | fProxy->drawPicture(picture, matrix, paint); |
reed@android.com | ed0bfb0 | 2009-05-13 21:01:21 +0000 | [diff] [blame] | 147 | } |
| 148 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 149 | void SkProxyCanvas::drawVertices(VertexMode vmode, int vertexCount, |
| 150 | const SkPoint vertices[], const SkPoint texs[], |
| 151 | const SkColor colors[], SkXfermode* xmode, |
| 152 | const uint16_t indices[], int indexCount, |
| 153 | const SkPaint& paint) { |
| 154 | fProxy->drawVertices(vmode, vertexCount, vertices, texs, colors, |
| 155 | xmode, indices, indexCount, paint); |
| 156 | } |
| 157 | |
dandov | b3c9d1c | 2014-08-12 08:34:29 -0700 | [diff] [blame] | 158 | void SkProxyCanvas::onDrawPatch(const SkPoint cubics[12], const SkColor colors[4], |
| 159 | const SkPoint texCoords[4], SkXfermode* xmode, |
| 160 | const SkPaint& paint) { |
| 161 | fProxy->drawPatch(cubics, colors, texCoords, xmode, paint); |
dandov | 963137b | 2014-08-07 07:49:53 -0700 | [diff] [blame] | 162 | } |
| 163 | |
reed@android.com | cb60844 | 2009-12-04 21:32:27 +0000 | [diff] [blame] | 164 | void SkProxyCanvas::drawData(const void* data, size_t length) { |
| 165 | fProxy->drawData(data, length); |
| 166 | } |
| 167 | |
robertphillips@google.com | 0a4805e | 2013-05-29 13:24:23 +0000 | [diff] [blame] | 168 | void SkProxyCanvas::beginCommentGroup(const char* description) { |
| 169 | fProxy->beginCommentGroup(description); |
| 170 | } |
| 171 | |
| 172 | void SkProxyCanvas::addComment(const char* kywd, const char* value) { |
| 173 | fProxy->addComment(kywd, value); |
| 174 | } |
| 175 | |
| 176 | void SkProxyCanvas::endCommentGroup() { |
| 177 | fProxy->endCommentGroup(); |
| 178 | } |
| 179 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 180 | SkDrawFilter* SkProxyCanvas::setDrawFilter(SkDrawFilter* filter) { |
| 181 | return fProxy->setDrawFilter(filter); |
| 182 | } |