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

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

Issue 2127233002: Added the framework for having canvas/recorder/picture record depth_set's. (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: updated tests to be more rigorous about translateZ in playback Created 4 years, 5 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 | « include/private/SkRecords.h ('k') | src/core/SkPictureFlat.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 2008 The Android Open Source Project 2 * Copyright 2008 The Android Open Source Project
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 "SkBitmapDevice.h" 8 #include "SkBitmapDevice.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkCanvasPriv.h" 10 #include "SkCanvasPriv.h"
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 one that is at or below this level in the stack (so we know what 287 one that is at or below this level in the stack (so we know what
288 bitmap/device to draw into from this level. This value is NOT 288 bitmap/device to draw into from this level. This value is NOT
289 reference counted, since the real owner is either our fLayer field, 289 reference counted, since the real owner is either our fLayer field,
290 or a previous one in a lower level.) 290 or a previous one in a lower level.)
291 */ 291 */
292 DeviceCM* fTopLayer; 292 DeviceCM* fTopLayer;
293 SkRasterClip fRasterClip; 293 SkRasterClip fRasterClip;
294 SkMatrix fMatrix; 294 SkMatrix fMatrix;
295 int fDeferredSaveCount; 295 int fDeferredSaveCount;
296 296
297 // This is the current cumulative depth (aggregate of all done translateZ ca lls)
298 SkScalar fCurDrawDepth;
299
297 MCRec(bool conservativeRasterClip) : fRasterClip(conservativeRasterClip) { 300 MCRec(bool conservativeRasterClip) : fRasterClip(conservativeRasterClip) {
298 fFilter = nullptr; 301 fFilter = nullptr;
299 fLayer = nullptr; 302 fLayer = nullptr;
300 fTopLayer = nullptr; 303 fTopLayer = nullptr;
301 fMatrix.reset(); 304 fMatrix.reset();
302 fDeferredSaveCount = 0; 305 fDeferredSaveCount = 0;
306 fCurDrawDepth = 0;
303 307
304 // don't bother initializing fNext 308 // don't bother initializing fNext
305 inc_rec(); 309 inc_rec();
306 } 310 }
307 MCRec(const MCRec& prev) : fRasterClip(prev.fRasterClip), fMatrix(prev.fMatr ix) { 311 MCRec(const MCRec& prev) : fRasterClip(prev.fRasterClip), fMatrix(prev.fMatr ix),
312 fCurDrawDepth(prev.fCurDrawDepth) {
308 fFilter = SkSafeRef(prev.fFilter); 313 fFilter = SkSafeRef(prev.fFilter);
309 fLayer = nullptr; 314 fLayer = nullptr;
310 fTopLayer = prev.fTopLayer; 315 fTopLayer = prev.fTopLayer;
311 fDeferredSaveCount = 0; 316 fDeferredSaveCount = 0;
312 317
313 // don't bother initializing fNext 318 // don't bother initializing fNext
314 inc_rec(); 319 inc_rec();
315 } 320 }
316 ~MCRec() { 321 ~MCRec() {
317 SkSafeUnref(fFilter); 322 SkSafeUnref(fFilter);
(...skipping 1196 matching lines...) Expand 10 before | Expand all | Expand 10 after
1514 void SkCanvas::setMatrix(const SkMatrix& matrix) { 1519 void SkCanvas::setMatrix(const SkMatrix& matrix) {
1515 this->checkForDeferredSave(); 1520 this->checkForDeferredSave();
1516 this->internalSetMatrix(matrix); 1521 this->internalSetMatrix(matrix);
1517 this->didSetMatrix(matrix); 1522 this->didSetMatrix(matrix);
1518 } 1523 }
1519 1524
1520 void SkCanvas::resetMatrix() { 1525 void SkCanvas::resetMatrix() {
1521 this->setMatrix(SkMatrix::I()); 1526 this->setMatrix(SkMatrix::I());
1522 } 1527 }
1523 1528
1529 void SkCanvas::translateZ(SkScalar z) {
1530 this->checkForDeferredSave();
1531 this->fMCRec->fCurDrawDepth += z;
1532 this->didTranslateZ(z);
1533 }
1534
1535 SkScalar SkCanvas::getZ() const {
1536 return this->fMCRec->fCurDrawDepth;
1537 }
1538
1524 ////////////////////////////////////////////////////////////////////////////// 1539 //////////////////////////////////////////////////////////////////////////////
1525 1540
1526 void SkCanvas::clipRect(const SkRect& rect, SkRegion::Op op, bool doAA) { 1541 void SkCanvas::clipRect(const SkRect& rect, SkRegion::Op op, bool doAA) {
1527 if (!fAllowSoftClip) { 1542 if (!fAllowSoftClip) {
1528 doAA = false; 1543 doAA = false;
1529 } 1544 }
1530 1545
1531 #ifdef SK_SUPPORT_PRECHECK_CLIPRECT 1546 #ifdef SK_SUPPORT_PRECHECK_CLIPRECT
1532 // Check if we can quick-accept the clip call (and do nothing) 1547 // Check if we can quick-accept the clip call (and do nothing)
1533 // 1548 //
(...skipping 1560 matching lines...) Expand 10 before | Expand all | Expand 10 after
3094 3109
3095 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { 3110 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() {
3096 fCanvas->restoreToCount(fSaveCount); 3111 fCanvas->restoreToCount(fSaveCount);
3097 } 3112 }
3098 3113
3099 #ifdef SK_SUPPORT_LEGACY_NEW_SURFACE_API 3114 #ifdef SK_SUPPORT_LEGACY_NEW_SURFACE_API
3100 SkSurface* SkCanvas::newSurface(const SkImageInfo& info, const SkSurfaceProps* p rops) { 3115 SkSurface* SkCanvas::newSurface(const SkImageInfo& info, const SkSurfaceProps* p rops) {
3101 return this->makeSurface(info, props).release(); 3116 return this->makeSurface(info, props).release();
3102 } 3117 }
3103 #endif 3118 #endif
OLDNEW
« no previous file with comments | « include/private/SkRecords.h ('k') | src/core/SkPictureFlat.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698