blob: bd4442dc378d1eaa6676ac3bf411e9ba5e83023f [file] [log] [blame]
Derek Sollenberger8872b382014-06-23 14:13:53 -04001/*
2 * Copyright (C) 2014 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
Derek Sollenberger8872b382014-06-23 14:13:53 -040017#include "Canvas.h"
Derek Sollenberger6f485562015-07-30 10:00:39 -040018#include "CanvasProperty.h"
19#include "Layer.h"
20#include "RenderNode.h"
Derek Sollenberger8872b382014-06-23 14:13:53 -040021
John Reck849911a2015-01-20 07:51:14 -080022#include <SkCanvas.h>
23#include <SkClipStack.h>
Derek Sollenberger6f485562015-07-30 10:00:39 -040024#include <SkDrawable.h>
John Reck849911a2015-01-20 07:51:14 -080025#include <SkDevice.h>
26#include <SkDeque.h>
27#include <SkDrawFilter.h>
28#include <SkGraphics.h>
Derek Sollenberger6f485562015-07-30 10:00:39 -040029#include <SkImage.h>
John Reck849911a2015-01-20 07:51:14 -080030#include <SkShader.h>
31#include <SkTArray.h>
Florin Malitaeecff562015-12-21 10:43:01 -050032#include <SkTLazy.h>
John Reck849911a2015-01-20 07:51:14 -080033#include <SkTemplates.h>
Derek Sollenberger8872b382014-06-23 14:13:53 -040034
Doris Liuf276acd2016-01-07 13:49:26 -080035#include "VectorDrawable.h"
36
Ben Wagner60126ef2015-08-07 12:13:48 -040037#include <memory>
38
Derek Sollenberger8872b382014-06-23 14:13:53 -040039namespace android {
40
41// Holds an SkCanvas reference plus additional native data.
42class SkiaCanvas : public Canvas {
43public:
John Reckc1b33d62015-04-22 09:04:45 -070044 explicit SkiaCanvas(const SkBitmap& bitmap);
Derek Sollenberger8872b382014-06-23 14:13:53 -040045
Leon Scroggins III18981292014-12-17 11:30:31 -050046 /**
47 * Create a new SkiaCanvas.
48 *
49 * @param canvas SkCanvas to handle calls made to this SkiaCanvas. Must
50 * not be NULL. This constructor will ref() the SkCanvas, and unref()
51 * it in its destructor.
52 */
53 explicit SkiaCanvas(SkCanvas* canvas) : mCanvas(canvas) {
Derek Sollenberger8872b382014-06-23 14:13:53 -040054 SkASSERT(canvas);
Leon Scroggins III18981292014-12-17 11:30:31 -050055 canvas->ref();
Derek Sollenberger8872b382014-06-23 14:13:53 -040056 }
57
Derek Sollenbergerb3d50e02015-01-29 11:19:31 -050058 virtual SkCanvas* asSkCanvas() override {
Derek Sollenberger8872b382014-06-23 14:13:53 -040059 return mCanvas.get();
60 }
61
Derek Sollenberger6f485562015-07-30 10:00:39 -040062 virtual void resetRecording(int width, int height) override {
63 LOG_ALWAYS_FATAL("SkiaCanvas cannot be reset as a recording canvas");
64 }
65
66 virtual uirenderer::DisplayList* finishRecording() override {
67 LOG_ALWAYS_FATAL("SkiaCanvas does not produce a DisplayList");
68 return nullptr;
69 }
70 virtual void insertReorderBarrier(bool enableReorder) override {
71 LOG_ALWAYS_FATAL("SkiaCanvas does not support reordering barriers");
72 }
73
John Reckc1b33d62015-04-22 09:04:45 -070074 virtual void setBitmap(const SkBitmap& bitmap) override;
Derek Sollenberger8872b382014-06-23 14:13:53 -040075
Derek Sollenbergerb3d50e02015-01-29 11:19:31 -050076 virtual bool isOpaque() override;
77 virtual int width() override;
78 virtual int height() override;
Derek Sollenberger8872b382014-06-23 14:13:53 -040079
Derek Sollenberger6578a982015-07-13 13:24:29 -040080 virtual void setHighContrastText(bool highContrastText) override {
81 mHighContrastText = highContrastText;
82 }
83 virtual bool isHighContrastText() override { return mHighContrastText; }
84
Derek Sollenbergerb3d50e02015-01-29 11:19:31 -050085 virtual int getSaveCount() const override;
Florin Malitaeecff562015-12-21 10:43:01 -050086 virtual int save(SaveFlags::Flags flags) override;
Derek Sollenbergerb3d50e02015-01-29 11:19:31 -050087 virtual void restore() override;
88 virtual void restoreToCount(int saveCount) override;
Derek Sollenberger8872b382014-06-23 14:13:53 -040089
90 virtual int saveLayer(float left, float top, float right, float bottom,
Florin Malitaeecff562015-12-21 10:43:01 -050091 const SkPaint* paint, SaveFlags::Flags flags) override;
Derek Sollenberger8872b382014-06-23 14:13:53 -040092 virtual int saveLayerAlpha(float left, float top, float right, float bottom,
Florin Malitaeecff562015-12-21 10:43:01 -050093 int alpha, SaveFlags::Flags flags) override;
Derek Sollenberger8872b382014-06-23 14:13:53 -040094
Derek Sollenbergerb3d50e02015-01-29 11:19:31 -050095 virtual void getMatrix(SkMatrix* outMatrix) const override;
96 virtual void setMatrix(const SkMatrix& matrix) override;
97 virtual void concat(const SkMatrix& matrix) override;
98 virtual void rotate(float degrees) override;
99 virtual void scale(float sx, float sy) override;
100 virtual void skew(float sx, float sy) override;
101 virtual void translate(float dx, float dy) override;
Derek Sollenberger8872b382014-06-23 14:13:53 -0400102
Derek Sollenbergerb3d50e02015-01-29 11:19:31 -0500103 virtual bool getClipBounds(SkRect* outRect) const override;
104 virtual bool quickRejectRect(float left, float top, float right, float bottom) const override;
105 virtual bool quickRejectPath(const SkPath& path) const override;
106 virtual bool clipRect(float left, float top, float right, float bottom,
107 SkRegion::Op op) override;
108 virtual bool clipPath(const SkPath* path, SkRegion::Op op) override;
109 virtual bool clipRegion(const SkRegion* region, SkRegion::Op op) override;
Derek Sollenberger8872b382014-06-23 14:13:53 -0400110
Derek Sollenbergerb3d50e02015-01-29 11:19:31 -0500111 virtual SkDrawFilter* getDrawFilter() override;
112 virtual void setDrawFilter(SkDrawFilter* drawFilter) override;
Derek Sollenberger8872b382014-06-23 14:13:53 -0400113
Derek Sollenbergerb3d50e02015-01-29 11:19:31 -0500114 virtual void drawColor(int color, SkXfermode::Mode mode) override;
115 virtual void drawPaint(const SkPaint& paint) override;
Derek Sollenberger8872b382014-06-23 14:13:53 -0400116
Derek Sollenbergerb3d50e02015-01-29 11:19:31 -0500117 virtual void drawPoint(float x, float y, const SkPaint& paint) override;
118 virtual void drawPoints(const float* points, int count, const SkPaint& paint) override;
Derek Sollenberger8872b382014-06-23 14:13:53 -0400119 virtual void drawLine(float startX, float startY, float stopX, float stopY,
Derek Sollenbergerb3d50e02015-01-29 11:19:31 -0500120 const SkPaint& paint) override;
121 virtual void drawLines(const float* points, int count, const SkPaint& paint) override;
122 virtual void drawRect(float left, float top, float right, float bottom,
123 const SkPaint& paint) override;
Derek Sollenberger94394b32015-07-10 09:58:41 -0400124 virtual void drawRegion(const SkRegion& region, const SkPaint& paint) override;
Derek Sollenberger8872b382014-06-23 14:13:53 -0400125 virtual void drawRoundRect(float left, float top, float right, float bottom,
Derek Sollenbergerb3d50e02015-01-29 11:19:31 -0500126 float rx, float ry, const SkPaint& paint) override;
127 virtual void drawCircle(float x, float y, float radius, const SkPaint& paint) override;
128 virtual void drawOval(float left, float top, float right, float bottom,
129 const SkPaint& paint) override;
Derek Sollenberger8872b382014-06-23 14:13:53 -0400130 virtual void drawArc(float left, float top, float right, float bottom,
Derek Sollenbergerb3d50e02015-01-29 11:19:31 -0500131 float startAngle, float sweepAngle, bool useCenter, const SkPaint& paint) override;
132 virtual void drawPath(const SkPath& path, const SkPaint& paint) override;
Derek Sollenberger8872b382014-06-23 14:13:53 -0400133 virtual void drawVertices(SkCanvas::VertexMode vertexMode, int vertexCount,
134 const float* verts, const float* tex, const int* colors,
Derek Sollenbergerb3d50e02015-01-29 11:19:31 -0500135 const uint16_t* indices, int indexCount, const SkPaint& paint) override;
Derek Sollenberger8872b382014-06-23 14:13:53 -0400136
Derek Sollenbergerb3d50e02015-01-29 11:19:31 -0500137 virtual void drawBitmap(const SkBitmap& bitmap, float left, float top,
138 const SkPaint* paint) override;
139 virtual void drawBitmap(const SkBitmap& bitmap, const SkMatrix& matrix,
140 const SkPaint* paint) override;
Derek Sollenberger8872b382014-06-23 14:13:53 -0400141 virtual void drawBitmap(const SkBitmap& bitmap, float srcLeft, float srcTop,
142 float srcRight, float srcBottom, float dstLeft, float dstTop,
Derek Sollenbergerb3d50e02015-01-29 11:19:31 -0500143 float dstRight, float dstBottom, const SkPaint* paint) override;
Derek Sollenberger8872b382014-06-23 14:13:53 -0400144 virtual void drawBitmapMesh(const SkBitmap& bitmap, int meshWidth, int meshHeight,
Derek Sollenbergerb3d50e02015-01-29 11:19:31 -0500145 const float* vertices, const int* colors, const SkPaint* paint) override;
Derek Sollenbergeredca3202015-07-10 13:56:39 -0400146 virtual void drawNinePatch(const SkBitmap& bitmap, const android::Res_png_9patch& chunk,
147 float dstLeft, float dstTop, float dstRight, float dstBottom,
148 const SkPaint* paint) override;
Derek Sollenberger8872b382014-06-23 14:13:53 -0400149
Derek Sollenbergeracb40992014-07-21 15:22:10 -0400150 virtual void drawText(const uint16_t* text, const float* positions, int count,
151 const SkPaint& paint, float x, float y,
Tom Hudson8dfaa492014-12-09 15:03:44 -0500152 float boundsLeft, float boundsTop, float boundsRight, float boundsBottom,
Derek Sollenbergerb3d50e02015-01-29 11:19:31 -0500153 float totalAdvance) override;
Derek Sollenberger8872b382014-06-23 14:13:53 -0400154 virtual void drawTextOnPath(const uint16_t* glyphs, int count, const SkPath& path,
Derek Sollenbergerb3d50e02015-01-29 11:19:31 -0500155 float hOffset, float vOffset, const SkPaint& paint) override;
Derek Sollenbergeracb40992014-07-21 15:22:10 -0400156
Derek Sollenbergerb3d50e02015-01-29 11:19:31 -0500157 virtual bool drawTextAbsolutePos() const override { return true; }
Doris Liuf276acd2016-01-07 13:49:26 -0800158 virtual void drawVectorDrawable(VectorDrawableRoot* vectorDrawable) override;
Derek Sollenberger8872b382014-06-23 14:13:53 -0400159
Derek Sollenberger6f485562015-07-30 10:00:39 -0400160 virtual void drawRoundRect(uirenderer::CanvasPropertyPrimitive* left,
161 uirenderer::CanvasPropertyPrimitive* top, uirenderer::CanvasPropertyPrimitive* right,
162 uirenderer::CanvasPropertyPrimitive* bottom, uirenderer::CanvasPropertyPrimitive* rx,
163 uirenderer::CanvasPropertyPrimitive* ry, uirenderer::CanvasPropertyPaint* paint) override;
164 virtual void drawCircle(uirenderer::CanvasPropertyPrimitive* x,
165 uirenderer::CanvasPropertyPrimitive* y, uirenderer::CanvasPropertyPrimitive* radius,
166 uirenderer::CanvasPropertyPaint* paint) override;
167
168 virtual void drawLayer(uirenderer::DeferredLayerUpdater* layerHandle) override;
169 virtual void drawRenderNode(uirenderer::RenderNode* renderNode) override;
170 virtual void callDrawGLFunction(Functor* functor) override;
171
Derek Sollenberger8872b382014-06-23 14:13:53 -0400172private:
173 struct SaveRec {
Florin Malitaeecff562015-12-21 10:43:01 -0500174 int saveCount;
175 SaveFlags::Flags saveFlags;
Derek Sollenberger8872b382014-06-23 14:13:53 -0400176 };
177
Derek Sollenberger6578a982015-07-13 13:24:29 -0400178 bool mHighContrastText = false;
179
Florin Malitaeecff562015-12-21 10:43:01 -0500180 void recordPartialSave(SaveFlags::Flags flags);
Derek Sollenberger8872b382014-06-23 14:13:53 -0400181 void saveClipsForFrame(SkTArray<SkClipStack::Element>& clips, int frameSaveCount);
182 void applyClips(const SkTArray<SkClipStack::Element>& clips);
183
Derek Sollenbergeracb40992014-07-21 15:22:10 -0400184 void drawPoints(const float* points, int count, const SkPaint& paint,
Derek Sollenberger8872b382014-06-23 14:13:53 -0400185 SkCanvas::PointMode mode);
Derek Sollenberger8872b382014-06-23 14:13:53 -0400186
187 SkAutoTUnref<SkCanvas> mCanvas;
Ben Wagner60126ef2015-08-07 12:13:48 -0400188 std::unique_ptr<SkDeque> mSaveStack; // lazily allocated, tracks partial saves.
Derek Sollenberger8872b382014-06-23 14:13:53 -0400189};
190
John Reckc1b33d62015-04-22 09:04:45 -0700191Canvas* Canvas::create_canvas(const SkBitmap& bitmap) {
Derek Sollenberger8872b382014-06-23 14:13:53 -0400192 return new SkiaCanvas(bitmap);
193}
194
195Canvas* Canvas::create_canvas(SkCanvas* skiaCanvas) {
196 return new SkiaCanvas(skiaCanvas);
197}
198
John Reckc1b33d62015-04-22 09:04:45 -0700199SkiaCanvas::SkiaCanvas(const SkBitmap& bitmap) {
200 mCanvas.reset(new SkCanvas(bitmap));
Derek Sollenberger8872b382014-06-23 14:13:53 -0400201}
202
203// ----------------------------------------------------------------------------
204// Canvas state operations: Replace Bitmap
205// ----------------------------------------------------------------------------
206
207class ClipCopier : public SkCanvas::ClipVisitor {
208public:
209 ClipCopier(SkCanvas* dstCanvas) : m_dstCanvas(dstCanvas) {}
210
211 virtual void clipRect(const SkRect& rect, SkRegion::Op op, bool antialias) {
212 m_dstCanvas->clipRect(rect, op, antialias);
213 }
214 virtual void clipRRect(const SkRRect& rrect, SkRegion::Op op, bool antialias) {
215 m_dstCanvas->clipRRect(rrect, op, antialias);
216 }
217 virtual void clipPath(const SkPath& path, SkRegion::Op op, bool antialias) {
218 m_dstCanvas->clipPath(path, op, antialias);
219 }
220
221private:
222 SkCanvas* m_dstCanvas;
223};
224
John Reckc1b33d62015-04-22 09:04:45 -0700225void SkiaCanvas::setBitmap(const SkBitmap& bitmap) {
226 SkCanvas* newCanvas = new SkCanvas(bitmap);
Derek Sollenberger8872b382014-06-23 14:13:53 -0400227
John Reckc1b33d62015-04-22 09:04:45 -0700228 if (!bitmap.isNull()) {
Derek Sollenberger8872b382014-06-23 14:13:53 -0400229 // Copy the canvas matrix & clip state.
230 newCanvas->setMatrix(mCanvas->getTotalMatrix());
Leon Scroggins IIIf35b9892015-07-31 10:38:40 -0400231
232 ClipCopier copier(newCanvas);
233 mCanvas->replayClips(&copier);
Derek Sollenberger8872b382014-06-23 14:13:53 -0400234 }
235
236 // unrefs the existing canvas
237 mCanvas.reset(newCanvas);
238
239 // clean up the old save stack
240 mSaveStack.reset(NULL);
241}
242
243// ----------------------------------------------------------------------------
244// Canvas state operations
245// ----------------------------------------------------------------------------
246
247bool SkiaCanvas::isOpaque() {
Leon Scroggins IIIf35b9892015-07-31 10:38:40 -0400248 return mCanvas->imageInfo().isOpaque();
Derek Sollenberger8872b382014-06-23 14:13:53 -0400249}
250
251int SkiaCanvas::width() {
Leon Scroggins IIIf35b9892015-07-31 10:38:40 -0400252 return mCanvas->imageInfo().width();
Derek Sollenberger8872b382014-06-23 14:13:53 -0400253}
254
255int SkiaCanvas::height() {
Leon Scroggins IIIf35b9892015-07-31 10:38:40 -0400256 return mCanvas->imageInfo().height();
Derek Sollenberger8872b382014-06-23 14:13:53 -0400257}
258
259// ----------------------------------------------------------------------------
260// Canvas state operations: Save (layer)
261// ----------------------------------------------------------------------------
262
263int SkiaCanvas::getSaveCount() const {
264 return mCanvas->getSaveCount();
265}
266
Florin Malitaeecff562015-12-21 10:43:01 -0500267int SkiaCanvas::save(SaveFlags::Flags flags) {
Derek Sollenberger8872b382014-06-23 14:13:53 -0400268 int count = mCanvas->save();
269 recordPartialSave(flags);
270 return count;
271}
272
Florin Malita5e271402015-11-04 14:36:02 -0500273// The SkiaCanvas::restore operation layers on the capability to preserve
274// either (or both) the matrix and/or clip state after a SkCanvas::restore
275// operation. It does this by explicitly saving off the clip & matrix state
276// when requested and playing it back after the SkCanvas::restore.
Derek Sollenberger8872b382014-06-23 14:13:53 -0400277void SkiaCanvas::restore() {
278 const SaveRec* rec = (NULL == mSaveStack.get())
279 ? NULL
280 : static_cast<SaveRec*>(mSaveStack->back());
Florin Malita5e271402015-11-04 14:36:02 -0500281 int currentSaveCount = mCanvas->getSaveCount();
Derek Sollenberger8872b382014-06-23 14:13:53 -0400282 SkASSERT(NULL == rec || currentSaveCount >= rec->saveCount);
283
284 if (NULL == rec || rec->saveCount != currentSaveCount) {
285 // Fast path - no record for this frame.
286 mCanvas->restore();
287 return;
288 }
289
Florin Malitaeecff562015-12-21 10:43:01 -0500290 bool preserveMatrix = !(rec->saveFlags & SaveFlags::Matrix);
291 bool preserveClip = !(rec->saveFlags & SaveFlags::Clip);
Derek Sollenberger8872b382014-06-23 14:13:53 -0400292
293 SkMatrix savedMatrix;
294 if (preserveMatrix) {
295 savedMatrix = mCanvas->getTotalMatrix();
296 }
297
298 SkTArray<SkClipStack::Element> savedClips;
Florin Malita5e271402015-11-04 14:36:02 -0500299 int topClipStackFrame = mCanvas->getClipStack()->getSaveCount();
Derek Sollenberger8872b382014-06-23 14:13:53 -0400300 if (preserveClip) {
Florin Malita5e271402015-11-04 14:36:02 -0500301 saveClipsForFrame(savedClips, topClipStackFrame);
Derek Sollenberger8872b382014-06-23 14:13:53 -0400302 }
303
304 mCanvas->restore();
305
306 if (preserveMatrix) {
307 mCanvas->setMatrix(savedMatrix);
308 }
309
Florin Malita5e271402015-11-04 14:36:02 -0500310 if (preserveClip && !savedClips.empty() &&
311 topClipStackFrame != mCanvas->getClipStack()->getSaveCount()) {
312 // Only reapply the saved clips if the top clip stack frame was actually
313 // popped by restore(). If it wasn't, it means it doesn't belong to the
314 // restored canvas frame (SkCanvas lazy save/restore kicked in).
Derek Sollenberger8872b382014-06-23 14:13:53 -0400315 applyClips(savedClips);
316 }
317
318 mSaveStack->pop_back();
319}
320
321void SkiaCanvas::restoreToCount(int restoreCount) {
322 while (mCanvas->getSaveCount() > restoreCount) {
323 this->restore();
324 }
325}
326
Florin Malitaeecff562015-12-21 10:43:01 -0500327static inline SkCanvas::SaveLayerFlags layerFlags(SaveFlags::Flags flags) {
328 SkCanvas::SaveLayerFlags layerFlags = 0;
329
330 if (!(flags & SaveFlags::HasAlphaLayer)) {
331 layerFlags |= SkCanvas::kIsOpaque_SaveLayerFlag;
332 }
333
334 if (!(flags & SaveFlags::ClipToLayer)) {
335 layerFlags |= SkCanvas::kDontClipToLayer_Legacy_SaveLayerFlag;
336 }
337
338 return layerFlags;
339}
340
Derek Sollenberger8872b382014-06-23 14:13:53 -0400341int SkiaCanvas::saveLayer(float left, float top, float right, float bottom,
Florin Malitaeecff562015-12-21 10:43:01 -0500342 const SkPaint* paint, SaveFlags::Flags flags) {
343 const SkRect bounds = SkRect::MakeLTRB(left, top, right, bottom);
344 const SkCanvas::SaveLayerRec rec(&bounds, paint, layerFlags(flags));
345
346 int count = mCanvas->saveLayer(rec);
Derek Sollenberger8872b382014-06-23 14:13:53 -0400347 recordPartialSave(flags);
348 return count;
349}
350
351int SkiaCanvas::saveLayerAlpha(float left, float top, float right, float bottom,
Florin Malitaeecff562015-12-21 10:43:01 -0500352 int alpha, SaveFlags::Flags flags) {
353 SkTLazy<SkPaint> alphaPaint;
354 if (static_cast<unsigned>(alpha) < 0xFF) {
355 alphaPaint.init()->setAlpha(alpha);
356 }
357
358 return this->saveLayer(left, top, right, bottom, alphaPaint.getMaybeNull(),
359 flags);
Derek Sollenberger8872b382014-06-23 14:13:53 -0400360}
361
362// ----------------------------------------------------------------------------
363// functions to emulate legacy SaveFlags (i.e. independent matrix/clip flags)
364// ----------------------------------------------------------------------------
365
Florin Malitaeecff562015-12-21 10:43:01 -0500366void SkiaCanvas::recordPartialSave(SaveFlags::Flags flags) {
Derek Sollenberger8872b382014-06-23 14:13:53 -0400367 // A partial save is a save operation which doesn't capture the full canvas state.
Florin Malitaeecff562015-12-21 10:43:01 -0500368 // (either SaveFlags::Matrix or SaveFlags::Clip is missing).
Derek Sollenberger8872b382014-06-23 14:13:53 -0400369
370 // Mask-out non canvas state bits.
Florin Malitaeecff562015-12-21 10:43:01 -0500371 flags &= SaveFlags::MatrixClip;
Derek Sollenberger8872b382014-06-23 14:13:53 -0400372
Florin Malitaeecff562015-12-21 10:43:01 -0500373 if (flags == SaveFlags::MatrixClip) {
Derek Sollenberger8872b382014-06-23 14:13:53 -0400374 // not a partial save.
375 return;
376 }
377
378 if (NULL == mSaveStack.get()) {
Ben Wagnerd1cbc162015-08-19 12:45:09 -0400379 mSaveStack.reset(new SkDeque(sizeof(struct SaveRec), 8));
Derek Sollenberger8872b382014-06-23 14:13:53 -0400380 }
381
382 SaveRec* rec = static_cast<SaveRec*>(mSaveStack->push_back());
Florin Malita5e271402015-11-04 14:36:02 -0500383 rec->saveCount = mCanvas->getSaveCount();
Derek Sollenberger8872b382014-06-23 14:13:53 -0400384 rec->saveFlags = flags;
385}
386
Florin Malita5e271402015-11-04 14:36:02 -0500387void SkiaCanvas::saveClipsForFrame(SkTArray<SkClipStack::Element>& clips,
388 int saveCountToBackup) {
389 // Each SkClipStack::Element stores the index of the canvas save
390 // with which it is associated. Backup only those Elements that
391 // are associated with 'saveCountToBackup'
Derek Sollenberger8872b382014-06-23 14:13:53 -0400392 SkClipStack::Iter clipIterator(*mCanvas->getClipStack(),
393 SkClipStack::Iter::kTop_IterStart);
Florin Malita5e271402015-11-04 14:36:02 -0500394 while (const SkClipStack::Element* elem = clipIterator.prev()) {
395 if (elem->getSaveCount() < saveCountToBackup) {
396 // done with the target save count.
Derek Sollenberger8872b382014-06-23 14:13:53 -0400397 break;
398 }
Florin Malita5e271402015-11-04 14:36:02 -0500399 SkASSERT(elem->getSaveCount() == saveCountToBackup);
Derek Sollenberger8872b382014-06-23 14:13:53 -0400400 clips.push_back(*elem);
401 }
402}
403
404void SkiaCanvas::applyClips(const SkTArray<SkClipStack::Element>& clips) {
405 ClipCopier clipCopier(mCanvas);
406
407 // The clip stack stores clips in device space.
408 SkMatrix origMatrix = mCanvas->getTotalMatrix();
409 mCanvas->resetMatrix();
410
411 // We pushed the clips in reverse order.
412 for (int i = clips.count() - 1; i >= 0; --i) {
413 clips[i].replay(&clipCopier);
414 }
415
416 mCanvas->setMatrix(origMatrix);
417}
418
419// ----------------------------------------------------------------------------
420// Canvas state operations: Matrix
421// ----------------------------------------------------------------------------
422
423void SkiaCanvas::getMatrix(SkMatrix* outMatrix) const {
424 *outMatrix = mCanvas->getTotalMatrix();
425}
426
427void SkiaCanvas::setMatrix(const SkMatrix& matrix) {
428 mCanvas->setMatrix(matrix);
429}
430
431void SkiaCanvas::concat(const SkMatrix& matrix) {
432 mCanvas->concat(matrix);
433}
434
435void SkiaCanvas::rotate(float degrees) {
436 mCanvas->rotate(degrees);
437}
438
439void SkiaCanvas::scale(float sx, float sy) {
440 mCanvas->scale(sx, sy);
441}
442
443void SkiaCanvas::skew(float sx, float sy) {
444 mCanvas->skew(sx, sy);
445}
446
447void SkiaCanvas::translate(float dx, float dy) {
448 mCanvas->translate(dx, dy);
449}
450
451// ----------------------------------------------------------------------------
452// Canvas state operations: Clips
453// ----------------------------------------------------------------------------
454
455// This function is a mirror of SkCanvas::getClipBounds except that it does
456// not outset the edge of the clip to account for anti-aliasing. There is
457// a skia bug to investigate pushing this logic into back into skia.
458// (see https://code.google.com/p/skia/issues/detail?id=1303)
459bool SkiaCanvas::getClipBounds(SkRect* outRect) const {
460 SkIRect ibounds;
461 if (!mCanvas->getClipDeviceBounds(&ibounds)) {
462 return false;
463 }
464
465 SkMatrix inverse;
466 // if we can't invert the CTM, we can't return local clip bounds
467 if (!mCanvas->getTotalMatrix().invert(&inverse)) {
468 if (outRect) {
469 outRect->setEmpty();
470 }
471 return false;
472 }
473
474 if (NULL != outRect) {
475 SkRect r = SkRect::Make(ibounds);
476 inverse.mapRect(outRect, r);
477 }
478 return true;
479}
480
481bool SkiaCanvas::quickRejectRect(float left, float top, float right, float bottom) const {
482 SkRect bounds = SkRect::MakeLTRB(left, top, right, bottom);
483 return mCanvas->quickReject(bounds);
484}
485
486bool SkiaCanvas::quickRejectPath(const SkPath& path) const {
487 return mCanvas->quickReject(path);
488}
489
490bool SkiaCanvas::clipRect(float left, float top, float right, float bottom, SkRegion::Op op) {
491 SkRect rect = SkRect::MakeLTRB(left, top, right, bottom);
492 mCanvas->clipRect(rect, op);
Chris Craik5ec6a282015-06-23 15:42:12 -0700493 return !mCanvas->isClipEmpty();
Derek Sollenberger8872b382014-06-23 14:13:53 -0400494}
495
496bool SkiaCanvas::clipPath(const SkPath* path, SkRegion::Op op) {
497 mCanvas->clipPath(*path, op);
Chris Craik5ec6a282015-06-23 15:42:12 -0700498 return !mCanvas->isClipEmpty();
Derek Sollenberger8872b382014-06-23 14:13:53 -0400499}
500
501bool SkiaCanvas::clipRegion(const SkRegion* region, SkRegion::Op op) {
502 SkPath rgnPath;
503 if (region->getBoundaryPath(&rgnPath)) {
504 // The region is specified in device space.
505 SkMatrix savedMatrix = mCanvas->getTotalMatrix();
506 mCanvas->resetMatrix();
507 mCanvas->clipPath(rgnPath, op);
508 mCanvas->setMatrix(savedMatrix);
509 } else {
510 mCanvas->clipRect(SkRect::MakeEmpty(), op);
511 }
Chris Craik5ec6a282015-06-23 15:42:12 -0700512 return !mCanvas->isClipEmpty();
Derek Sollenberger8872b382014-06-23 14:13:53 -0400513}
514
515// ----------------------------------------------------------------------------
516// Canvas state operations: Filters
517// ----------------------------------------------------------------------------
518
Derek Sollenbergeracb40992014-07-21 15:22:10 -0400519SkDrawFilter* SkiaCanvas::getDrawFilter() {
520 return mCanvas->getDrawFilter();
521}
522
Derek Sollenberger8872b382014-06-23 14:13:53 -0400523void SkiaCanvas::setDrawFilter(SkDrawFilter* drawFilter) {
524 mCanvas->setDrawFilter(drawFilter);
525}
526
527// ----------------------------------------------------------------------------
528// Canvas draw operations
529// ----------------------------------------------------------------------------
530
531void SkiaCanvas::drawColor(int color, SkXfermode::Mode mode) {
532 mCanvas->drawColor(color, mode);
533}
534
Derek Sollenbergeracb40992014-07-21 15:22:10 -0400535void SkiaCanvas::drawPaint(const SkPaint& paint) {
Derek Sollenberger8872b382014-06-23 14:13:53 -0400536 mCanvas->drawPaint(paint);
537}
538
539// ----------------------------------------------------------------------------
540// Canvas draw operations: Geometry
541// ----------------------------------------------------------------------------
542
Derek Sollenbergeracb40992014-07-21 15:22:10 -0400543void SkiaCanvas::drawPoints(const float* points, int count, const SkPaint& paint,
Derek Sollenberger8872b382014-06-23 14:13:53 -0400544 SkCanvas::PointMode mode) {
545 // convert the floats into SkPoints
546 count >>= 1; // now it is the number of points
Ben Wagner6bbf68d2015-08-19 11:26:06 -0400547 std::unique_ptr<SkPoint[]> pts(new SkPoint[count]);
Derek Sollenberger8872b382014-06-23 14:13:53 -0400548 for (int i = 0; i < count; i++) {
549 pts[i].set(points[0], points[1]);
550 points += 2;
551 }
Ben Wagner6bbf68d2015-08-19 11:26:06 -0400552 mCanvas->drawPoints(mode, count, pts.get(), paint);
Derek Sollenberger8872b382014-06-23 14:13:53 -0400553}
554
555
Derek Sollenbergeracb40992014-07-21 15:22:10 -0400556void SkiaCanvas::drawPoint(float x, float y, const SkPaint& paint) {
Derek Sollenberger8872b382014-06-23 14:13:53 -0400557 mCanvas->drawPoint(x, y, paint);
558}
559
Derek Sollenbergeracb40992014-07-21 15:22:10 -0400560void SkiaCanvas::drawPoints(const float* points, int count, const SkPaint& paint) {
Derek Sollenberger8872b382014-06-23 14:13:53 -0400561 this->drawPoints(points, count, paint, SkCanvas::kPoints_PointMode);
562}
563
564void SkiaCanvas::drawLine(float startX, float startY, float stopX, float stopY,
Derek Sollenbergeracb40992014-07-21 15:22:10 -0400565 const SkPaint& paint) {
Derek Sollenberger8872b382014-06-23 14:13:53 -0400566 mCanvas->drawLine(startX, startY, stopX, stopY, paint);
567}
568
Derek Sollenbergeracb40992014-07-21 15:22:10 -0400569void SkiaCanvas::drawLines(const float* points, int count, const SkPaint& paint) {
Derek Sollenberger8872b382014-06-23 14:13:53 -0400570 this->drawPoints(points, count, paint, SkCanvas::kLines_PointMode);
571}
572
573void SkiaCanvas::drawRect(float left, float top, float right, float bottom,
Derek Sollenbergeracb40992014-07-21 15:22:10 -0400574 const SkPaint& paint) {
Derek Sollenberger8872b382014-06-23 14:13:53 -0400575 mCanvas->drawRectCoords(left, top, right, bottom, paint);
576
577}
578
Derek Sollenberger94394b32015-07-10 09:58:41 -0400579void SkiaCanvas::drawRegion(const SkRegion& region, const SkPaint& paint) {
580 SkRegion::Iterator it(region);
581 while (!it.done()) {
582 mCanvas->drawRect(SkRect::Make(it.rect()), paint);
583 it.next();
584 }
585}
586
Derek Sollenberger8872b382014-06-23 14:13:53 -0400587void SkiaCanvas::drawRoundRect(float left, float top, float right, float bottom,
Derek Sollenbergeracb40992014-07-21 15:22:10 -0400588 float rx, float ry, const SkPaint& paint) {
Derek Sollenberger8872b382014-06-23 14:13:53 -0400589 SkRect rect = SkRect::MakeLTRB(left, top, right, bottom);
590 mCanvas->drawRoundRect(rect, rx, ry, paint);
591}
592
Derek Sollenbergeracb40992014-07-21 15:22:10 -0400593void SkiaCanvas::drawCircle(float x, float y, float radius, const SkPaint& paint) {
Derek Sollenberger8872b382014-06-23 14:13:53 -0400594 mCanvas->drawCircle(x, y, radius, paint);
595}
596
Derek Sollenbergeracb40992014-07-21 15:22:10 -0400597void SkiaCanvas::drawOval(float left, float top, float right, float bottom, const SkPaint& paint) {
Derek Sollenberger8872b382014-06-23 14:13:53 -0400598 SkRect oval = SkRect::MakeLTRB(left, top, right, bottom);
599 mCanvas->drawOval(oval, paint);
600}
601
602void SkiaCanvas::drawArc(float left, float top, float right, float bottom,
Derek Sollenbergeracb40992014-07-21 15:22:10 -0400603 float startAngle, float sweepAngle, bool useCenter, const SkPaint& paint) {
Derek Sollenberger8872b382014-06-23 14:13:53 -0400604 SkRect arc = SkRect::MakeLTRB(left, top, right, bottom);
605 mCanvas->drawArc(arc, startAngle, sweepAngle, useCenter, paint);
606}
607
Derek Sollenbergeracb40992014-07-21 15:22:10 -0400608void SkiaCanvas::drawPath(const SkPath& path, const SkPaint& paint) {
Derek Sollenberger8872b382014-06-23 14:13:53 -0400609 mCanvas->drawPath(path, paint);
610}
611
612void SkiaCanvas::drawVertices(SkCanvas::VertexMode vertexMode, int vertexCount,
613 const float* verts, const float* texs, const int* colors,
Derek Sollenbergeracb40992014-07-21 15:22:10 -0400614 const uint16_t* indices, int indexCount, const SkPaint& paint) {
Derek Sollenberger8872b382014-06-23 14:13:53 -0400615#ifndef SK_SCALAR_IS_FLOAT
616 SkDEBUGFAIL("SkScalar must be a float for these conversions to be valid");
617#endif
618 const int ptCount = vertexCount >> 1;
619 mCanvas->drawVertices(vertexMode, ptCount, (SkPoint*)verts, (SkPoint*)texs,
620 (SkColor*)colors, NULL, indices, indexCount, paint);
621}
622
623// ----------------------------------------------------------------------------
624// Canvas draw operations: Bitmaps
625// ----------------------------------------------------------------------------
626
Derek Sollenbergeracb40992014-07-21 15:22:10 -0400627void SkiaCanvas::drawBitmap(const SkBitmap& bitmap, float left, float top, const SkPaint* paint) {
Derek Sollenberger8872b382014-06-23 14:13:53 -0400628 mCanvas->drawBitmap(bitmap, left, top, paint);
629}
630
Derek Sollenbergeracb40992014-07-21 15:22:10 -0400631void SkiaCanvas::drawBitmap(const SkBitmap& bitmap, const SkMatrix& matrix, const SkPaint* paint) {
Mike Reed70ffbf92014-12-08 17:03:30 -0500632 SkAutoCanvasRestore acr(mCanvas, true);
633 mCanvas->concat(matrix);
634 mCanvas->drawBitmap(bitmap, 0, 0, paint);
Derek Sollenberger8872b382014-06-23 14:13:53 -0400635}
636
637void SkiaCanvas::drawBitmap(const SkBitmap& bitmap, float srcLeft, float srcTop,
638 float srcRight, float srcBottom, float dstLeft, float dstTop,
Derek Sollenbergeracb40992014-07-21 15:22:10 -0400639 float dstRight, float dstBottom, const SkPaint* paint) {
Derek Sollenberger8872b382014-06-23 14:13:53 -0400640 SkRect srcRect = SkRect::MakeLTRB(srcLeft, srcTop, srcRight, srcBottom);
641 SkRect dstRect = SkRect::MakeLTRB(dstLeft, dstTop, dstRight, dstBottom);
Leon Scroggins IIIf35b9892015-07-31 10:38:40 -0400642 mCanvas->drawBitmapRect(bitmap, srcRect, dstRect, paint);
Derek Sollenberger8872b382014-06-23 14:13:53 -0400643}
644
645void SkiaCanvas::drawBitmapMesh(const SkBitmap& bitmap, int meshWidth, int meshHeight,
Derek Sollenbergeracb40992014-07-21 15:22:10 -0400646 const float* vertices, const int* colors, const SkPaint* paint) {
Derek Sollenberger8872b382014-06-23 14:13:53 -0400647
648 const int ptCount = (meshWidth + 1) * (meshHeight + 1);
649 const int indexCount = meshWidth * meshHeight * 6;
650
651 /* Our temp storage holds 2 or 3 arrays.
652 texture points [ptCount * sizeof(SkPoint)]
653 optionally vertex points [ptCount * sizeof(SkPoint)] if we need a
654 copy to convert from float to fixed
655 indices [ptCount * sizeof(uint16_t)]
656 */
657 ssize_t storageSize = ptCount * sizeof(SkPoint); // texs[]
658 storageSize += indexCount * sizeof(uint16_t); // indices[]
659
660
661#ifndef SK_SCALAR_IS_FLOAT
662 SkDEBUGFAIL("SkScalar must be a float for these conversions to be valid");
663#endif
Ben Wagner6bbf68d2015-08-19 11:26:06 -0400664 std::unique_ptr<char[]> storage(new char[storageSize]);
Derek Sollenberger8872b382014-06-23 14:13:53 -0400665 SkPoint* texs = (SkPoint*)storage.get();
666 uint16_t* indices = (uint16_t*)(texs + ptCount);
667
668 // cons up texture coordinates and indices
669 {
670 const SkScalar w = SkIntToScalar(bitmap.width());
671 const SkScalar h = SkIntToScalar(bitmap.height());
672 const SkScalar dx = w / meshWidth;
673 const SkScalar dy = h / meshHeight;
674
675 SkPoint* texsPtr = texs;
676 SkScalar y = 0;
677 for (int i = 0; i <= meshHeight; i++) {
678 if (i == meshHeight) {
679 y = h; // to ensure numerically we hit h exactly
680 }
681 SkScalar x = 0;
682 for (int j = 0; j < meshWidth; j++) {
683 texsPtr->set(x, y);
684 texsPtr += 1;
685 x += dx;
686 }
687 texsPtr->set(w, y);
688 texsPtr += 1;
689 y += dy;
690 }
691 SkASSERT(texsPtr - texs == ptCount);
692 }
693
694 // cons up indices
695 {
696 uint16_t* indexPtr = indices;
697 int index = 0;
698 for (int i = 0; i < meshHeight; i++) {
699 for (int j = 0; j < meshWidth; j++) {
700 // lower-left triangle
701 *indexPtr++ = index;
702 *indexPtr++ = index + meshWidth + 1;
703 *indexPtr++ = index + meshWidth + 2;
704 // upper-right triangle
705 *indexPtr++ = index;
706 *indexPtr++ = index + meshWidth + 2;
707 *indexPtr++ = index + 1;
708 // bump to the next cell
709 index += 1;
710 }
711 // bump to the next row
712 index += 1;
713 }
714 SkASSERT(indexPtr - indices == indexCount);
715 SkASSERT((char*)indexPtr - (char*)storage.get() == storageSize);
716 }
717
718 // double-check that we have legal indices
719#ifdef SK_DEBUG
720 {
721 for (int i = 0; i < indexCount; i++) {
722 SkASSERT((unsigned)indices[i] < (unsigned)ptCount);
723 }
724 }
725#endif
726
727 // cons-up a shader for the bitmap
Derek Sollenbergeracb40992014-07-21 15:22:10 -0400728 SkPaint tmpPaint;
Derek Sollenberger8872b382014-06-23 14:13:53 -0400729 if (paint) {
730 tmpPaint = *paint;
731 }
732 SkShader* shader = SkShader::CreateBitmapShader(bitmap,
733 SkShader::kClamp_TileMode,
734 SkShader::kClamp_TileMode);
735 SkSafeUnref(tmpPaint.setShader(shader));
736
737 mCanvas->drawVertices(SkCanvas::kTriangles_VertexMode, ptCount, (SkPoint*)vertices,
738 texs, (const SkColor*)colors, NULL, indices,
739 indexCount, tmpPaint);
740}
741
Derek Sollenbergeredca3202015-07-10 13:56:39 -0400742void SkiaCanvas::drawNinePatch(const SkBitmap& bitmap, const Res_png_9patch& chunk,
743 float dstLeft, float dstTop, float dstRight, float dstBottom, const SkPaint* paint) {
744 SkRect bounds = SkRect::MakeLTRB(dstLeft, dstTop, dstRight, dstBottom);
745 NinePatch::Draw(mCanvas, bounds, bitmap, chunk, paint, nullptr);
746}
747
Doris Liuf276acd2016-01-07 13:49:26 -0800748void SkiaCanvas::drawVectorDrawable(VectorDrawableRoot* vectorDrawable) {
749 const SkBitmap& bitmap = vectorDrawable->getBitmapUpdateIfDirty();
750 SkRect bounds = vectorDrawable->getBounds();
751 drawBitmap(bitmap, 0, 0, bitmap.width(), bitmap.height(),
752 bounds.fLeft, bounds.fTop, bounds.fRight, bounds.fBottom,
753 vectorDrawable->getPaint());
754}
755
Derek Sollenberger8872b382014-06-23 14:13:53 -0400756// ----------------------------------------------------------------------------
757// Canvas draw operations: Text
758// ----------------------------------------------------------------------------
759
Derek Sollenbergeracb40992014-07-21 15:22:10 -0400760void SkiaCanvas::drawText(const uint16_t* text, const float* positions, int count,
761 const SkPaint& paint, float x, float y,
Tom Hudson8dfaa492014-12-09 15:03:44 -0500762 float boundsLeft, float boundsTop, float boundsRight, float boundsBottom,
763 float totalAdvance) {
Derek Sollenbergeracb40992014-07-21 15:22:10 -0400764 // Set align to left for drawing, as we don't want individual
765 // glyphs centered or right-aligned; the offset above takes
766 // care of all alignment.
767 SkPaint paintCopy(paint);
768 paintCopy.setTextAlign(SkPaint::kLeft_Align);
Derek Sollenberger8872b382014-06-23 14:13:53 -0400769
Ben Wagnere3a40ea2015-08-19 15:49:37 -0400770 static_assert(sizeof(SkPoint) == sizeof(float)*2, "SkPoint is no longer two floats");
Derek Sollenbergeracb40992014-07-21 15:22:10 -0400771 mCanvas->drawPosText(text, count << 1, reinterpret_cast<const SkPoint*>(positions), paintCopy);
Chris Craika1717272015-11-19 13:02:43 -0800772 drawTextDecorations(x, y, totalAdvance, paint);
Derek Sollenberger8872b382014-06-23 14:13:53 -0400773}
774
775void SkiaCanvas::drawTextOnPath(const uint16_t* glyphs, int count, const SkPath& path,
Derek Sollenbergeracb40992014-07-21 15:22:10 -0400776 float hOffset, float vOffset, const SkPaint& paint) {
Tom Hudson34e79c12015-04-14 11:34:39 -0400777 mCanvas->drawTextOnPathHV(glyphs, count << 1, path, hOffset, vOffset, paint);
Derek Sollenberger8872b382014-06-23 14:13:53 -0400778}
779
Derek Sollenberger6f485562015-07-30 10:00:39 -0400780// ----------------------------------------------------------------------------
781// Canvas draw operations: Animations
782// ----------------------------------------------------------------------------
783
784class AnimatedRoundRect : public SkDrawable {
785 public:
786 AnimatedRoundRect(uirenderer::CanvasPropertyPrimitive* left,
787 uirenderer::CanvasPropertyPrimitive* top, uirenderer::CanvasPropertyPrimitive* right,
788 uirenderer::CanvasPropertyPrimitive* bottom, uirenderer::CanvasPropertyPrimitive* rx,
789 uirenderer::CanvasPropertyPrimitive* ry, uirenderer::CanvasPropertyPaint* p) :
790 mLeft(left), mTop(top), mRight(right), mBottom(bottom), mRx(rx), mRy(ry), mPaint(p) {}
791
792 protected:
793 virtual SkRect onGetBounds() override {
794 return SkRect::MakeLTRB(mLeft->value, mTop->value, mRight->value, mBottom->value);
795 }
796 virtual void onDraw(SkCanvas* canvas) override {
797 SkRect rect = SkRect::MakeLTRB(mLeft->value, mTop->value, mRight->value, mBottom->value);
798 canvas->drawRoundRect(rect, mRx->value, mRy->value, mPaint->value);
799 }
800
801 private:
802 sp<uirenderer::CanvasPropertyPrimitive> mLeft;
803 sp<uirenderer::CanvasPropertyPrimitive> mTop;
804 sp<uirenderer::CanvasPropertyPrimitive> mRight;
805 sp<uirenderer::CanvasPropertyPrimitive> mBottom;
806 sp<uirenderer::CanvasPropertyPrimitive> mRx;
807 sp<uirenderer::CanvasPropertyPrimitive> mRy;
808 sp<uirenderer::CanvasPropertyPaint> mPaint;
809};
810
811class AnimatedCircle : public SkDrawable {
812 public:
813 AnimatedCircle(uirenderer::CanvasPropertyPrimitive* x, uirenderer::CanvasPropertyPrimitive* y,
814 uirenderer::CanvasPropertyPrimitive* radius, uirenderer::CanvasPropertyPaint* paint) :
815 mX(x), mY(y), mRadius(radius), mPaint(paint) {}
816
817 protected:
818 virtual SkRect onGetBounds() override {
819 const float x = mX->value;
820 const float y = mY->value;
821 const float radius = mRadius->value;
822 return SkRect::MakeLTRB(x - radius, y - radius, x + radius, y + radius);
823 }
824 virtual void onDraw(SkCanvas* canvas) override {
825 canvas->drawCircle(mX->value, mY->value, mRadius->value, mPaint->value);
826 }
827
828 private:
829 sp<uirenderer::CanvasPropertyPrimitive> mX;
830 sp<uirenderer::CanvasPropertyPrimitive> mY;
831 sp<uirenderer::CanvasPropertyPrimitive> mRadius;
832 sp<uirenderer::CanvasPropertyPaint> mPaint;
833};
834
835void SkiaCanvas::drawRoundRect(uirenderer::CanvasPropertyPrimitive* left,
836 uirenderer::CanvasPropertyPrimitive* top, uirenderer::CanvasPropertyPrimitive* right,
837 uirenderer::CanvasPropertyPrimitive* bottom, uirenderer::CanvasPropertyPrimitive* rx,
838 uirenderer::CanvasPropertyPrimitive* ry, uirenderer::CanvasPropertyPaint* paint) {
839 SkAutoTUnref<AnimatedRoundRect> drawable(
840 new AnimatedRoundRect(left, top, right, bottom, rx, ry, paint));
841 mCanvas->drawDrawable(drawable.get());
842}
843
844void SkiaCanvas::drawCircle(uirenderer::CanvasPropertyPrimitive* x, uirenderer::CanvasPropertyPrimitive* y,
845 uirenderer::CanvasPropertyPrimitive* radius, uirenderer::CanvasPropertyPaint* paint) {
846 SkAutoTUnref<AnimatedCircle> drawable(new AnimatedCircle(x, y, radius, paint));
847 mCanvas->drawDrawable(drawable.get());
848}
849
850// ----------------------------------------------------------------------------
851// Canvas draw operations: View System
852// ----------------------------------------------------------------------------
853
854void SkiaCanvas::drawLayer(uirenderer::DeferredLayerUpdater* layer) { }
855
856void SkiaCanvas::drawRenderNode(uirenderer::RenderNode* renderNode) { }
857
858void SkiaCanvas::callDrawGLFunction(Functor* functor) { }
859
Derek Sollenberger8872b382014-06-23 14:13:53 -0400860} // namespace android