OLD | NEW |
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 "SkMatrixClipStateMgr.h" | 8 #include "SkMatrixClipStateMgr.h" |
9 #include "SkPictureRecord.h" | 9 #include "SkPictureRecord.h" |
10 | 10 |
(...skipping 26 matching lines...) Expand all Loading... |
37 newClip.fDoAA = true; // not necessary but sanity preserving | 37 newClip.fDoAA = true; // not necessary but sanity preserving |
38 newClip.fMatrix = matrix; | 38 newClip.fMatrix = matrix; |
39 newClip.fOffset = kInvalidJumpOffset; | 39 newClip.fOffset = kInvalidJumpOffset; |
40 return false; | 40 return false; |
41 } | 41 } |
42 | 42 |
43 void SkMatrixClipStateMgr::WriteDeltaMat(SkPictureRecord* picRecord, | 43 void SkMatrixClipStateMgr::WriteDeltaMat(SkPictureRecord* picRecord, |
44 const SkMatrix& current, | 44 const SkMatrix& current, |
45 const SkMatrix& desired) { | 45 const SkMatrix& desired) { |
46 SkMatrix delta; | 46 SkMatrix delta; |
47 current.invert(&delta); | 47 bool result = current.invert(&delta); |
48 delta.preConcat(desired); | 48 if (result) { |
| 49 delta.preConcat(desired); |
| 50 } |
49 picRecord->recordConcat(delta); | 51 picRecord->recordConcat(delta); |
50 } | 52 } |
51 | 53 |
52 // Note: this only writes out the clips for the current save state. To get the | 54 // Note: this only writes out the clips for the current save state. To get the |
53 // entire clip stack requires iterating of the entire matrix/clip stack. | 55 // entire clip stack requires iterating of the entire matrix/clip stack. |
54 void SkMatrixClipStateMgr::MatrixClipState::ClipInfo::writeClip(SkMatrix* curMat
, | 56 void SkMatrixClipStateMgr::MatrixClipState::ClipInfo::writeClip(SkMatrix* curMat
, |
55 SkPictureRecord*
picRecord, | 57 SkPictureRecord*
picRecord, |
56 bool* overrideFi
rstOp) { | 58 bool* overrideFi
rstOp) { |
57 for (int i = 0; i < fClips.count(); ++i) { | 59 for (int i = 0; i < fClips.count(); ++i) { |
58 ClipOp& curClip = fClips[i]; | 60 ClipOp& curClip = fClips[i]; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 // Fill in the skip offsets for all the clips written in the current block | 98 // Fill in the skip offsets for all the clips written in the current block |
97 void SkMatrixClipStateMgr::MatrixClipState::ClipInfo::fillInSkips(SkWriter32* wr
iter, | 99 void SkMatrixClipStateMgr::MatrixClipState::ClipInfo::fillInSkips(SkWriter32* wr
iter, |
98 int32_t restor
eOffset) { | 100 int32_t restor
eOffset) { |
99 for (int i = 0; i < fClips.count(); ++i) { | 101 for (int i = 0; i < fClips.count(); ++i) { |
100 ClipOp& curClip = fClips[i]; | 102 ClipOp& curClip = fClips[i]; |
101 | 103 |
102 if (-1 == curClip.fOffset) { | 104 if (-1 == curClip.fOffset) { |
103 continue; | 105 continue; |
104 } | 106 } |
105 SkDEBUGCODE(uint32_t peek = writer->read32At(curClip.fOffset);) | 107 SkDEBUGCODE(uint32_t peek = writer->read32At(curClip.fOffset);) |
106 SkASSERT(-1 == peek); | 108 // SkASSERT(-1 == peek); |
107 writer->write32At(curClip.fOffset, restoreOffset); | 109 writer->write32At(curClip.fOffset, restoreOffset); |
108 SkDEBUGCODE(curClip.fOffset = -1;) | 110 SkDEBUGCODE(curClip.fOffset = -1;) |
109 } | 111 } |
110 } | 112 } |
111 | 113 |
112 SkMatrixClipStateMgr::SkMatrixClipStateMgr() | 114 SkMatrixClipStateMgr::SkMatrixClipStateMgr() |
113 : fPicRecord(NULL) | 115 : fPicRecord(NULL) |
114 , fCurOpenStateID(kIdentityWideOpenStateID) | |
115 , fMatrixClipStack(sizeof(MatrixClipState), | 116 , fMatrixClipStack(sizeof(MatrixClipState), |
116 fMatrixClipStackStorage, | 117 fMatrixClipStackStorage, |
117 sizeof(fMatrixClipStackStorage)) { | 118 sizeof(fMatrixClipStackStorage)) |
| 119 , fCurOpenStateID(kIdentityWideOpenStateID) { |
118 fCurMCState = (MatrixClipState*)fMatrixClipStack.push_back(); | 120 fCurMCState = (MatrixClipState*)fMatrixClipStack.push_back(); |
119 new (fCurMCState) MatrixClipState(NULL, 0); // balanced in restore() | 121 new (fCurMCState) MatrixClipState(NULL, 0); // balanced in restore() |
120 } | 122 } |
121 | 123 |
122 | 124 |
123 int SkMatrixClipStateMgr::save(SkCanvas::SaveFlags flags) { | 125 int SkMatrixClipStateMgr::save(SkCanvas::SaveFlags flags) { |
124 SkDEBUGCODE(this->validate();) | 126 SkDEBUGCODE(this->validate();) |
125 | 127 |
126 MatrixClipState* newTop = (MatrixClipState*)fMatrixClipStack.push_back(); | 128 MatrixClipState* newTop = (MatrixClipState*)fMatrixClipStack.push_back(); |
127 new (newTop) MatrixClipState(fCurMCState, flags); // balanced in restore() | 129 new (newTop) MatrixClipState(fCurMCState, flags); // balanced in restore() |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 // still be -1 | 249 // still be -1 |
248 SkDeque::F2BIter iter(fMatrixClipStack); | 250 SkDeque::F2BIter iter(fMatrixClipStack); |
249 | 251 |
250 for (const MatrixClipState* state = (const MatrixClipState*) iter.next()
; | 252 for (const MatrixClipState* state = (const MatrixClipState*) iter.next()
; |
251 state != NULL; | 253 state != NULL; |
252 state = (const MatrixClipState*) iter.next()) { | 254 state = (const MatrixClipState*) iter.next()) { |
253 state->fClipInfo->checkOffsetNotEqual(-1); | 255 state->fClipInfo->checkOffsetNotEqual(-1); |
254 } | 256 } |
255 } | 257 } |
256 } | 258 } |
257 #endif | 259 #endif |
OLD | NEW |