Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(187)

Side by Side Diff: src/core/SkRecorder.cpp

Issue 545613002: Implement all SkCanvas overrides that SkPictureRecord does. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/core/SkRecorder.h ('k') | src/core/SkRecords.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkRecorder.h" 8 #include "SkRecorder.h"
9 #include "SkPatchUtils.h" 9 #include "SkPatchUtils.h"
10 #include "SkPicture.h" 10 #include "SkPicture.h"
11 11
12 // SkCanvas will fail in mysterious ways if it doesn't know the real width and h eight. 12 // SkCanvas will fail in mysterious ways if it doesn't know the real width and h eight.
13 SkRecorder::SkRecorder(SkRecord* record, int width, int height) 13 SkRecorder::SkRecorder(SkRecord* record, int width, int height)
14 : SkCanvas(width, height), fRecord(record) {} 14 : SkCanvas(width, height)
15 , fRecord(record)
16 , fSaveLayerCount(0) {}
15 17
16 void SkRecorder::forgetRecord() { 18 void SkRecorder::forgetRecord() {
17 fRecord = NULL; 19 fRecord = NULL;
18 } 20 }
19 21
20 // To make appending to fRecord a little less verbose. 22 // To make appending to fRecord a little less verbose.
21 #define APPEND(T, ...) \ 23 #define APPEND(T, ...) \
22 SkNEW_PLACEMENT_ARGS(fRecord->append<SkRecords::T>(), SkRecords::T, (__V A_ARGS__)) 24 SkNEW_PLACEMENT_ARGS(fRecord->append<SkRecords::T>(), SkRecords::T, (__V A_ARGS__))
23 25
24 // For methods which must call back into SkCanvas. 26 // For methods which must call back into SkCanvas.
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 void SkRecorder::onDrawPatch(const SkPoint cubics[12], const SkColor colors[4], 224 void SkRecorder::onDrawPatch(const SkPoint cubics[12], const SkColor colors[4],
223 const SkPoint texCoords[4], SkXfermode* xmode, cons t SkPaint& paint) { 225 const SkPoint texCoords[4], SkXfermode* xmode, cons t SkPaint& paint) {
224 APPEND(DrawPatch, delay_copy(paint), 226 APPEND(DrawPatch, delay_copy(paint),
225 cubics ? this->copy(cubics, SkPatchUtils::kNumCtrlPts) : NULL, 227 cubics ? this->copy(cubics, SkPatchUtils::kNumCtrlPts) : NULL,
226 colors ? this->copy(colors, SkPatchUtils::kNumCorners) : NULL, 228 colors ? this->copy(colors, SkPatchUtils::kNumCorners) : NULL,
227 texCoords ? this->copy(texCoords, SkPatchUtils::kNumCorners) : NULL, 229 texCoords ? this->copy(texCoords, SkPatchUtils::kNumCorners) : NULL,
228 xmode); 230 xmode);
229 } 231 }
230 232
231 void SkRecorder::willSave() { 233 void SkRecorder::willSave() {
234 fSaveIsSaveLayer.push(false);
232 APPEND(Save); 235 APPEND(Save);
233 } 236 }
234 237
235 SkCanvas::SaveLayerStrategy SkRecorder::willSaveLayer(const SkRect* bounds, 238 SkCanvas::SaveLayerStrategy SkRecorder::willSaveLayer(const SkRect* bounds,
236 const SkPaint* paint, 239 const SkPaint* paint,
237 SkCanvas::SaveFlags flags) { 240 SkCanvas::SaveFlags flags) {
241 fSaveLayerCount++;
242 fSaveIsSaveLayer.push(true);
238 APPEND(SaveLayer, this->copy(bounds), this->copy(paint), flags); 243 APPEND(SaveLayer, this->copy(bounds), this->copy(paint), flags);
239 return SkCanvas::kNoLayer_SaveLayerStrategy; 244 return SkCanvas::kNoLayer_SaveLayerStrategy;
240 } 245 }
241 246
242 void SkRecorder::didRestore() { 247 void SkRecorder::didRestore() {
248 SkBool8 saveLayer;
249 fSaveIsSaveLayer.pop(&saveLayer);
250 if (saveLayer) {
251 fSaveLayerCount--;
252 }
243 APPEND(Restore, this->devBounds(), this->getTotalMatrix()); 253 APPEND(Restore, this->devBounds(), this->getTotalMatrix());
244 } 254 }
245 255
246 void SkRecorder::onPushCull(const SkRect& rect) { 256 void SkRecorder::onPushCull(const SkRect& rect) {
247 APPEND(PushCull, rect); 257 APPEND(PushCull, rect);
248 } 258 }
249 259
250 void SkRecorder::onPopCull() { 260 void SkRecorder::onPopCull() {
251 APPEND(PopCull); 261 APPEND(PopCull);
252 } 262 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 APPEND(BeginCommentGroup, this->copy(description)); 298 APPEND(BeginCommentGroup, this->copy(description));
289 } 299 }
290 300
291 void SkRecorder::addComment(const char* key, const char* value) { 301 void SkRecorder::addComment(const char* key, const char* value) {
292 APPEND(AddComment, this->copy(key), this->copy(value)); 302 APPEND(AddComment, this->copy(key), this->copy(value));
293 } 303 }
294 304
295 void SkRecorder::endCommentGroup() { 305 void SkRecorder::endCommentGroup() {
296 APPEND(EndCommentGroup); 306 APPEND(EndCommentGroup);
297 } 307 }
308
309 bool SkRecorder::isDrawingToLayer() const {
310 return fSaveLayerCount > 0;
311 }
312
313 void SkRecorder::drawData(const void* data, size_t length) {
314 APPEND(DrawData, copy((const char*)data), length);
315 }
OLDNEW
« no previous file with comments | « src/core/SkRecorder.h ('k') | src/core/SkRecords.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698