1c4b21e6c03a6cdb03e116b9f510eb10cf8daedb1commit-bot@chromium.org/* 2c4b21e6c03a6cdb03e116b9f510eb10cf8daedb1commit-bot@chromium.org * Copyright 2014 Google Inc. 3c4b21e6c03a6cdb03e116b9f510eb10cf8daedb1commit-bot@chromium.org * 4c4b21e6c03a6cdb03e116b9f510eb10cf8daedb1commit-bot@chromium.org * Use of this source code is governed by a BSD-style license that can be 5c4b21e6c03a6cdb03e116b9f510eb10cf8daedb1commit-bot@chromium.org * found in the LICENSE file. 6c4b21e6c03a6cdb03e116b9f510eb10cf8daedb1commit-bot@chromium.org */ 7c4b21e6c03a6cdb03e116b9f510eb10cf8daedb1commit-bot@chromium.org 8b3c9d1c33caf325aada244204215eb790c228c12dandov#include "SkPatchUtils.h" 9e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org#include "SkPicture.h" 1098b8485a4cc911420e20af2670d21a5478a06264mtklein#include "SkPictureUtils.h" 1198b8485a4cc911420e20af2670d21a5478a06264mtklein#include "SkRecorder.h" 12e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org 133cb3840c9af6f70896cf5565a38d4ee03c02d767reedSkDrawableList::~SkDrawableList() { 141bdfd3f4f09e47364f76d3f08177b1ce844ac786reed fArray.unrefAll(); 151bdfd3f4f09e47364f76d3f08177b1ce844ac786reed} 161bdfd3f4f09e47364f76d3f08177b1ce844ac786reed 17b7ed856fadae52401d3bbcac22cfc3391780ace8reedSkPicture::SnapshotArray* SkDrawableList::newDrawableSnapshot() { 181bdfd3f4f09e47364f76d3f08177b1ce844ac786reed const int count = fArray.count(); 191bdfd3f4f09e47364f76d3f08177b1ce844ac786reed if (0 == count) { 201bdfd3f4f09e47364f76d3f08177b1ce844ac786reed return NULL; 211bdfd3f4f09e47364f76d3f08177b1ce844ac786reed } 221bdfd3f4f09e47364f76d3f08177b1ce844ac786reed SkAutoTMalloc<const SkPicture*> pics(count); 231bdfd3f4f09e47364f76d3f08177b1ce844ac786reed for (int i = 0; i < count; ++i) { 241bdfd3f4f09e47364f76d3f08177b1ce844ac786reed pics[i] = fArray[i]->newPictureSnapshot(); 251bdfd3f4f09e47364f76d3f08177b1ce844ac786reed } 26b7ed856fadae52401d3bbcac22cfc3391780ace8reed return SkNEW_ARGS(SkPicture::SnapshotArray, (pics.detach(), count)); 271bdfd3f4f09e47364f76d3f08177b1ce844ac786reed} 281bdfd3f4f09e47364f76d3f08177b1ce844ac786reed 293cb3840c9af6f70896cf5565a38d4ee03c02d767reedvoid SkDrawableList::append(SkDrawable* drawable) { 301bdfd3f4f09e47364f76d3f08177b1ce844ac786reed *fArray.append() = SkRef(drawable); 311bdfd3f4f09e47364f76d3f08177b1ce844ac786reed} 321bdfd3f4f09e47364f76d3f08177b1ce844ac786reed 331bdfd3f4f09e47364f76d3f08177b1ce844ac786reed/////////////////////////////////////////////////////////////////////////////////////////////// 341bdfd3f4f09e47364f76d3f08177b1ce844ac786reed 35b7ed856fadae52401d3bbcac22cfc3391780ace8reedSkRecorder::SkRecorder(SkRecord* record, int width, int height) 3678e276889795454891cbba48ab11927968114953reed : SkCanvas(SkIRect::MakeWH(width, height), SkCanvas::kConservativeRasterClip_InitFlag) 3798b8485a4cc911420e20af2670d21a5478a06264mtklein , fApproxBytesUsedBySubPictures(0) 38b7ed856fadae52401d3bbcac22cfc3391780ace8reed , fRecord(record) {} 3978e276889795454891cbba48ab11927968114953reed 40b7ed856fadae52401d3bbcac22cfc3391780ace8reedSkRecorder::SkRecorder(SkRecord* record, const SkRect& bounds) 4178e276889795454891cbba48ab11927968114953reed : SkCanvas(bounds.roundOut(), SkCanvas::kConservativeRasterClip_InitFlag) 4298b8485a4cc911420e20af2670d21a5478a06264mtklein , fApproxBytesUsedBySubPictures(0) 43b7ed856fadae52401d3bbcac22cfc3391780ace8reed , fRecord(record) {} 44e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org 45b7ed856fadae52401d3bbcac22cfc3391780ace8reedvoid SkRecorder::reset(SkRecord* record, const SkRect& bounds) { 46feaadee1c38e1d4e1ec0069a3509ef6fbc5fbeffmtklein this->forgetRecord(); 47feaadee1c38e1d4e1ec0069a3509ef6fbc5fbeffmtklein fRecord = record; 48feaadee1c38e1d4e1ec0069a3509ef6fbc5fbeffmtklein this->resetForNextPicture(bounds.roundOut()); 49feaadee1c38e1d4e1ec0069a3509ef6fbc5fbeffmtklein} 50feaadee1c38e1d4e1ec0069a3509ef6fbc5fbeffmtklein 51732bd66ac2aea4bacd1e7e8f33628f7efb50f1d0commit-bot@chromium.orgvoid SkRecorder::forgetRecord() { 521bdfd3f4f09e47364f76d3f08177b1ce844ac786reed fDrawableList.reset(NULL); 5398b8485a4cc911420e20af2670d21a5478a06264mtklein fApproxBytesUsedBySubPictures = 0; 54732bd66ac2aea4bacd1e7e8f33628f7efb50f1d0commit-bot@chromium.org fRecord = NULL; 55732bd66ac2aea4bacd1e7e8f33628f7efb50f1d0commit-bot@chromium.org} 56732bd66ac2aea4bacd1e7e8f33628f7efb50f1d0commit-bot@chromium.org 57e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org// To make appending to fRecord a little less verbose. 58b7ed856fadae52401d3bbcac22cfc3391780ace8reed#define APPEND(T, ...) \ 59e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org SkNEW_PLACEMENT_ARGS(fRecord->append<SkRecords::T>(), SkRecords::T, (__VA_ARGS__)) 60e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org 61a095041f5148dd1e71f38d0546335ed94199104bcommit-bot@chromium.org// For methods which must call back into SkCanvas. 62a095041f5148dd1e71f38d0546335ed94199104bcommit-bot@chromium.org#define INHERITED(method, ...) this->SkCanvas::method(__VA_ARGS__) 63d9ce2be6b24b1c89d13c2edb63c3462b0f5c6aa3commit-bot@chromium.org 64e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org// The structs we're creating all copy their constructor arguments. Given the way the SkRecords 65e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org// framework works, sometimes they happen to technically be copied twice, which is fine and elided 66e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org// into a single copy unless the class has a non-trivial copy constructor. For classes with 67e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org// non-trivial copy constructors, we skip the first copy (and its destruction) by wrapping the value 68e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org// with delay_copy(), forcing the argument to be passed by const&. 69e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org// 70e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org// This is used below for SkBitmap, SkPaint, SkPath, and SkRegion, which all have non-trivial copy 71e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org// constructors and destructors. You'll know you've got a good candidate T if you see ~T() show up 72e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org// unexpectedly on a profile of record time. Otherwise don't bother. 73e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.orgtemplate <typename T> 74e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.orgclass Reference { 75e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.orgpublic: 76e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org Reference(const T& x) : fX(x) {} 77e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org operator const T&() const { return fX; } 78e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.orgprivate: 79e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org const T& fX; 80e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org}; 81e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org 82e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.orgtemplate <typename T> 83e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.orgstatic Reference<T> delay_copy(const T& x) { return Reference<T>(x); } 84e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org 85e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org// Use copy() only for optional arguments, to be copied if present or skipped if not. 86e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org// (For most types we just pass by value and let copy constructors do their thing.) 87e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.orgtemplate <typename T> 88e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.orgT* SkRecorder::copy(const T* src) { 89e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org if (NULL == src) { 90e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org return NULL; 91e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org } 92e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org return SkNEW_PLACEMENT_ARGS(fRecord->alloc<T>(), T, (*src)); 93e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org} 94e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org 95e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org// This copy() is for arrays. 96e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org// It will work with POD or non-POD, though currently we only use it for POD. 97e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.orgtemplate <typename T> 982347b624678fedf1d2f7ab1d79b9ad70087c3392reedT* SkRecorder::copy(const T src[], size_t count) { 99e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org if (NULL == src) { 100e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org return NULL; 101e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org } 102e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org T* dst = fRecord->alloc<T>(count); 1032347b624678fedf1d2f7ab1d79b9ad70087c3392reed for (size_t i = 0; i < count; i++) { 104e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org SkNEW_PLACEMENT_ARGS(dst + i, T, (src[i])); 105e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org } 106e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org return dst; 107e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org} 108e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org 109e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org// Specialization for copying strings, using memcpy. 110e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org// This measured around 2x faster for copying code points, 111e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org// but I found no corresponding speedup for other arrays. 112e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.orgtemplate <> 1132347b624678fedf1d2f7ab1d79b9ad70087c3392reedchar* SkRecorder::copy(const char src[], size_t count) { 114e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org if (NULL == src) { 115e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org return NULL; 116e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org } 117e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org char* dst = fRecord->alloc<char>(count); 118e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org memcpy(dst, src, count); 119e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org return dst; 120e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org} 121e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org 1225f0e82204ecca0805a7689cdba5f802458e103f4mtklein// As above, assuming and copying a terminating \0. 1235f0e82204ecca0805a7689cdba5f802458e103f4mtkleintemplate <> 1245f0e82204ecca0805a7689cdba5f802458e103f4mtkleinchar* SkRecorder::copy(const char* src) { 1255f0e82204ecca0805a7689cdba5f802458e103f4mtklein return this->copy(src, strlen(src)+1); 1265f0e82204ecca0805a7689cdba5f802458e103f4mtklein} 1275f0e82204ecca0805a7689cdba5f802458e103f4mtklein 1285f0e82204ecca0805a7689cdba5f802458e103f4mtklein 12941af966ab338e95eee81ab618ab28195075338f7reedvoid SkRecorder::onDrawPaint(const SkPaint& paint) { 130e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org APPEND(DrawPaint, delay_copy(paint)); 131e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org} 132e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org 13341af966ab338e95eee81ab618ab28195075338f7reedvoid SkRecorder::onDrawPoints(PointMode mode, 13441af966ab338e95eee81ab618ab28195075338f7reed size_t count, 13541af966ab338e95eee81ab618ab28195075338f7reed const SkPoint pts[], 13641af966ab338e95eee81ab618ab28195075338f7reed const SkPaint& paint) { 13742ddcd49060f64be57f00e651650154f9b4f3a08mtklein APPEND(DrawPoints, delay_copy(paint), mode, SkToUInt(count), this->copy(pts, count)); 138e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org} 139e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org 14041af966ab338e95eee81ab618ab28195075338f7reedvoid SkRecorder::onDrawRect(const SkRect& rect, const SkPaint& paint) { 14137f6e62f114b72d34bcd3140b16b3b30fe5750c8commit-bot@chromium.org APPEND(DrawRect, delay_copy(paint), rect); 142e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org} 143e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org 14441af966ab338e95eee81ab618ab28195075338f7reedvoid SkRecorder::onDrawOval(const SkRect& oval, const SkPaint& paint) { 14537f6e62f114b72d34bcd3140b16b3b30fe5750c8commit-bot@chromium.org APPEND(DrawOval, delay_copy(paint), oval); 146e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org} 147e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org 14841af966ab338e95eee81ab618ab28195075338f7reedvoid SkRecorder::onDrawRRect(const SkRRect& rrect, const SkPaint& paint) { 14937f6e62f114b72d34bcd3140b16b3b30fe5750c8commit-bot@chromium.org APPEND(DrawRRect, delay_copy(paint), rrect); 150e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org} 151e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org 152d9ce2be6b24b1c89d13c2edb63c3462b0f5c6aa3commit-bot@chromium.orgvoid SkRecorder::onDrawDRRect(const SkRRect& outer, const SkRRect& inner, const SkPaint& paint) { 15337f6e62f114b72d34bcd3140b16b3b30fe5750c8commit-bot@chromium.org APPEND(DrawDRRect, delay_copy(paint), outer, inner); 154d9ce2be6b24b1c89d13c2edb63c3462b0f5c6aa3commit-bot@chromium.org} 155d9ce2be6b24b1c89d13c2edb63c3462b0f5c6aa3commit-bot@chromium.org 1563cb3840c9af6f70896cf5565a38d4ee03c02d767reedvoid SkRecorder::onDrawDrawable(SkDrawable* drawable) { 1571bdfd3f4f09e47364f76d3f08177b1ce844ac786reed if (!fDrawableList) { 1583cb3840c9af6f70896cf5565a38d4ee03c02d767reed fDrawableList.reset(SkNEW(SkDrawableList)); 1591bdfd3f4f09e47364f76d3f08177b1ce844ac786reed } 1601bdfd3f4f09e47364f76d3f08177b1ce844ac786reed fDrawableList->append(drawable); 1611bdfd3f4f09e47364f76d3f08177b1ce844ac786reed APPEND(DrawDrawable, drawable->getBounds(), fDrawableList->count() - 1); 1626be2aa9a251bf6022570a03140f956655b3ef1dareed} 1636be2aa9a251bf6022570a03140f956655b3ef1dareed 16441af966ab338e95eee81ab618ab28195075338f7reedvoid SkRecorder::onDrawPath(const SkPath& path, const SkPaint& paint) { 165af57903f330a0afd0c10244d4a66f64fdbef5d1emtklein APPEND(DrawPath, delay_copy(paint), delay_copy(path)); 166e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org} 167e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org 16841af966ab338e95eee81ab618ab28195075338f7reedvoid SkRecorder::onDrawBitmap(const SkBitmap& bitmap, 16941af966ab338e95eee81ab618ab28195075338f7reed SkScalar left, 17041af966ab338e95eee81ab618ab28195075338f7reed SkScalar top, 17141af966ab338e95eee81ab618ab28195075338f7reed const SkPaint* paint) { 17237f6e62f114b72d34bcd3140b16b3b30fe5750c8commit-bot@chromium.org APPEND(DrawBitmap, this->copy(paint), delay_copy(bitmap), left, top); 173e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org} 174e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org 17541af966ab338e95eee81ab618ab28195075338f7reedvoid SkRecorder::onDrawBitmapRect(const SkBitmap& bitmap, 17641af966ab338e95eee81ab618ab28195075338f7reed const SkRect* src, 17741af966ab338e95eee81ab618ab28195075338f7reed const SkRect& dst, 17841af966ab338e95eee81ab618ab28195075338f7reed const SkPaint* paint, 17941af966ab338e95eee81ab618ab28195075338f7reed DrawBitmapRectFlags flags) { 18042ddcd49060f64be57f00e651650154f9b4f3a08mtklein if (kBleed_DrawBitmapRectFlag == flags) { 18142ddcd49060f64be57f00e651650154f9b4f3a08mtklein APPEND(DrawBitmapRectToRectBleed, 18242ddcd49060f64be57f00e651650154f9b4f3a08mtklein this->copy(paint), delay_copy(bitmap), this->copy(src), dst); 18342ddcd49060f64be57f00e651650154f9b4f3a08mtklein return; 18442ddcd49060f64be57f00e651650154f9b4f3a08mtklein } 18542ddcd49060f64be57f00e651650154f9b4f3a08mtklein SkASSERT(kNone_DrawBitmapRectFlag == flags); 186e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org APPEND(DrawBitmapRectToRect, 18742ddcd49060f64be57f00e651650154f9b4f3a08mtklein this->copy(paint), delay_copy(bitmap), this->copy(src), dst); 188e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org} 189e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org 19041af966ab338e95eee81ab618ab28195075338f7reedvoid SkRecorder::onDrawBitmapNine(const SkBitmap& bitmap, 19141af966ab338e95eee81ab618ab28195075338f7reed const SkIRect& center, 19241af966ab338e95eee81ab618ab28195075338f7reed const SkRect& dst, 19341af966ab338e95eee81ab618ab28195075338f7reed const SkPaint* paint) { 19437f6e62f114b72d34bcd3140b16b3b30fe5750c8commit-bot@chromium.org APPEND(DrawBitmapNine, this->copy(paint), delay_copy(bitmap), center, dst); 195e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org} 196e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org 19741af966ab338e95eee81ab618ab28195075338f7reedvoid SkRecorder::onDrawImage(const SkImage* image, SkScalar left, SkScalar top, 19841af966ab338e95eee81ab618ab28195075338f7reed const SkPaint* paint) { 19965151754b9fdb6a968d7307764c20655d1b680a0piotaixr APPEND(DrawImage, this->copy(paint), image, left, top); 20065151754b9fdb6a968d7307764c20655d1b680a0piotaixr} 20165151754b9fdb6a968d7307764c20655d1b680a0piotaixr 20241af966ab338e95eee81ab618ab28195075338f7reedvoid SkRecorder::onDrawImageRect(const SkImage* image, const SkRect* src, 20341af966ab338e95eee81ab618ab28195075338f7reed const SkRect& dst, 20441af966ab338e95eee81ab618ab28195075338f7reed const SkPaint* paint) { 20565151754b9fdb6a968d7307764c20655d1b680a0piotaixr APPEND(DrawImageRect, this->copy(paint), image, this->copy(src), dst); 20665151754b9fdb6a968d7307764c20655d1b680a0piotaixr} 20765151754b9fdb6a968d7307764c20655d1b680a0piotaixr 20841af966ab338e95eee81ab618ab28195075338f7reedvoid SkRecorder::onDrawSprite(const SkBitmap& bitmap, int left, int top, const SkPaint* paint) { 20937f6e62f114b72d34bcd3140b16b3b30fe5750c8commit-bot@chromium.org APPEND(DrawSprite, this->copy(paint), delay_copy(bitmap), left, top); 210e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org} 211e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org 212e0d9ce890e67d02727ac2811bb456ddb64f827d4reed@google.comvoid SkRecorder::onDrawText(const void* text, size_t byteLength, 213e0d9ce890e67d02727ac2811bb456ddb64f827d4reed@google.com SkScalar x, SkScalar y, const SkPaint& paint) { 214e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org APPEND(DrawText, 21537f6e62f114b72d34bcd3140b16b3b30fe5750c8commit-bot@chromium.org delay_copy(paint), this->copy((const char*)text, byteLength), byteLength, x, y); 216e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org} 217e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org 218e0d9ce890e67d02727ac2811bb456ddb64f827d4reed@google.comvoid SkRecorder::onDrawPosText(const void* text, size_t byteLength, 219e0d9ce890e67d02727ac2811bb456ddb64f827d4reed@google.com const SkPoint pos[], const SkPaint& paint) { 220e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org const unsigned points = paint.countText(text, byteLength); 221e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org APPEND(DrawPosText, 22237f6e62f114b72d34bcd3140b16b3b30fe5750c8commit-bot@chromium.org delay_copy(paint), 22337f6e62f114b72d34bcd3140b16b3b30fe5750c8commit-bot@chromium.org this->copy((const char*)text, byteLength), 22437f6e62f114b72d34bcd3140b16b3b30fe5750c8commit-bot@chromium.org byteLength, 22537f6e62f114b72d34bcd3140b16b3b30fe5750c8commit-bot@chromium.org this->copy(pos, points)); 226e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org} 227e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org 228e0d9ce890e67d02727ac2811bb456ddb64f827d4reed@google.comvoid SkRecorder::onDrawPosTextH(const void* text, size_t byteLength, 229e0d9ce890e67d02727ac2811bb456ddb64f827d4reed@google.com const SkScalar xpos[], SkScalar constY, const SkPaint& paint) { 230e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org const unsigned points = paint.countText(text, byteLength); 231e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org APPEND(DrawPosTextH, 23237f6e62f114b72d34bcd3140b16b3b30fe5750c8commit-bot@chromium.org delay_copy(paint), 23337f6e62f114b72d34bcd3140b16b3b30fe5750c8commit-bot@chromium.org this->copy((const char*)text, byteLength), 23442ddcd49060f64be57f00e651650154f9b4f3a08mtklein SkToUInt(byteLength), 23542ddcd49060f64be57f00e651650154f9b4f3a08mtklein constY, 23642ddcd49060f64be57f00e651650154f9b4f3a08mtklein this->copy(xpos, points)); 237e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org} 238e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org 239e0d9ce890e67d02727ac2811bb456ddb64f827d4reed@google.comvoid SkRecorder::onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path, 240e0d9ce890e67d02727ac2811bb456ddb64f827d4reed@google.com const SkMatrix* matrix, const SkPaint& paint) { 241e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org APPEND(DrawTextOnPath, 24237f6e62f114b72d34bcd3140b16b3b30fe5750c8commit-bot@chromium.org delay_copy(paint), 24337f6e62f114b72d34bcd3140b16b3b30fe5750c8commit-bot@chromium.org this->copy((const char*)text, byteLength), 24437f6e62f114b72d34bcd3140b16b3b30fe5750c8commit-bot@chromium.org byteLength, 245af57903f330a0afd0c10244d4a66f64fdbef5d1emtklein delay_copy(path), 246af57903f330a0afd0c10244d4a66f64fdbef5d1emtklein matrix ? *matrix : SkMatrix::I()); 247e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org} 248e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org 24900d5c2c6523321d25b32905ff4822f083a4173eefmalitavoid SkRecorder::onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y, 25000d5c2c6523321d25b32905ff4822f083a4173eefmalita const SkPaint& paint) { 25100d5c2c6523321d25b32905ff4822f083a4173eefmalita APPEND(DrawTextBlob, delay_copy(paint), blob, x, y); 25200d5c2c6523321d25b32905ff4822f083a4173eefmalita} 25300d5c2c6523321d25b32905ff4822f083a4173eefmalita 254d5fa1a455aad61f3e99081fe7a9b065cb3b115c6reedvoid SkRecorder::onDrawPicture(const SkPicture* pic, const SkMatrix* matrix, const SkPaint* paint) { 25598b8485a4cc911420e20af2670d21a5478a06264mtklein fApproxBytesUsedBySubPictures += SkPictureUtils::ApproximateBytesUsed(pic); 256af57903f330a0afd0c10244d4a66f64fdbef5d1emtklein APPEND(DrawPicture, this->copy(paint), pic, matrix ? *matrix : SkMatrix::I()); 257e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org} 258e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org 25941af966ab338e95eee81ab618ab28195075338f7reedvoid SkRecorder::onDrawVertices(VertexMode vmode, 26041af966ab338e95eee81ab618ab28195075338f7reed int vertexCount, const SkPoint vertices[], 26141af966ab338e95eee81ab618ab28195075338f7reed const SkPoint texs[], const SkColor colors[], 26241af966ab338e95eee81ab618ab28195075338f7reed SkXfermode* xmode, 26341af966ab338e95eee81ab618ab28195075338f7reed const uint16_t indices[], int indexCount, const SkPaint& paint) { 26437f6e62f114b72d34bcd3140b16b3b30fe5750c8commit-bot@chromium.org APPEND(DrawVertices, delay_copy(paint), 26537f6e62f114b72d34bcd3140b16b3b30fe5750c8commit-bot@chromium.org vmode, 266e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org vertexCount, 267e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org this->copy(vertices, vertexCount), 268e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org texs ? this->copy(texs, vertexCount) : NULL, 269e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org colors ? this->copy(colors, vertexCount) : NULL, 270e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org xmode, 271e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org this->copy(indices, indexCount), 27237f6e62f114b72d34bcd3140b16b3b30fe5750c8commit-bot@chromium.org indexCount); 273e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org} 274e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org 275b3c9d1c33caf325aada244204215eb790c228c12dandovvoid SkRecorder::onDrawPatch(const SkPoint cubics[12], const SkColor colors[4], 276b3c9d1c33caf325aada244204215eb790c228c12dandov const SkPoint texCoords[4], SkXfermode* xmode, const SkPaint& paint) { 277b3c9d1c33caf325aada244204215eb790c228c12dandov APPEND(DrawPatch, delay_copy(paint), 278b3c9d1c33caf325aada244204215eb790c228c12dandov cubics ? this->copy(cubics, SkPatchUtils::kNumCtrlPts) : NULL, 279b3c9d1c33caf325aada244204215eb790c228c12dandov colors ? this->copy(colors, SkPatchUtils::kNumCorners) : NULL, 280b3c9d1c33caf325aada244204215eb790c228c12dandov texCoords ? this->copy(texCoords, SkPatchUtils::kNumCorners) : NULL, 281b3c9d1c33caf325aada244204215eb790c228c12dandov xmode); 282963137b75c0a1fe91f35e9826742f36309f5e65ddandov} 283963137b75c0a1fe91f35e9826742f36309f5e65ddandov 2845f6102d07982043542343ff0a6c67b1319ac9fc7Florin Malitavoid SkRecorder::willSave() { 2855f6102d07982043542343ff0a6c67b1319ac9fc7Florin Malita APPEND(Save); 286e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org} 287e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org 288e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.orgSkCanvas::SaveLayerStrategy SkRecorder::willSaveLayer(const SkRect* bounds, 289e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org const SkPaint* paint, 290e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org SkCanvas::SaveFlags flags) { 291e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org APPEND(SaveLayer, this->copy(bounds), this->copy(paint), flags); 292e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org return SkCanvas::kNoLayer_SaveLayerStrategy; 293e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org} 294e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org 2956cfa73a29a26edf1d03bca224ad6860396308ffcmtkleinvoid SkRecorder::didRestore() { 296a723b576aed31a6eb2bdda6388e6bd779d04c6b0mtklein APPEND(Restore, this->devBounds(), this->getTotalMatrix()); 297e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org} 298e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org 299e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.orgvoid SkRecorder::didConcat(const SkMatrix& matrix) { 3006332f1dd20d73a6d8b9564af7c27d09394eb6596mtklein this->didSetMatrix(this->getTotalMatrix()); 301e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org} 302e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org 303e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.orgvoid SkRecorder::didSetMatrix(const SkMatrix& matrix) { 30446bc6217ca41178c357a68be2869b8b2f6defe47mtklein SkDEVCODE(if (matrix != this->getTotalMatrix()) { 305ec924b9696277df4c684e73315194482e1d43e50mtklein matrix.dump(); 306ec924b9696277df4c684e73315194482e1d43e50mtklein this->getTotalMatrix().dump(); 307ec924b9696277df4c684e73315194482e1d43e50mtklein SkASSERT(matrix == this->getTotalMatrix()); 308ec924b9696277df4c684e73315194482e1d43e50mtklein }) 309e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org APPEND(SetMatrix, matrix); 310e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org} 311e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org 312e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.orgvoid SkRecorder::onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle edgeStyle) { 313d9ce2be6b24b1c89d13c2edb63c3462b0f5c6aa3commit-bot@chromium.org INHERITED(onClipRect, rect, op, edgeStyle); 314cdeeb095a629b0db9f0ddff09516f2b78255c047mtklein SkRecords::RegionOpAndAA opAA(op, kSoft_ClipEdgeStyle == edgeStyle); 315cdeeb095a629b0db9f0ddff09516f2b78255c047mtklein APPEND(ClipRect, this->devBounds(), rect, opAA); 316e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org} 317e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org 318e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.orgvoid SkRecorder::onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeStyle edgeStyle) { 319d954498c01ccf0417feacf89e45d0c62a06a813breed INHERITED(onClipRRect, rrect, op, edgeStyle); 320cdeeb095a629b0db9f0ddff09516f2b78255c047mtklein SkRecords::RegionOpAndAA opAA(op, kSoft_ClipEdgeStyle == edgeStyle); 321cdeeb095a629b0db9f0ddff09516f2b78255c047mtklein APPEND(ClipRRect, this->devBounds(), rrect, opAA); 322e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org} 323e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org 324e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.orgvoid SkRecorder::onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle edgeStyle) { 325d954498c01ccf0417feacf89e45d0c62a06a813breed INHERITED(onClipPath, path, op, edgeStyle); 326cdeeb095a629b0db9f0ddff09516f2b78255c047mtklein SkRecords::RegionOpAndAA opAA(op, kSoft_ClipEdgeStyle == edgeStyle); 327af57903f330a0afd0c10244d4a66f64fdbef5d1emtklein APPEND(ClipPath, this->devBounds(), delay_copy(path), opAA); 328e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org} 329e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org 330e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.orgvoid SkRecorder::onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op) { 331d9ce2be6b24b1c89d13c2edb63c3462b0f5c6aa3commit-bot@chromium.org INHERITED(onClipRegion, deviceRgn, op); 332a723b576aed31a6eb2bdda6388e6bd779d04c6b0mtklein APPEND(ClipRegion, this->devBounds(), delay_copy(deviceRgn), op); 333e3ff558a4baf4cb924e7513a81c8073ddae385fccommit-bot@chromium.org} 3345f0e82204ecca0805a7689cdba5f802458e103f4mtklein 3355f0e82204ecca0805a7689cdba5f802458e103f4mtkleinvoid SkRecorder::beginCommentGroup(const char* description) { 3365f0e82204ecca0805a7689cdba5f802458e103f4mtklein APPEND(BeginCommentGroup, this->copy(description)); 3375f0e82204ecca0805a7689cdba5f802458e103f4mtklein} 3385f0e82204ecca0805a7689cdba5f802458e103f4mtklein 3395f0e82204ecca0805a7689cdba5f802458e103f4mtkleinvoid SkRecorder::addComment(const char* key, const char* value) { 3405f0e82204ecca0805a7689cdba5f802458e103f4mtklein APPEND(AddComment, this->copy(key), this->copy(value)); 3415f0e82204ecca0805a7689cdba5f802458e103f4mtklein} 3425f0e82204ecca0805a7689cdba5f802458e103f4mtklein 3435f0e82204ecca0805a7689cdba5f802458e103f4mtkleinvoid SkRecorder::endCommentGroup() { 3445f0e82204ecca0805a7689cdba5f802458e103f4mtklein APPEND(EndCommentGroup); 3455f0e82204ecca0805a7689cdba5f802458e103f4mtklein} 34629dfaa80f5776904f42b72b387a99e75f8dc5f5fmtklein 347