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

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

Issue 161143002: add region to dictionary in SkMatrixClipStackMgr (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: base files missing retry Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « src/core/SkMatrixClipStateMgr.h ('k') | no next file » | 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 "SkMatrixClipStateMgr.h" 8 #include "SkMatrixClipStateMgr.h"
9 #include "SkPictureRecord.h" 9 #include "SkPictureRecord.h"
10 10
11 bool SkMatrixClipStateMgr::MatrixClipState::ClipInfo::clipPath(SkPictureRecord* picRecord, 11 bool SkMatrixClipStateMgr::MatrixClipState::ClipInfo::clipPath(SkPictureRecord* picRecord,
12 const SkPath& pat h, 12 const SkPath& pat h,
13 SkRegion::Op op, 13 SkRegion::Op op,
14 bool doAA, 14 bool doAA,
15 int matrixID) { 15 int matrixID) {
16 int pathID = picRecord->addPathToHeap(path); 16 int pathID = picRecord->addPathToHeap(path);
17 17
18 ClipOp& newClip = fClips.push_back(); 18 ClipOp* newClip = fClips.append();
19 newClip.fClipType = kPath_ClipType; 19 newClip->fClipType = kPath_ClipType;
20 newClip.fGeom.fPathID = pathID; 20 newClip->fGeom.fPathID = pathID;
21 newClip.fOp = op; 21 newClip->fOp = op;
22 newClip.fDoAA = doAA; 22 newClip->fDoAA = doAA;
23 newClip.fMatrixID = matrixID; 23 newClip->fMatrixID = matrixID;
24 newClip.fOffset = kInvalidJumpOffset; 24 newClip->fOffset = kInvalidJumpOffset;
25 return false; 25 return false;
26 } 26 }
27 27
28 bool SkMatrixClipStateMgr::MatrixClipState::ClipInfo::clipRegion(SkPictureRecord * picRecord, 28 bool SkMatrixClipStateMgr::MatrixClipState::ClipInfo::clipRegion(SkPictureRecord * picRecord,
29 const SkRegion& region, 29 int regionID,
30 SkRegion::Op op , 30 SkRegion::Op op ,
31 int matrixID) { 31 int matrixID) {
32 // TODO: add a region dictionary so we don't have to copy the region in here 32 // TODO: add a region dictionary so we don't have to copy the region in here
33 ClipOp& newClip = fClips.push_back(); 33 ClipOp* newClip = fClips.append();
34 newClip.fClipType = kRegion_ClipType; 34 newClip->fClipType = kRegion_ClipType;
35 newClip.fGeom.fRegion = SkNEW(SkRegion(region)); 35 newClip->fGeom.fRegionID = regionID;
36 newClip.fOp = op; 36 newClip->fOp = op;
37 newClip.fDoAA = true; // not necessary but sanity preserving 37 newClip->fDoAA = true; // not necessary but sanity preserving
38 newClip.fMatrixID = matrixID; 38 newClip->fMatrixID = matrixID;
39 newClip.fOffset = kInvalidJumpOffset; 39 newClip->fOffset = kInvalidJumpOffset;
40 return false; 40 return false;
41 } 41 }
42 42
43 void SkMatrixClipStateMgr::writeDeltaMat(int currentMatID, int desiredMatID) { 43 void SkMatrixClipStateMgr::writeDeltaMat(int currentMatID, int desiredMatID) {
44 const SkMatrix& current = this->lookupMat(currentMatID); 44 const SkMatrix& current = this->lookupMat(currentMatID);
45 const SkMatrix& desired = this->lookupMat(desiredMatID); 45 const SkMatrix& desired = this->lookupMat(desiredMatID);
46 46
47 SkMatrix delta; 47 SkMatrix delta;
48 bool result = current.invert(&delta); 48 bool result = current.invert(&delta);
49 if (result) { 49 if (result) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 op, curClip.fD oAA); 85 op, curClip.fD oAA);
86 break; 86 break;
87 case kRRect_ClipType: 87 case kRRect_ClipType:
88 curClip.fOffset = mgr->getPicRecord()->recordClipRRect(curClip.fGeom .fRRect, op, 88 curClip.fOffset = mgr->getPicRecord()->recordClipRRect(curClip.fGeom .fRRect, op,
89 curClip.fDoAA ); 89 curClip.fDoAA );
90 break; 90 break;
91 case kPath_ClipType: 91 case kPath_ClipType:
92 curClip.fOffset = mgr->getPicRecord()->recordClipPath(curClip.fGeom. fPathID, op, 92 curClip.fOffset = mgr->getPicRecord()->recordClipPath(curClip.fGeom. fPathID, op,
93 curClip.fDoAA) ; 93 curClip.fDoAA) ;
94 break; 94 break;
95 case kRegion_ClipType: 95 case kRegion_ClipType: {
96 curClip.fOffset = mgr->getPicRecord()->recordClipRegion(*curClip.fGe om.fRegion, op); 96 const SkRegion* region = mgr->lookupRegion(curClip.fGeom.fRegionID);
97 curClip.fOffset = mgr->getPicRecord()->recordClipRegion(*region, op) ;
97 break; 98 break;
99 }
98 default: 100 default:
99 SkASSERT(0); 101 SkASSERT(0);
100 } 102 }
101 } 103 }
102 } 104 }
103 105
104 // Fill in the skip offsets for all the clips written in the current block 106 // Fill in the skip offsets for all the clips written in the current block
105 void SkMatrixClipStateMgr::MatrixClipState::ClipInfo::fillInSkips(SkWriter32* wr iter, 107 void SkMatrixClipStateMgr::MatrixClipState::ClipInfo::fillInSkips(SkWriter32* wr iter,
106 int32_t restor eOffset) { 108 int32_t restor eOffset) {
107 for (int i = 0; i < fClips.count(); ++i) { 109 for (int i = 0; i < fClips.count(); ++i) {
(...skipping 16 matching lines...) Expand all
124 sizeof(fMatrixClipStackStorage)) 126 sizeof(fMatrixClipStackStorage))
125 , fCurOpenStateID(kIdentityWideOpenStateID) { 127 , fCurOpenStateID(kIdentityWideOpenStateID) {
126 128
127 // The first slot in the matrix dictionary is reserved for the identity matr ix 129 // The first slot in the matrix dictionary is reserved for the identity matr ix
128 fMatrixDict.append()->reset(); 130 fMatrixDict.append()->reset();
129 131
130 fCurMCState = (MatrixClipState*)fMatrixClipStack.push_back(); 132 fCurMCState = (MatrixClipState*)fMatrixClipStack.push_back();
131 new (fCurMCState) MatrixClipState(NULL, 0); // balanced in restore() 133 new (fCurMCState) MatrixClipState(NULL, 0); // balanced in restore()
132 } 134 }
133 135
136 SkMatrixClipStateMgr::~SkMatrixClipStateMgr() {
137 for (int i = 0; i < fRegionDict.count(); ++i) {
138 SkDELETE(fRegionDict[i]);
139 }
140 }
141
134 142
135 int SkMatrixClipStateMgr::save(SkCanvas::SaveFlags flags) { 143 int SkMatrixClipStateMgr::save(SkCanvas::SaveFlags flags) {
136 SkDEBUGCODE(this->validate();) 144 SkDEBUGCODE(this->validate();)
137 145
138 MatrixClipState* newTop = (MatrixClipState*)fMatrixClipStack.push_back(); 146 MatrixClipState* newTop = (MatrixClipState*)fMatrixClipStack.push_back();
139 new (newTop) MatrixClipState(fCurMCState, flags); // balanced in restore() 147 new (newTop) MatrixClipState(fCurMCState, flags); // balanced in restore()
140 fCurMCState = newTop; 148 fCurMCState = newTop;
141 149
142 SkDEBUGCODE(this->validate();) 150 SkDEBUGCODE(this->validate();)
143 151
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 269
262 for (const MatrixClipState* state = (const MatrixClipState*) iter.next() ; 270 for (const MatrixClipState* state = (const MatrixClipState*) iter.next() ;
263 state != NULL; 271 state != NULL;
264 state = (const MatrixClipState*) iter.next()) { 272 state = (const MatrixClipState*) iter.next()) {
265 state->fClipInfo->checkOffsetNotEqual(-1); 273 state->fClipInfo->checkOffsetNotEqual(-1);
266 } 274 }
267 } 275 }
268 } 276 }
269 #endif 277 #endif
270 278
279 int SkMatrixClipStateMgr::addRegionToDict(const SkRegion& region) {
280 int index = fRegionDict.count();
281 *fRegionDict.append() = SkNEW(SkRegion(region));
282 return index;
283 }
284
271 int SkMatrixClipStateMgr::addMatToDict(const SkMatrix& mat) { 285 int SkMatrixClipStateMgr::addMatToDict(const SkMatrix& mat) {
272 if (mat.isIdentity()) { 286 if (mat.isIdentity()) {
273 return kIdentityMatID; 287 return kIdentityMatID;
274 } 288 }
275 289
276 *fMatrixDict.append() = mat; 290 *fMatrixDict.append() = mat;
277 return fMatrixDict.count()-1; 291 return fMatrixDict.count()-1;
278 } 292 }
OLDNEW
« no previous file with comments | « src/core/SkMatrixClipStateMgr.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698