blob: 8cae771f39b21981add3ca6c9ac02f09734806f3 [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 Sollenbergerc1908132016-07-15 10:28:16 -040017#include "SkiaCanvas.h"
Derek Sollenberger8872b382014-06-23 14:13:53 -040018
Derek Sollenbergerc1908132016-07-15 10:28:16 -040019#include "CanvasProperty.h"
Matt Sarett7de73852016-10-25 18:36:39 -040020#include "NinePatchUtils.h"
Derek Sollenbergerc1908132016-07-15 10:28:16 -040021#include "VectorDrawable.h"
sergeyvaed7f582016-10-14 16:30:21 -070022#include "hwui/Bitmap.h"
Yuqian Liafc221492016-07-18 13:07:42 -040023#include "hwui/MinikinUtils.h"
Stan Iliev021693b2016-10-17 16:26:15 -040024#include "pipeline/skia/AnimatedDrawables.h"
Derek Sollenbergerc1908132016-07-15 10:28:16 -040025
Derek Sollenberger6f485562015-07-30 10:00:39 -040026#include <SkDrawable.h>
John Reck849911a2015-01-20 07:51:14 -080027#include <SkDevice.h>
28#include <SkDeque.h>
29#include <SkDrawFilter.h>
30#include <SkGraphics.h>
Derek Sollenberger6f485562015-07-30 10:00:39 -040031#include <SkImage.h>
Matt Sarett62feb3a2016-09-20 10:34:11 -040032#include <SkImagePriv.h>
Yuqian Liafc221492016-07-18 13:07:42 -040033#include <SkRSXform.h>
John Reck849911a2015-01-20 07:51:14 -080034#include <SkShader.h>
John Reck849911a2015-01-20 07:51:14 -080035#include <SkTemplates.h>
Stan Ilievf50806a2016-10-24 10:40:39 -040036#include <SkTextBlob.h>
Derek Sollenberger8872b382014-06-23 14:13:53 -040037
Ben Wagner60126ef2015-08-07 12:13:48 -040038#include <memory>
39
Derek Sollenberger8872b382014-06-23 14:13:53 -040040namespace android {
41
Stan Ilievf50806a2016-10-24 10:40:39 -040042using uirenderer::PaintUtils;
43
John Reckc1b33d62015-04-22 09:04:45 -070044Canvas* Canvas::create_canvas(const SkBitmap& bitmap) {
Derek Sollenberger8872b382014-06-23 14:13:53 -040045 return new SkiaCanvas(bitmap);
46}
47
48Canvas* Canvas::create_canvas(SkCanvas* skiaCanvas) {
49 return new SkiaCanvas(skiaCanvas);
50}
51
Stan Ilievf50806a2016-10-24 10:40:39 -040052SkiaCanvas::SkiaCanvas() {}
53
54SkiaCanvas::SkiaCanvas(SkCanvas* canvas)
Mike Reed6acfe162016-11-18 17:21:09 -050055 : mCanvas(canvas) {}
Stan Ilievf50806a2016-10-24 10:40:39 -040056
John Reckc1b33d62015-04-22 09:04:45 -070057SkiaCanvas::SkiaCanvas(const SkBitmap& bitmap) {
Mike Reed6acfe162016-11-18 17:21:09 -050058 mCanvasOwned = std::unique_ptr<SkCanvas>(new SkCanvas(bitmap));
59 mCanvas = mCanvasOwned.get();
Derek Sollenberger8872b382014-06-23 14:13:53 -040060}
61
Stan Iliev021693b2016-10-17 16:26:15 -040062SkiaCanvas::~SkiaCanvas() {}
63
Derek Sollenbergerc1908132016-07-15 10:28:16 -040064void SkiaCanvas::reset(SkCanvas* skiaCanvas) {
Mike Reed6acfe162016-11-18 17:21:09 -050065 if (mCanvas != skiaCanvas) {
66 mCanvas = skiaCanvas;
67 mCanvasOwned.reset();
68 }
Derek Sollenbergerc1908132016-07-15 10:28:16 -040069 mSaveStack.reset(nullptr);
70 mHighContrastText = false;
71}
72
Derek Sollenberger8872b382014-06-23 14:13:53 -040073// ----------------------------------------------------------------------------
74// Canvas state operations: Replace Bitmap
75// ----------------------------------------------------------------------------
76
77class ClipCopier : public SkCanvas::ClipVisitor {
78public:
Chih-Hung Hsiehc6baf562016-04-27 11:29:23 -070079 explicit ClipCopier(SkCanvas* dstCanvas) : m_dstCanvas(dstCanvas) {}
Derek Sollenberger8872b382014-06-23 14:13:53 -040080
Mike Reed6e49c9f2016-12-02 15:36:59 -050081 virtual void clipRect(const SkRect& rect, SkClipOp op, bool antialias) {
Derek Sollenberger8872b382014-06-23 14:13:53 -040082 m_dstCanvas->clipRect(rect, op, antialias);
83 }
Mike Reed6e49c9f2016-12-02 15:36:59 -050084 virtual void clipRRect(const SkRRect& rrect, SkClipOp op, bool antialias) {
Derek Sollenberger8872b382014-06-23 14:13:53 -040085 m_dstCanvas->clipRRect(rrect, op, antialias);
86 }
Mike Reed6e49c9f2016-12-02 15:36:59 -050087 virtual void clipPath(const SkPath& path, SkClipOp op, bool antialias) {
Derek Sollenberger8872b382014-06-23 14:13:53 -040088 m_dstCanvas->clipPath(path, op, antialias);
89 }
90
91private:
92 SkCanvas* m_dstCanvas;
93};
94
John Reckc1b33d62015-04-22 09:04:45 -070095void SkiaCanvas::setBitmap(const SkBitmap& bitmap) {
Stan Ilievf50806a2016-10-24 10:40:39 -040096 SkCanvas* newCanvas = new SkCanvas(bitmap);
Derek Sollenberger8872b382014-06-23 14:13:53 -040097
John Reckc1b33d62015-04-22 09:04:45 -070098 if (!bitmap.isNull()) {
Derek Sollenberger8872b382014-06-23 14:13:53 -040099 // Copy the canvas matrix & clip state.
100 newCanvas->setMatrix(mCanvas->getTotalMatrix());
Leon Scroggins IIIf35b9892015-07-31 10:38:40 -0400101
Stan Ilievf50806a2016-10-24 10:40:39 -0400102 ClipCopier copier(newCanvas);
Leon Scroggins IIIf35b9892015-07-31 10:38:40 -0400103 mCanvas->replayClips(&copier);
Derek Sollenberger8872b382014-06-23 14:13:53 -0400104 }
105
Mike Reed6acfe162016-11-18 17:21:09 -0500106 // deletes the previously owned canvas (if any)
107 mCanvasOwned = std::unique_ptr<SkCanvas>(newCanvas);
108 mCanvas = newCanvas;
Derek Sollenberger8872b382014-06-23 14:13:53 -0400109
110 // clean up the old save stack
Stan Ilievf50806a2016-10-24 10:40:39 -0400111 mSaveStack.reset(nullptr);
Derek Sollenberger8872b382014-06-23 14:13:53 -0400112}
113
114// ----------------------------------------------------------------------------
115// Canvas state operations
116// ----------------------------------------------------------------------------
117
118bool SkiaCanvas::isOpaque() {
Leon Scroggins IIIf35b9892015-07-31 10:38:40 -0400119 return mCanvas->imageInfo().isOpaque();
Derek Sollenberger8872b382014-06-23 14:13:53 -0400120}
121
122int SkiaCanvas::width() {
Leon Scroggins IIIf35b9892015-07-31 10:38:40 -0400123 return mCanvas->imageInfo().width();
Derek Sollenberger8872b382014-06-23 14:13:53 -0400124}
125
126int SkiaCanvas::height() {
Leon Scroggins IIIf35b9892015-07-31 10:38:40 -0400127 return mCanvas->imageInfo().height();
Derek Sollenberger8872b382014-06-23 14:13:53 -0400128}
129
130// ----------------------------------------------------------------------------
131// Canvas state operations: Save (layer)
132// ----------------------------------------------------------------------------
133
134int SkiaCanvas::getSaveCount() const {
135 return mCanvas->getSaveCount();
136}
137
Florin Malitaeecff562015-12-21 10:43:01 -0500138int SkiaCanvas::save(SaveFlags::Flags flags) {
Derek Sollenberger8872b382014-06-23 14:13:53 -0400139 int count = mCanvas->save();
140 recordPartialSave(flags);
141 return count;
142}
143
Florin Malita5e271402015-11-04 14:36:02 -0500144// The SkiaCanvas::restore operation layers on the capability to preserve
145// either (or both) the matrix and/or clip state after a SkCanvas::restore
146// operation. It does this by explicitly saving off the clip & matrix state
147// when requested and playing it back after the SkCanvas::restore.
Derek Sollenberger8872b382014-06-23 14:13:53 -0400148void SkiaCanvas::restore() {
Stan Ilievf50806a2016-10-24 10:40:39 -0400149 const auto* rec = this->currentSaveRec();
150 if (!rec) {
Derek Sollenberger8872b382014-06-23 14:13:53 -0400151 // Fast path - no record for this frame.
152 mCanvas->restore();
153 return;
154 }
155
Florin Malitaeecff562015-12-21 10:43:01 -0500156 bool preserveMatrix = !(rec->saveFlags & SaveFlags::Matrix);
157 bool preserveClip = !(rec->saveFlags & SaveFlags::Clip);
Derek Sollenberger8872b382014-06-23 14:13:53 -0400158
159 SkMatrix savedMatrix;
160 if (preserveMatrix) {
161 savedMatrix = mCanvas->getTotalMatrix();
162 }
163
Stan Ilievf50806a2016-10-24 10:40:39 -0400164 const size_t clipIndex = rec->clipIndex;
Derek Sollenberger8872b382014-06-23 14:13:53 -0400165
166 mCanvas->restore();
Stan Ilievf50806a2016-10-24 10:40:39 -0400167 mSaveStack->pop_back();
Derek Sollenberger8872b382014-06-23 14:13:53 -0400168
169 if (preserveMatrix) {
170 mCanvas->setMatrix(savedMatrix);
171 }
172
Stan Ilievf50806a2016-10-24 10:40:39 -0400173 if (preserveClip) {
174 this->applyPersistentClips(clipIndex);
Derek Sollenberger8872b382014-06-23 14:13:53 -0400175 }
Derek Sollenberger8872b382014-06-23 14:13:53 -0400176}
177
178void SkiaCanvas::restoreToCount(int restoreCount) {
179 while (mCanvas->getSaveCount() > restoreCount) {
180 this->restore();
181 }
182}
183
Florin Malitaeecff562015-12-21 10:43:01 -0500184static inline SkCanvas::SaveLayerFlags layerFlags(SaveFlags::Flags flags) {
185 SkCanvas::SaveLayerFlags layerFlags = 0;
186
Yuqian Li83427ff2016-09-14 11:14:06 -0400187 // We intentionally ignore the SaveFlags::HasAlphaLayer and
188 // SkCanvas::kIsOpaque_SaveLayerFlag flags because HWUI ignores it
189 // and our Android client may use it incorrectly.
190 // In Skia, this flag is purely for performance optimization.
Florin Malitaeecff562015-12-21 10:43:01 -0500191
192 if (!(flags & SaveFlags::ClipToLayer)) {
193 layerFlags |= SkCanvas::kDontClipToLayer_Legacy_SaveLayerFlag;
194 }
195
196 return layerFlags;
197}
198
Derek Sollenberger8872b382014-06-23 14:13:53 -0400199int SkiaCanvas::saveLayer(float left, float top, float right, float bottom,
Florin Malitaeecff562015-12-21 10:43:01 -0500200 const SkPaint* paint, SaveFlags::Flags flags) {
201 const SkRect bounds = SkRect::MakeLTRB(left, top, right, bottom);
Stan Iliev68885e32016-12-14 11:18:34 -0500202 //always save matrix and clip to match the behaviour of Skia and HWUI pipelines and to ensure
203 //android state tracking behavior matches that of the Skia API (partial save is not supported)
204 const SkCanvas::SaveLayerRec rec(&bounds, paint, layerFlags(flags | SaveFlags::MatrixClip));
Florin Malitaeecff562015-12-21 10:43:01 -0500205
Stan Iliev68885e32016-12-14 11:18:34 -0500206 return mCanvas->saveLayer(rec);
Derek Sollenberger8872b382014-06-23 14:13:53 -0400207}
208
209int SkiaCanvas::saveLayerAlpha(float left, float top, float right, float bottom,
Florin Malitaeecff562015-12-21 10:43:01 -0500210 int alpha, SaveFlags::Flags flags) {
Florin Malitaeecff562015-12-21 10:43:01 -0500211 if (static_cast<unsigned>(alpha) < 0xFF) {
Yuqian Lifd92ee42016-04-27 17:03:38 -0400212 SkPaint alphaPaint;
213 alphaPaint.setAlpha(alpha);
214 return this->saveLayer(left, top, right, bottom, &alphaPaint, flags);
Florin Malitaeecff562015-12-21 10:43:01 -0500215 }
Yuqian Lifd92ee42016-04-27 17:03:38 -0400216 return this->saveLayer(left, top, right, bottom, nullptr, flags);
Derek Sollenberger8872b382014-06-23 14:13:53 -0400217}
218
Stan Ilievf50806a2016-10-24 10:40:39 -0400219class SkiaCanvas::Clip {
220public:
Mike Reed6e49c9f2016-12-02 15:36:59 -0500221 Clip(const SkRect& rect, SkClipOp op, const SkMatrix& m)
Stan Ilievf50806a2016-10-24 10:40:39 -0400222 : mType(Type::Rect), mOp(op), mMatrix(m), mRRect(SkRRect::MakeRect(rect)) {}
Mike Reed6e49c9f2016-12-02 15:36:59 -0500223 Clip(const SkRRect& rrect, SkClipOp op, const SkMatrix& m)
Stan Ilievf50806a2016-10-24 10:40:39 -0400224 : mType(Type::RRect), mOp(op), mMatrix(m), mRRect(rrect) {}
Mike Reed6e49c9f2016-12-02 15:36:59 -0500225 Clip(const SkPath& path, SkClipOp op, const SkMatrix& m)
Stan Ilievf50806a2016-10-24 10:40:39 -0400226 : mType(Type::Path), mOp(op), mMatrix(m), mPath(&path) {}
227
228 void apply(SkCanvas* canvas) const {
229 canvas->setMatrix(mMatrix);
230 switch (mType) {
231 case Type::Rect:
232 canvas->clipRect(mRRect.rect(), mOp);
233 break;
234 case Type::RRect:
235 canvas->clipRRect(mRRect, mOp);
236 break;
237 case Type::Path:
238 canvas->clipPath(*mPath.get(), mOp);
239 break;
240 }
241 }
242
243private:
244 enum class Type {
245 Rect,
246 RRect,
247 Path,
248 };
249
Mike Reed6e49c9f2016-12-02 15:36:59 -0500250 Type mType;
251 SkClipOp mOp;
252 SkMatrix mMatrix;
Stan Ilievf50806a2016-10-24 10:40:39 -0400253
254 // These are logically a union (tracked separately due to non-POD path).
255 SkTLazy<SkPath> mPath;
256 SkRRect mRRect;
257};
258
259const SkiaCanvas::SaveRec* SkiaCanvas::currentSaveRec() const {
260 const SaveRec* rec = mSaveStack
261 ? static_cast<const SaveRec*>(mSaveStack->back())
262 : nullptr;
263 int currentSaveCount = mCanvas->getSaveCount();
264 SkASSERT(!rec || currentSaveCount >= rec->saveCount);
265
266 return (rec && rec->saveCount == currentSaveCount) ? rec : nullptr;
267}
268
Derek Sollenberger8872b382014-06-23 14:13:53 -0400269// ----------------------------------------------------------------------------
270// functions to emulate legacy SaveFlags (i.e. independent matrix/clip flags)
271// ----------------------------------------------------------------------------
272
Florin Malitaeecff562015-12-21 10:43:01 -0500273void SkiaCanvas::recordPartialSave(SaveFlags::Flags flags) {
Derek Sollenberger8872b382014-06-23 14:13:53 -0400274 // A partial save is a save operation which doesn't capture the full canvas state.
Florin Malitaeecff562015-12-21 10:43:01 -0500275 // (either SaveFlags::Matrix or SaveFlags::Clip is missing).
Derek Sollenberger8872b382014-06-23 14:13:53 -0400276
277 // Mask-out non canvas state bits.
Florin Malitaeecff562015-12-21 10:43:01 -0500278 flags &= SaveFlags::MatrixClip;
Derek Sollenberger8872b382014-06-23 14:13:53 -0400279
Florin Malitaeecff562015-12-21 10:43:01 -0500280 if (flags == SaveFlags::MatrixClip) {
Derek Sollenberger8872b382014-06-23 14:13:53 -0400281 // not a partial save.
282 return;
283 }
284
Stan Ilievf50806a2016-10-24 10:40:39 -0400285 if (!mSaveStack) {
Ben Wagnerd1cbc162015-08-19 12:45:09 -0400286 mSaveStack.reset(new SkDeque(sizeof(struct SaveRec), 8));
Derek Sollenberger8872b382014-06-23 14:13:53 -0400287 }
288
289 SaveRec* rec = static_cast<SaveRec*>(mSaveStack->push_back());
Florin Malita5e271402015-11-04 14:36:02 -0500290 rec->saveCount = mCanvas->getSaveCount();
Derek Sollenberger8872b382014-06-23 14:13:53 -0400291 rec->saveFlags = flags;
Stan Ilievf50806a2016-10-24 10:40:39 -0400292 rec->clipIndex = mClipStack.size();
Derek Sollenberger8872b382014-06-23 14:13:53 -0400293}
294
Stan Ilievf50806a2016-10-24 10:40:39 -0400295template <typename T>
Mike Reed6e49c9f2016-12-02 15:36:59 -0500296void SkiaCanvas::recordClip(const T& clip, SkClipOp op) {
Stan Ilievf50806a2016-10-24 10:40:39 -0400297 // Only need tracking when in a partial save frame which
298 // doesn't restore the clip.
299 const SaveRec* rec = this->currentSaveRec();
300 if (rec && !(rec->saveFlags & SaveFlags::Clip)) {
301 mClipStack.emplace_back(clip, op, mCanvas->getTotalMatrix());
Derek Sollenberger8872b382014-06-23 14:13:53 -0400302 }
303}
304
Stan Ilievf50806a2016-10-24 10:40:39 -0400305// Applies and optionally removes all clips >= index.
306void SkiaCanvas::applyPersistentClips(size_t clipStartIndex) {
307 SkASSERT(clipStartIndex <= mClipStack.size());
308 const auto begin = mClipStack.cbegin() + clipStartIndex;
309 const auto end = mClipStack.cend();
Derek Sollenberger8872b382014-06-23 14:13:53 -0400310
Stan Ilievf50806a2016-10-24 10:40:39 -0400311 // Clip application mutates the CTM.
312 const SkMatrix saveMatrix = mCanvas->getTotalMatrix();
Derek Sollenberger8872b382014-06-23 14:13:53 -0400313
Stan Ilievf50806a2016-10-24 10:40:39 -0400314 for (auto clip = begin; clip != end; ++clip) {
Mike Reed6acfe162016-11-18 17:21:09 -0500315 clip->apply(mCanvas);
Derek Sollenberger8872b382014-06-23 14:13:53 -0400316 }
317
Stan Ilievf50806a2016-10-24 10:40:39 -0400318 mCanvas->setMatrix(saveMatrix);
319
320 // If the current/post-restore save rec is also persisting clips, we
321 // leave them on the stack to be reapplied part of the next restore().
322 // Otherwise we're done and just pop them.
323 const auto* rec = this->currentSaveRec();
324 if (!rec || (rec->saveFlags & SaveFlags::Clip)) {
325 mClipStack.erase(begin, end);
326 }
Derek Sollenberger8872b382014-06-23 14:13:53 -0400327}
328
329// ----------------------------------------------------------------------------
330// Canvas state operations: Matrix
331// ----------------------------------------------------------------------------
332
333void SkiaCanvas::getMatrix(SkMatrix* outMatrix) const {
334 *outMatrix = mCanvas->getTotalMatrix();
335}
336
337void SkiaCanvas::setMatrix(const SkMatrix& matrix) {
338 mCanvas->setMatrix(matrix);
339}
340
341void SkiaCanvas::concat(const SkMatrix& matrix) {
342 mCanvas->concat(matrix);
343}
344
345void SkiaCanvas::rotate(float degrees) {
346 mCanvas->rotate(degrees);
347}
348
349void SkiaCanvas::scale(float sx, float sy) {
350 mCanvas->scale(sx, sy);
351}
352
353void SkiaCanvas::skew(float sx, float sy) {
354 mCanvas->skew(sx, sy);
355}
356
357void SkiaCanvas::translate(float dx, float dy) {
358 mCanvas->translate(dx, dy);
359}
360
361// ----------------------------------------------------------------------------
362// Canvas state operations: Clips
363// ----------------------------------------------------------------------------
364
365// This function is a mirror of SkCanvas::getClipBounds except that it does
366// not outset the edge of the clip to account for anti-aliasing. There is
367// a skia bug to investigate pushing this logic into back into skia.
368// (see https://code.google.com/p/skia/issues/detail?id=1303)
369bool SkiaCanvas::getClipBounds(SkRect* outRect) const {
370 SkIRect ibounds;
371 if (!mCanvas->getClipDeviceBounds(&ibounds)) {
372 return false;
373 }
374
375 SkMatrix inverse;
376 // if we can't invert the CTM, we can't return local clip bounds
377 if (!mCanvas->getTotalMatrix().invert(&inverse)) {
378 if (outRect) {
379 outRect->setEmpty();
380 }
381 return false;
382 }
383
384 if (NULL != outRect) {
385 SkRect r = SkRect::Make(ibounds);
386 inverse.mapRect(outRect, r);
387 }
388 return true;
389}
390
391bool SkiaCanvas::quickRejectRect(float left, float top, float right, float bottom) const {
392 SkRect bounds = SkRect::MakeLTRB(left, top, right, bottom);
393 return mCanvas->quickReject(bounds);
394}
395
396bool SkiaCanvas::quickRejectPath(const SkPath& path) const {
397 return mCanvas->quickReject(path);
398}
399
Mike Reed6e49c9f2016-12-02 15:36:59 -0500400bool SkiaCanvas::clipRect(float left, float top, float right, float bottom, SkClipOp op) {
Derek Sollenberger8872b382014-06-23 14:13:53 -0400401 SkRect rect = SkRect::MakeLTRB(left, top, right, bottom);
Stan Ilievf50806a2016-10-24 10:40:39 -0400402 this->recordClip(rect, op);
Derek Sollenberger8872b382014-06-23 14:13:53 -0400403 mCanvas->clipRect(rect, op);
Chris Craik5ec6a282015-06-23 15:42:12 -0700404 return !mCanvas->isClipEmpty();
Derek Sollenberger8872b382014-06-23 14:13:53 -0400405}
406
Mike Reed6e49c9f2016-12-02 15:36:59 -0500407bool SkiaCanvas::clipPath(const SkPath* path, SkClipOp op) {
Derek Sollenbergerc1908132016-07-15 10:28:16 -0400408 SkRRect roundRect;
409 if (path->isRRect(&roundRect)) {
Stan Ilievf50806a2016-10-24 10:40:39 -0400410 this->recordClip(roundRect, op);
Derek Sollenbergerc1908132016-07-15 10:28:16 -0400411 mCanvas->clipRRect(roundRect, op);
412 } else {
Stan Ilievf50806a2016-10-24 10:40:39 -0400413 this->recordClip(*path, op);
Derek Sollenbergerc1908132016-07-15 10:28:16 -0400414 mCanvas->clipPath(*path, op);
415 }
Chris Craik5ec6a282015-06-23 15:42:12 -0700416 return !mCanvas->isClipEmpty();
Derek Sollenberger8872b382014-06-23 14:13:53 -0400417}
418
Mike Reed6e49c9f2016-12-02 15:36:59 -0500419bool SkiaCanvas::clipRegion(const SkRegion* region, SkClipOp op) {
Derek Sollenberger8872b382014-06-23 14:13:53 -0400420 SkPath rgnPath;
421 if (region->getBoundaryPath(&rgnPath)) {
422 // The region is specified in device space.
423 SkMatrix savedMatrix = mCanvas->getTotalMatrix();
424 mCanvas->resetMatrix();
Stan Ilievf50806a2016-10-24 10:40:39 -0400425 this->recordClip(rgnPath, op);
Derek Sollenberger8872b382014-06-23 14:13:53 -0400426 mCanvas->clipPath(rgnPath, op);
427 mCanvas->setMatrix(savedMatrix);
428 } else {
Stan Ilievf50806a2016-10-24 10:40:39 -0400429 const auto emptyClip = SkRect::MakeEmpty();
430 this->recordClip(emptyClip, op);
431 mCanvas->clipRect(emptyClip, op);
Derek Sollenberger8872b382014-06-23 14:13:53 -0400432 }
Chris Craik5ec6a282015-06-23 15:42:12 -0700433 return !mCanvas->isClipEmpty();
Derek Sollenberger8872b382014-06-23 14:13:53 -0400434}
435
436// ----------------------------------------------------------------------------
437// Canvas state operations: Filters
438// ----------------------------------------------------------------------------
439
Derek Sollenbergeracb40992014-07-21 15:22:10 -0400440SkDrawFilter* SkiaCanvas::getDrawFilter() {
441 return mCanvas->getDrawFilter();
442}
443
Derek Sollenberger8872b382014-06-23 14:13:53 -0400444void SkiaCanvas::setDrawFilter(SkDrawFilter* drawFilter) {
445 mCanvas->setDrawFilter(drawFilter);
446}
447
448// ----------------------------------------------------------------------------
449// Canvas draw operations
450// ----------------------------------------------------------------------------
451
Mike Reed260ab722016-10-07 15:59:20 -0400452void SkiaCanvas::drawColor(int color, SkBlendMode mode) {
Derek Sollenberger8872b382014-06-23 14:13:53 -0400453 mCanvas->drawColor(color, mode);
454}
455
Derek Sollenbergeracb40992014-07-21 15:22:10 -0400456void SkiaCanvas::drawPaint(const SkPaint& paint) {
Derek Sollenberger8872b382014-06-23 14:13:53 -0400457 mCanvas->drawPaint(paint);
458}
459
460// ----------------------------------------------------------------------------
461// Canvas draw operations: Geometry
462// ----------------------------------------------------------------------------
463
Derek Sollenbergeracb40992014-07-21 15:22:10 -0400464void SkiaCanvas::drawPoints(const float* points, int count, const SkPaint& paint,
Derek Sollenberger8872b382014-06-23 14:13:53 -0400465 SkCanvas::PointMode mode) {
Stan Ilievf50806a2016-10-24 10:40:39 -0400466 if (CC_UNLIKELY(count < 2 || PaintUtils::paintWillNotDraw(paint))) return;
Derek Sollenberger8872b382014-06-23 14:13:53 -0400467 // convert the floats into SkPoints
468 count >>= 1; // now it is the number of points
Ben Wagner6bbf68d2015-08-19 11:26:06 -0400469 std::unique_ptr<SkPoint[]> pts(new SkPoint[count]);
Derek Sollenberger8872b382014-06-23 14:13:53 -0400470 for (int i = 0; i < count; i++) {
471 pts[i].set(points[0], points[1]);
472 points += 2;
473 }
Ben Wagner6bbf68d2015-08-19 11:26:06 -0400474 mCanvas->drawPoints(mode, count, pts.get(), paint);
Derek Sollenberger8872b382014-06-23 14:13:53 -0400475}
476
477
Derek Sollenbergeracb40992014-07-21 15:22:10 -0400478void SkiaCanvas::drawPoint(float x, float y, const SkPaint& paint) {
Derek Sollenberger8872b382014-06-23 14:13:53 -0400479 mCanvas->drawPoint(x, y, paint);
480}
481
Derek Sollenbergeracb40992014-07-21 15:22:10 -0400482void SkiaCanvas::drawPoints(const float* points, int count, const SkPaint& paint) {
Derek Sollenberger8872b382014-06-23 14:13:53 -0400483 this->drawPoints(points, count, paint, SkCanvas::kPoints_PointMode);
484}
485
486void SkiaCanvas::drawLine(float startX, float startY, float stopX, float stopY,
Derek Sollenbergeracb40992014-07-21 15:22:10 -0400487 const SkPaint& paint) {
Derek Sollenberger8872b382014-06-23 14:13:53 -0400488 mCanvas->drawLine(startX, startY, stopX, stopY, paint);
489}
490
Derek Sollenbergeracb40992014-07-21 15:22:10 -0400491void SkiaCanvas::drawLines(const float* points, int count, const SkPaint& paint) {
Stan Ilievf50806a2016-10-24 10:40:39 -0400492 if (CC_UNLIKELY(count < 4 || PaintUtils::paintWillNotDraw(paint))) return;
Derek Sollenberger8872b382014-06-23 14:13:53 -0400493 this->drawPoints(points, count, paint, SkCanvas::kLines_PointMode);
494}
495
496void SkiaCanvas::drawRect(float left, float top, float right, float bottom,
Derek Sollenbergeracb40992014-07-21 15:22:10 -0400497 const SkPaint& paint) {
Stan Ilievf50806a2016-10-24 10:40:39 -0400498 if (CC_UNLIKELY(PaintUtils::paintWillNotDraw(paint))) return;
Derek Sollenberger8872b382014-06-23 14:13:53 -0400499 mCanvas->drawRectCoords(left, top, right, bottom, paint);
500
501}
502
Derek Sollenberger94394b32015-07-10 09:58:41 -0400503void SkiaCanvas::drawRegion(const SkRegion& region, const SkPaint& paint) {
Stan Ilievf50806a2016-10-24 10:40:39 -0400504 if (CC_UNLIKELY(PaintUtils::paintWillNotDraw(paint))) return;
505 mCanvas->drawRegion(region, paint);
Derek Sollenberger94394b32015-07-10 09:58:41 -0400506}
507
Derek Sollenberger8872b382014-06-23 14:13:53 -0400508void SkiaCanvas::drawRoundRect(float left, float top, float right, float bottom,
Derek Sollenbergeracb40992014-07-21 15:22:10 -0400509 float rx, float ry, const SkPaint& paint) {
Stan Ilievf50806a2016-10-24 10:40:39 -0400510 if (CC_UNLIKELY(PaintUtils::paintWillNotDraw(paint))) return;
Derek Sollenberger8872b382014-06-23 14:13:53 -0400511 SkRect rect = SkRect::MakeLTRB(left, top, right, bottom);
512 mCanvas->drawRoundRect(rect, rx, ry, paint);
513}
514
Derek Sollenbergeracb40992014-07-21 15:22:10 -0400515void SkiaCanvas::drawCircle(float x, float y, float radius, const SkPaint& paint) {
Stan Ilievf50806a2016-10-24 10:40:39 -0400516 if (CC_UNLIKELY(radius <= 0 || PaintUtils::paintWillNotDraw(paint))) return;
Derek Sollenberger8872b382014-06-23 14:13:53 -0400517 mCanvas->drawCircle(x, y, radius, paint);
518}
519
Derek Sollenbergeracb40992014-07-21 15:22:10 -0400520void SkiaCanvas::drawOval(float left, float top, float right, float bottom, const SkPaint& paint) {
Stan Ilievf50806a2016-10-24 10:40:39 -0400521 if (CC_UNLIKELY(PaintUtils::paintWillNotDraw(paint))) return;
Derek Sollenberger8872b382014-06-23 14:13:53 -0400522 SkRect oval = SkRect::MakeLTRB(left, top, right, bottom);
523 mCanvas->drawOval(oval, paint);
524}
525
526void SkiaCanvas::drawArc(float left, float top, float right, float bottom,
Derek Sollenbergeracb40992014-07-21 15:22:10 -0400527 float startAngle, float sweepAngle, bool useCenter, const SkPaint& paint) {
Stan Ilievf50806a2016-10-24 10:40:39 -0400528 if (CC_UNLIKELY(PaintUtils::paintWillNotDraw(paint))) return;
Derek Sollenberger8872b382014-06-23 14:13:53 -0400529 SkRect arc = SkRect::MakeLTRB(left, top, right, bottom);
530 mCanvas->drawArc(arc, startAngle, sweepAngle, useCenter, paint);
531}
532
Derek Sollenbergeracb40992014-07-21 15:22:10 -0400533void SkiaCanvas::drawPath(const SkPath& path, const SkPaint& paint) {
Stan Ilievf50806a2016-10-24 10:40:39 -0400534 if (CC_UNLIKELY(PaintUtils::paintWillNotDraw(paint))) return;
Derek Sollenbergerc1908132016-07-15 10:28:16 -0400535 SkRect rect;
536 SkRRect roundRect;
537 if (path.isOval(&rect)) {
538 mCanvas->drawOval(rect, paint);
539 } else if (path.isRRect(&roundRect)) {
540 mCanvas->drawRRect(roundRect, paint);
541 } else {
542 mCanvas->drawPath(path, paint);
543 }
Derek Sollenberger8872b382014-06-23 14:13:53 -0400544}
545
546void SkiaCanvas::drawVertices(SkCanvas::VertexMode vertexMode, int vertexCount,
547 const float* verts, const float* texs, const int* colors,
Derek Sollenbergeracb40992014-07-21 15:22:10 -0400548 const uint16_t* indices, int indexCount, const SkPaint& paint) {
Derek Sollenberger8872b382014-06-23 14:13:53 -0400549#ifndef SK_SCALAR_IS_FLOAT
550 SkDEBUGFAIL("SkScalar must be a float for these conversions to be valid");
551#endif
552 const int ptCount = vertexCount >> 1;
553 mCanvas->drawVertices(vertexMode, ptCount, (SkPoint*)verts, (SkPoint*)texs,
Mike Reedc2f31df2016-10-28 17:21:45 -0400554 (SkColor*)colors, indices, indexCount, paint);
Derek Sollenberger8872b382014-06-23 14:13:53 -0400555}
556
557// ----------------------------------------------------------------------------
558// Canvas draw operations: Bitmaps
559// ----------------------------------------------------------------------------
560
sergeyvaed7f582016-10-14 16:30:21 -0700561void SkiaCanvas::drawBitmap(Bitmap& bitmap, float left, float top, const SkPaint* paint) {
562 SkBitmap skBitmap;
563 bitmap.getSkBitmap(&skBitmap);
564 mCanvas->drawBitmap(skBitmap, left, top, paint);
Derek Sollenberger8872b382014-06-23 14:13:53 -0400565}
566
sergeyvfc9999502016-10-17 13:07:38 -0700567void SkiaCanvas::drawBitmap(Bitmap& hwuiBitmap, const SkMatrix& matrix, const SkPaint* paint) {
568 SkBitmap bitmap;
569 hwuiBitmap.getSkBitmap(&bitmap);
Mike Reed6acfe162016-11-18 17:21:09 -0500570 SkAutoCanvasRestore acr(mCanvas, true);
Mike Reed70ffbf92014-12-08 17:03:30 -0500571 mCanvas->concat(matrix);
572 mCanvas->drawBitmap(bitmap, 0, 0, paint);
Derek Sollenberger8872b382014-06-23 14:13:53 -0400573}
574
sergeyvfc9999502016-10-17 13:07:38 -0700575void SkiaCanvas::drawBitmap(Bitmap& hwuiBitmap, float srcLeft, float srcTop,
Derek Sollenberger8872b382014-06-23 14:13:53 -0400576 float srcRight, float srcBottom, float dstLeft, float dstTop,
Derek Sollenbergeracb40992014-07-21 15:22:10 -0400577 float dstRight, float dstBottom, const SkPaint* paint) {
sergeyvfc9999502016-10-17 13:07:38 -0700578 SkBitmap bitmap;
579 hwuiBitmap.getSkBitmap(&bitmap);
Derek Sollenberger8872b382014-06-23 14:13:53 -0400580 SkRect srcRect = SkRect::MakeLTRB(srcLeft, srcTop, srcRight, srcBottom);
581 SkRect dstRect = SkRect::MakeLTRB(dstLeft, dstTop, dstRight, dstBottom);
Leon Scroggins IIIf35b9892015-07-31 10:38:40 -0400582 mCanvas->drawBitmapRect(bitmap, srcRect, dstRect, paint);
Derek Sollenberger8872b382014-06-23 14:13:53 -0400583}
584
sergeyv5fd2a1c2016-10-20 15:04:28 -0700585void SkiaCanvas::drawBitmapMesh(Bitmap& hwuiBitmap, int meshWidth, int meshHeight,
Derek Sollenbergeracb40992014-07-21 15:22:10 -0400586 const float* vertices, const int* colors, const SkPaint* paint) {
sergeyv5fd2a1c2016-10-20 15:04:28 -0700587 SkBitmap bitmap;
588 hwuiBitmap.getSkBitmap(&bitmap);
Derek Sollenberger8872b382014-06-23 14:13:53 -0400589 const int ptCount = (meshWidth + 1) * (meshHeight + 1);
590 const int indexCount = meshWidth * meshHeight * 6;
591
592 /* Our temp storage holds 2 or 3 arrays.
593 texture points [ptCount * sizeof(SkPoint)]
594 optionally vertex points [ptCount * sizeof(SkPoint)] if we need a
595 copy to convert from float to fixed
596 indices [ptCount * sizeof(uint16_t)]
597 */
598 ssize_t storageSize = ptCount * sizeof(SkPoint); // texs[]
599 storageSize += indexCount * sizeof(uint16_t); // indices[]
600
601
602#ifndef SK_SCALAR_IS_FLOAT
603 SkDEBUGFAIL("SkScalar must be a float for these conversions to be valid");
604#endif
Ben Wagner6bbf68d2015-08-19 11:26:06 -0400605 std::unique_ptr<char[]> storage(new char[storageSize]);
Derek Sollenberger8872b382014-06-23 14:13:53 -0400606 SkPoint* texs = (SkPoint*)storage.get();
607 uint16_t* indices = (uint16_t*)(texs + ptCount);
608
609 // cons up texture coordinates and indices
610 {
611 const SkScalar w = SkIntToScalar(bitmap.width());
612 const SkScalar h = SkIntToScalar(bitmap.height());
613 const SkScalar dx = w / meshWidth;
614 const SkScalar dy = h / meshHeight;
615
616 SkPoint* texsPtr = texs;
617 SkScalar y = 0;
618 for (int i = 0; i <= meshHeight; i++) {
619 if (i == meshHeight) {
620 y = h; // to ensure numerically we hit h exactly
621 }
622 SkScalar x = 0;
623 for (int j = 0; j < meshWidth; j++) {
624 texsPtr->set(x, y);
625 texsPtr += 1;
626 x += dx;
627 }
628 texsPtr->set(w, y);
629 texsPtr += 1;
630 y += dy;
631 }
632 SkASSERT(texsPtr - texs == ptCount);
633 }
634
635 // cons up indices
636 {
637 uint16_t* indexPtr = indices;
638 int index = 0;
639 for (int i = 0; i < meshHeight; i++) {
640 for (int j = 0; j < meshWidth; j++) {
641 // lower-left triangle
642 *indexPtr++ = index;
643 *indexPtr++ = index + meshWidth + 1;
644 *indexPtr++ = index + meshWidth + 2;
645 // upper-right triangle
646 *indexPtr++ = index;
647 *indexPtr++ = index + meshWidth + 2;
648 *indexPtr++ = index + 1;
649 // bump to the next cell
650 index += 1;
651 }
652 // bump to the next row
653 index += 1;
654 }
655 SkASSERT(indexPtr - indices == indexCount);
656 SkASSERT((char*)indexPtr - (char*)storage.get() == storageSize);
657 }
658
659 // double-check that we have legal indices
660#ifdef SK_DEBUG
661 {
662 for (int i = 0; i < indexCount; i++) {
663 SkASSERT((unsigned)indices[i] < (unsigned)ptCount);
664 }
665 }
666#endif
667
668 // cons-up a shader for the bitmap
Derek Sollenbergeracb40992014-07-21 15:22:10 -0400669 SkPaint tmpPaint;
Derek Sollenberger8872b382014-06-23 14:13:53 -0400670 if (paint) {
671 tmpPaint = *paint;
672 }
Stan Ilievf50806a2016-10-24 10:40:39 -0400673
674 sk_sp<SkImage> image = SkMakeImageFromRasterBitmap(bitmap, kNever_SkCopyPixelsMode);
675 tmpPaint.setShader(image->makeShader(SkShader::kClamp_TileMode, SkShader::kClamp_TileMode));
Derek Sollenberger8872b382014-06-23 14:13:53 -0400676
677 mCanvas->drawVertices(SkCanvas::kTriangles_VertexMode, ptCount, (SkPoint*)vertices,
Mike Reedc2f31df2016-10-28 17:21:45 -0400678 texs, (const SkColor*)colors, indices,
Derek Sollenberger8872b382014-06-23 14:13:53 -0400679 indexCount, tmpPaint);
680}
681
sergeyv5fd2a1c2016-10-20 15:04:28 -0700682void SkiaCanvas::drawNinePatch(Bitmap& hwuiBitmap, const Res_png_9patch& chunk,
Derek Sollenbergeredca3202015-07-10 13:56:39 -0400683 float dstLeft, float dstTop, float dstRight, float dstBottom, const SkPaint* paint) {
Stan Ilievf50806a2016-10-24 10:40:39 -0400684
sergeyv5fd2a1c2016-10-20 15:04:28 -0700685 SkBitmap bitmap;
686 hwuiBitmap.getSkBitmap(&bitmap);
Stan Ilievf50806a2016-10-24 10:40:39 -0400687
688 SkCanvas::Lattice lattice;
Matt Sarett7de73852016-10-25 18:36:39 -0400689 NinePatchUtils::SetLatticeDivs(&lattice, chunk, bitmap.width(), bitmap.height());
Stan Ilievf50806a2016-10-24 10:40:39 -0400690
691 lattice.fFlags = nullptr;
692 int numFlags = 0;
Stan Iliev021693b2016-10-17 16:26:15 -0400693 if (chunk.numColors > 0 && chunk.numColors == NinePatchUtils::NumDistinctRects(lattice)) {
Stan Ilievf50806a2016-10-24 10:40:39 -0400694 // We can expect the framework to give us a color for every distinct rect.
695 // Skia requires a flag for every rect.
696 numFlags = (lattice.fXCount + 1) * (lattice.fYCount + 1);
697 }
698
699 SkAutoSTMalloc<25, SkCanvas::Lattice::Flags> flags(numFlags);
700 if (numFlags > 0) {
Stan Iliev021693b2016-10-17 16:26:15 -0400701 NinePatchUtils::SetLatticeFlags(&lattice, flags.get(), numFlags, chunk);
Stan Ilievf50806a2016-10-24 10:40:39 -0400702 }
703
704 lattice.fBounds = nullptr;
705 SkRect dst = SkRect::MakeLTRB(dstLeft, dstTop, dstRight, dstBottom);
706 mCanvas->drawBitmapLattice(bitmap, lattice, dst, paint);
Derek Sollenbergeredca3202015-07-10 13:56:39 -0400707}
708
Doris Liu766431a2016-02-04 22:17:11 +0000709void SkiaCanvas::drawVectorDrawable(VectorDrawableRoot* vectorDrawable) {
Doris Liu1d8e1942016-03-02 15:16:28 -0800710 vectorDrawable->drawStaging(this);
Doris Liu766431a2016-02-04 22:17:11 +0000711}
712
Derek Sollenberger8872b382014-06-23 14:13:53 -0400713// ----------------------------------------------------------------------------
714// Canvas draw operations: Text
715// ----------------------------------------------------------------------------
716
sergeyvdccca442016-03-21 15:38:21 -0700717void SkiaCanvas::drawGlyphs(const uint16_t* text, const float* positions, int count,
Derek Sollenbergeracb40992014-07-21 15:22:10 -0400718 const SkPaint& paint, float x, float y,
Tom Hudson8dfaa492014-12-09 15:03:44 -0500719 float boundsLeft, float boundsTop, float boundsRight, float boundsBottom,
720 float totalAdvance) {
Stan Ilievf50806a2016-10-24 10:40:39 -0400721 if (!text || !positions || count <= 0 || PaintUtils::paintWillNotDrawText(paint)) return;
722 // Set align to left for drawing, as we don't want individual
723 // glyphs centered or right-aligned; the offset above takes
724 // care of all alignment.
725 SkPaint paintCopy(paint);
726 paintCopy.setTextAlign(SkPaint::kLeft_Align);
727
728 SkRect bounds = SkRect::MakeLTRB(boundsLeft + x, boundsTop + y,
729 boundsRight + x, boundsBottom + y);
730
731 SkTextBlobBuilder builder;
732 const SkTextBlobBuilder::RunBuffer& buffer = builder.allocRunPos(paintCopy, count, &bounds);
733 // TODO: we could reduce the number of memcpy's if the this were exposed further up
734 // in the architecture.
735 memcpy(buffer.glyphs, text, count * sizeof(uint16_t));
736 memcpy(buffer.pos, positions, (count << 1) * sizeof(float));
737
738 sk_sp<SkTextBlob> textBlob(builder.make());
739 mCanvas->drawTextBlob(textBlob, 0, 0, paintCopy);
740 drawTextDecorations(x, y, totalAdvance, paintCopy);
Derek Sollenberger8872b382014-06-23 14:13:53 -0400741}
742
Yuqian Liafc221492016-07-18 13:07:42 -0400743void SkiaCanvas::drawLayoutOnPath(const minikin::Layout& layout, float hOffset, float vOffset,
744 const SkPaint& paint, const SkPath& path, size_t start, size_t end) {
745 const int N = end - start;
Derek Sollenbergere547dd02016-11-09 11:55:59 -0500746 SkAutoSTMalloc<1024, uint8_t> storage(N * (sizeof(uint16_t) + sizeof(SkRSXform)));
Yuqian Liafc221492016-07-18 13:07:42 -0400747 SkRSXform* xform = (SkRSXform*)storage.get();
748 uint16_t* glyphs = (uint16_t*)(xform + N);
749 SkPathMeasure meas(path, false);
750
751 for (size_t i = start; i < end; i++) {
752 glyphs[i - start] = layout.getGlyphId(i);
753 float x = hOffset + layout.getX(i);
754 float y = vOffset + layout.getY(i);
755
756 SkPoint pos;
757 SkVector tan;
758 if (!meas.getPosTan(x, &pos, &tan)) {
759 pos.set(x, y);
760 tan.set(1, 0);
761 }
762 xform[i - start].fSCos = tan.x();
763 xform[i - start].fSSin = tan.y();
764 xform[i - start].fTx = pos.x() - tan.y() * y;
765 xform[i - start].fTy = pos.y() + tan.x() * y;
766 }
767
768 this->asSkCanvas()->drawTextRSXform(glyphs, sizeof(uint16_t) * N, xform, nullptr, paint);
Derek Sollenberger8872b382014-06-23 14:13:53 -0400769}
770
Derek Sollenberger6f485562015-07-30 10:00:39 -0400771// ----------------------------------------------------------------------------
772// Canvas draw operations: Animations
773// ----------------------------------------------------------------------------
774
Derek Sollenberger6f485562015-07-30 10:00:39 -0400775void SkiaCanvas::drawRoundRect(uirenderer::CanvasPropertyPrimitive* left,
776 uirenderer::CanvasPropertyPrimitive* top, uirenderer::CanvasPropertyPrimitive* right,
777 uirenderer::CanvasPropertyPrimitive* bottom, uirenderer::CanvasPropertyPrimitive* rx,
778 uirenderer::CanvasPropertyPrimitive* ry, uirenderer::CanvasPropertyPaint* paint) {
Stan Iliev021693b2016-10-17 16:26:15 -0400779 sk_sp<uirenderer::skiapipeline::AnimatedRoundRect> drawable(
780 new uirenderer::skiapipeline::AnimatedRoundRect(left, top, right, bottom, rx, ry, paint));
Derek Sollenberger6f485562015-07-30 10:00:39 -0400781 mCanvas->drawDrawable(drawable.get());
782}
783
784void SkiaCanvas::drawCircle(uirenderer::CanvasPropertyPrimitive* x, uirenderer::CanvasPropertyPrimitive* y,
785 uirenderer::CanvasPropertyPrimitive* radius, uirenderer::CanvasPropertyPaint* paint) {
Stan Iliev021693b2016-10-17 16:26:15 -0400786 sk_sp<uirenderer::skiapipeline::AnimatedCircle> drawable(new uirenderer::skiapipeline::AnimatedCircle(x, y, radius, paint));
Derek Sollenberger6f485562015-07-30 10:00:39 -0400787 mCanvas->drawDrawable(drawable.get());
788}
789
790// ----------------------------------------------------------------------------
791// Canvas draw operations: View System
792// ----------------------------------------------------------------------------
793
Stan Ilievf50806a2016-10-24 10:40:39 -0400794void SkiaCanvas::drawLayer(uirenderer::DeferredLayerUpdater* layerUpdater) {
Derek Sollenbergerc1908132016-07-15 10:28:16 -0400795 LOG_ALWAYS_FATAL("SkiaCanvas can't directly draw Layers");
796}
Derek Sollenberger6f485562015-07-30 10:00:39 -0400797
Derek Sollenbergerc1908132016-07-15 10:28:16 -0400798void SkiaCanvas::drawRenderNode(uirenderer::RenderNode* renderNode) {
799 LOG_ALWAYS_FATAL("SkiaCanvas can't directly draw RenderNodes");
800}
Derek Sollenberger6f485562015-07-30 10:00:39 -0400801
John Reckcd1c3eb2016-04-14 10:38:54 -0700802void SkiaCanvas::callDrawGLFunction(Functor* functor,
Derek Sollenbergerc1908132016-07-15 10:28:16 -0400803 uirenderer::GlFunctorLifecycleListener* listener) {
804 LOG_ALWAYS_FATAL("SkiaCanvas can't directly draw GL Content");
805}
Derek Sollenberger6f485562015-07-30 10:00:39 -0400806
Derek Sollenberger8872b382014-06-23 14:13:53 -0400807} // namespace android