Debian Codegraph @

libs/hwui/RecordingCanvas.cpp

raw symbols SCIP
1 /*
2 * Copyright (C) 2018 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #include "RecordingCanvas.h"
18 #include <hwui/Paint.h>
19
20 #include <GrRecordingContext.h>
21
22 #include <experimental/type_traits>
23
24 #include "SkAndroidFrameworkUtils.h"
25 #include "SkCanvas.h"
26 #include "SkCanvasPriv.h"
27 #include "SkColor.h"
28 #include "SkData.h"
29 #include "SkDrawShadowInfo.h"
30 #include "SkImage.h"
31 #include "SkImageFilter.h"
32 #include "SkLatticeIter.h"
33 #include "SkMath.h"
34 #include "SkPicture.h"
35 #include "SkRSXform.h"
36 #include "SkRegion.h"
37 #include "SkTextBlob.h"
38 #include "SkVertices.h"
39 #include "VectorDrawable.h"
40 #include "pipeline/skia/AnimatedDrawables.h"
41 #include "pipeline/skia/FunctorDrawable.h"
42
43 namespace android {
44 namespace uirenderer {
45
46 #ifndef SKLITEDL_PAGE
47 #define SKLITEDL_PAGE 4096
48 #endif
49
50 // A stand-in for an optional SkRect which was not set, e.g. bounds for a saveLayer().
51 static const SkRect kUnset = {SK_ScalarInfinity, 0, 0, 0};
52 static const SkRect* maybe_unset(const SkRect& r) {
53 return r.left() == SK_ScalarInfinity ? nullptr : &r;
54 }
55
56 // copy_v(dst, src,n, src,n, ...) copies an arbitrary number of typed srcs into dst.
57 static void copy_v(void* dst) {}
58
59 template <typename S, typename... Rest>
60 static void copy_v(void* dst, const S* src, int n, Rest&&... rest) {
61 SkASSERTF(((uintptr_t)dst & (alignof(S) - 1)) == 0,
62 "Expected %p to be aligned for at least %zu bytes.", dst, alignof(S));
63 sk_careful_memcpy(dst, src, n * sizeof(S));
64 copy_v(SkTAddOffset<void>(dst, n * sizeof(S)), std::forward<Rest>(rest)...);
65 }
66
67 // Helper for getting back at arrays which have been copy_v'd together after an Op.
68 template <typename D, typename T>
69 static const D* pod(const T* op, size_t offset = 0) {
70 return SkTAddOffset<const D>(op + 1, offset);
71 }
72
73 namespace {
74
75 #define X(T) T,
76 enum class Type : uint8_t {
77 #include "DisplayListOps.in"
78 };
79 #undef X
80
81 struct Op {
82 uint32_t type : 8;
83 uint32_t skip : 24;
84 };
85 static_assert(sizeof(Op) == 4, "");
86
87 struct Flush final : Op {
88 static const auto kType = Type::Flush;
89 void draw(SkCanvas* c, const SkMatrix&) const { c->flush(); }
90 };
91
92 struct Save final : Op {
93 static const auto kType = Type::Save;
94 void draw(SkCanvas* c, const SkMatrix&) const { c->save(); }
95 };
96 struct Restore final : Op {
97 static const auto kType = Type::Restore;
98 void draw(SkCanvas* c, const SkMatrix&) const { c->restore(); }
99 };
100 struct SaveLayer final : Op {
101 static const auto kType = Type::SaveLayer;
102 SaveLayer(const SkRect* bounds, const SkPaint* paint, const SkImageFilter* backdrop,
103 SkCanvas::SaveLayerFlags flags) {
104 if (bounds) {
105 this->bounds = *bounds;
106 }
107 if (paint) {
108 this->paint = *paint;
109 }
110 this->backdrop = sk_ref_sp(backdrop);
111 this->flags = flags;
112 }
113 SkRect bounds = kUnset;
114 SkPaint paint;
115 sk_sp<const SkImageFilter> backdrop;
116 SkCanvas::SaveLayerFlags flags;
117 void draw(SkCanvas* c, const SkMatrix&) const {
118 c->saveLayer({maybe_unset(bounds), &paint, backdrop.get(), flags});
119 }
120 };
121 struct SaveBehind final : Op {
122 static const auto kType = Type::SaveBehind;
123 SaveBehind(const SkRect* subset) {
124 if (subset) { this->subset = *subset; }
125 }
126 SkRect subset = kUnset;
127 void draw(SkCanvas* c, const SkMatrix&) const {
128 SkAndroidFrameworkUtils::SaveBehind(c, &subset);
129 }
130 };
131
132 struct Concat final : Op {
133 static const auto kType = Type::Concat;
134 Concat(const SkM44& matrix) : matrix(matrix) {}
135 SkM44 matrix;
136 void draw(SkCanvas* c, const SkMatrix&) const { c->concat(matrix); }
137 };
138 struct SetMatrix final : Op {
139 static const auto kType = Type::SetMatrix;
140 SetMatrix(const SkM44& matrix) : matrix(matrix) {}
141 SkM44 matrix;
142 void draw(SkCanvas* c, const SkMatrix& original) const {
143 c->setMatrix(SkM44(original) * matrix);
144 }
145 };
146 struct Scale final : Op {
147 static const auto kType = Type::Scale;
148 Scale(SkScalar sx, SkScalar sy) : sx(sx), sy(sy) {}
149 SkScalar sx, sy;
150 void draw(SkCanvas* c, const SkMatrix&) const { c->scale(sx, sy); }
151 };
152 struct Translate final : Op {
153 static const auto kType = Type::Translate;
154 Translate(SkScalar dx, SkScalar dy) : dx(dx), dy(dy) {}
155 SkScalar dx, dy;
156 void draw(SkCanvas* c, const SkMatrix&) const { c->translate(dx, dy); }
157 };
158
159 struct ClipPath final : Op {
160 static const auto kType = Type::ClipPath;
161 ClipPath(const SkPath& path, SkClipOp op, bool aa) : path(path), op(op), aa(aa) {}
162 SkPath path;
163 SkClipOp op;
164 bool aa;
165 void draw(SkCanvas* c, const SkMatrix&) const { c->clipPath(path, op, aa); }
166 };
167 struct ClipRect final : Op {
168 static const auto kType = Type::ClipRect;
169 ClipRect(const SkRect& rect, SkClipOp op, bool aa) : rect(rect), op(op), aa(aa) {}
170 SkRect rect;
171 SkClipOp op;
172 bool aa;
173 void draw(SkCanvas* c, const SkMatrix&) const { c->clipRect(rect, op, aa); }
174 };
175 struct ClipRRect final : Op {
176 static const auto kType = Type::ClipRRect;
177 ClipRRect(const SkRRect& rrect, SkClipOp op, bool aa) : rrect(rrect), op(op), aa(aa) {}
178 SkRRect rrect;
179 SkClipOp op;
180 bool aa;
181 void draw(SkCanvas* c, const SkMatrix&) const { c->clipRRect(rrect, op, aa); }
182 };
183 struct ClipRegion final : Op {
184 static const auto kType = Type::ClipRegion;
185 ClipRegion(const SkRegion& region, SkClipOp op) : region(region), op(op) {}
186 SkRegion region;
187 SkClipOp op;
188 void draw(SkCanvas* c, const SkMatrix&) const { c->clipRegion(region, op); }
189 };
190 struct ResetClip final : Op {
191 static const auto kType = Type::ResetClip;
192 ResetClip() {}
193 void draw(SkCanvas* c, const SkMatrix&) const { SkAndroidFrameworkUtils::ResetClip(c); }
194 };
195
196 struct DrawPaint final : Op {
197 static const auto kType = Type::DrawPaint;
198 DrawPaint(const SkPaint& paint) : paint(paint) {}
199 SkPaint paint;
200 void draw(SkCanvas* c, const SkMatrix&) const { c->drawPaint(paint); }
201 };
202 struct DrawBehind final : Op {
203 static const auto kType = Type::DrawBehind;
204 DrawBehind(const SkPaint& paint) : paint(paint) {}
205 SkPaint paint;
206 void draw(SkCanvas* c, const SkMatrix&) const { SkCanvasPriv::DrawBehind(c, paint); }
207 };
208 struct DrawPath final : Op {
209 static const auto kType = Type::DrawPath;
210 DrawPath(const SkPath& path, const SkPaint& paint) : path(path), paint(paint) {}
211 SkPath path;
212 SkPaint paint;
213 void draw(SkCanvas* c, const SkMatrix&) const { c->drawPath(path, paint); }
214 };
215 struct DrawRect final : Op {
216 static const auto kType = Type::DrawRect;
217 DrawRect(const SkRect& rect, const SkPaint& paint) : rect(rect), paint(paint) {}
218 SkRect rect;
219 SkPaint paint;
220 void draw(SkCanvas* c, const SkMatrix&) const { c->drawRect(rect, paint); }
221 };
222 struct DrawRegion final : Op {
223 static const auto kType = Type::DrawRegion;
224 DrawRegion(const SkRegion& region, const SkPaint& paint) : region(region), paint(paint) {}
225 SkRegion region;
226 SkPaint paint;
227 void draw(SkCanvas* c, const SkMatrix&) const { c->drawRegion(region, paint); }
228 };
229 struct DrawOval final : Op {
230 static const auto kType = Type::DrawOval;
231 DrawOval(const SkRect& oval, const SkPaint& paint) : oval(oval), paint(paint) {}
232 SkRect oval;
233 SkPaint paint;
234 void draw(SkCanvas* c, const SkMatrix&) const { c->drawOval(oval, paint); }
235 };
236 struct DrawArc final : Op {
237 static const auto kType = Type::DrawArc;
238 DrawArc(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle, bool useCenter,
239 const SkPaint& paint)
240 : oval(oval)
241 , startAngle(startAngle)
242 , sweepAngle(sweepAngle)
243 , useCenter(useCenter)
244 , paint(paint) {}
245 SkRect oval;
246 SkScalar startAngle;
247 SkScalar sweepAngle;
248 bool useCenter;
249 SkPaint paint;
250 void draw(SkCanvas* c, const SkMatrix&) const {
251 c->drawArc(oval, startAngle, sweepAngle, useCenter, paint);
252 }
253 };
254 struct DrawRRect final : Op {
255 static const auto kType = Type::DrawRRect;
256 DrawRRect(const SkRRect& rrect, const SkPaint& paint) : rrect(rrect), paint(paint) {}
257 SkRRect rrect;
258 SkPaint paint;
259 void draw(SkCanvas* c, const SkMatrix&) const { c->drawRRect(rrect, paint); }
260 };
261 struct DrawDRRect final : Op {
262 static const auto kType = Type::DrawDRRect;
263 DrawDRRect(const SkRRect& outer, const SkRRect& inner, const SkPaint& paint)
264 : outer(outer), inner(inner), paint(paint) {}
265 SkRRect outer, inner;
266 SkPaint paint;
267 void draw(SkCanvas* c, const SkMatrix&) const { c->drawDRRect(outer, inner, paint); }
268 };
269
270 struct DrawAnnotation final : Op {
271 static const auto kType = Type::DrawAnnotation;
272 DrawAnnotation(const SkRect& rect, SkData* value) : rect(rect), value(sk_ref_sp(value)) {}
273 SkRect rect;
274 sk_sp<SkData> value;
275 void draw(SkCanvas* c, const SkMatrix&) const {
276 c->drawAnnotation(rect, pod<char>(this), value.get());
277 }
278 };
279 struct DrawDrawable final : Op {
280 static const auto kType = Type::DrawDrawable;
281 DrawDrawable(SkDrawable* drawable, const SkMatrix* matrix) : drawable(sk_ref_sp(drawable)) {
282 if (matrix) {
283 this->matrix = *matrix;
284 }
285 }
286 sk_sp<SkDrawable> drawable;
287 SkMatrix matrix = SkMatrix::I();
288 // It is important that we call drawable->draw(c) here instead of c->drawDrawable(drawable).
289 // Drawables are mutable and in cases, like RenderNodeDrawable, are not expected to produce the
290 // same content if retained outside the duration of the frame. Therefore we resolve
291 // them now and do not allow the canvas to take a reference to the drawable and potentially
292 // keep it alive for longer than the frames duration (e.g. SKP serialization).
293 void draw(SkCanvas* c, const SkMatrix&) const { drawable->draw(c, &matrix); }
294 };
295 struct DrawPicture final : Op {
296 static const auto kType = Type::DrawPicture;
297 DrawPicture(const SkPicture* picture, const SkMatrix* matrix, const SkPaint* paint)
298 : picture(sk_ref_sp(picture)) {
299 if (matrix) {
300 this->matrix = *matrix;
301 }
302 if (paint) {
303 this->paint = *paint;
304 has_paint = true;
305 }
306 }
307 sk_sp<const SkPicture> picture;
308 SkMatrix matrix = SkMatrix::I();
309 SkPaint paint;
310 bool has_paint = false; // TODO: why is a default paint not the same?
311 void draw(SkCanvas* c, const SkMatrix&) const {
312 c->drawPicture(picture.get(), &matrix, has_paint ? &paint : nullptr);
313 }
314 };
315
316 struct DrawImage final : Op {
317 static const auto kType = Type::DrawImage;
318 DrawImage(sk_sp<const SkImage>&& image, SkScalar x, SkScalar y,
319 const SkSamplingOptions& sampling, const SkPaint* paint, BitmapPalette palette)
320 : image(std::move(image)), x(x), y(y), sampling(sampling), palette(palette) {
321 if (paint) {
322 this->paint = *paint;
323 }
324 }
325 sk_sp<const SkImage> image;
326 SkScalar x, y;
327 SkSamplingOptions sampling;
328 SkPaint paint;
329 BitmapPalette palette;
330 void draw(SkCanvas* c, const SkMatrix&) const {
331 c->drawImage(image.get(), x, y, sampling, &paint);
332 }
333 };
334 struct DrawImageRect final : Op {
335 static const auto kType = Type::DrawImageRect;
336 DrawImageRect(sk_sp<const SkImage>&& image, const SkRect* src, const SkRect& dst,
337 const SkSamplingOptions& sampling, const SkPaint* paint,
338 SkCanvas::SrcRectConstraint constraint, BitmapPalette palette)
339 : image(std::move(image)), dst(dst), sampling(sampling), constraint(constraint)
340 , palette(palette) {
341 this->src = src ? *src : SkRect::MakeIWH(this->image->width(), this->image->height());
342 if (paint) {
343 this->paint = *paint;
344 }
345 }
346 sk_sp<const SkImage> image;
347 SkRect src, dst;
348 SkSamplingOptions sampling;
349 SkPaint paint;
350 SkCanvas::SrcRectConstraint constraint;
351 BitmapPalette palette;
352 void draw(SkCanvas* c, const SkMatrix&) const {
353 c->drawImageRect(image.get(), src, dst, sampling, &paint, constraint);
354 }
355 };
356 struct DrawImageLattice final : Op {
357 static const auto kType = Type::DrawImageLattice;
358 DrawImageLattice(sk_sp<const SkImage>&& image, int xs, int ys, int fs, const SkIRect& src,
359 const SkRect& dst, SkFilterMode filter, const SkPaint* paint,
360 BitmapPalette palette)
361 : image(std::move(image))
362 , xs(xs)
363 , ys(ys)
364 , fs(fs)
365 , src(src)
366 , dst(dst)
367 , filter(filter)
368 , palette(palette) {
369 if (paint) {
370 this->paint = *paint;
371 }
372 }
373 sk_sp<const SkImage> image;
374 int xs, ys, fs;
375 SkIRect src;
376 SkRect dst;
377 SkFilterMode filter;
378 SkPaint paint;
379 BitmapPalette palette;
380 void draw(SkCanvas* c, const SkMatrix&) const {
381 auto xdivs = pod<int>(this, 0), ydivs = pod<int>(this, xs * sizeof(int));
382 auto colors = (0 == fs) ? nullptr : pod<SkColor>(this, (xs + ys) * sizeof(int));
383 auto flags =
384 (0 == fs) ? nullptr : pod<SkCanvas::Lattice::RectType>(
385 this, (xs + ys) * sizeof(int) + fs * sizeof(SkColor));
386 c->drawImageLattice(image.get(), {xdivs, ydivs, flags, xs, ys, &src, colors}, dst,
387 filter, &paint);
388 }
389 };
390
391 struct DrawTextBlob final : Op {
392 static const auto kType = Type::DrawTextBlob;
393 DrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y, const SkPaint& paint)
394 : blob(sk_ref_sp(blob)), x(x), y(y), paint(paint), drawTextBlobMode(gDrawTextBlobMode) {}
395 sk_sp<const SkTextBlob> blob;
396 SkScalar x, y;
397 SkPaint paint;
398 DrawTextBlobMode drawTextBlobMode;
399 void draw(SkCanvas* c, const SkMatrix&) const { c->drawTextBlob(blob.get(), x, y, paint); }
400 };
401
402 struct DrawPatch final : Op {
403 static const auto kType = Type::DrawPatch;
404 DrawPatch(const SkPoint cubics[12], const SkColor colors[4], const SkPoint texs[4],
405 SkBlendMode bmode, const SkPaint& paint)
406 : xfermode(bmode), paint(paint) {
407 copy_v(this->cubics, cubics, 12);
408 if (colors) {
409 copy_v(this->colors, colors, 4);
410 has_colors = true;
411 }
412 if (texs) {
413 copy_v(this->texs, texs, 4);
414 has_texs = true;
415 }
416 }
417 SkPoint cubics[12];
418 SkColor colors[4];
419 SkPoint texs[4];
420 SkBlendMode xfermode;
421 SkPaint paint;
422 bool has_colors = false;
423 bool has_texs = false;
424 void draw(SkCanvas* c, const SkMatrix&) const {
425 c->drawPatch(cubics, has_colors ? colors : nullptr, has_texs ? texs : nullptr, xfermode,
426 paint);
427 }
428 };
429 struct DrawPoints final : Op {
430 static const auto kType = Type::DrawPoints;
431 DrawPoints(SkCanvas::PointMode mode, size_t count, const SkPaint& paint)
432 : mode(mode), count(count), paint(paint) {}
433 SkCanvas::PointMode mode;
434 size_t count;
435 SkPaint paint;
436 void draw(SkCanvas* c, const SkMatrix&) const {
437 c->drawPoints(mode, count, pod<SkPoint>(this), paint);
438 }
439 };
440 struct DrawVertices final : Op {
441 static const auto kType = Type::DrawVertices;
442 DrawVertices(const SkVertices* v, SkBlendMode m, const SkPaint& p)
443 : vertices(sk_ref_sp(const_cast<SkVertices*>(v))), mode(m), paint(p) {}
444 sk_sp<SkVertices> vertices;
445 SkBlendMode mode;
446 SkPaint paint;
447 void draw(SkCanvas* c, const SkMatrix&) const {
448 c->drawVertices(vertices, mode, paint);
449 }
450 };
451 struct DrawAtlas final : Op {
452 static const auto kType = Type::DrawAtlas;
453 DrawAtlas(const SkImage* atlas, int count, SkBlendMode mode, const SkSamplingOptions& sampling,
454 const SkRect* cull, const SkPaint* paint, bool has_colors)
455 : atlas(sk_ref_sp(atlas)), count(count), mode(mode), sampling(sampling)
456 , has_colors(has_colors) {
457 if (cull) {
458 this->cull = *cull;
459 }
460 if (paint) {
461 this->paint = *paint;
462 }
463 }
464 sk_sp<const SkImage> atlas;
465 int count;
466 SkBlendMode mode;
467 SkSamplingOptions sampling;
468 SkRect cull = kUnset;
469 SkPaint paint;
470 bool has_colors;
471 void draw(SkCanvas* c, const SkMatrix&) const {
472 auto xforms = pod<SkRSXform>(this, 0);
473 auto texs = pod<SkRect>(this, count * sizeof(SkRSXform));
474 auto colors = has_colors ? pod<SkColor>(this, count * (sizeof(SkRSXform) + sizeof(SkRect)))
475 : nullptr;
476 c->drawAtlas(atlas.get(), xforms, texs, colors, count, mode, sampling, maybe_unset(cull),
477 &paint);
478 }
479 };
480 struct DrawShadowRec final : Op {
481 static const auto kType = Type::DrawShadowRec;
482 DrawShadowRec(const SkPath& path, const SkDrawShadowRec& rec) : fPath(path), fRec(rec) {}
483 SkPath fPath;
484 SkDrawShadowRec fRec;
485 void draw(SkCanvas* c, const SkMatrix&) const { c->private_draw_shadow_rec(fPath, fRec); }
486 };
487
488 struct DrawVectorDrawable final : Op {
489 static const auto kType = Type::DrawVectorDrawable;
490 DrawVectorDrawable(VectorDrawableRoot* tree)
491 : mRoot(tree)
492 , mBounds(tree->stagingProperties().getBounds())
493 , palette(tree->computePalette()) {
494 // Recording, so use staging properties
495 tree->getPaintFor(&paint, tree->stagingProperties());
496 }
497
498 void draw(SkCanvas* canvas, const SkMatrix&) const {
499 mRoot->draw(canvas, mBounds, paint);
500 }
501
502 sp<VectorDrawableRoot> mRoot;
503 SkRect mBounds;
504 Paint paint;
505 BitmapPalette palette;
506 };
507
508 struct DrawRippleDrawable final : Op {
509 static const auto kType = Type::DrawRippleDrawable;
510 DrawRippleDrawable(const skiapipeline::RippleDrawableParams& params) : mParams(params) {}
511
512 void draw(SkCanvas* canvas, const SkMatrix&) const {
513 skiapipeline::AnimatedRippleDrawable::draw(canvas, mParams);
514 }
515
516 skiapipeline::RippleDrawableParams mParams;
517 };
518
519 struct DrawWebView final : Op {
520 static const auto kType = Type::DrawWebView;
521 DrawWebView(skiapipeline::FunctorDrawable* drawable) : drawable(sk_ref_sp(drawable)) {}
522 sk_sp<skiapipeline::FunctorDrawable> drawable;
523 // We can't invoke SkDrawable::draw directly, because VkFunctorDrawable expects
524 // SkDrawable::onSnapGpuDrawHandler callback instead of SkDrawable::onDraw.
525 // SkCanvas::drawDrawable/SkGpuDevice::drawDrawable has the logic to invoke
526 // onSnapGpuDrawHandler.
527 private:
528 // Unfortunately WebView does not have complex clip information serialized, and we only perform
529 // best-effort stencil fill for GLES. So for Vulkan we create an intermediate layer if the
530 // canvas clip is complex.
531 static bool needsCompositedLayer(SkCanvas* c) {
532 if (Properties::getRenderPipelineType() != RenderPipelineType::SkiaVulkan) {
533 return false;
534 }
535 SkRegion clipRegion;
536 // WebView's rasterizer has access to simple clips, so for Vulkan we only need to check if
537 // the clip is more complex than a rectangle.
538 c->temporary_internal_getRgnClip(&clipRegion);
539 return clipRegion.isComplex();
540 }
541
542 mutable SkImageInfo mLayerImageInfo;
543 mutable sk_sp<SkSurface> mLayerSurface = nullptr;
544
545 public:
546 void draw(SkCanvas* c, const SkMatrix&) const {
547 if (needsCompositedLayer(c)) {
548 // What we do now is create an offscreen surface, sized by the clip bounds.
549 // We won't apply a clip while drawing - clipping will be performed when compositing the
550 // surface back onto the original canvas. Note also that we're not using saveLayer
551 // because the webview functor still doesn't respect the canvas clip stack.
552 const SkIRect deviceBounds = c->getDeviceClipBounds();
553 if (mLayerSurface == nullptr || c->imageInfo() != mLayerImageInfo) {
554 GrRecordingContext* directContext = c->recordingContext();
555 mLayerImageInfo =
556 c->imageInfo().makeWH(deviceBounds.width(), deviceBounds.height());
557 mLayerSurface = SkSurface::MakeRenderTarget(directContext, SkBudgeted::kYes,
558 mLayerImageInfo, 0,
559 kTopLeft_GrSurfaceOrigin, nullptr);
560 }
561
562 SkCanvas* layerCanvas = mLayerSurface->getCanvas();
563
564 SkAutoCanvasRestore(layerCanvas, true);
565 layerCanvas->clear(SK_ColorTRANSPARENT);
566
567 // Preserve the transform from the original canvas, but now the clip rectangle is
568 // anchored at the origin so we need to transform the clipped content to the origin.
569 SkM44 mat4(c->getLocalToDevice());
570 mat4.postTranslate(-deviceBounds.fLeft, -deviceBounds.fTop);
571 layerCanvas->concat(mat4);
572 layerCanvas->drawDrawable(drawable.get());
573
574 SkAutoCanvasRestore acr(c, true);
575
576 // Temporarily use an identity transform, because this is just blitting to the parent
577 // canvas with an offset.
578 SkMatrix invertedMatrix;
579 if (!c->getTotalMatrix().invert(&invertedMatrix)) {
580 ALOGW("Unable to extract invert canvas matrix; aborting VkFunctor draw");
581 return;
582 }
583 c->concat(invertedMatrix);
584 mLayerSurface->draw(c, deviceBounds.fLeft, deviceBounds.fTop);
585 } else {
586 c->drawDrawable(drawable.get());
587 }
588 }
589 };
590 }
591
592 template <typename T, typename... Args>
593 void* DisplayListData::push(size_t pod, Args&&... args) {
594 size_t skip = SkAlignPtr(sizeof(T) + pod);
595 SkASSERT(skip < (1 << 24));
596 if (fUsed + skip > fReserved) {
597 static_assert(SkIsPow2(SKLITEDL_PAGE), "This math needs updating for non-pow2.");
598 // Next greater multiple of SKLITEDL_PAGE.
599 fReserved = (fUsed + skip + SKLITEDL_PAGE) & ~(SKLITEDL_PAGE - 1);
600 fBytes.realloc(fReserved);
601 LOG_ALWAYS_FATAL_IF(fBytes.get() == nullptr, "realloc(%zd) failed", fReserved);
602 }
603 SkASSERT(fUsed + skip <= fReserved);
604 auto op = (T*)(fBytes.get() + fUsed);
605 fUsed += skip;
606 new (op) T{std::forward<Args>(args)...};
607 op->type = (uint32_t)T::kType;
608 op->skip = skip;
609 return op + 1;
610 }
611
612 template <typename Fn, typename... Args>
613 inline void DisplayListData::map(const Fn fns[], Args... args) const {
614 auto end = fBytes.get() + fUsed;
615 for (const uint8_t* ptr = fBytes.get(); ptr < end;) {
616 auto op = (const Op*)ptr;
617 auto type = op->type;
618 auto skip = op->skip;
619 if (auto fn = fns[type]) { // We replace no-op functions with nullptrs
620 fn(op, args...); // to avoid the overhead of a pointless call.
621 }
622 ptr += skip;
623 }
624 }
625
626 void DisplayListData::flush() {
627 this->push<Flush>(0);
628 }
629
630 void DisplayListData::save() {
631 this->push<Save>(0);
632 }
633 void DisplayListData::restore() {
634 this->push<Restore>(0);
635 }
636 void DisplayListData::saveLayer(const SkRect* bounds, const SkPaint* paint,
637 const SkImageFilter* backdrop, SkCanvas::SaveLayerFlags flags) {
638 this->push<SaveLayer>(0, bounds, paint, backdrop, flags);
639 }
640
641 void DisplayListData::saveBehind(const SkRect* subset) {
642 this->push<SaveBehind>(0, subset);
643 }
644
645 void DisplayListData::concat(const SkM44& m) {
646 this->push<Concat>(0, m);
647 }
648 void DisplayListData::setMatrix(const SkM44& matrix) {
649 this->push<SetMatrix>(0, matrix);
650 }
651 void DisplayListData::scale(SkScalar sx, SkScalar sy) {
652 this->push<Scale>(0, sx, sy);
653 }
654 void DisplayListData::translate(SkScalar dx, SkScalar dy) {
655 this->push<Translate>(0, dx, dy);
656 }
657
658 void DisplayListData::clipPath(const SkPath& path, SkClipOp op, bool aa) {
659 this->push<ClipPath>(0, path, op, aa);
660 }
661 void DisplayListData::clipRect(const SkRect& rect, SkClipOp op, bool aa) {
662 this->push<ClipRect>(0, rect, op, aa);
663 }
664 void DisplayListData::clipRRect(const SkRRect& rrect, SkClipOp op, bool aa) {
665 this->push<ClipRRect>(0, rrect, op, aa);
666 }
667 void DisplayListData::clipRegion(const SkRegion& region, SkClipOp op) {
668 this->push<ClipRegion>(0, region, op);
669 }
670 void DisplayListData::resetClip() {
671 this->push<ResetClip>(0);
672 }
673
674 void DisplayListData::drawPaint(const SkPaint& paint) {
675 this->push<DrawPaint>(0, paint);
676 }
677 void DisplayListData::drawBehind(const SkPaint& paint) {
678 this->push<DrawBehind>(0, paint);
679 }
680 void DisplayListData::drawPath(const SkPath& path, const SkPaint& paint) {
681 this->push<DrawPath>(0, path, paint);
682 }
683 void DisplayListData::drawRect(const SkRect& rect, const SkPaint& paint) {
684 this->push<DrawRect>(0, rect, paint);
685 }
686 void DisplayListData::drawRegion(const SkRegion& region, const SkPaint& paint) {
687 this->push<DrawRegion>(0, region, paint);
688 }
689 void DisplayListData::drawOval(const SkRect& oval, const SkPaint& paint) {
690 this->push<DrawOval>(0, oval, paint);
691 }
692 void DisplayListData::drawArc(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle,
693 bool useCenter, const SkPaint& paint) {
694 this->push<DrawArc>(0, oval, startAngle, sweepAngle, useCenter, paint);
695 }
696 void DisplayListData::drawRRect(const SkRRect& rrect, const SkPaint& paint) {
697 this->push<DrawRRect>(0, rrect, paint);
698 }
699 void DisplayListData::drawDRRect(const SkRRect& outer, const SkRRect& inner, const SkPaint& paint) {
700 this->push<DrawDRRect>(0, outer, inner, paint);
701 }
702
703 void DisplayListData::drawAnnotation(const SkRect& rect, const char* key, SkData* value) {
704 size_t bytes = strlen(key) + 1;
705 void* pod = this->push<DrawAnnotation>(bytes, rect, value);
706 copy_v(pod, key, bytes);
707 }
708 void DisplayListData::drawDrawable(SkDrawable* drawable, const SkMatrix* matrix) {
709 this->push<DrawDrawable>(0, drawable, matrix);
710 }
711 void DisplayListData::drawPicture(const SkPicture* picture, const SkMatrix* matrix,
712 const SkPaint* paint) {
713 this->push<DrawPicture>(0, picture, matrix, paint);
714 }
715 void DisplayListData::drawImage(sk_sp<const SkImage> image, SkScalar x, SkScalar y,
716 const SkSamplingOptions& sampling, const SkPaint* paint,
717 BitmapPalette palette) {
718 this->push<DrawImage>(0, std::move(image), x, y, sampling, paint, palette);
719 }
720 void DisplayListData::drawImageRect(sk_sp<const SkImage> image, const SkRect* src,
721 const SkRect& dst, const SkSamplingOptions& sampling,
722 const SkPaint* paint, SkCanvas::SrcRectConstraint constraint,
723 BitmapPalette palette) {
724 this->push<DrawImageRect>(0, std::move(image), src, dst, sampling, paint, constraint, palette);
725 }
726 void DisplayListData::drawImageLattice(sk_sp<const SkImage> image, const SkCanvas::Lattice& lattice,
727 const SkRect& dst, SkFilterMode filter, const SkPaint* paint,
728 BitmapPalette palette) {
729 int xs = lattice.fXCount, ys = lattice.fYCount;
730 int fs = lattice.fRectTypes ? (xs + 1) * (ys + 1) : 0;
731 size_t bytes = (xs + ys) * sizeof(int) + fs * sizeof(SkCanvas::Lattice::RectType) +
732 fs * sizeof(SkColor);
733 SkASSERT(lattice.fBounds);
734 void* pod = this->push<DrawImageLattice>(bytes, std::move(image), xs, ys, fs, *lattice.fBounds,
735 dst, filter, paint, palette);
736 copy_v(pod, lattice.fXDivs, xs, lattice.fYDivs, ys, lattice.fColors, fs, lattice.fRectTypes,
737 fs);
738 }
739
740 void DisplayListData::drawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
741 const SkPaint& paint) {
742 this->push<DrawTextBlob>(0, blob, x, y, paint);
743 mHasText = true;
744 }
745
746 void DisplayListData::drawRippleDrawable(const skiapipeline::RippleDrawableParams& params) {
747 this->push<DrawRippleDrawable>(0, params);
748 }
749
750 void DisplayListData::drawPatch(const SkPoint points[12], const SkColor colors[4],
751 const SkPoint texs[4], SkBlendMode bmode, const SkPaint& paint) {
752 this->push<DrawPatch>(0, points, colors, texs, bmode, paint);
753 }
754 void DisplayListData::drawPoints(SkCanvas::PointMode mode, size_t count, const SkPoint points[],
755 const SkPaint& paint) {
756 void* pod = this->push<DrawPoints>(count * sizeof(SkPoint), mode, count, paint);
757 copy_v(pod, points, count);
758 }
759 void DisplayListData::drawVertices(const SkVertices* vert, SkBlendMode mode, const SkPaint& paint) {
760 this->push<DrawVertices>(0, vert, mode, paint);
761 }
762 void DisplayListData::drawAtlas(const SkImage* atlas, const SkRSXform xforms[], const SkRect texs[],
763 const SkColor colors[], int count, SkBlendMode xfermode,
764 const SkSamplingOptions& sampling, const SkRect* cull,
765 const SkPaint* paint) {
766 size_t bytes = count * (sizeof(SkRSXform) + sizeof(SkRect));
767 if (colors) {
768 bytes += count * sizeof(SkColor);
769 }
770 void* pod = this->push<DrawAtlas>(bytes, atlas, count, xfermode, sampling, cull, paint,
771 colors != nullptr);
772 copy_v(pod, xforms, count, texs, count, colors, colors ? count : 0);
773 }
774 void DisplayListData::drawShadowRec(const SkPath& path, const SkDrawShadowRec& rec) {
775 this->push<DrawShadowRec>(0, path, rec);
776 }
777 void DisplayListData::drawVectorDrawable(VectorDrawableRoot* tree) {
778 this->push<DrawVectorDrawable>(0, tree);
779 }
780 void DisplayListData::drawWebView(skiapipeline::FunctorDrawable* drawable) {
781 this->push<DrawWebView>(0, drawable);
782 }
783
784 typedef void (*draw_fn)(const void*, SkCanvas*, const SkMatrix&);
785 typedef void (*void_fn)(const void*);
786 typedef void (*color_transform_fn)(const void*, ColorTransform);
787
788 // All ops implement draw().
789 #define X(T) \
790 [](const void* op, SkCanvas* c, const SkMatrix& original) { \
791 ((const T*)op)->draw(c, original); \
792 },
793 static const draw_fn draw_fns[] = {
794 #include "DisplayListOps.in"
795 };
796 #undef X
797
798 // Most state ops (matrix, clip, save, restore) have a trivial destructor.
799 #define X(T) \
800 !std::is_trivially_destructible<T>::value ? [](const void* op) { ((const T*)op)->~T(); } \
801 : (void_fn) nullptr,
802
803 static const void_fn dtor_fns[] = {
804 #include "DisplayListOps.in"
805 };
806 #undef X
807
808 void DisplayListData::draw(SkCanvas* canvas) const {
809 SkAutoCanvasRestore acr(canvas, false);
810 this->map(draw_fns, canvas, canvas->getTotalMatrix());
811 }
812
813 DisplayListData::~DisplayListData() {
814 this->reset();
815 }
816
817 void DisplayListData::reset() {
818 this->map(dtor_fns);
819
820 // Leave fBytes and fReserved alone.
821 fUsed = 0;
822 }
823
824 template <class T>
825 using has_paint_helper = decltype(std::declval<T>().paint);
826
827 template <class T>
828 constexpr bool has_paint = std::experimental::is_detected_v<has_paint_helper, T>;
829
830 template <class T>
831 using has_palette_helper = decltype(std::declval<T>().palette);
832
833 template <class T>
834 constexpr bool has_palette = std::experimental::is_detected_v<has_palette_helper, T>;
835
836 template <class T>
837 constexpr color_transform_fn colorTransformForOp() {
838 if
839 constexpr(has_paint<T> && has_palette<T>) {
840 // It's a bitmap
841 return [](const void* opRaw, ColorTransform transform) {
842 // TODO: We should be const. Or not. Or just use a different map
843 // Unclear, but this is the quick fix
844 const T* op = reinterpret_cast<const T*>(opRaw);
845 const SkPaint* paint = &op->paint;
846 transformPaint(transform, const_cast<SkPaint*>(paint), op->palette);
847 };
848 }
849 else if
850 constexpr(has_paint<T>) {
851 return [](const void* opRaw, ColorTransform transform) {
852 // TODO: We should be const. Or not. Or just use a different map
853 // Unclear, but this is the quick fix
854 const T* op = reinterpret_cast<const T*>(opRaw);
855 const SkPaint* paint = &op->paint;
856 transformPaint(transform, const_cast<SkPaint*>(paint));
857 };
858 }
859 else {
860 return nullptr;
861 }
862 }
863
864 template<>
865 constexpr color_transform_fn colorTransformForOp<DrawTextBlob>() {
866 return [](const void *opRaw, ColorTransform transform) {
867 const DrawTextBlob *op = reinterpret_cast<const DrawTextBlob*>(opRaw);
868 switch (op->drawTextBlobMode) {
869 case DrawTextBlobMode::HctOutline:
870 const_cast<SkPaint&>(op->paint).setColor(SK_ColorBLACK);
871 break;
872 case DrawTextBlobMode::HctInner:
873 const_cast<SkPaint&>(op->paint).setColor(SK_ColorWHITE);
874 break;
875 default:
876 transformPaint(transform, const_cast<SkPaint*>(&(op->paint)));
877 break;
878 }
879 };
880 }
881
882 template <>
883 constexpr color_transform_fn colorTransformForOp<DrawRippleDrawable>() {
884 return [](const void* opRaw, ColorTransform transform) {
885 const DrawRippleDrawable* op = reinterpret_cast<const DrawRippleDrawable*>(opRaw);
886 // Ripple drawable needs to contrast against the background, so we need the inverse color.
887 SkColor color = transformColorInverse(transform, op->mParams.color);
888 const_cast<DrawRippleDrawable*>(op)->mParams.color = color;
889 };
890 }
891
892 #define X(T) colorTransformForOp<T>(),
893 static const color_transform_fn color_transform_fns[] = {
894 #include "DisplayListOps.in"
895 };
896 #undef X
897
898 void DisplayListData::applyColorTransform(ColorTransform transform) {
899 this->map(color_transform_fns, transform);
900 }
901
902 RecordingCanvas::RecordingCanvas() : INHERITED(1, 1), fDL(nullptr) {}
903
904 void RecordingCanvas::reset(DisplayListData* dl, const SkIRect& bounds) {
905 this->resetCanvas(bounds.right(), bounds.bottom());
906 fDL = dl;
907 mClipMayBeComplex = false;
908 mSaveCount = mComplexSaveCount = 0;
909 }
910
911 sk_sp<SkSurface> RecordingCanvas::onNewSurface(const SkImageInfo&, const SkSurfaceProps&) {
912 return nullptr;
913 }
914
915 void RecordingCanvas::onFlush() {
916 fDL->flush();
917 }
918
919 void RecordingCanvas::willSave() {
920 mSaveCount++;
921 fDL->save();
922 }
923 SkCanvas::SaveLayerStrategy RecordingCanvas::getSaveLayerStrategy(const SaveLayerRec& rec) {
924 fDL->saveLayer(rec.fBounds, rec.fPaint, rec.fBackdrop, rec.fSaveLayerFlags);
925 return SkCanvas::kNoLayer_SaveLayerStrategy;
926 }
927 void RecordingCanvas::willRestore() {
928 mSaveCount--;
929 if (mSaveCount < mComplexSaveCount) {
930 mClipMayBeComplex = false;
931 mComplexSaveCount = 0;
932 }
933 fDL->restore();
934 }
935
936 bool RecordingCanvas::onDoSaveBehind(const SkRect* subset) {
937 fDL->saveBehind(subset);
938 return false;
939 }
940
941 void RecordingCanvas::didConcat44(const SkM44& m) {
942 fDL->concat(m);
943 }
944 void RecordingCanvas::didSetM44(const SkM44& matrix) {
945 fDL->setMatrix(matrix);
946 }
947 void RecordingCanvas::didScale(SkScalar sx, SkScalar sy) {
948 fDL->scale(sx, sy);
949 }
950 void RecordingCanvas::didTranslate(SkScalar dx, SkScalar dy) {
951 fDL->translate(dx, dy);
952 }
953
954 void RecordingCanvas::onClipRect(const SkRect& rect, SkClipOp op, ClipEdgeStyle style) {
955 fDL->clipRect(rect, op, style == kSoft_ClipEdgeStyle);
956 if (!getTotalMatrix().isScaleTranslate()) {
957 setClipMayBeComplex();
958 }
959 this->INHERITED::onClipRect(rect, op, style);
960 }
961 void RecordingCanvas::onClipRRect(const SkRRect& rrect, SkClipOp op, ClipEdgeStyle style) {
962 if (rrect.getType() > SkRRect::kRect_Type || !getTotalMatrix().isScaleTranslate()) {
963 setClipMayBeComplex();
964 }
965 fDL->clipRRect(rrect, op, style == kSoft_ClipEdgeStyle);
966 this->INHERITED::onClipRRect(rrect, op, style);
967 }
968 void RecordingCanvas::onClipPath(const SkPath& path, SkClipOp op, ClipEdgeStyle style) {
969 setClipMayBeComplex();
970 fDL->clipPath(path, op, style == kSoft_ClipEdgeStyle);
971 this->INHERITED::onClipPath(path, op, style);
972 }
973 void RecordingCanvas::onClipRegion(const SkRegion& region, SkClipOp op) {
974 if (region.isComplex() || !getTotalMatrix().isScaleTranslate()) {
975 setClipMayBeComplex();
976 }
977 fDL->clipRegion(region, op);
978 this->INHERITED::onClipRegion(region, op);
979 }
980 void RecordingCanvas::onResetClip() {
981 // This is part of "replace op" emulation, but rely on the following intersection
982 // clip to potentially mark the clip as complex. If we are already complex, we do
983 // not reset the complexity so that we don't break the contract that no higher
984 // save point has a complex clip when "not complex".
985 fDL->resetClip();
986 this->INHERITED::onResetClip();
987 }
988
989 void RecordingCanvas::onDrawPaint(const SkPaint& paint) {
990 fDL->drawPaint(paint);
991 }
992 void RecordingCanvas::onDrawBehind(const SkPaint& paint) {
993 fDL->drawBehind(paint);
994 }
995 void RecordingCanvas::onDrawPath(const SkPath& path, const SkPaint& paint) {
996 fDL->drawPath(path, paint);
997 }
998 void RecordingCanvas::onDrawRect(const SkRect& rect, const SkPaint& paint) {
999 fDL->drawRect(rect, paint);
1000 }
1001 void RecordingCanvas::onDrawRegion(const SkRegion& region, const SkPaint& paint) {
1002 fDL->drawRegion(region, paint);
1003 }
1004 void RecordingCanvas::onDrawOval(const SkRect& oval, const SkPaint& paint) {
1005 fDL->drawOval(oval, paint);
1006 }
1007 void RecordingCanvas::onDrawArc(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle,
1008 bool useCenter, const SkPaint& paint) {
1009 fDL->drawArc(oval, startAngle, sweepAngle, useCenter, paint);
1010 }
1011 void RecordingCanvas::onDrawRRect(const SkRRect& rrect, const SkPaint& paint) {
1012 fDL->drawRRect(rrect, paint);
1013 }
1014 void RecordingCanvas::onDrawDRRect(const SkRRect& out, const SkRRect& in, const SkPaint& paint) {
1015 fDL->drawDRRect(out, in, paint);
1016 }
1017
1018 void RecordingCanvas::onDrawDrawable(SkDrawable* drawable, const SkMatrix* matrix) {
1019 fDL->drawDrawable(drawable, matrix);
1020 }
1021 void RecordingCanvas::onDrawPicture(const SkPicture* picture, const SkMatrix* matrix,
1022 const SkPaint* paint) {
1023 fDL->drawPicture(picture, matrix, paint);
1024 }
1025 void RecordingCanvas::onDrawAnnotation(const SkRect& rect, const char key[], SkData* val) {
1026 fDL->drawAnnotation(rect, key, val);
1027 }
1028
1029 void RecordingCanvas::onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
1030 const SkPaint& paint) {
1031 fDL->drawTextBlob(blob, x, y, paint);
1032 }
1033
1034 void RecordingCanvas::drawRippleDrawable(const skiapipeline::RippleDrawableParams& params) {
1035 fDL->drawRippleDrawable(params);
1036 }
1037
1038 void RecordingCanvas::drawImage(const sk_sp<SkImage>& image, SkScalar x, SkScalar y,
1039 const SkSamplingOptions& sampling, const SkPaint* paint,
1040 BitmapPalette palette) {
1041 fDL->drawImage(image, x, y, sampling, paint, palette);
1042 }
1043
1044 void RecordingCanvas::drawImageRect(const sk_sp<SkImage>& image, const SkRect& src,
1045 const SkRect& dst, const SkSamplingOptions& sampling,
1046 const SkPaint* paint, SrcRectConstraint constraint,
1047 BitmapPalette palette) {
1048 fDL->drawImageRect(image, &src, dst, sampling, paint, constraint, palette);
1049 }
1050
1051 void RecordingCanvas::drawImageLattice(const sk_sp<SkImage>& image, const Lattice& lattice,
1052 const SkRect& dst, SkFilterMode filter, const SkPaint* paint,
1053 BitmapPalette palette) {
1054 if (!image || dst.isEmpty()) {
1055 return;
1056 }
1057
1058 SkIRect bounds;
1059 Lattice latticePlusBounds = lattice;
1060 if (!latticePlusBounds.fBounds) {
1061 bounds = SkIRect::MakeWH(image->width(), image->height());
1062 latticePlusBounds.fBounds = &bounds;
1063 }
1064
1065 if (SkLatticeIter::Valid(image->width(), image->height(), latticePlusBounds)) {
1066 fDL->drawImageLattice(image, latticePlusBounds, dst, filter, paint, palette);
1067 } else {
1068 SkSamplingOptions sampling(filter, SkMipmapMode::kNone);
1069 fDL->drawImageRect(image, nullptr, dst, sampling, paint, kFast_SrcRectConstraint, palette);
1070 }
1071 }
1072
1073 void RecordingCanvas::onDrawImage2(const SkImage* img, SkScalar x, SkScalar y,
1074 const SkSamplingOptions& sampling, const SkPaint* paint) {
1075 fDL->drawImage(sk_ref_sp(img), x, y, sampling, paint, BitmapPalette::Unknown);
1076 }
1077
1078 void RecordingCanvas::onDrawImageRect2(const SkImage* img, const SkRect& src, const SkRect& dst,
1079 const SkSamplingOptions& sampling, const SkPaint* paint,
1080 SrcRectConstraint constraint) {
1081 fDL->drawImageRect(sk_ref_sp(img), &src, dst, sampling, paint, constraint,
1082 BitmapPalette::Unknown);
1083 }
1084
1085 void RecordingCanvas::onDrawImageLattice2(const SkImage* img, const SkCanvas::Lattice& lattice,
1086 const SkRect& dst, SkFilterMode filter,
1087 const SkPaint* paint) {
1088 fDL->drawImageLattice(sk_ref_sp(img), lattice, dst, filter, paint, BitmapPalette::Unknown);
1089 }
1090
1091 void RecordingCanvas::onDrawPatch(const SkPoint cubics[12], const SkColor colors[4],
1092 const SkPoint texCoords[4], SkBlendMode bmode,
1093 const SkPaint& paint) {
1094 fDL->drawPatch(cubics, colors, texCoords, bmode, paint);
1095 }
1096 void RecordingCanvas::onDrawPoints(SkCanvas::PointMode mode, size_t count, const SkPoint pts[],
1097 const SkPaint& paint) {
1098 fDL->drawPoints(mode, count, pts, paint);
1099 }
1100 void RecordingCanvas::onDrawVerticesObject(const SkVertices* vertices,
1101 SkBlendMode mode, const SkPaint& paint) {
1102 fDL->drawVertices(vertices, mode, paint);
1103 }
1104 void RecordingCanvas::onDrawAtlas2(const SkImage* atlas, const SkRSXform xforms[],
1105 const SkRect texs[], const SkColor colors[], int count,
1106 SkBlendMode bmode, const SkSamplingOptions& sampling,
1107 const SkRect* cull, const SkPaint* paint) {
1108 fDL->drawAtlas(atlas, xforms, texs, colors, count, bmode, sampling, cull, paint);
1109 }
1110 void RecordingCanvas::onDrawShadowRec(const SkPath& path, const SkDrawShadowRec& rec) {
1111 fDL->drawShadowRec(path, rec);
1112 }
1113
1114 void RecordingCanvas::drawVectorDrawable(VectorDrawableRoot* tree) {
1115 fDL->drawVectorDrawable(tree);
1116 }
1117
1118 void RecordingCanvas::drawWebView(skiapipeline::FunctorDrawable* drawable) {
1119 fDL->drawWebView(drawable);
1120 }
1121
1122 } // namespace uirenderer
1123 } // namespace android