Derek Sollenberger | 8872b38 | 2014-06-23 14:13:53 -0400 | [diff] [blame] | 1 | /* |
| 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 Sollenberger | c190813 | 2016-07-15 10:28:16 -0400 | [diff] [blame] | 17 | #include "SkiaCanvas.h" |
Derek Sollenberger | 8872b38 | 2014-06-23 14:13:53 -0400 | [diff] [blame] | 18 | |
Derek Sollenberger | c190813 | 2016-07-15 10:28:16 -0400 | [diff] [blame] | 19 | #include "CanvasProperty.h" |
Matt Sarett | 7de7385 | 2016-10-25 18:36:39 -0400 | [diff] [blame] | 20 | #include "NinePatchUtils.h" |
Derek Sollenberger | c190813 | 2016-07-15 10:28:16 -0400 | [diff] [blame] | 21 | #include "VectorDrawable.h" |
sergeyv | aed7f58 | 2016-10-14 16:30:21 -0700 | [diff] [blame] | 22 | #include "hwui/Bitmap.h" |
Yuqian Li | afc22149 | 2016-07-18 13:07:42 -0400 | [diff] [blame] | 23 | #include "hwui/MinikinUtils.h" |
Ben Wagner | 0ed10be | 2018-06-28 17:08:16 -0400 | [diff] [blame] | 24 | #include "hwui/PaintFilter.h" |
Stan Iliev | 021693b | 2016-10-17 16:26:15 -0400 | [diff] [blame] | 25 | #include "pipeline/skia/AnimatedDrawables.h" |
Derek Sollenberger | c190813 | 2016-07-15 10:28:16 -0400 | [diff] [blame] | 26 | |
Derek Sollenberger | 24fc901 | 2018-12-07 14:12:12 -0500 | [diff] [blame] | 27 | #include <SkAndroidFrameworkUtils.h> |
Leon Scroggins III | 671cce2 | 2018-01-14 16:52:17 -0500 | [diff] [blame] | 28 | #include <SkAnimatedImage.h> |
Derek Sollenberger | ac33a48 | 2019-04-22 16:28:09 -0400 | [diff] [blame^] | 29 | #include <SkCanvasPriv.h> |
Matt Sarett | d0814db | 2017-04-13 09:33:18 -0400 | [diff] [blame] | 30 | #include <SkCanvasStateUtils.h> |
Derek Sollenberger | fb0c8fc | 2017-07-26 13:53:27 -0400 | [diff] [blame] | 31 | #include <SkColorFilter.h> |
John Reck | 849911a | 2015-01-20 07:51:14 -0800 | [diff] [blame] | 32 | #include <SkDeque.h> |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 33 | #include <SkDrawable.h> |
Mike Reed | 1c79eab | 2018-11-21 11:01:57 -0500 | [diff] [blame] | 34 | #include <SkFont.h> |
John Reck | 849911a | 2015-01-20 07:51:14 -0800 | [diff] [blame] | 35 | #include <SkGraphics.h> |
Derek Sollenberger | 6f48556 | 2015-07-30 10:00:39 -0400 | [diff] [blame] | 36 | #include <SkImage.h> |
Matt Sarett | 62feb3a | 2016-09-20 10:34:11 -0400 | [diff] [blame] | 37 | #include <SkImagePriv.h> |
Leon Scroggins III | 671cce2 | 2018-01-14 16:52:17 -0500 | [diff] [blame] | 38 | #include <SkPicture.h> |
Yuqian Li | afc22149 | 2016-07-18 13:07:42 -0400 | [diff] [blame] | 39 | #include <SkRSXform.h> |
John Reck | 849911a | 2015-01-20 07:51:14 -0800 | [diff] [blame] | 40 | #include <SkShader.h> |
John Reck | 849911a | 2015-01-20 07:51:14 -0800 | [diff] [blame] | 41 | #include <SkTemplates.h> |
Stan Iliev | f50806a | 2016-10-24 10:40:39 -0400 | [diff] [blame] | 42 | #include <SkTextBlob.h> |
Derek Sollenberger | 8872b38 | 2014-06-23 14:13:53 -0400 | [diff] [blame] | 43 | |
Ben Wagner | 60126ef | 2015-08-07 12:13:48 -0400 | [diff] [blame] | 44 | #include <memory> |
Ben Wagner | 0ed10be | 2018-06-28 17:08:16 -0400 | [diff] [blame] | 45 | #include <optional> |
| 46 | #include <utility> |
Ben Wagner | 60126ef | 2015-08-07 12:13:48 -0400 | [diff] [blame] | 47 | |
Derek Sollenberger | 8872b38 | 2014-06-23 14:13:53 -0400 | [diff] [blame] | 48 | namespace android { |
| 49 | |
Stan Iliev | f50806a | 2016-10-24 10:40:39 -0400 | [diff] [blame] | 50 | using uirenderer::PaintUtils; |
| 51 | |
John Reck | c1b33d6 | 2015-04-22 09:04:45 -0700 | [diff] [blame] | 52 | Canvas* Canvas::create_canvas(const SkBitmap& bitmap) { |
Derek Sollenberger | 8872b38 | 2014-06-23 14:13:53 -0400 | [diff] [blame] | 53 | return new SkiaCanvas(bitmap); |
| 54 | } |
| 55 | |
Derek Sollenberger | fa3e340 | 2017-08-04 08:35:10 -0400 | [diff] [blame] | 56 | Canvas* Canvas::create_canvas(SkCanvas* skiaCanvas) { |
| 57 | return new SkiaCanvas(skiaCanvas); |
Derek Sollenberger | 8872b38 | 2014-06-23 14:13:53 -0400 | [diff] [blame] | 58 | } |
| 59 | |
Stan Iliev | f50806a | 2016-10-24 10:40:39 -0400 | [diff] [blame] | 60 | SkiaCanvas::SkiaCanvas() {} |
| 61 | |
Derek Sollenberger | fa3e340 | 2017-08-04 08:35:10 -0400 | [diff] [blame] | 62 | SkiaCanvas::SkiaCanvas(SkCanvas* canvas) : mCanvas(canvas) {} |
Stan Iliev | f50806a | 2016-10-24 10:40:39 -0400 | [diff] [blame] | 63 | |
John Reck | c1b33d6 | 2015-04-22 09:04:45 -0700 | [diff] [blame] | 64 | SkiaCanvas::SkiaCanvas(const SkBitmap& bitmap) { |
Derek Sollenberger | d01b591 | 2018-10-19 15:55:33 -0400 | [diff] [blame] | 65 | mCanvasOwned = std::unique_ptr<SkCanvas>(new SkCanvas(bitmap)); |
| 66 | mCanvas = mCanvasOwned.get(); |
Derek Sollenberger | 8872b38 | 2014-06-23 14:13:53 -0400 | [diff] [blame] | 67 | } |
| 68 | |
Stan Iliev | 021693b | 2016-10-17 16:26:15 -0400 | [diff] [blame] | 69 | SkiaCanvas::~SkiaCanvas() {} |
| 70 | |
Derek Sollenberger | c190813 | 2016-07-15 10:28:16 -0400 | [diff] [blame] | 71 | void SkiaCanvas::reset(SkCanvas* skiaCanvas) { |
Mike Reed | 6acfe16 | 2016-11-18 17:21:09 -0500 | [diff] [blame] | 72 | if (mCanvas != skiaCanvas) { |
| 73 | mCanvas = skiaCanvas; |
| 74 | mCanvasOwned.reset(); |
| 75 | } |
Derek Sollenberger | c190813 | 2016-07-15 10:28:16 -0400 | [diff] [blame] | 76 | mSaveStack.reset(nullptr); |
Derek Sollenberger | c190813 | 2016-07-15 10:28:16 -0400 | [diff] [blame] | 77 | } |
| 78 | |
Derek Sollenberger | 8872b38 | 2014-06-23 14:13:53 -0400 | [diff] [blame] | 79 | // ---------------------------------------------------------------------------- |
| 80 | // Canvas state operations: Replace Bitmap |
| 81 | // ---------------------------------------------------------------------------- |
| 82 | |
John Reck | c1b33d6 | 2015-04-22 09:04:45 -0700 | [diff] [blame] | 83 | void SkiaCanvas::setBitmap(const SkBitmap& bitmap) { |
Tony Mantler | 4f641d1 | 2017-03-14 22:36:14 +0000 | [diff] [blame] | 84 | // deletes the previously owned canvas (if any) |
Derek Sollenberger | d01b591 | 2018-10-19 15:55:33 -0400 | [diff] [blame] | 85 | mCanvasOwned.reset(new SkCanvas(bitmap)); |
| 86 | mCanvas = mCanvasOwned.get(); |
Tony Mantler | 4f641d1 | 2017-03-14 22:36:14 +0000 | [diff] [blame] | 87 | |
Derek Sollenberger | 8872b38 | 2014-06-23 14:13:53 -0400 | [diff] [blame] | 88 | // clean up the old save stack |
Stan Iliev | f50806a | 2016-10-24 10:40:39 -0400 | [diff] [blame] | 89 | mSaveStack.reset(nullptr); |
Derek Sollenberger | 8872b38 | 2014-06-23 14:13:53 -0400 | [diff] [blame] | 90 | } |
| 91 | |
| 92 | // ---------------------------------------------------------------------------- |
| 93 | // Canvas state operations |
| 94 | // ---------------------------------------------------------------------------- |
| 95 | |
| 96 | bool SkiaCanvas::isOpaque() { |
Leon Scroggins III | f35b989 | 2015-07-31 10:38:40 -0400 | [diff] [blame] | 97 | return mCanvas->imageInfo().isOpaque(); |
Derek Sollenberger | 8872b38 | 2014-06-23 14:13:53 -0400 | [diff] [blame] | 98 | } |
| 99 | |
| 100 | int SkiaCanvas::width() { |
Leon Scroggins III | f35b989 | 2015-07-31 10:38:40 -0400 | [diff] [blame] | 101 | return mCanvas->imageInfo().width(); |
Derek Sollenberger | 8872b38 | 2014-06-23 14:13:53 -0400 | [diff] [blame] | 102 | } |
| 103 | |
| 104 | int SkiaCanvas::height() { |
Leon Scroggins III | f35b989 | 2015-07-31 10:38:40 -0400 | [diff] [blame] | 105 | return mCanvas->imageInfo().height(); |
Derek Sollenberger | 8872b38 | 2014-06-23 14:13:53 -0400 | [diff] [blame] | 106 | } |
| 107 | |
| 108 | // ---------------------------------------------------------------------------- |
| 109 | // Canvas state operations: Save (layer) |
| 110 | // ---------------------------------------------------------------------------- |
| 111 | |
| 112 | int SkiaCanvas::getSaveCount() const { |
| 113 | return mCanvas->getSaveCount(); |
| 114 | } |
| 115 | |
Florin Malita | eecff56 | 2015-12-21 10:43:01 -0500 | [diff] [blame] | 116 | int SkiaCanvas::save(SaveFlags::Flags flags) { |
Derek Sollenberger | 8872b38 | 2014-06-23 14:13:53 -0400 | [diff] [blame] | 117 | int count = mCanvas->save(); |
| 118 | recordPartialSave(flags); |
| 119 | return count; |
| 120 | } |
| 121 | |
Florin Malita | 5e27140 | 2015-11-04 14:36:02 -0500 | [diff] [blame] | 122 | // The SkiaCanvas::restore operation layers on the capability to preserve |
| 123 | // either (or both) the matrix and/or clip state after a SkCanvas::restore |
| 124 | // operation. It does this by explicitly saving off the clip & matrix state |
| 125 | // when requested and playing it back after the SkCanvas::restore. |
Derek Sollenberger | 8872b38 | 2014-06-23 14:13:53 -0400 | [diff] [blame] | 126 | void SkiaCanvas::restore() { |
Stan Iliev | f50806a | 2016-10-24 10:40:39 -0400 | [diff] [blame] | 127 | const auto* rec = this->currentSaveRec(); |
| 128 | if (!rec) { |
Derek Sollenberger | 8872b38 | 2014-06-23 14:13:53 -0400 | [diff] [blame] | 129 | // Fast path - no record for this frame. |
| 130 | mCanvas->restore(); |
| 131 | return; |
| 132 | } |
| 133 | |
Florin Malita | eecff56 | 2015-12-21 10:43:01 -0500 | [diff] [blame] | 134 | bool preserveMatrix = !(rec->saveFlags & SaveFlags::Matrix); |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 135 | bool preserveClip = !(rec->saveFlags & SaveFlags::Clip); |
Derek Sollenberger | 8872b38 | 2014-06-23 14:13:53 -0400 | [diff] [blame] | 136 | |
| 137 | SkMatrix savedMatrix; |
| 138 | if (preserveMatrix) { |
| 139 | savedMatrix = mCanvas->getTotalMatrix(); |
| 140 | } |
| 141 | |
Stan Iliev | f50806a | 2016-10-24 10:40:39 -0400 | [diff] [blame] | 142 | const size_t clipIndex = rec->clipIndex; |
Derek Sollenberger | 8872b38 | 2014-06-23 14:13:53 -0400 | [diff] [blame] | 143 | |
| 144 | mCanvas->restore(); |
Stan Iliev | f50806a | 2016-10-24 10:40:39 -0400 | [diff] [blame] | 145 | mSaveStack->pop_back(); |
Derek Sollenberger | 8872b38 | 2014-06-23 14:13:53 -0400 | [diff] [blame] | 146 | |
| 147 | if (preserveMatrix) { |
| 148 | mCanvas->setMatrix(savedMatrix); |
| 149 | } |
| 150 | |
Stan Iliev | f50806a | 2016-10-24 10:40:39 -0400 | [diff] [blame] | 151 | if (preserveClip) { |
| 152 | this->applyPersistentClips(clipIndex); |
Derek Sollenberger | 8872b38 | 2014-06-23 14:13:53 -0400 | [diff] [blame] | 153 | } |
Derek Sollenberger | 8872b38 | 2014-06-23 14:13:53 -0400 | [diff] [blame] | 154 | } |
| 155 | |
| 156 | void SkiaCanvas::restoreToCount(int restoreCount) { |
| 157 | while (mCanvas->getSaveCount() > restoreCount) { |
| 158 | this->restore(); |
| 159 | } |
| 160 | } |
| 161 | |
Florin Malita | eecff56 | 2015-12-21 10:43:01 -0500 | [diff] [blame] | 162 | static inline SkCanvas::SaveLayerFlags layerFlags(SaveFlags::Flags flags) { |
| 163 | SkCanvas::SaveLayerFlags layerFlags = 0; |
| 164 | |
Florin Malita | eecff56 | 2015-12-21 10:43:01 -0500 | [diff] [blame] | 165 | if (!(flags & SaveFlags::ClipToLayer)) { |
| 166 | layerFlags |= SkCanvas::kDontClipToLayer_Legacy_SaveLayerFlag; |
| 167 | } |
| 168 | |
| 169 | return layerFlags; |
| 170 | } |
| 171 | |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 172 | int SkiaCanvas::saveLayer(float left, float top, float right, float bottom, const SkPaint* paint, |
| 173 | SaveFlags::Flags flags) { |
Florin Malita | eecff56 | 2015-12-21 10:43:01 -0500 | [diff] [blame] | 174 | const SkRect bounds = SkRect::MakeLTRB(left, top, right, bottom); |
Derek Sollenberger | b820119 | 2017-01-09 16:11:59 -0500 | [diff] [blame] | 175 | const SkCanvas::SaveLayerRec rec(&bounds, paint, layerFlags(flags)); |
Florin Malita | eecff56 | 2015-12-21 10:43:01 -0500 | [diff] [blame] | 176 | |
Stan Iliev | 68885e3 | 2016-12-14 11:18:34 -0500 | [diff] [blame] | 177 | return mCanvas->saveLayer(rec); |
Derek Sollenberger | 8872b38 | 2014-06-23 14:13:53 -0400 | [diff] [blame] | 178 | } |
| 179 | |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 180 | int SkiaCanvas::saveLayerAlpha(float left, float top, float right, float bottom, int alpha, |
| 181 | SaveFlags::Flags flags) { |
Florin Malita | eecff56 | 2015-12-21 10:43:01 -0500 | [diff] [blame] | 182 | if (static_cast<unsigned>(alpha) < 0xFF) { |
Yuqian Li | fd92ee4 | 2016-04-27 17:03:38 -0400 | [diff] [blame] | 183 | SkPaint alphaPaint; |
| 184 | alphaPaint.setAlpha(alpha); |
| 185 | return this->saveLayer(left, top, right, bottom, &alphaPaint, flags); |
Florin Malita | eecff56 | 2015-12-21 10:43:01 -0500 | [diff] [blame] | 186 | } |
Yuqian Li | fd92ee4 | 2016-04-27 17:03:38 -0400 | [diff] [blame] | 187 | return this->saveLayer(left, top, right, bottom, nullptr, flags); |
Derek Sollenberger | 8872b38 | 2014-06-23 14:13:53 -0400 | [diff] [blame] | 188 | } |
| 189 | |
Derek Sollenberger | 24fc901 | 2018-12-07 14:12:12 -0500 | [diff] [blame] | 190 | int SkiaCanvas::saveUnclippedLayer(int left, int top, int right, int bottom) { |
| 191 | SkRect bounds = SkRect::MakeLTRB(left, top, right, bottom); |
| 192 | return SkAndroidFrameworkUtils::SaveBehind(mCanvas, &bounds); |
| 193 | } |
| 194 | |
Derek Sollenberger | ac33a48 | 2019-04-22 16:28:09 -0400 | [diff] [blame^] | 195 | void SkiaCanvas::restoreUnclippedLayer(int restoreCount, const SkPaint& paint) { |
| 196 | |
| 197 | while (mCanvas->getSaveCount() > restoreCount + 1) { |
| 198 | this->restore(); |
| 199 | } |
| 200 | |
| 201 | if (mCanvas->getSaveCount() == restoreCount + 1) { |
| 202 | SkCanvasPriv::DrawBehind(mCanvas, *filterPaint(paint)); |
| 203 | this->restore(); |
| 204 | } |
| 205 | } |
| 206 | |
Stan Iliev | f50806a | 2016-10-24 10:40:39 -0400 | [diff] [blame] | 207 | class SkiaCanvas::Clip { |
| 208 | public: |
Mike Reed | 6e49c9f | 2016-12-02 15:36:59 -0500 | [diff] [blame] | 209 | Clip(const SkRect& rect, SkClipOp op, const SkMatrix& m) |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 210 | : mType(Type::Rect), mOp(op), mMatrix(m), mRRect(SkRRect::MakeRect(rect)) {} |
Mike Reed | 6e49c9f | 2016-12-02 15:36:59 -0500 | [diff] [blame] | 211 | Clip(const SkRRect& rrect, SkClipOp op, const SkMatrix& m) |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 212 | : mType(Type::RRect), mOp(op), mMatrix(m), mRRect(rrect) {} |
Mike Reed | 6e49c9f | 2016-12-02 15:36:59 -0500 | [diff] [blame] | 213 | Clip(const SkPath& path, SkClipOp op, const SkMatrix& m) |
Ben Wagner | 0ed10be | 2018-06-28 17:08:16 -0400 | [diff] [blame] | 214 | : mType(Type::Path), mOp(op), mMatrix(m), mPath(std::in_place, path) {} |
Stan Iliev | f50806a | 2016-10-24 10:40:39 -0400 | [diff] [blame] | 215 | |
| 216 | void apply(SkCanvas* canvas) const { |
| 217 | canvas->setMatrix(mMatrix); |
| 218 | switch (mType) { |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 219 | case Type::Rect: |
| 220 | canvas->clipRect(mRRect.rect(), mOp); |
| 221 | break; |
| 222 | case Type::RRect: |
| 223 | canvas->clipRRect(mRRect, mOp); |
| 224 | break; |
| 225 | case Type::Path: |
Ben Wagner | 0ed10be | 2018-06-28 17:08:16 -0400 | [diff] [blame] | 226 | canvas->clipPath(mPath.value(), mOp); |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 227 | break; |
Stan Iliev | f50806a | 2016-10-24 10:40:39 -0400 | [diff] [blame] | 228 | } |
| 229 | } |
| 230 | |
| 231 | private: |
| 232 | enum class Type { |
| 233 | Rect, |
| 234 | RRect, |
| 235 | Path, |
| 236 | }; |
| 237 | |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 238 | Type mType; |
| 239 | SkClipOp mOp; |
| 240 | SkMatrix mMatrix; |
Stan Iliev | f50806a | 2016-10-24 10:40:39 -0400 | [diff] [blame] | 241 | |
| 242 | // These are logically a union (tracked separately due to non-POD path). |
Ben Wagner | 0ed10be | 2018-06-28 17:08:16 -0400 | [diff] [blame] | 243 | std::optional<SkPath> mPath; |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 244 | SkRRect mRRect; |
Stan Iliev | f50806a | 2016-10-24 10:40:39 -0400 | [diff] [blame] | 245 | }; |
| 246 | |
| 247 | const SkiaCanvas::SaveRec* SkiaCanvas::currentSaveRec() const { |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 248 | const SaveRec* rec = mSaveStack ? static_cast<const SaveRec*>(mSaveStack->back()) : nullptr; |
Stan Iliev | f50806a | 2016-10-24 10:40:39 -0400 | [diff] [blame] | 249 | int currentSaveCount = mCanvas->getSaveCount(); |
| 250 | SkASSERT(!rec || currentSaveCount >= rec->saveCount); |
| 251 | |
| 252 | return (rec && rec->saveCount == currentSaveCount) ? rec : nullptr; |
| 253 | } |
| 254 | |
Derek Sollenberger | 8872b38 | 2014-06-23 14:13:53 -0400 | [diff] [blame] | 255 | // ---------------------------------------------------------------------------- |
| 256 | // functions to emulate legacy SaveFlags (i.e. independent matrix/clip flags) |
| 257 | // ---------------------------------------------------------------------------- |
| 258 | |
Florin Malita | eecff56 | 2015-12-21 10:43:01 -0500 | [diff] [blame] | 259 | void SkiaCanvas::recordPartialSave(SaveFlags::Flags flags) { |
Derek Sollenberger | 8872b38 | 2014-06-23 14:13:53 -0400 | [diff] [blame] | 260 | // A partial save is a save operation which doesn't capture the full canvas state. |
Florin Malita | eecff56 | 2015-12-21 10:43:01 -0500 | [diff] [blame] | 261 | // (either SaveFlags::Matrix or SaveFlags::Clip is missing). |
Derek Sollenberger | 8872b38 | 2014-06-23 14:13:53 -0400 | [diff] [blame] | 262 | |
| 263 | // Mask-out non canvas state bits. |
Florin Malita | eecff56 | 2015-12-21 10:43:01 -0500 | [diff] [blame] | 264 | flags &= SaveFlags::MatrixClip; |
Derek Sollenberger | 8872b38 | 2014-06-23 14:13:53 -0400 | [diff] [blame] | 265 | |
Florin Malita | eecff56 | 2015-12-21 10:43:01 -0500 | [diff] [blame] | 266 | if (flags == SaveFlags::MatrixClip) { |
Derek Sollenberger | 8872b38 | 2014-06-23 14:13:53 -0400 | [diff] [blame] | 267 | // not a partial save. |
| 268 | return; |
| 269 | } |
| 270 | |
Stan Iliev | f50806a | 2016-10-24 10:40:39 -0400 | [diff] [blame] | 271 | if (!mSaveStack) { |
Ben Wagner | d1cbc16 | 2015-08-19 12:45:09 -0400 | [diff] [blame] | 272 | mSaveStack.reset(new SkDeque(sizeof(struct SaveRec), 8)); |
Derek Sollenberger | 8872b38 | 2014-06-23 14:13:53 -0400 | [diff] [blame] | 273 | } |
| 274 | |
| 275 | SaveRec* rec = static_cast<SaveRec*>(mSaveStack->push_back()); |
Florin Malita | 5e27140 | 2015-11-04 14:36:02 -0500 | [diff] [blame] | 276 | rec->saveCount = mCanvas->getSaveCount(); |
Derek Sollenberger | 8872b38 | 2014-06-23 14:13:53 -0400 | [diff] [blame] | 277 | rec->saveFlags = flags; |
Stan Iliev | f50806a | 2016-10-24 10:40:39 -0400 | [diff] [blame] | 278 | rec->clipIndex = mClipStack.size(); |
Derek Sollenberger | 8872b38 | 2014-06-23 14:13:53 -0400 | [diff] [blame] | 279 | } |
| 280 | |
Stan Iliev | f50806a | 2016-10-24 10:40:39 -0400 | [diff] [blame] | 281 | template <typename T> |
Mike Reed | 6e49c9f | 2016-12-02 15:36:59 -0500 | [diff] [blame] | 282 | void SkiaCanvas::recordClip(const T& clip, SkClipOp op) { |
Stan Iliev | f50806a | 2016-10-24 10:40:39 -0400 | [diff] [blame] | 283 | // Only need tracking when in a partial save frame which |
| 284 | // doesn't restore the clip. |
| 285 | const SaveRec* rec = this->currentSaveRec(); |
| 286 | if (rec && !(rec->saveFlags & SaveFlags::Clip)) { |
| 287 | mClipStack.emplace_back(clip, op, mCanvas->getTotalMatrix()); |
Derek Sollenberger | 8872b38 | 2014-06-23 14:13:53 -0400 | [diff] [blame] | 288 | } |
| 289 | } |
| 290 | |
Stan Iliev | f50806a | 2016-10-24 10:40:39 -0400 | [diff] [blame] | 291 | // Applies and optionally removes all clips >= index. |
| 292 | void SkiaCanvas::applyPersistentClips(size_t clipStartIndex) { |
| 293 | SkASSERT(clipStartIndex <= mClipStack.size()); |
| 294 | const auto begin = mClipStack.cbegin() + clipStartIndex; |
| 295 | const auto end = mClipStack.cend(); |
Derek Sollenberger | 8872b38 | 2014-06-23 14:13:53 -0400 | [diff] [blame] | 296 | |
Stan Iliev | f50806a | 2016-10-24 10:40:39 -0400 | [diff] [blame] | 297 | // Clip application mutates the CTM. |
| 298 | const SkMatrix saveMatrix = mCanvas->getTotalMatrix(); |
Derek Sollenberger | 8872b38 | 2014-06-23 14:13:53 -0400 | [diff] [blame] | 299 | |
Stan Iliev | f50806a | 2016-10-24 10:40:39 -0400 | [diff] [blame] | 300 | for (auto clip = begin; clip != end; ++clip) { |
Mike Reed | 6acfe16 | 2016-11-18 17:21:09 -0500 | [diff] [blame] | 301 | clip->apply(mCanvas); |
Derek Sollenberger | 8872b38 | 2014-06-23 14:13:53 -0400 | [diff] [blame] | 302 | } |
| 303 | |
Stan Iliev | f50806a | 2016-10-24 10:40:39 -0400 | [diff] [blame] | 304 | mCanvas->setMatrix(saveMatrix); |
| 305 | |
| 306 | // If the current/post-restore save rec is also persisting clips, we |
| 307 | // leave them on the stack to be reapplied part of the next restore(). |
| 308 | // Otherwise we're done and just pop them. |
| 309 | const auto* rec = this->currentSaveRec(); |
| 310 | if (!rec || (rec->saveFlags & SaveFlags::Clip)) { |
| 311 | mClipStack.erase(begin, end); |
| 312 | } |
Derek Sollenberger | 8872b38 | 2014-06-23 14:13:53 -0400 | [diff] [blame] | 313 | } |
| 314 | |
| 315 | // ---------------------------------------------------------------------------- |
| 316 | // Canvas state operations: Matrix |
| 317 | // ---------------------------------------------------------------------------- |
| 318 | |
| 319 | void SkiaCanvas::getMatrix(SkMatrix* outMatrix) const { |
| 320 | *outMatrix = mCanvas->getTotalMatrix(); |
| 321 | } |
| 322 | |
| 323 | void SkiaCanvas::setMatrix(const SkMatrix& matrix) { |
| 324 | mCanvas->setMatrix(matrix); |
| 325 | } |
| 326 | |
| 327 | void SkiaCanvas::concat(const SkMatrix& matrix) { |
| 328 | mCanvas->concat(matrix); |
| 329 | } |
| 330 | |
| 331 | void SkiaCanvas::rotate(float degrees) { |
| 332 | mCanvas->rotate(degrees); |
| 333 | } |
| 334 | |
| 335 | void SkiaCanvas::scale(float sx, float sy) { |
| 336 | mCanvas->scale(sx, sy); |
| 337 | } |
| 338 | |
| 339 | void SkiaCanvas::skew(float sx, float sy) { |
| 340 | mCanvas->skew(sx, sy); |
| 341 | } |
| 342 | |
| 343 | void SkiaCanvas::translate(float dx, float dy) { |
| 344 | mCanvas->translate(dx, dy); |
| 345 | } |
| 346 | |
| 347 | // ---------------------------------------------------------------------------- |
| 348 | // Canvas state operations: Clips |
| 349 | // ---------------------------------------------------------------------------- |
| 350 | |
| 351 | // This function is a mirror of SkCanvas::getClipBounds except that it does |
| 352 | // not outset the edge of the clip to account for anti-aliasing. There is |
| 353 | // a skia bug to investigate pushing this logic into back into skia. |
| 354 | // (see https://code.google.com/p/skia/issues/detail?id=1303) |
| 355 | bool SkiaCanvas::getClipBounds(SkRect* outRect) const { |
| 356 | SkIRect ibounds; |
Mike Reed | 5e43898 | 2017-01-25 08:23:25 -0500 | [diff] [blame] | 357 | if (!mCanvas->getDeviceClipBounds(&ibounds)) { |
Derek Sollenberger | 8872b38 | 2014-06-23 14:13:53 -0400 | [diff] [blame] | 358 | return false; |
| 359 | } |
| 360 | |
| 361 | SkMatrix inverse; |
| 362 | // if we can't invert the CTM, we can't return local clip bounds |
| 363 | if (!mCanvas->getTotalMatrix().invert(&inverse)) { |
| 364 | if (outRect) { |
| 365 | outRect->setEmpty(); |
| 366 | } |
| 367 | return false; |
| 368 | } |
| 369 | |
| 370 | if (NULL != outRect) { |
| 371 | SkRect r = SkRect::Make(ibounds); |
| 372 | inverse.mapRect(outRect, r); |
| 373 | } |
| 374 | return true; |
| 375 | } |
| 376 | |
| 377 | bool SkiaCanvas::quickRejectRect(float left, float top, float right, float bottom) const { |
| 378 | SkRect bounds = SkRect::MakeLTRB(left, top, right, bottom); |
| 379 | return mCanvas->quickReject(bounds); |
| 380 | } |
| 381 | |
| 382 | bool SkiaCanvas::quickRejectPath(const SkPath& path) const { |
| 383 | return mCanvas->quickReject(path); |
| 384 | } |
| 385 | |
Mike Reed | 6e49c9f | 2016-12-02 15:36:59 -0500 | [diff] [blame] | 386 | bool SkiaCanvas::clipRect(float left, float top, float right, float bottom, SkClipOp op) { |
Derek Sollenberger | 8872b38 | 2014-06-23 14:13:53 -0400 | [diff] [blame] | 387 | SkRect rect = SkRect::MakeLTRB(left, top, right, bottom); |
Stan Iliev | f50806a | 2016-10-24 10:40:39 -0400 | [diff] [blame] | 388 | this->recordClip(rect, op); |
Derek Sollenberger | 8872b38 | 2014-06-23 14:13:53 -0400 | [diff] [blame] | 389 | mCanvas->clipRect(rect, op); |
Chris Craik | 5ec6a28 | 2015-06-23 15:42:12 -0700 | [diff] [blame] | 390 | return !mCanvas->isClipEmpty(); |
Derek Sollenberger | 8872b38 | 2014-06-23 14:13:53 -0400 | [diff] [blame] | 391 | } |
| 392 | |
Mike Reed | 6e49c9f | 2016-12-02 15:36:59 -0500 | [diff] [blame] | 393 | bool SkiaCanvas::clipPath(const SkPath* path, SkClipOp op) { |
Derek Sollenberger | f7d98f4 | 2017-04-17 11:27:36 -0400 | [diff] [blame] | 394 | this->recordClip(*path, op); |
| 395 | mCanvas->clipPath(*path, op); |
Chris Craik | 5ec6a28 | 2015-06-23 15:42:12 -0700 | [diff] [blame] | 396 | return !mCanvas->isClipEmpty(); |
Derek Sollenberger | 8872b38 | 2014-06-23 14:13:53 -0400 | [diff] [blame] | 397 | } |
| 398 | |
Derek Sollenberger | 8872b38 | 2014-06-23 14:13:53 -0400 | [diff] [blame] | 399 | // ---------------------------------------------------------------------------- |
| 400 | // Canvas state operations: Filters |
| 401 | // ---------------------------------------------------------------------------- |
| 402 | |
Ben Wagner | 0ed10be | 2018-06-28 17:08:16 -0400 | [diff] [blame] | 403 | PaintFilter* SkiaCanvas::getPaintFilter() { |
| 404 | return mPaintFilter.get(); |
Derek Sollenberger | acb4099 | 2014-07-21 15:22:10 -0400 | [diff] [blame] | 405 | } |
| 406 | |
Ben Wagner | 0ed10be | 2018-06-28 17:08:16 -0400 | [diff] [blame] | 407 | void SkiaCanvas::setPaintFilter(sk_sp<PaintFilter> paintFilter) { |
| 408 | mPaintFilter = std::move(paintFilter); |
Derek Sollenberger | 8872b38 | 2014-06-23 14:13:53 -0400 | [diff] [blame] | 409 | } |
| 410 | |
| 411 | // ---------------------------------------------------------------------------- |
Matt Sarett | d0814db | 2017-04-13 09:33:18 -0400 | [diff] [blame] | 412 | // Canvas state operations: Capture |
| 413 | // ---------------------------------------------------------------------------- |
| 414 | |
| 415 | SkCanvasState* SkiaCanvas::captureCanvasState() const { |
| 416 | SkCanvas* canvas = mCanvas; |
| 417 | if (mCanvasOwned) { |
| 418 | // Important to use the underlying SkCanvas, not the wrapper. |
| 419 | canvas = mCanvasOwned.get(); |
| 420 | } |
| 421 | |
| 422 | // Workarounds for http://crbug.com/271096: SW draw only supports |
| 423 | // translate & scale transforms, and a simple rectangular clip. |
| 424 | // (This also avoids significant wasted time in calling |
| 425 | // SkCanvasStateUtils::CaptureCanvasState when the clip is complex). |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 426 | if (!canvas->isClipRect() || (canvas->getTotalMatrix().getType() & |
| 427 | ~(SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask))) { |
| 428 | return nullptr; |
Matt Sarett | d0814db | 2017-04-13 09:33:18 -0400 | [diff] [blame] | 429 | } |
| 430 | |
| 431 | return SkCanvasStateUtils::CaptureCanvasState(canvas); |
| 432 | } |
| 433 | |
| 434 | // ---------------------------------------------------------------------------- |
Derek Sollenberger | 8872b38 | 2014-06-23 14:13:53 -0400 | [diff] [blame] | 435 | // Canvas draw operations |
| 436 | // ---------------------------------------------------------------------------- |
| 437 | |
Mike Reed | 260ab72 | 2016-10-07 15:59:20 -0400 | [diff] [blame] | 438 | void SkiaCanvas::drawColor(int color, SkBlendMode mode) { |
Derek Sollenberger | 8872b38 | 2014-06-23 14:13:53 -0400 | [diff] [blame] | 439 | mCanvas->drawColor(color, mode); |
| 440 | } |
| 441 | |
Ben Wagner | 0ed10be | 2018-06-28 17:08:16 -0400 | [diff] [blame] | 442 | SkiaCanvas::PaintCoW&& SkiaCanvas::filterPaint(PaintCoW&& paint) const { |
| 443 | if (mPaintFilter) { |
| 444 | mPaintFilter->filter(&paint.writeable()); |
| 445 | } |
| 446 | return std::move(paint); |
| 447 | } |
| 448 | |
Derek Sollenberger | acb4099 | 2014-07-21 15:22:10 -0400 | [diff] [blame] | 449 | void SkiaCanvas::drawPaint(const SkPaint& paint) { |
Ben Wagner | 0ed10be | 2018-06-28 17:08:16 -0400 | [diff] [blame] | 450 | mCanvas->drawPaint(*filterPaint(paint)); |
Derek Sollenberger | 8872b38 | 2014-06-23 14:13:53 -0400 | [diff] [blame] | 451 | } |
| 452 | |
| 453 | // ---------------------------------------------------------------------------- |
| 454 | // Canvas draw operations: Geometry |
| 455 | // ---------------------------------------------------------------------------- |
| 456 | |
Derek Sollenberger | acb4099 | 2014-07-21 15:22:10 -0400 | [diff] [blame] | 457 | void SkiaCanvas::drawPoints(const float* points, int count, const SkPaint& paint, |
Derek Sollenberger | 8872b38 | 2014-06-23 14:13:53 -0400 | [diff] [blame] | 458 | SkCanvas::PointMode mode) { |
Derek Sollenberger | 792fb32 | 2017-03-03 14:02:09 -0500 | [diff] [blame] | 459 | if (CC_UNLIKELY(count < 2 || paint.nothingToDraw())) return; |
Derek Sollenberger | 8872b38 | 2014-06-23 14:13:53 -0400 | [diff] [blame] | 460 | // convert the floats into SkPoints |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 461 | count >>= 1; // now it is the number of points |
Ben Wagner | 6bbf68d | 2015-08-19 11:26:06 -0400 | [diff] [blame] | 462 | std::unique_ptr<SkPoint[]> pts(new SkPoint[count]); |
Derek Sollenberger | 8872b38 | 2014-06-23 14:13:53 -0400 | [diff] [blame] | 463 | for (int i = 0; i < count; i++) { |
| 464 | pts[i].set(points[0], points[1]); |
| 465 | points += 2; |
| 466 | } |
Ben Wagner | 0ed10be | 2018-06-28 17:08:16 -0400 | [diff] [blame] | 467 | mCanvas->drawPoints(mode, count, pts.get(), *filterPaint(paint)); |
Derek Sollenberger | 8872b38 | 2014-06-23 14:13:53 -0400 | [diff] [blame] | 468 | } |
| 469 | |
Derek Sollenberger | acb4099 | 2014-07-21 15:22:10 -0400 | [diff] [blame] | 470 | void SkiaCanvas::drawPoint(float x, float y, const SkPaint& paint) { |
Ben Wagner | 0ed10be | 2018-06-28 17:08:16 -0400 | [diff] [blame] | 471 | mCanvas->drawPoint(x, y, *filterPaint(paint)); |
Derek Sollenberger | 8872b38 | 2014-06-23 14:13:53 -0400 | [diff] [blame] | 472 | } |
| 473 | |
Derek Sollenberger | acb4099 | 2014-07-21 15:22:10 -0400 | [diff] [blame] | 474 | void SkiaCanvas::drawPoints(const float* points, int count, const SkPaint& paint) { |
Ben Wagner | 0ed10be | 2018-06-28 17:08:16 -0400 | [diff] [blame] | 475 | this->drawPoints(points, count, *filterPaint(paint), SkCanvas::kPoints_PointMode); |
Derek Sollenberger | 8872b38 | 2014-06-23 14:13:53 -0400 | [diff] [blame] | 476 | } |
| 477 | |
| 478 | void SkiaCanvas::drawLine(float startX, float startY, float stopX, float stopY, |
Derek Sollenberger | acb4099 | 2014-07-21 15:22:10 -0400 | [diff] [blame] | 479 | const SkPaint& paint) { |
Ben Wagner | 0ed10be | 2018-06-28 17:08:16 -0400 | [diff] [blame] | 480 | mCanvas->drawLine(startX, startY, stopX, stopY, *filterPaint(paint)); |
Derek Sollenberger | 8872b38 | 2014-06-23 14:13:53 -0400 | [diff] [blame] | 481 | } |
| 482 | |
Derek Sollenberger | acb4099 | 2014-07-21 15:22:10 -0400 | [diff] [blame] | 483 | void SkiaCanvas::drawLines(const float* points, int count, const SkPaint& paint) { |
Derek Sollenberger | 792fb32 | 2017-03-03 14:02:09 -0500 | [diff] [blame] | 484 | if (CC_UNLIKELY(count < 4 || paint.nothingToDraw())) return; |
Ben Wagner | 0ed10be | 2018-06-28 17:08:16 -0400 | [diff] [blame] | 485 | this->drawPoints(points, count, *filterPaint(paint), SkCanvas::kLines_PointMode); |
Derek Sollenberger | 8872b38 | 2014-06-23 14:13:53 -0400 | [diff] [blame] | 486 | } |
| 487 | |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 488 | void SkiaCanvas::drawRect(float left, float top, float right, float bottom, const SkPaint& paint) { |
Derek Sollenberger | 792fb32 | 2017-03-03 14:02:09 -0500 | [diff] [blame] | 489 | if (CC_UNLIKELY(paint.nothingToDraw())) return; |
Ben Wagner | 0ed10be | 2018-06-28 17:08:16 -0400 | [diff] [blame] | 490 | mCanvas->drawRect({left, top, right, bottom}, *filterPaint(paint)); |
Derek Sollenberger | 8872b38 | 2014-06-23 14:13:53 -0400 | [diff] [blame] | 491 | } |
| 492 | |
Derek Sollenberger | 94394b3 | 2015-07-10 09:58:41 -0400 | [diff] [blame] | 493 | void SkiaCanvas::drawRegion(const SkRegion& region, const SkPaint& paint) { |
Derek Sollenberger | 792fb32 | 2017-03-03 14:02:09 -0500 | [diff] [blame] | 494 | if (CC_UNLIKELY(paint.nothingToDraw())) return; |
Ben Wagner | 0ed10be | 2018-06-28 17:08:16 -0400 | [diff] [blame] | 495 | mCanvas->drawRegion(region, *filterPaint(paint)); |
Derek Sollenberger | 94394b3 | 2015-07-10 09:58:41 -0400 | [diff] [blame] | 496 | } |
| 497 | |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 498 | void SkiaCanvas::drawRoundRect(float left, float top, float right, float bottom, float rx, float ry, |
| 499 | const SkPaint& paint) { |
Derek Sollenberger | 792fb32 | 2017-03-03 14:02:09 -0500 | [diff] [blame] | 500 | if (CC_UNLIKELY(paint.nothingToDraw())) return; |
Derek Sollenberger | 8872b38 | 2014-06-23 14:13:53 -0400 | [diff] [blame] | 501 | SkRect rect = SkRect::MakeLTRB(left, top, right, bottom); |
Ben Wagner | 0ed10be | 2018-06-28 17:08:16 -0400 | [diff] [blame] | 502 | mCanvas->drawRoundRect(rect, rx, ry, *filterPaint(paint)); |
Derek Sollenberger | 8872b38 | 2014-06-23 14:13:53 -0400 | [diff] [blame] | 503 | } |
| 504 | |
Nader Jawad | adfe1d9 | 2018-09-27 12:27:36 -0700 | [diff] [blame] | 505 | void SkiaCanvas::drawDoubleRoundRect(const SkRRect& outer, const SkRRect& inner, |
| 506 | const SkPaint& paint) { |
| 507 | mCanvas->drawDRRect(outer, inner, *filterPaint(paint)); |
| 508 | } |
| 509 | |
Derek Sollenberger | acb4099 | 2014-07-21 15:22:10 -0400 | [diff] [blame] | 510 | void SkiaCanvas::drawCircle(float x, float y, float radius, const SkPaint& paint) { |
Derek Sollenberger | 792fb32 | 2017-03-03 14:02:09 -0500 | [diff] [blame] | 511 | if (CC_UNLIKELY(radius <= 0 || paint.nothingToDraw())) return; |
Ben Wagner | 0ed10be | 2018-06-28 17:08:16 -0400 | [diff] [blame] | 512 | mCanvas->drawCircle(x, y, radius, *filterPaint(paint)); |
Derek Sollenberger | 8872b38 | 2014-06-23 14:13:53 -0400 | [diff] [blame] | 513 | } |
| 514 | |
Derek Sollenberger | acb4099 | 2014-07-21 15:22:10 -0400 | [diff] [blame] | 515 | void SkiaCanvas::drawOval(float left, float top, float right, float bottom, const SkPaint& paint) { |
Derek Sollenberger | 792fb32 | 2017-03-03 14:02:09 -0500 | [diff] [blame] | 516 | if (CC_UNLIKELY(paint.nothingToDraw())) return; |
Derek Sollenberger | 8872b38 | 2014-06-23 14:13:53 -0400 | [diff] [blame] | 517 | SkRect oval = SkRect::MakeLTRB(left, top, right, bottom); |
Ben Wagner | 0ed10be | 2018-06-28 17:08:16 -0400 | [diff] [blame] | 518 | mCanvas->drawOval(oval, *filterPaint(paint)); |
Derek Sollenberger | 8872b38 | 2014-06-23 14:13:53 -0400 | [diff] [blame] | 519 | } |
| 520 | |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 521 | void SkiaCanvas::drawArc(float left, float top, float right, float bottom, float startAngle, |
| 522 | float sweepAngle, bool useCenter, const SkPaint& paint) { |
Derek Sollenberger | 792fb32 | 2017-03-03 14:02:09 -0500 | [diff] [blame] | 523 | if (CC_UNLIKELY(paint.nothingToDraw())) return; |
Derek Sollenberger | 8872b38 | 2014-06-23 14:13:53 -0400 | [diff] [blame] | 524 | SkRect arc = SkRect::MakeLTRB(left, top, right, bottom); |
Derek Sollenberger | ef3b218 | 2017-11-06 13:55:59 -0500 | [diff] [blame] | 525 | if (fabs(sweepAngle) >= 360.0f) { |
Ben Wagner | 0ed10be | 2018-06-28 17:08:16 -0400 | [diff] [blame] | 526 | mCanvas->drawOval(arc, *filterPaint(paint)); |
Derek Sollenberger | ef3b218 | 2017-11-06 13:55:59 -0500 | [diff] [blame] | 527 | } else { |
Ben Wagner | 0ed10be | 2018-06-28 17:08:16 -0400 | [diff] [blame] | 528 | mCanvas->drawArc(arc, startAngle, sweepAngle, useCenter, *filterPaint(paint)); |
Derek Sollenberger | ef3b218 | 2017-11-06 13:55:59 -0500 | [diff] [blame] | 529 | } |
Derek Sollenberger | 8872b38 | 2014-06-23 14:13:53 -0400 | [diff] [blame] | 530 | } |
| 531 | |
Derek Sollenberger | acb4099 | 2014-07-21 15:22:10 -0400 | [diff] [blame] | 532 | void SkiaCanvas::drawPath(const SkPath& path, const SkPaint& paint) { |
Derek Sollenberger | 792fb32 | 2017-03-03 14:02:09 -0500 | [diff] [blame] | 533 | if (CC_UNLIKELY(paint.nothingToDraw())) return; |
Stan Iliev | 6dcfdec | 2017-08-15 16:42:05 -0400 | [diff] [blame] | 534 | if (CC_UNLIKELY(path.isEmpty() && (!path.isInverseFillType()))) { |
| 535 | return; |
| 536 | } |
Ben Wagner | 0ed10be | 2018-06-28 17:08:16 -0400 | [diff] [blame] | 537 | mCanvas->drawPath(path, *filterPaint(paint)); |
Derek Sollenberger | 8872b38 | 2014-06-23 14:13:53 -0400 | [diff] [blame] | 538 | } |
| 539 | |
Mike Reed | 826deef | 2017-04-04 15:32:04 -0400 | [diff] [blame] | 540 | void SkiaCanvas::drawVertices(const SkVertices* vertices, SkBlendMode mode, const SkPaint& paint) { |
Ben Wagner | 0ed10be | 2018-06-28 17:08:16 -0400 | [diff] [blame] | 541 | mCanvas->drawVertices(vertices, mode, *filterPaint(paint)); |
Derek Sollenberger | 8872b38 | 2014-06-23 14:13:53 -0400 | [diff] [blame] | 542 | } |
| 543 | |
| 544 | // ---------------------------------------------------------------------------- |
| 545 | // Canvas draw operations: Bitmaps |
| 546 | // ---------------------------------------------------------------------------- |
| 547 | |
Derek Sollenberger | fb0c8fc | 2017-07-26 13:53:27 -0400 | [diff] [blame] | 548 | void SkiaCanvas::drawBitmap(Bitmap& bitmap, float left, float top, const SkPaint* paint) { |
Derek Sollenberger | d01b591 | 2018-10-19 15:55:33 -0400 | [diff] [blame] | 549 | mCanvas->drawImage(bitmap.makeImage(), left, top, filterPaint(paint)); |
Derek Sollenberger | fb0c8fc | 2017-07-26 13:53:27 -0400 | [diff] [blame] | 550 | } |
| 551 | |
| 552 | void SkiaCanvas::drawBitmap(Bitmap& bitmap, const SkMatrix& matrix, const SkPaint* paint) { |
Mike Reed | 6acfe16 | 2016-11-18 17:21:09 -0500 | [diff] [blame] | 553 | SkAutoCanvasRestore acr(mCanvas, true); |
Mike Reed | 70ffbf9 | 2014-12-08 17:03:30 -0500 | [diff] [blame] | 554 | mCanvas->concat(matrix); |
Derek Sollenberger | d01b591 | 2018-10-19 15:55:33 -0400 | [diff] [blame] | 555 | mCanvas->drawImage(bitmap.makeImage(), 0, 0, filterPaint(paint)); |
Derek Sollenberger | 8872b38 | 2014-06-23 14:13:53 -0400 | [diff] [blame] | 556 | } |
| 557 | |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 558 | void SkiaCanvas::drawBitmap(Bitmap& bitmap, float srcLeft, float srcTop, float srcRight, |
| 559 | float srcBottom, float dstLeft, float dstTop, float dstRight, |
| 560 | float dstBottom, const SkPaint* paint) { |
Derek Sollenberger | 8872b38 | 2014-06-23 14:13:53 -0400 | [diff] [blame] | 561 | SkRect srcRect = SkRect::MakeLTRB(srcLeft, srcTop, srcRight, srcBottom); |
| 562 | SkRect dstRect = SkRect::MakeLTRB(dstLeft, dstTop, dstRight, dstBottom); |
Derek Sollenberger | fb0c8fc | 2017-07-26 13:53:27 -0400 | [diff] [blame] | 563 | |
Derek Sollenberger | d01b591 | 2018-10-19 15:55:33 -0400 | [diff] [blame] | 564 | mCanvas->drawImageRect(bitmap.makeImage(), srcRect, dstRect, filterPaint(paint), |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 565 | SkCanvas::kFast_SrcRectConstraint); |
Derek Sollenberger | 8872b38 | 2014-06-23 14:13:53 -0400 | [diff] [blame] | 566 | } |
| 567 | |
Derek Sollenberger | fb0c8fc | 2017-07-26 13:53:27 -0400 | [diff] [blame] | 568 | void SkiaCanvas::drawBitmapMesh(Bitmap& bitmap, int meshWidth, int meshHeight, |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 569 | const float* vertices, const int* colors, const SkPaint* paint) { |
Derek Sollenberger | 8872b38 | 2014-06-23 14:13:53 -0400 | [diff] [blame] | 570 | const int ptCount = (meshWidth + 1) * (meshHeight + 1); |
| 571 | const int indexCount = meshWidth * meshHeight * 6; |
Mike Reed | 871cd2d | 2017-03-17 10:15:52 -0400 | [diff] [blame] | 572 | uint32_t flags = SkVertices::kHasTexCoords_BuilderFlag; |
| 573 | if (colors) { |
| 574 | flags |= SkVertices::kHasColors_BuilderFlag; |
| 575 | } |
Mike Reed | 826deef | 2017-04-04 15:32:04 -0400 | [diff] [blame] | 576 | SkVertices::Builder builder(SkVertices::kTriangles_VertexMode, ptCount, indexCount, flags); |
Mike Reed | 871cd2d | 2017-03-17 10:15:52 -0400 | [diff] [blame] | 577 | memcpy(builder.positions(), vertices, ptCount * sizeof(SkPoint)); |
| 578 | if (colors) { |
| 579 | memcpy(builder.colors(), colors, ptCount * sizeof(SkColor)); |
| 580 | } |
| 581 | SkPoint* texs = builder.texCoords(); |
| 582 | uint16_t* indices = builder.indices(); |
Derek Sollenberger | 8872b38 | 2014-06-23 14:13:53 -0400 | [diff] [blame] | 583 | |
| 584 | // cons up texture coordinates and indices |
| 585 | { |
Derek Sollenberger | fb0c8fc | 2017-07-26 13:53:27 -0400 | [diff] [blame] | 586 | const SkScalar w = SkIntToScalar(bitmap.width()); |
| 587 | const SkScalar h = SkIntToScalar(bitmap.height()); |
Derek Sollenberger | 8872b38 | 2014-06-23 14:13:53 -0400 | [diff] [blame] | 588 | const SkScalar dx = w / meshWidth; |
| 589 | const SkScalar dy = h / meshHeight; |
| 590 | |
| 591 | SkPoint* texsPtr = texs; |
| 592 | SkScalar y = 0; |
| 593 | for (int i = 0; i <= meshHeight; i++) { |
| 594 | if (i == meshHeight) { |
| 595 | y = h; // to ensure numerically we hit h exactly |
| 596 | } |
| 597 | SkScalar x = 0; |
| 598 | for (int j = 0; j < meshWidth; j++) { |
| 599 | texsPtr->set(x, y); |
| 600 | texsPtr += 1; |
| 601 | x += dx; |
| 602 | } |
| 603 | texsPtr->set(w, y); |
| 604 | texsPtr += 1; |
| 605 | y += dy; |
| 606 | } |
| 607 | SkASSERT(texsPtr - texs == ptCount); |
| 608 | } |
| 609 | |
| 610 | // cons up indices |
| 611 | { |
| 612 | uint16_t* indexPtr = indices; |
| 613 | int index = 0; |
| 614 | for (int i = 0; i < meshHeight; i++) { |
| 615 | for (int j = 0; j < meshWidth; j++) { |
| 616 | // lower-left triangle |
| 617 | *indexPtr++ = index; |
| 618 | *indexPtr++ = index + meshWidth + 1; |
| 619 | *indexPtr++ = index + meshWidth + 2; |
| 620 | // upper-right triangle |
| 621 | *indexPtr++ = index; |
| 622 | *indexPtr++ = index + meshWidth + 2; |
| 623 | *indexPtr++ = index + 1; |
| 624 | // bump to the next cell |
| 625 | index += 1; |
| 626 | } |
| 627 | // bump to the next row |
| 628 | index += 1; |
| 629 | } |
| 630 | SkASSERT(indexPtr - indices == indexCount); |
Derek Sollenberger | 8872b38 | 2014-06-23 14:13:53 -0400 | [diff] [blame] | 631 | } |
| 632 | |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 633 | // double-check that we have legal indices |
Derek Sollenberger | 8872b38 | 2014-06-23 14:13:53 -0400 | [diff] [blame] | 634 | #ifdef SK_DEBUG |
| 635 | { |
| 636 | for (int i = 0; i < indexCount; i++) { |
| 637 | SkASSERT((unsigned)indices[i] < (unsigned)ptCount); |
| 638 | } |
| 639 | } |
| 640 | #endif |
| 641 | |
| 642 | // cons-up a shader for the bitmap |
Ben Wagner | 0ed10be | 2018-06-28 17:08:16 -0400 | [diff] [blame] | 643 | PaintCoW paintCoW(paint); |
| 644 | SkPaint& tmpPaint = paintCoW.writeable(); |
Stan Iliev | f50806a | 2016-10-24 10:40:39 -0400 | [diff] [blame] | 645 | |
Derek Sollenberger | d01b591 | 2018-10-19 15:55:33 -0400 | [diff] [blame] | 646 | sk_sp<SkImage> image = bitmap.makeImage(); |
Mike Reed | 1c2f5fc | 2019-04-10 16:57:52 -0400 | [diff] [blame] | 647 | sk_sp<SkShader> shader = image->makeShader(); |
Ben Wagner | 0ed10be | 2018-06-28 17:08:16 -0400 | [diff] [blame] | 648 | tmpPaint.setShader(std::move(shader)); |
Derek Sollenberger | 8872b38 | 2014-06-23 14:13:53 -0400 | [diff] [blame] | 649 | |
Ben Wagner | 0ed10be | 2018-06-28 17:08:16 -0400 | [diff] [blame] | 650 | mCanvas->drawVertices(builder.detach(), SkBlendMode::kModulate, |
| 651 | *filterPaint(std::move(paintCoW))); |
Derek Sollenberger | 8872b38 | 2014-06-23 14:13:53 -0400 | [diff] [blame] | 652 | } |
| 653 | |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 654 | void SkiaCanvas::drawNinePatch(Bitmap& bitmap, const Res_png_9patch& chunk, float dstLeft, |
| 655 | float dstTop, float dstRight, float dstBottom, |
| 656 | const SkPaint* paint) { |
Stan Iliev | f50806a | 2016-10-24 10:40:39 -0400 | [diff] [blame] | 657 | SkCanvas::Lattice lattice; |
Derek Sollenberger | fb0c8fc | 2017-07-26 13:53:27 -0400 | [diff] [blame] | 658 | NinePatchUtils::SetLatticeDivs(&lattice, chunk, bitmap.width(), bitmap.height()); |
Stan Iliev | f50806a | 2016-10-24 10:40:39 -0400 | [diff] [blame] | 659 | |
Stan Iliev | e12d731 | 2017-12-04 14:48:27 -0500 | [diff] [blame] | 660 | lattice.fRectTypes = nullptr; |
| 661 | lattice.fColors = nullptr; |
Stan Iliev | f50806a | 2016-10-24 10:40:39 -0400 | [diff] [blame] | 662 | int numFlags = 0; |
Stan Iliev | 021693b | 2016-10-17 16:26:15 -0400 | [diff] [blame] | 663 | if (chunk.numColors > 0 && chunk.numColors == NinePatchUtils::NumDistinctRects(lattice)) { |
Stan Iliev | f50806a | 2016-10-24 10:40:39 -0400 | [diff] [blame] | 664 | // We can expect the framework to give us a color for every distinct rect. |
| 665 | // Skia requires a flag for every rect. |
| 666 | numFlags = (lattice.fXCount + 1) * (lattice.fYCount + 1); |
| 667 | } |
| 668 | |
Stan Iliev | e12d731 | 2017-12-04 14:48:27 -0500 | [diff] [blame] | 669 | SkAutoSTMalloc<25, SkCanvas::Lattice::RectType> flags(numFlags); |
| 670 | SkAutoSTMalloc<25, SkColor> colors(numFlags); |
Stan Iliev | f50806a | 2016-10-24 10:40:39 -0400 | [diff] [blame] | 671 | if (numFlags > 0) { |
Stan Iliev | e12d731 | 2017-12-04 14:48:27 -0500 | [diff] [blame] | 672 | NinePatchUtils::SetLatticeFlags(&lattice, flags.get(), numFlags, chunk, colors.get()); |
Stan Iliev | f50806a | 2016-10-24 10:40:39 -0400 | [diff] [blame] | 673 | } |
| 674 | |
| 675 | lattice.fBounds = nullptr; |
| 676 | SkRect dst = SkRect::MakeLTRB(dstLeft, dstTop, dstRight, dstBottom); |
Derek Sollenberger | fb0c8fc | 2017-07-26 13:53:27 -0400 | [diff] [blame] | 677 | |
Derek Sollenberger | d01b591 | 2018-10-19 15:55:33 -0400 | [diff] [blame] | 678 | mCanvas->drawImageLattice(bitmap.makeImage().get(), lattice, dst, filterPaint(paint)); |
Derek Sollenberger | edca320 | 2015-07-10 13:56:39 -0400 | [diff] [blame] | 679 | } |
| 680 | |
Derek Sollenberger | 2d14213 | 2018-01-22 10:25:26 -0500 | [diff] [blame] | 681 | double SkiaCanvas::drawAnimatedImage(AnimatedImageDrawable* imgDrawable) { |
| 682 | return imgDrawable->drawStaging(mCanvas); |
Leon Scroggins III | 671cce2 | 2018-01-14 16:52:17 -0500 | [diff] [blame] | 683 | } |
| 684 | |
Doris Liu | 766431a | 2016-02-04 22:17:11 +0000 | [diff] [blame] | 685 | void SkiaCanvas::drawVectorDrawable(VectorDrawableRoot* vectorDrawable) { |
Doris Liu | 1d8e194 | 2016-03-02 15:16:28 -0800 | [diff] [blame] | 686 | vectorDrawable->drawStaging(this); |
Doris Liu | 766431a | 2016-02-04 22:17:11 +0000 | [diff] [blame] | 687 | } |
| 688 | |
Derek Sollenberger | 8872b38 | 2014-06-23 14:13:53 -0400 | [diff] [blame] | 689 | // ---------------------------------------------------------------------------- |
| 690 | // Canvas draw operations: Text |
| 691 | // ---------------------------------------------------------------------------- |
| 692 | |
Mike Reed | 2dfd55d | 2019-01-08 16:19:03 -0500 | [diff] [blame] | 693 | void SkiaCanvas::drawGlyphs(ReadGlyphFunc glyphFunc, int count, const Paint& paint, float x, |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 694 | float y, float boundsLeft, float boundsTop, float boundsRight, |
| 695 | float boundsBottom, float totalAdvance) { |
Stan Iliev | 0b58d99 | 2017-03-30 18:22:27 -0400 | [diff] [blame] | 696 | if (count <= 0 || paint.nothingToDraw()) return; |
Mike Reed | f6d86ac | 2019-01-18 14:13:23 -0500 | [diff] [blame] | 697 | Paint paintCopy(paint); |
Ben Wagner | 0ed10be | 2018-06-28 17:08:16 -0400 | [diff] [blame] | 698 | if (mPaintFilter) { |
Mike Reed | f6d86ac | 2019-01-18 14:13:23 -0500 | [diff] [blame] | 699 | mPaintFilter->filterFullPaint(&paintCopy); |
Ben Wagner | 0ed10be | 2018-06-28 17:08:16 -0400 | [diff] [blame] | 700 | } |
Mike Reed | f6d86ac | 2019-01-18 14:13:23 -0500 | [diff] [blame] | 701 | const SkFont& font = paintCopy.getSkFont(); |
Stan Iliev | 7717e22 | 2018-02-05 18:04:11 -0500 | [diff] [blame] | 702 | // Stroke with a hairline is drawn on HW with a fill style for compatibility with Android O and |
| 703 | // older. |
John Reck | e170fb6 | 2018-05-07 08:12:07 -0700 | [diff] [blame] | 704 | if (!mCanvasOwned && sApiLevel <= 27 && paintCopy.getStrokeWidth() <= 0 && |
| 705 | paintCopy.getStyle() == SkPaint::kStroke_Style) { |
Stan Iliev | 7717e22 | 2018-02-05 18:04:11 -0500 | [diff] [blame] | 706 | paintCopy.setStyle(SkPaint::kFill_Style); |
| 707 | } |
Stan Iliev | f50806a | 2016-10-24 10:40:39 -0400 | [diff] [blame] | 708 | |
Stan Iliev | f50806a | 2016-10-24 10:40:39 -0400 | [diff] [blame] | 709 | SkTextBlobBuilder builder; |
Mike Reed | 2e204fc | 2019-01-28 13:31:36 -0500 | [diff] [blame] | 710 | const SkTextBlobBuilder::RunBuffer& buffer = builder.allocRunPos(font, count); |
Stan Iliev | 0b58d99 | 2017-03-30 18:22:27 -0400 | [diff] [blame] | 711 | glyphFunc(buffer.glyphs, buffer.pos); |
Stan Iliev | f50806a | 2016-10-24 10:40:39 -0400 | [diff] [blame] | 712 | |
| 713 | sk_sp<SkTextBlob> textBlob(builder.make()); |
| 714 | mCanvas->drawTextBlob(textBlob, 0, 0, paintCopy); |
| 715 | drawTextDecorations(x, y, totalAdvance, paintCopy); |
Derek Sollenberger | 8872b38 | 2014-06-23 14:13:53 -0400 | [diff] [blame] | 716 | } |
| 717 | |
Yuqian Li | afc22149 | 2016-07-18 13:07:42 -0400 | [diff] [blame] | 718 | void SkiaCanvas::drawLayoutOnPath(const minikin::Layout& layout, float hOffset, float vOffset, |
Mike Reed | 2dfd55d | 2019-01-08 16:19:03 -0500 | [diff] [blame] | 719 | const Paint& paint, const SkPath& path, size_t start, |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 720 | size_t end) { |
Mike Reed | f6d86ac | 2019-01-18 14:13:23 -0500 | [diff] [blame] | 721 | Paint paintCopy(paint); |
Ben Wagner | 0ed10be | 2018-06-28 17:08:16 -0400 | [diff] [blame] | 722 | if (mPaintFilter) { |
Mike Reed | f6d86ac | 2019-01-18 14:13:23 -0500 | [diff] [blame] | 723 | mPaintFilter->filterFullPaint(&paintCopy); |
Ben Wagner | 0ed10be | 2018-06-28 17:08:16 -0400 | [diff] [blame] | 724 | } |
Mike Reed | f6d86ac | 2019-01-18 14:13:23 -0500 | [diff] [blame] | 725 | const SkFont& font = paintCopy.getSkFont(); |
Derek Sollenberger | 415a74b | 2018-03-14 15:03:13 -0400 | [diff] [blame] | 726 | |
Yuqian Li | afc22149 | 2016-07-18 13:07:42 -0400 | [diff] [blame] | 727 | const int N = end - start; |
Mike Reed | 4a4b1be | 2019-01-01 15:43:06 -0500 | [diff] [blame] | 728 | SkTextBlobBuilder builder; |
| 729 | auto rec = builder.allocRunRSXform(font, N); |
| 730 | SkRSXform* xform = (SkRSXform*)rec.pos; |
| 731 | uint16_t* glyphs = rec.glyphs; |
Yuqian Li | afc22149 | 2016-07-18 13:07:42 -0400 | [diff] [blame] | 732 | SkPathMeasure meas(path, false); |
| 733 | |
| 734 | for (size_t i = start; i < end; i++) { |
| 735 | glyphs[i - start] = layout.getGlyphId(i); |
Stan Iliev | c6c96dd | 2018-01-10 16:06:04 -0500 | [diff] [blame] | 736 | float halfWidth = layout.getCharAdvance(i) * 0.5f; |
| 737 | float x = hOffset + layout.getX(i) + halfWidth; |
Yuqian Li | afc22149 | 2016-07-18 13:07:42 -0400 | [diff] [blame] | 738 | float y = vOffset + layout.getY(i); |
| 739 | |
| 740 | SkPoint pos; |
| 741 | SkVector tan; |
| 742 | if (!meas.getPosTan(x, &pos, &tan)) { |
| 743 | pos.set(x, y); |
| 744 | tan.set(1, 0); |
| 745 | } |
| 746 | xform[i - start].fSCos = tan.x(); |
| 747 | xform[i - start].fSSin = tan.y(); |
Stan Iliev | c6c96dd | 2018-01-10 16:06:04 -0500 | [diff] [blame] | 748 | xform[i - start].fTx = pos.x() - tan.y() * y - halfWidth * tan.x(); |
| 749 | xform[i - start].fTy = pos.y() + tan.x() * y - halfWidth * tan.y(); |
Yuqian Li | afc22149 | 2016-07-18 13:07:42 -0400 | [diff] [blame] | 750 | } |
| 751 | |
Mike Reed | 4a4b1be | 2019-01-01 15:43:06 -0500 | [diff] [blame] | 752 | this->asSkCanvas()->drawTextBlob(builder.make(), 0, 0, paintCopy); |
Derek Sollenberger | 8872b38 | 2014-06-23 14:13:53 -0400 | [diff] [blame] | 753 | } |
| 754 | |
Derek Sollenberger | 6f48556 | 2015-07-30 10:00:39 -0400 | [diff] [blame] | 755 | // ---------------------------------------------------------------------------- |
| 756 | // Canvas draw operations: Animations |
| 757 | // ---------------------------------------------------------------------------- |
| 758 | |
Derek Sollenberger | 6f48556 | 2015-07-30 10:00:39 -0400 | [diff] [blame] | 759 | void SkiaCanvas::drawRoundRect(uirenderer::CanvasPropertyPrimitive* left, |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 760 | uirenderer::CanvasPropertyPrimitive* top, |
| 761 | uirenderer::CanvasPropertyPrimitive* right, |
| 762 | uirenderer::CanvasPropertyPrimitive* bottom, |
| 763 | uirenderer::CanvasPropertyPrimitive* rx, |
| 764 | uirenderer::CanvasPropertyPrimitive* ry, |
| 765 | uirenderer::CanvasPropertyPaint* paint) { |
Stan Iliev | 021693b | 2016-10-17 16:26:15 -0400 | [diff] [blame] | 766 | sk_sp<uirenderer::skiapipeline::AnimatedRoundRect> drawable( |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 767 | new uirenderer::skiapipeline::AnimatedRoundRect(left, top, right, bottom, rx, ry, |
| 768 | paint)); |
Derek Sollenberger | 6f48556 | 2015-07-30 10:00:39 -0400 | [diff] [blame] | 769 | mCanvas->drawDrawable(drawable.get()); |
| 770 | } |
| 771 | |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 772 | void SkiaCanvas::drawCircle(uirenderer::CanvasPropertyPrimitive* x, |
| 773 | uirenderer::CanvasPropertyPrimitive* y, |
| 774 | uirenderer::CanvasPropertyPrimitive* radius, |
| 775 | uirenderer::CanvasPropertyPaint* paint) { |
| 776 | sk_sp<uirenderer::skiapipeline::AnimatedCircle> drawable( |
| 777 | new uirenderer::skiapipeline::AnimatedCircle(x, y, radius, paint)); |
Derek Sollenberger | 6f48556 | 2015-07-30 10:00:39 -0400 | [diff] [blame] | 778 | mCanvas->drawDrawable(drawable.get()); |
| 779 | } |
| 780 | |
| 781 | // ---------------------------------------------------------------------------- |
| 782 | // Canvas draw operations: View System |
| 783 | // ---------------------------------------------------------------------------- |
| 784 | |
Stan Iliev | f50806a | 2016-10-24 10:40:39 -0400 | [diff] [blame] | 785 | void SkiaCanvas::drawLayer(uirenderer::DeferredLayerUpdater* layerUpdater) { |
Derek Sollenberger | c190813 | 2016-07-15 10:28:16 -0400 | [diff] [blame] | 786 | LOG_ALWAYS_FATAL("SkiaCanvas can't directly draw Layers"); |
| 787 | } |
Derek Sollenberger | 6f48556 | 2015-07-30 10:00:39 -0400 | [diff] [blame] | 788 | |
Derek Sollenberger | c190813 | 2016-07-15 10:28:16 -0400 | [diff] [blame] | 789 | void SkiaCanvas::drawRenderNode(uirenderer::RenderNode* renderNode) { |
| 790 | LOG_ALWAYS_FATAL("SkiaCanvas can't directly draw RenderNodes"); |
| 791 | } |
Derek Sollenberger | 6f48556 | 2015-07-30 10:00:39 -0400 | [diff] [blame] | 792 | |
John Reck | cd1c3eb | 2016-04-14 10:38:54 -0700 | [diff] [blame] | 793 | void SkiaCanvas::callDrawGLFunction(Functor* functor, |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 794 | uirenderer::GlFunctorLifecycleListener* listener) { |
Derek Sollenberger | c190813 | 2016-07-15 10:28:16 -0400 | [diff] [blame] | 795 | LOG_ALWAYS_FATAL("SkiaCanvas can't directly draw GL Content"); |
| 796 | } |
Derek Sollenberger | 6f48556 | 2015-07-30 10:00:39 -0400 | [diff] [blame] | 797 | |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 798 | } // namespace android |