blob: ed6e52245243564ab0b8eccc369ed12b640ced6e [file] [log] [blame]
Derek Sollenberger8872b382014-06-23 14:13:53 -04001/*
2 * Copyright (C) 2014 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Derek Sollenbergerc1908132016-07-15 10:28:16 -040017#include "SkiaCanvas.h"
Derek Sollenberger8872b382014-06-23 14:13:53 -040018
Derek Sollenbergerc1908132016-07-15 10:28:16 -040019#include "CanvasProperty.h"
Matt Sarett7de73852016-10-25 18:36:39 -040020#include "NinePatchUtils.h"
Derek Sollenbergerc1908132016-07-15 10:28:16 -040021#include "VectorDrawable.h"
sergeyvaed7f582016-10-14 16:30:21 -070022#include "hwui/Bitmap.h"
Yuqian Liafc221492016-07-18 13:07:42 -040023#include "hwui/MinikinUtils.h"
Stan Iliev021693b2016-10-17 16:26:15 -040024#include "pipeline/skia/AnimatedDrawables.h"
Derek Sollenbergerc1908132016-07-15 10:28:16 -040025
Matt Sarett44dc2702017-04-13 09:33:18 -040026#include <SkCanvasStateUtils.h>
Matt Sarettea70d222017-03-29 16:25:10 -040027#include <SkColorSpaceXformCanvas.h>
Derek Sollenberger6f485562015-07-30 10:00:39 -040028#include <SkDrawable.h>
John Reck849911a2015-01-20 07:51:14 -080029#include <SkDeque.h>
30#include <SkDrawFilter.h>
31#include <SkGraphics.h>
Derek Sollenberger6f485562015-07-30 10:00:39 -040032#include <SkImage.h>
Matt Sarett62feb3a2016-09-20 10:34:11 -040033#include <SkImagePriv.h>
Yuqian Liafc221492016-07-18 13:07:42 -040034#include <SkRSXform.h>
John Reck849911a2015-01-20 07:51:14 -080035#include <SkShader.h>
John Reck849911a2015-01-20 07:51:14 -080036#include <SkTemplates.h>
Stan Ilievf50806a2016-10-24 10:40:39 -040037#include <SkTextBlob.h>
Derek Sollenberger8872b382014-06-23 14:13:53 -040038
Ben Wagner60126ef2015-08-07 12:13:48 -040039#include <memory>
40
Derek Sollenberger8872b382014-06-23 14:13:53 -040041namespace android {
42
Stan Ilievf50806a2016-10-24 10:40:39 -040043using uirenderer::PaintUtils;
44
John Reckc1b33d62015-04-22 09:04:45 -070045Canvas* Canvas::create_canvas(const SkBitmap& bitmap) {
Derek Sollenberger8872b382014-06-23 14:13:53 -040046 return new SkiaCanvas(bitmap);
47}
48
Matt Sarettea70d222017-03-29 16:25:10 -040049Canvas* Canvas::create_canvas(SkCanvas* skiaCanvas, XformToSRGB xformToSRGB) {
50 return new SkiaCanvas(skiaCanvas, xformToSRGB);
Derek Sollenberger8872b382014-06-23 14:13:53 -040051}
52
Stan Ilievf50806a2016-10-24 10:40:39 -040053SkiaCanvas::SkiaCanvas() {}
54
Matt Sarettea70d222017-03-29 16:25:10 -040055SkiaCanvas::SkiaCanvas(SkCanvas* canvas, XformToSRGB xformToSRGB)
56 : mCanvas(canvas)
57{
58 LOG_ALWAYS_FATAL_IF(XformToSRGB::kImmediate == xformToSRGB);
59}
Stan Ilievf50806a2016-10-24 10:40:39 -040060
John Reckc1b33d62015-04-22 09:04:45 -070061SkiaCanvas::SkiaCanvas(const SkBitmap& bitmap) {
Romain Guy82426562017-04-04 19:38:50 -070062 sk_sp<SkColorSpace> cs = bitmap.refColorSpace();
Mike Reed6acfe162016-11-18 17:21:09 -050063 mCanvasOwned = std::unique_ptr<SkCanvas>(new SkCanvas(bitmap));
Romain Guy82426562017-04-04 19:38:50 -070064 mCanvasWrapper = SkCreateColorSpaceXformCanvas(mCanvasOwned.get(),
65 cs == nullptr ? SkColorSpace::MakeSRGB() : std::move(cs));
Matt Sarettea70d222017-03-29 16:25:10 -040066 mCanvas = mCanvasWrapper.get();
Derek Sollenberger8872b382014-06-23 14:13:53 -040067}
68
Stan Iliev021693b2016-10-17 16:26:15 -040069SkiaCanvas::~SkiaCanvas() {}
70
Derek Sollenbergerc1908132016-07-15 10:28:16 -040071void SkiaCanvas::reset(SkCanvas* skiaCanvas) {
Mike Reed6acfe162016-11-18 17:21:09 -050072 if (mCanvas != skiaCanvas) {
73 mCanvas = skiaCanvas;
74 mCanvasOwned.reset();
75 }
Derek Sollenbergerc1908132016-07-15 10:28:16 -040076 mSaveStack.reset(nullptr);
77 mHighContrastText = false;
78}
79
Derek Sollenberger8872b382014-06-23 14:13:53 -040080// ----------------------------------------------------------------------------
81// Canvas state operations: Replace Bitmap
82// ----------------------------------------------------------------------------
83
John Reckc1b33d62015-04-22 09:04:45 -070084void SkiaCanvas::setBitmap(const SkBitmap& bitmap) {
Romain Guy82426562017-04-04 19:38:50 -070085 sk_sp<SkColorSpace> cs = bitmap.refColorSpace();
Matt Sarettea70d222017-03-29 16:25:10 -040086 std::unique_ptr<SkCanvas> newCanvas = std::unique_ptr<SkCanvas>(new SkCanvas(bitmap));
Romain Guy82426562017-04-04 19:38:50 -070087 std::unique_ptr<SkCanvas> newCanvasWrapper = SkCreateColorSpaceXformCanvas(newCanvas.get(),
88 cs == nullptr ? SkColorSpace::MakeSRGB() : std::move(cs));
Tony Mantler4f641d12017-03-14 22:36:14 +000089
Tony Mantler4f641d12017-03-14 22:36:14 +000090 // deletes the previously owned canvas (if any)
Matt Sarettea70d222017-03-29 16:25:10 -040091 mCanvasOwned = std::move(newCanvas);
92 mCanvasWrapper = std::move(newCanvasWrapper);
93 mCanvas = mCanvasWrapper.get();
Tony Mantler4f641d12017-03-14 22:36:14 +000094
Derek Sollenberger8872b382014-06-23 14:13:53 -040095 // clean up the old save stack
Stan Ilievf50806a2016-10-24 10:40:39 -040096 mSaveStack.reset(nullptr);
Derek Sollenberger8872b382014-06-23 14:13:53 -040097}
98
99// ----------------------------------------------------------------------------
100// Canvas state operations
101// ----------------------------------------------------------------------------
102
103bool SkiaCanvas::isOpaque() {
Leon Scroggins IIIf35b9892015-07-31 10:38:40 -0400104 return mCanvas->imageInfo().isOpaque();
Derek Sollenberger8872b382014-06-23 14:13:53 -0400105}
106
107int SkiaCanvas::width() {
Leon Scroggins IIIf35b9892015-07-31 10:38:40 -0400108 return mCanvas->imageInfo().width();
Derek Sollenberger8872b382014-06-23 14:13:53 -0400109}
110
111int SkiaCanvas::height() {
Leon Scroggins IIIf35b9892015-07-31 10:38:40 -0400112 return mCanvas->imageInfo().height();
Derek Sollenberger8872b382014-06-23 14:13:53 -0400113}
114
115// ----------------------------------------------------------------------------
116// Canvas state operations: Save (layer)
117// ----------------------------------------------------------------------------
118
119int SkiaCanvas::getSaveCount() const {
120 return mCanvas->getSaveCount();
121}
122
Florin Malitaeecff562015-12-21 10:43:01 -0500123int SkiaCanvas::save(SaveFlags::Flags flags) {
Derek Sollenberger8872b382014-06-23 14:13:53 -0400124 int count = mCanvas->save();
125 recordPartialSave(flags);
126 return count;
127}
128
Florin Malita5e271402015-11-04 14:36:02 -0500129// The SkiaCanvas::restore operation layers on the capability to preserve
130// either (or both) the matrix and/or clip state after a SkCanvas::restore
131// operation. It does this by explicitly saving off the clip & matrix state
132// when requested and playing it back after the SkCanvas::restore.
Derek Sollenberger8872b382014-06-23 14:13:53 -0400133void SkiaCanvas::restore() {
Stan Ilievf50806a2016-10-24 10:40:39 -0400134 const auto* rec = this->currentSaveRec();
135 if (!rec) {
Derek Sollenberger8872b382014-06-23 14:13:53 -0400136 // Fast path - no record for this frame.
137 mCanvas->restore();
138 return;
139 }
140
Florin Malitaeecff562015-12-21 10:43:01 -0500141 bool preserveMatrix = !(rec->saveFlags & SaveFlags::Matrix);
142 bool preserveClip = !(rec->saveFlags & SaveFlags::Clip);
Derek Sollenberger8872b382014-06-23 14:13:53 -0400143
144 SkMatrix savedMatrix;
145 if (preserveMatrix) {
146 savedMatrix = mCanvas->getTotalMatrix();
147 }
148
Stan Ilievf50806a2016-10-24 10:40:39 -0400149 const size_t clipIndex = rec->clipIndex;
Derek Sollenberger8872b382014-06-23 14:13:53 -0400150
151 mCanvas->restore();
Stan Ilievf50806a2016-10-24 10:40:39 -0400152 mSaveStack->pop_back();
Derek Sollenberger8872b382014-06-23 14:13:53 -0400153
154 if (preserveMatrix) {
155 mCanvas->setMatrix(savedMatrix);
156 }
157
Stan Ilievf50806a2016-10-24 10:40:39 -0400158 if (preserveClip) {
159 this->applyPersistentClips(clipIndex);
Derek Sollenberger8872b382014-06-23 14:13:53 -0400160 }
Derek Sollenberger8872b382014-06-23 14:13:53 -0400161}
162
163void SkiaCanvas::restoreToCount(int restoreCount) {
164 while (mCanvas->getSaveCount() > restoreCount) {
165 this->restore();
166 }
167}
168
Florin Malitaeecff562015-12-21 10:43:01 -0500169static inline SkCanvas::SaveLayerFlags layerFlags(SaveFlags::Flags flags) {
170 SkCanvas::SaveLayerFlags layerFlags = 0;
171
Yuqian Li83427ff2016-09-14 11:14:06 -0400172 // We intentionally ignore the SaveFlags::HasAlphaLayer and
173 // SkCanvas::kIsOpaque_SaveLayerFlag flags because HWUI ignores it
174 // and our Android client may use it incorrectly.
175 // In Skia, this flag is purely for performance optimization.
Florin Malitaeecff562015-12-21 10:43:01 -0500176
177 if (!(flags & SaveFlags::ClipToLayer)) {
178 layerFlags |= SkCanvas::kDontClipToLayer_Legacy_SaveLayerFlag;
179 }
180
181 return layerFlags;
182}
183
Derek Sollenberger8872b382014-06-23 14:13:53 -0400184int SkiaCanvas::saveLayer(float left, float top, float right, float bottom,
Florin Malitaeecff562015-12-21 10:43:01 -0500185 const SkPaint* paint, SaveFlags::Flags flags) {
186 const SkRect bounds = SkRect::MakeLTRB(left, top, right, bottom);
Derek Sollenbergerb8201192017-01-09 16:11:59 -0500187 const SkCanvas::SaveLayerRec rec(&bounds, paint, layerFlags(flags));
Florin Malitaeecff562015-12-21 10:43:01 -0500188
Stan Iliev68885e32016-12-14 11:18:34 -0500189 return mCanvas->saveLayer(rec);
Derek Sollenberger8872b382014-06-23 14:13:53 -0400190}
191
192int SkiaCanvas::saveLayerAlpha(float left, float top, float right, float bottom,
Florin Malitaeecff562015-12-21 10:43:01 -0500193 int alpha, SaveFlags::Flags flags) {
Florin Malitaeecff562015-12-21 10:43:01 -0500194 if (static_cast<unsigned>(alpha) < 0xFF) {
Yuqian Lifd92ee42016-04-27 17:03:38 -0400195 SkPaint alphaPaint;
196 alphaPaint.setAlpha(alpha);
197 return this->saveLayer(left, top, right, bottom, &alphaPaint, flags);
Florin Malitaeecff562015-12-21 10:43:01 -0500198 }
Yuqian Lifd92ee42016-04-27 17:03:38 -0400199 return this->saveLayer(left, top, right, bottom, nullptr, flags);
Derek Sollenberger8872b382014-06-23 14:13:53 -0400200}
201
Stan Ilievf50806a2016-10-24 10:40:39 -0400202class SkiaCanvas::Clip {
203public:
Mike Reed6e49c9f2016-12-02 15:36:59 -0500204 Clip(const SkRect& rect, SkClipOp op, const SkMatrix& m)
Stan Ilievf50806a2016-10-24 10:40:39 -0400205 : mType(Type::Rect), mOp(op), mMatrix(m), mRRect(SkRRect::MakeRect(rect)) {}
Mike Reed6e49c9f2016-12-02 15:36:59 -0500206 Clip(const SkRRect& rrect, SkClipOp op, const SkMatrix& m)
Stan Ilievf50806a2016-10-24 10:40:39 -0400207 : mType(Type::RRect), mOp(op), mMatrix(m), mRRect(rrect) {}
Mike Reed6e49c9f2016-12-02 15:36:59 -0500208 Clip(const SkPath& path, SkClipOp op, const SkMatrix& m)
Stan Ilievf50806a2016-10-24 10:40:39 -0400209 : mType(Type::Path), mOp(op), mMatrix(m), mPath(&path) {}
210
211 void apply(SkCanvas* canvas) const {
212 canvas->setMatrix(mMatrix);
213 switch (mType) {
214 case Type::Rect:
215 canvas->clipRect(mRRect.rect(), mOp);
216 break;
217 case Type::RRect:
218 canvas->clipRRect(mRRect, mOp);
219 break;
220 case Type::Path:
221 canvas->clipPath(*mPath.get(), mOp);
222 break;
223 }
224 }
225
226private:
227 enum class Type {
228 Rect,
229 RRect,
230 Path,
231 };
232
Mike Reed6e49c9f2016-12-02 15:36:59 -0500233 Type mType;
234 SkClipOp mOp;
235 SkMatrix mMatrix;
Stan Ilievf50806a2016-10-24 10:40:39 -0400236
237 // These are logically a union (tracked separately due to non-POD path).
238 SkTLazy<SkPath> mPath;
239 SkRRect mRRect;
240};
241
242const SkiaCanvas::SaveRec* SkiaCanvas::currentSaveRec() const {
243 const SaveRec* rec = mSaveStack
244 ? static_cast<const SaveRec*>(mSaveStack->back())
245 : nullptr;
246 int currentSaveCount = mCanvas->getSaveCount();
247 SkASSERT(!rec || currentSaveCount >= rec->saveCount);
248
249 return (rec && rec->saveCount == currentSaveCount) ? rec : nullptr;
250}
251
Derek Sollenberger8872b382014-06-23 14:13:53 -0400252// ----------------------------------------------------------------------------
253// functions to emulate legacy SaveFlags (i.e. independent matrix/clip flags)
254// ----------------------------------------------------------------------------
255
Florin Malitaeecff562015-12-21 10:43:01 -0500256void SkiaCanvas::recordPartialSave(SaveFlags::Flags flags) {
Derek Sollenberger8872b382014-06-23 14:13:53 -0400257 // A partial save is a save operation which doesn't capture the full canvas state.
Florin Malitaeecff562015-12-21 10:43:01 -0500258 // (either SaveFlags::Matrix or SaveFlags::Clip is missing).
Derek Sollenberger8872b382014-06-23 14:13:53 -0400259
260 // Mask-out non canvas state bits.
Florin Malitaeecff562015-12-21 10:43:01 -0500261 flags &= SaveFlags::MatrixClip;
Derek Sollenberger8872b382014-06-23 14:13:53 -0400262
Florin Malitaeecff562015-12-21 10:43:01 -0500263 if (flags == SaveFlags::MatrixClip) {
Derek Sollenberger8872b382014-06-23 14:13:53 -0400264 // not a partial save.
265 return;
266 }
267
Stan Ilievf50806a2016-10-24 10:40:39 -0400268 if (!mSaveStack) {
Ben Wagnerd1cbc162015-08-19 12:45:09 -0400269 mSaveStack.reset(new SkDeque(sizeof(struct SaveRec), 8));
Derek Sollenberger8872b382014-06-23 14:13:53 -0400270 }
271
272 SaveRec* rec = static_cast<SaveRec*>(mSaveStack->push_back());
Florin Malita5e271402015-11-04 14:36:02 -0500273 rec->saveCount = mCanvas->getSaveCount();
Derek Sollenberger8872b382014-06-23 14:13:53 -0400274 rec->saveFlags = flags;
Stan Ilievf50806a2016-10-24 10:40:39 -0400275 rec->clipIndex = mClipStack.size();
Derek Sollenberger8872b382014-06-23 14:13:53 -0400276}
277
Stan Ilievf50806a2016-10-24 10:40:39 -0400278template <typename T>
Mike Reed6e49c9f2016-12-02 15:36:59 -0500279void SkiaCanvas::recordClip(const T& clip, SkClipOp op) {
Stan Ilievf50806a2016-10-24 10:40:39 -0400280 // Only need tracking when in a partial save frame which
281 // doesn't restore the clip.
282 const SaveRec* rec = this->currentSaveRec();
283 if (rec && !(rec->saveFlags & SaveFlags::Clip)) {
284 mClipStack.emplace_back(clip, op, mCanvas->getTotalMatrix());
Derek Sollenberger8872b382014-06-23 14:13:53 -0400285 }
286}
287
Stan Ilievf50806a2016-10-24 10:40:39 -0400288// Applies and optionally removes all clips >= index.
289void SkiaCanvas::applyPersistentClips(size_t clipStartIndex) {
290 SkASSERT(clipStartIndex <= mClipStack.size());
291 const auto begin = mClipStack.cbegin() + clipStartIndex;
292 const auto end = mClipStack.cend();
Derek Sollenberger8872b382014-06-23 14:13:53 -0400293
Stan Ilievf50806a2016-10-24 10:40:39 -0400294 // Clip application mutates the CTM.
295 const SkMatrix saveMatrix = mCanvas->getTotalMatrix();
Derek Sollenberger8872b382014-06-23 14:13:53 -0400296
Stan Ilievf50806a2016-10-24 10:40:39 -0400297 for (auto clip = begin; clip != end; ++clip) {
Mike Reed6acfe162016-11-18 17:21:09 -0500298 clip->apply(mCanvas);
Derek Sollenberger8872b382014-06-23 14:13:53 -0400299 }
300
Stan Ilievf50806a2016-10-24 10:40:39 -0400301 mCanvas->setMatrix(saveMatrix);
302
303 // If the current/post-restore save rec is also persisting clips, we
304 // leave them on the stack to be reapplied part of the next restore().
305 // Otherwise we're done and just pop them.
306 const auto* rec = this->currentSaveRec();
307 if (!rec || (rec->saveFlags & SaveFlags::Clip)) {
308 mClipStack.erase(begin, end);
309 }
Derek Sollenberger8872b382014-06-23 14:13:53 -0400310}
311
312// ----------------------------------------------------------------------------
313// Canvas state operations: Matrix
314// ----------------------------------------------------------------------------
315
316void SkiaCanvas::getMatrix(SkMatrix* outMatrix) const {
317 *outMatrix = mCanvas->getTotalMatrix();
318}
319
320void SkiaCanvas::setMatrix(const SkMatrix& matrix) {
321 mCanvas->setMatrix(matrix);
322}
323
324void SkiaCanvas::concat(const SkMatrix& matrix) {
325 mCanvas->concat(matrix);
326}
327
328void SkiaCanvas::rotate(float degrees) {
329 mCanvas->rotate(degrees);
330}
331
332void SkiaCanvas::scale(float sx, float sy) {
333 mCanvas->scale(sx, sy);
334}
335
336void SkiaCanvas::skew(float sx, float sy) {
337 mCanvas->skew(sx, sy);
338}
339
340void SkiaCanvas::translate(float dx, float dy) {
341 mCanvas->translate(dx, dy);
342}
343
344// ----------------------------------------------------------------------------
345// Canvas state operations: Clips
346// ----------------------------------------------------------------------------
347
348// This function is a mirror of SkCanvas::getClipBounds except that it does
349// not outset the edge of the clip to account for anti-aliasing. There is
350// a skia bug to investigate pushing this logic into back into skia.
351// (see https://code.google.com/p/skia/issues/detail?id=1303)
352bool SkiaCanvas::getClipBounds(SkRect* outRect) const {
353 SkIRect ibounds;
Mike Reed5e438982017-01-25 08:23:25 -0500354 if (!mCanvas->getDeviceClipBounds(&ibounds)) {
Derek Sollenberger8872b382014-06-23 14:13:53 -0400355 return false;
356 }
357
358 SkMatrix inverse;
359 // if we can't invert the CTM, we can't return local clip bounds
360 if (!mCanvas->getTotalMatrix().invert(&inverse)) {
361 if (outRect) {
362 outRect->setEmpty();
363 }
364 return false;
365 }
366
367 if (NULL != outRect) {
368 SkRect r = SkRect::Make(ibounds);
369 inverse.mapRect(outRect, r);
370 }
371 return true;
372}
373
374bool SkiaCanvas::quickRejectRect(float left, float top, float right, float bottom) const {
375 SkRect bounds = SkRect::MakeLTRB(left, top, right, bottom);
376 return mCanvas->quickReject(bounds);
377}
378
379bool SkiaCanvas::quickRejectPath(const SkPath& path) const {
380 return mCanvas->quickReject(path);
381}
382
Mike Reed6e49c9f2016-12-02 15:36:59 -0500383bool SkiaCanvas::clipRect(float left, float top, float right, float bottom, SkClipOp op) {
Derek Sollenberger8872b382014-06-23 14:13:53 -0400384 SkRect rect = SkRect::MakeLTRB(left, top, right, bottom);
Stan Ilievf50806a2016-10-24 10:40:39 -0400385 this->recordClip(rect, op);
Derek Sollenberger8872b382014-06-23 14:13:53 -0400386 mCanvas->clipRect(rect, op);
Chris Craik5ec6a282015-06-23 15:42:12 -0700387 return !mCanvas->isClipEmpty();
Derek Sollenberger8872b382014-06-23 14:13:53 -0400388}
389
Mike Reed6e49c9f2016-12-02 15:36:59 -0500390bool SkiaCanvas::clipPath(const SkPath* path, SkClipOp op) {
Derek Sollenbergerc1908132016-07-15 10:28:16 -0400391 SkRRect roundRect;
392 if (path->isRRect(&roundRect)) {
Stan Ilievf50806a2016-10-24 10:40:39 -0400393 this->recordClip(roundRect, op);
Derek Sollenbergerc1908132016-07-15 10:28:16 -0400394 mCanvas->clipRRect(roundRect, op);
395 } else {
Stan Ilievf50806a2016-10-24 10:40:39 -0400396 this->recordClip(*path, op);
Derek Sollenbergerc1908132016-07-15 10:28:16 -0400397 mCanvas->clipPath(*path, op);
398 }
Chris Craik5ec6a282015-06-23 15:42:12 -0700399 return !mCanvas->isClipEmpty();
Derek Sollenberger8872b382014-06-23 14:13:53 -0400400}
401
Derek Sollenberger8872b382014-06-23 14:13:53 -0400402// ----------------------------------------------------------------------------
403// Canvas state operations: Filters
404// ----------------------------------------------------------------------------
405
Derek Sollenbergeracb40992014-07-21 15:22:10 -0400406SkDrawFilter* SkiaCanvas::getDrawFilter() {
407 return mCanvas->getDrawFilter();
408}
409
Derek Sollenberger8872b382014-06-23 14:13:53 -0400410void SkiaCanvas::setDrawFilter(SkDrawFilter* drawFilter) {
411 mCanvas->setDrawFilter(drawFilter);
412}
413
414// ----------------------------------------------------------------------------
Matt Sarett44dc2702017-04-13 09:33:18 -0400415// Canvas state operations: Capture
416// ----------------------------------------------------------------------------
417
418SkCanvasState* SkiaCanvas::captureCanvasState() const {
419 SkCanvas* canvas = mCanvas;
420 if (mCanvasOwned) {
421 // Important to use the underlying SkCanvas, not the wrapper.
422 canvas = mCanvasOwned.get();
423 }
424
425 // Workarounds for http://crbug.com/271096: SW draw only supports
426 // translate & scale transforms, and a simple rectangular clip.
427 // (This also avoids significant wasted time in calling
428 // SkCanvasStateUtils::CaptureCanvasState when the clip is complex).
429 if (!canvas->isClipRect() ||
430 (canvas->getTotalMatrix().getType() &
431 ~(SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask))) {
432 return nullptr;
433 }
434
435 return SkCanvasStateUtils::CaptureCanvasState(canvas);
436}
437
438// ----------------------------------------------------------------------------
Derek Sollenberger8872b382014-06-23 14:13:53 -0400439// Canvas draw operations
440// ----------------------------------------------------------------------------
441
Mike Reed260ab722016-10-07 15:59:20 -0400442void SkiaCanvas::drawColor(int color, SkBlendMode mode) {
Derek Sollenberger8872b382014-06-23 14:13:53 -0400443 mCanvas->drawColor(color, mode);
444}
445
Derek Sollenbergeracb40992014-07-21 15:22:10 -0400446void SkiaCanvas::drawPaint(const SkPaint& paint) {
Derek Sollenberger8872b382014-06-23 14:13:53 -0400447 mCanvas->drawPaint(paint);
448}
449
450// ----------------------------------------------------------------------------
451// Canvas draw operations: Geometry
452// ----------------------------------------------------------------------------
453
Derek Sollenbergeracb40992014-07-21 15:22:10 -0400454void SkiaCanvas::drawPoints(const float* points, int count, const SkPaint& paint,
Derek Sollenberger8872b382014-06-23 14:13:53 -0400455 SkCanvas::PointMode mode) {
Derek Sollenberger792fb322017-03-03 14:02:09 -0500456 if (CC_UNLIKELY(count < 2 || paint.nothingToDraw())) return;
Derek Sollenberger8872b382014-06-23 14:13:53 -0400457 // convert the floats into SkPoints
458 count >>= 1; // now it is the number of points
Ben Wagner6bbf68d2015-08-19 11:26:06 -0400459 std::unique_ptr<SkPoint[]> pts(new SkPoint[count]);
Derek Sollenberger8872b382014-06-23 14:13:53 -0400460 for (int i = 0; i < count; i++) {
461 pts[i].set(points[0], points[1]);
462 points += 2;
463 }
Ben Wagner6bbf68d2015-08-19 11:26:06 -0400464 mCanvas->drawPoints(mode, count, pts.get(), paint);
Derek Sollenberger8872b382014-06-23 14:13:53 -0400465}
466
467
Derek Sollenbergeracb40992014-07-21 15:22:10 -0400468void SkiaCanvas::drawPoint(float x, float y, const SkPaint& paint) {
Derek Sollenberger8872b382014-06-23 14:13:53 -0400469 mCanvas->drawPoint(x, y, paint);
470}
471
Derek Sollenbergeracb40992014-07-21 15:22:10 -0400472void SkiaCanvas::drawPoints(const float* points, int count, const SkPaint& paint) {
Derek Sollenberger8872b382014-06-23 14:13:53 -0400473 this->drawPoints(points, count, paint, SkCanvas::kPoints_PointMode);
474}
475
476void SkiaCanvas::drawLine(float startX, float startY, float stopX, float stopY,
Derek Sollenbergeracb40992014-07-21 15:22:10 -0400477 const SkPaint& paint) {
Derek Sollenberger8872b382014-06-23 14:13:53 -0400478 mCanvas->drawLine(startX, startY, stopX, stopY, paint);
479}
480
Derek Sollenbergeracb40992014-07-21 15:22:10 -0400481void SkiaCanvas::drawLines(const float* points, int count, const SkPaint& paint) {
Derek Sollenberger792fb322017-03-03 14:02:09 -0500482 if (CC_UNLIKELY(count < 4 || paint.nothingToDraw())) return;
Derek Sollenberger8872b382014-06-23 14:13:53 -0400483 this->drawPoints(points, count, paint, SkCanvas::kLines_PointMode);
484}
485
486void SkiaCanvas::drawRect(float left, float top, float right, float bottom,
Derek Sollenbergeracb40992014-07-21 15:22:10 -0400487 const SkPaint& paint) {
Derek Sollenberger792fb322017-03-03 14:02:09 -0500488 if (CC_UNLIKELY(paint.nothingToDraw())) return;
Derek Sollenberger8872b382014-06-23 14:13:53 -0400489 mCanvas->drawRectCoords(left, top, right, bottom, paint);
490
491}
492
Derek Sollenberger94394b32015-07-10 09:58:41 -0400493void SkiaCanvas::drawRegion(const SkRegion& region, const SkPaint& paint) {
Derek Sollenberger792fb322017-03-03 14:02:09 -0500494 if (CC_UNLIKELY(paint.nothingToDraw())) return;
Stan Ilievf50806a2016-10-24 10:40:39 -0400495 mCanvas->drawRegion(region, paint);
Derek Sollenberger94394b32015-07-10 09:58:41 -0400496}
497
Derek Sollenberger8872b382014-06-23 14:13:53 -0400498void SkiaCanvas::drawRoundRect(float left, float top, float right, float bottom,
Derek Sollenbergeracb40992014-07-21 15:22:10 -0400499 float rx, float ry, const SkPaint& paint) {
Derek Sollenberger792fb322017-03-03 14:02:09 -0500500 if (CC_UNLIKELY(paint.nothingToDraw())) return;
Derek Sollenberger8872b382014-06-23 14:13:53 -0400501 SkRect rect = SkRect::MakeLTRB(left, top, right, bottom);
502 mCanvas->drawRoundRect(rect, rx, ry, paint);
503}
504
Derek Sollenbergeracb40992014-07-21 15:22:10 -0400505void SkiaCanvas::drawCircle(float x, float y, float radius, const SkPaint& paint) {
Derek Sollenberger792fb322017-03-03 14:02:09 -0500506 if (CC_UNLIKELY(radius <= 0 || paint.nothingToDraw())) return;
Derek Sollenberger8872b382014-06-23 14:13:53 -0400507 mCanvas->drawCircle(x, y, radius, paint);
508}
509
Derek Sollenbergeracb40992014-07-21 15:22:10 -0400510void SkiaCanvas::drawOval(float left, float top, float right, float bottom, const SkPaint& paint) {
Derek Sollenberger792fb322017-03-03 14:02:09 -0500511 if (CC_UNLIKELY(paint.nothingToDraw())) return;
Derek Sollenberger8872b382014-06-23 14:13:53 -0400512 SkRect oval = SkRect::MakeLTRB(left, top, right, bottom);
513 mCanvas->drawOval(oval, paint);
514}
515
516void SkiaCanvas::drawArc(float left, float top, float right, float bottom,
Derek Sollenbergeracb40992014-07-21 15:22:10 -0400517 float startAngle, float sweepAngle, bool useCenter, const SkPaint& paint) {
Derek Sollenberger792fb322017-03-03 14:02:09 -0500518 if (CC_UNLIKELY(paint.nothingToDraw())) return;
Derek Sollenberger8872b382014-06-23 14:13:53 -0400519 SkRect arc = SkRect::MakeLTRB(left, top, right, bottom);
520 mCanvas->drawArc(arc, startAngle, sweepAngle, useCenter, paint);
521}
522
Derek Sollenbergeracb40992014-07-21 15:22:10 -0400523void SkiaCanvas::drawPath(const SkPath& path, const SkPaint& paint) {
Derek Sollenberger792fb322017-03-03 14:02:09 -0500524 if (CC_UNLIKELY(paint.nothingToDraw())) return;
Derek Sollenbergerd7f13f82017-03-09 13:08:27 -0500525 mCanvas->drawPath(path, paint);
Derek Sollenberger8872b382014-06-23 14:13:53 -0400526}
527
528void SkiaCanvas::drawVertices(SkCanvas::VertexMode vertexMode, int vertexCount,
529 const float* verts, const float* texs, const int* colors,
Derek Sollenbergeracb40992014-07-21 15:22:10 -0400530 const uint16_t* indices, int indexCount, const SkPaint& paint) {
Derek Sollenberger8872b382014-06-23 14:13:53 -0400531#ifndef SK_SCALAR_IS_FLOAT
532 SkDEBUGFAIL("SkScalar must be a float for these conversions to be valid");
533#endif
534 const int ptCount = vertexCount >> 1;
Mike Reed871cd2d2017-03-17 10:15:52 -0400535 mCanvas->drawVertices(SkVertices::MakeCopy(vertexMode, ptCount, (SkPoint*)verts,
536 (SkPoint*)texs, (SkColor*)colors,
537 indexCount, indices),
538 SkBlendMode::kModulate, paint);
Derek Sollenberger8872b382014-06-23 14:13:53 -0400539}
540
541// ----------------------------------------------------------------------------
542// Canvas draw operations: Bitmaps
543// ----------------------------------------------------------------------------
544
sergeyvaed7f582016-10-14 16:30:21 -0700545void SkiaCanvas::drawBitmap(Bitmap& bitmap, float left, float top, const SkPaint* paint) {
546 SkBitmap skBitmap;
547 bitmap.getSkBitmap(&skBitmap);
548 mCanvas->drawBitmap(skBitmap, left, top, paint);
Derek Sollenberger8872b382014-06-23 14:13:53 -0400549}
550
sergeyvfc9999502016-10-17 13:07:38 -0700551void SkiaCanvas::drawBitmap(Bitmap& hwuiBitmap, const SkMatrix& matrix, const SkPaint* paint) {
552 SkBitmap bitmap;
553 hwuiBitmap.getSkBitmap(&bitmap);
Mike Reed6acfe162016-11-18 17:21:09 -0500554 SkAutoCanvasRestore acr(mCanvas, true);
Mike Reed70ffbf92014-12-08 17:03:30 -0500555 mCanvas->concat(matrix);
556 mCanvas->drawBitmap(bitmap, 0, 0, paint);
Derek Sollenberger8872b382014-06-23 14:13:53 -0400557}
558
sergeyvfc9999502016-10-17 13:07:38 -0700559void SkiaCanvas::drawBitmap(Bitmap& hwuiBitmap, float srcLeft, float srcTop,
Derek Sollenberger8872b382014-06-23 14:13:53 -0400560 float srcRight, float srcBottom, float dstLeft, float dstTop,
Derek Sollenbergeracb40992014-07-21 15:22:10 -0400561 float dstRight, float dstBottom, const SkPaint* paint) {
sergeyvfc9999502016-10-17 13:07:38 -0700562 SkBitmap bitmap;
563 hwuiBitmap.getSkBitmap(&bitmap);
Derek Sollenberger8872b382014-06-23 14:13:53 -0400564 SkRect srcRect = SkRect::MakeLTRB(srcLeft, srcTop, srcRight, srcBottom);
565 SkRect dstRect = SkRect::MakeLTRB(dstLeft, dstTop, dstRight, dstBottom);
Leon Scroggins IIIf35b9892015-07-31 10:38:40 -0400566 mCanvas->drawBitmapRect(bitmap, srcRect, dstRect, paint);
Derek Sollenberger8872b382014-06-23 14:13:53 -0400567}
568
sergeyv5fd2a1c2016-10-20 15:04:28 -0700569void SkiaCanvas::drawBitmapMesh(Bitmap& hwuiBitmap, int meshWidth, int meshHeight,
Derek Sollenbergeracb40992014-07-21 15:22:10 -0400570 const float* vertices, const int* colors, const SkPaint* paint) {
sergeyv5fd2a1c2016-10-20 15:04:28 -0700571 SkBitmap bitmap;
572 hwuiBitmap.getSkBitmap(&bitmap);
Derek Sollenberger8872b382014-06-23 14:13:53 -0400573 const int ptCount = (meshWidth + 1) * (meshHeight + 1);
574 const int indexCount = meshWidth * meshHeight * 6;
Mike Reed871cd2d2017-03-17 10:15:52 -0400575 uint32_t flags = SkVertices::kHasTexCoords_BuilderFlag;
576 if (colors) {
577 flags |= SkVertices::kHasColors_BuilderFlag;
578 }
579 SkVertices::Builder builder(SkCanvas::kTriangles_VertexMode, ptCount, indexCount, flags);
580 memcpy(builder.positions(), vertices, ptCount * sizeof(SkPoint));
581 if (colors) {
582 memcpy(builder.colors(), colors, ptCount * sizeof(SkColor));
583 }
584 SkPoint* texs = builder.texCoords();
585 uint16_t* indices = builder.indices();
Derek Sollenberger8872b382014-06-23 14:13:53 -0400586
587 // cons up texture coordinates and indices
588 {
589 const SkScalar w = SkIntToScalar(bitmap.width());
590 const SkScalar h = SkIntToScalar(bitmap.height());
591 const SkScalar dx = w / meshWidth;
592 const SkScalar dy = h / meshHeight;
593
594 SkPoint* texsPtr = texs;
595 SkScalar y = 0;
596 for (int i = 0; i <= meshHeight; i++) {
597 if (i == meshHeight) {
598 y = h; // to ensure numerically we hit h exactly
599 }
600 SkScalar x = 0;
601 for (int j = 0; j < meshWidth; j++) {
602 texsPtr->set(x, y);
603 texsPtr += 1;
604 x += dx;
605 }
606 texsPtr->set(w, y);
607 texsPtr += 1;
608 y += dy;
609 }
610 SkASSERT(texsPtr - texs == ptCount);
611 }
612
613 // cons up indices
614 {
615 uint16_t* indexPtr = indices;
616 int index = 0;
617 for (int i = 0; i < meshHeight; i++) {
618 for (int j = 0; j < meshWidth; j++) {
619 // lower-left triangle
620 *indexPtr++ = index;
621 *indexPtr++ = index + meshWidth + 1;
622 *indexPtr++ = index + meshWidth + 2;
623 // upper-right triangle
624 *indexPtr++ = index;
625 *indexPtr++ = index + meshWidth + 2;
626 *indexPtr++ = index + 1;
627 // bump to the next cell
628 index += 1;
629 }
630 // bump to the next row
631 index += 1;
632 }
633 SkASSERT(indexPtr - indices == indexCount);
Derek Sollenberger8872b382014-06-23 14:13:53 -0400634 }
635
636 // double-check that we have legal indices
637#ifdef SK_DEBUG
638 {
639 for (int i = 0; i < indexCount; i++) {
640 SkASSERT((unsigned)indices[i] < (unsigned)ptCount);
641 }
642 }
643#endif
644
645 // cons-up a shader for the bitmap
Derek Sollenbergeracb40992014-07-21 15:22:10 -0400646 SkPaint tmpPaint;
Derek Sollenberger8872b382014-06-23 14:13:53 -0400647 if (paint) {
648 tmpPaint = *paint;
649 }
Stan Ilievf50806a2016-10-24 10:40:39 -0400650
651 sk_sp<SkImage> image = SkMakeImageFromRasterBitmap(bitmap, kNever_SkCopyPixelsMode);
652 tmpPaint.setShader(image->makeShader(SkShader::kClamp_TileMode, SkShader::kClamp_TileMode));
Derek Sollenberger8872b382014-06-23 14:13:53 -0400653
Mike Reed871cd2d2017-03-17 10:15:52 -0400654 mCanvas->drawVertices(builder.detach(), SkBlendMode::kModulate, tmpPaint);
Derek Sollenberger8872b382014-06-23 14:13:53 -0400655}
656
sergeyv5fd2a1c2016-10-20 15:04:28 -0700657void SkiaCanvas::drawNinePatch(Bitmap& hwuiBitmap, const Res_png_9patch& chunk,
Derek Sollenbergeredca3202015-07-10 13:56:39 -0400658 float dstLeft, float dstTop, float dstRight, float dstBottom, const SkPaint* paint) {
Stan Ilievf50806a2016-10-24 10:40:39 -0400659
sergeyv5fd2a1c2016-10-20 15:04:28 -0700660 SkBitmap bitmap;
661 hwuiBitmap.getSkBitmap(&bitmap);
Stan Ilievf50806a2016-10-24 10:40:39 -0400662
663 SkCanvas::Lattice lattice;
Matt Sarett7de73852016-10-25 18:36:39 -0400664 NinePatchUtils::SetLatticeDivs(&lattice, chunk, bitmap.width(), bitmap.height());
Stan Ilievf50806a2016-10-24 10:40:39 -0400665
666 lattice.fFlags = nullptr;
667 int numFlags = 0;
Stan Iliev021693b2016-10-17 16:26:15 -0400668 if (chunk.numColors > 0 && chunk.numColors == NinePatchUtils::NumDistinctRects(lattice)) {
Stan Ilievf50806a2016-10-24 10:40:39 -0400669 // We can expect the framework to give us a color for every distinct rect.
670 // Skia requires a flag for every rect.
671 numFlags = (lattice.fXCount + 1) * (lattice.fYCount + 1);
672 }
673
674 SkAutoSTMalloc<25, SkCanvas::Lattice::Flags> flags(numFlags);
675 if (numFlags > 0) {
Stan Iliev021693b2016-10-17 16:26:15 -0400676 NinePatchUtils::SetLatticeFlags(&lattice, flags.get(), numFlags, chunk);
Stan Ilievf50806a2016-10-24 10:40:39 -0400677 }
678
679 lattice.fBounds = nullptr;
680 SkRect dst = SkRect::MakeLTRB(dstLeft, dstTop, dstRight, dstBottom);
681 mCanvas->drawBitmapLattice(bitmap, lattice, dst, paint);
Derek Sollenbergeredca3202015-07-10 13:56:39 -0400682}
683
Doris Liu766431a2016-02-04 22:17:11 +0000684void SkiaCanvas::drawVectorDrawable(VectorDrawableRoot* vectorDrawable) {
Doris Liu1d8e1942016-03-02 15:16:28 -0800685 vectorDrawable->drawStaging(this);
Doris Liu766431a2016-02-04 22:17:11 +0000686}
687
Derek Sollenberger8872b382014-06-23 14:13:53 -0400688// ----------------------------------------------------------------------------
689// Canvas draw operations: Text
690// ----------------------------------------------------------------------------
691
sergeyvdccca442016-03-21 15:38:21 -0700692void SkiaCanvas::drawGlyphs(const uint16_t* text, const float* positions, int count,
Derek Sollenbergeracb40992014-07-21 15:22:10 -0400693 const SkPaint& paint, float x, float y,
Tom Hudson8dfaa492014-12-09 15:03:44 -0500694 float boundsLeft, float boundsTop, float boundsRight, float boundsBottom,
695 float totalAdvance) {
Derek Sollenberger792fb322017-03-03 14:02:09 -0500696 if (!text || !positions || count <= 0 || paint.nothingToDraw()) return;
Stan Ilievf50806a2016-10-24 10:40:39 -0400697 // Set align to left for drawing, as we don't want individual
698 // glyphs centered or right-aligned; the offset above takes
699 // care of all alignment.
700 SkPaint paintCopy(paint);
701 paintCopy.setTextAlign(SkPaint::kLeft_Align);
702
703 SkRect bounds = SkRect::MakeLTRB(boundsLeft + x, boundsTop + y,
704 boundsRight + x, boundsBottom + y);
705
706 SkTextBlobBuilder builder;
707 const SkTextBlobBuilder::RunBuffer& buffer = builder.allocRunPos(paintCopy, count, &bounds);
708 // TODO: we could reduce the number of memcpy's if the this were exposed further up
709 // in the architecture.
710 memcpy(buffer.glyphs, text, count * sizeof(uint16_t));
711 memcpy(buffer.pos, positions, (count << 1) * sizeof(float));
712
713 sk_sp<SkTextBlob> textBlob(builder.make());
714 mCanvas->drawTextBlob(textBlob, 0, 0, paintCopy);
715 drawTextDecorations(x, y, totalAdvance, paintCopy);
Derek Sollenberger8872b382014-06-23 14:13:53 -0400716}
717
Yuqian Liafc221492016-07-18 13:07:42 -0400718void SkiaCanvas::drawLayoutOnPath(const minikin::Layout& layout, float hOffset, float vOffset,
719 const SkPaint& paint, const SkPath& path, size_t start, size_t end) {
720 const int N = end - start;
Derek Sollenbergere547dd02016-11-09 11:55:59 -0500721 SkAutoSTMalloc<1024, uint8_t> storage(N * (sizeof(uint16_t) + sizeof(SkRSXform)));
Yuqian Liafc221492016-07-18 13:07:42 -0400722 SkRSXform* xform = (SkRSXform*)storage.get();
723 uint16_t* glyphs = (uint16_t*)(xform + N);
724 SkPathMeasure meas(path, false);
725
726 for (size_t i = start; i < end; i++) {
727 glyphs[i - start] = layout.getGlyphId(i);
728 float x = hOffset + layout.getX(i);
729 float y = vOffset + layout.getY(i);
730
731 SkPoint pos;
732 SkVector tan;
733 if (!meas.getPosTan(x, &pos, &tan)) {
734 pos.set(x, y);
735 tan.set(1, 0);
736 }
737 xform[i - start].fSCos = tan.x();
738 xform[i - start].fSSin = tan.y();
739 xform[i - start].fTx = pos.x() - tan.y() * y;
740 xform[i - start].fTy = pos.y() + tan.x() * y;
741 }
742
743 this->asSkCanvas()->drawTextRSXform(glyphs, sizeof(uint16_t) * N, xform, nullptr, paint);
Derek Sollenberger8872b382014-06-23 14:13:53 -0400744}
745
Derek Sollenberger6f485562015-07-30 10:00:39 -0400746// ----------------------------------------------------------------------------
747// Canvas draw operations: Animations
748// ----------------------------------------------------------------------------
749
Derek Sollenberger6f485562015-07-30 10:00:39 -0400750void SkiaCanvas::drawRoundRect(uirenderer::CanvasPropertyPrimitive* left,
751 uirenderer::CanvasPropertyPrimitive* top, uirenderer::CanvasPropertyPrimitive* right,
752 uirenderer::CanvasPropertyPrimitive* bottom, uirenderer::CanvasPropertyPrimitive* rx,
753 uirenderer::CanvasPropertyPrimitive* ry, uirenderer::CanvasPropertyPaint* paint) {
Stan Iliev021693b2016-10-17 16:26:15 -0400754 sk_sp<uirenderer::skiapipeline::AnimatedRoundRect> drawable(
755 new uirenderer::skiapipeline::AnimatedRoundRect(left, top, right, bottom, rx, ry, paint));
Derek Sollenberger6f485562015-07-30 10:00:39 -0400756 mCanvas->drawDrawable(drawable.get());
757}
758
759void SkiaCanvas::drawCircle(uirenderer::CanvasPropertyPrimitive* x, uirenderer::CanvasPropertyPrimitive* y,
760 uirenderer::CanvasPropertyPrimitive* radius, uirenderer::CanvasPropertyPaint* paint) {
Stan Iliev021693b2016-10-17 16:26:15 -0400761 sk_sp<uirenderer::skiapipeline::AnimatedCircle> drawable(new uirenderer::skiapipeline::AnimatedCircle(x, y, radius, paint));
Derek Sollenberger6f485562015-07-30 10:00:39 -0400762 mCanvas->drawDrawable(drawable.get());
763}
764
765// ----------------------------------------------------------------------------
766// Canvas draw operations: View System
767// ----------------------------------------------------------------------------
768
Stan Ilievf50806a2016-10-24 10:40:39 -0400769void SkiaCanvas::drawLayer(uirenderer::DeferredLayerUpdater* layerUpdater) {
Derek Sollenbergerc1908132016-07-15 10:28:16 -0400770 LOG_ALWAYS_FATAL("SkiaCanvas can't directly draw Layers");
771}
Derek Sollenberger6f485562015-07-30 10:00:39 -0400772
Derek Sollenbergerc1908132016-07-15 10:28:16 -0400773void SkiaCanvas::drawRenderNode(uirenderer::RenderNode* renderNode) {
774 LOG_ALWAYS_FATAL("SkiaCanvas can't directly draw RenderNodes");
775}
Derek Sollenberger6f485562015-07-30 10:00:39 -0400776
John Reckcd1c3eb2016-04-14 10:38:54 -0700777void SkiaCanvas::callDrawGLFunction(Functor* functor,
Derek Sollenbergerc1908132016-07-15 10:28:16 -0400778 uirenderer::GlFunctorLifecycleListener* listener) {
779 LOG_ALWAYS_FATAL("SkiaCanvas can't directly draw GL Content");
780}
Derek Sollenberger6f485562015-07-30 10:00:39 -0400781
Derek Sollenberger8872b382014-06-23 14:13:53 -0400782} // namespace android