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 "GrPictureUtils.h" | 8 #include "GrPictureUtils.h" |
9 | 9 |
10 #include "SkPaintPriv.h" | 10 #include "SkPaintPriv.h" |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 void trackSaveLayers(const SkRecords::SaveLayer& sl) { this->pushSaveLayerBl
ock(sl.paint); } | 101 void trackSaveLayers(const SkRecords::SaveLayer& sl) { this->pushSaveLayerBl
ock(sl.paint); } |
102 void trackSaveLayers(const SkRecords::Restore& r) { this->popSaveBlock(); } | 102 void trackSaveLayers(const SkRecords::Restore& r) { this->popSaveBlock(); } |
103 void trackSaveLayers(const SkRecords::DrawPicture& dp) { | 103 void trackSaveLayers(const SkRecords::DrawPicture& dp) { |
104 // For sub-pictures, we wrap their layer information within the parent | 104 // For sub-pictures, we wrap their layer information within the parent |
105 // picture's rendering hierarchy | 105 // picture's rendering hierarchy |
106 const GrAccelData* childData = GPUOptimize(dp.picture); | 106 const GrAccelData* childData = GPUOptimize(dp.picture); |
107 | 107 |
108 for (int i = 0; i < childData->numSaveLayers(); ++i) { | 108 for (int i = 0; i < childData->numSaveLayers(); ++i) { |
109 const GrAccelData::SaveLayerInfo& src = childData->saveLayerInfo(i); | 109 const GrAccelData::SaveLayerInfo& src = childData->saveLayerInfo(i); |
110 | 110 |
| 111 SkRect srcRect = SkRect::Make(src.fBounds); |
| 112 SkIRect newClip(fCurrentClipBounds); |
| 113 |
| 114 if (!newClip.intersect(this->adjustAndMap(srcRect, dp.paint))) { |
| 115 continue; |
| 116 } |
| 117 |
111 this->updateStackForSaveLayer(); | 118 this->updateStackForSaveLayer(); |
112 | 119 |
113 // TODO: need to store an SkRect in GrAccelData::SaveLayerInfo? | |
114 SkRect srcRect = SkRect::MakeXYWH(SkIntToScalar(src.fOffset.fX), | |
115 SkIntToScalar(src.fOffset.fY), | |
116 SkIntToScalar(src.fSize.width()), | |
117 SkIntToScalar(src.fSize.height()))
; | |
118 SkIRect newClip(fCurrentClipBounds); | |
119 newClip.intersect(this->adjustAndMap(srcRect, dp.paint)); | |
120 | |
121 GrAccelData::SaveLayerInfo& dst = fAccelData->addSaveLayerInfo(); | 120 GrAccelData::SaveLayerInfo& dst = fAccelData->addSaveLayerInfo(); |
122 | 121 |
123 // If src.fPicture is NULL the layer is in dp.picture; otherwise | 122 // If src.fPicture is NULL the layer is in dp.picture; otherwise |
124 // it belongs to a sub-picture. | 123 // it belongs to a sub-picture. |
125 dst.fPicture = src.fPicture ? src.fPicture : static_cast<const SkPic
ture*>(dp.picture); | 124 dst.fPicture = src.fPicture ? src.fPicture : static_cast<const SkPic
ture*>(dp.picture); |
126 dst.fPicture->ref(); | 125 dst.fPicture->ref(); |
127 dst.fSize = SkISize::Make(newClip.width(), newClip.height()); | 126 dst.fBounds = newClip; |
128 dst.fOffset = SkIPoint::Make(newClip.fLeft, newClip.fTop); | |
129 dst.fOriginXform = src.fOriginXform; | 127 dst.fOriginXform = src.fOriginXform; |
130 dst.fOriginXform.postConcat(*fCTM); | 128 dst.fOriginXform.postConcat(*fCTM); |
131 if (src.fPaint) { | 129 if (src.fPaint) { |
132 dst.fPaint = SkNEW_ARGS(SkPaint, (*src.fPaint)); | 130 dst.fPaint = SkNEW_ARGS(SkPaint, (*src.fPaint)); |
133 } | 131 } |
134 dst.fSaveLayerOpID = src.fSaveLayerOpID; | 132 dst.fSaveLayerOpID = src.fSaveLayerOpID; |
135 dst.fRestoreOpID = src.fRestoreOpID; | 133 dst.fRestoreOpID = src.fRestoreOpID; |
136 dst.fHasNestedLayers = src.fHasNestedLayers; | 134 dst.fHasNestedLayers = src.fHasNestedLayers; |
137 dst.fIsNested = fSaveLayersInStack > 0 || src.fIsNested; | 135 dst.fIsNested = fSaveLayersInStack > 0 || src.fIsNested; |
138 } | 136 } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 | 172 |
175 if (!si.fIsSaveLayer) { | 173 if (!si.fIsSaveLayer) { |
176 return; | 174 return; |
177 } | 175 } |
178 | 176 |
179 --fSaveLayersInStack; | 177 --fSaveLayersInStack; |
180 | 178 |
181 GrAccelData::SaveLayerInfo& slInfo = fAccelData->addSaveLayerInfo(); | 179 GrAccelData::SaveLayerInfo& slInfo = fAccelData->addSaveLayerInfo(); |
182 | 180 |
183 SkASSERT(NULL == slInfo.fPicture); // This layer is in the top-most pic
ture | 181 SkASSERT(NULL == slInfo.fPicture); // This layer is in the top-most pic
ture |
184 slInfo.fSize = SkISize::Make(si.fBounds.width(), si.fBounds.height()); | 182 slInfo.fBounds = si.fBounds; |
185 slInfo.fOffset = SkIPoint::Make(si.fBounds.fLeft, si.fBounds.fTop); | |
186 slInfo.fOriginXform = *fCTM; | 183 slInfo.fOriginXform = *fCTM; |
187 if (si.fPaint) { | 184 if (si.fPaint) { |
188 slInfo.fPaint = SkNEW_ARGS(SkPaint, (*si.fPaint)); | 185 slInfo.fPaint = SkNEW_ARGS(SkPaint, (*si.fPaint)); |
189 } | 186 } |
190 slInfo.fSaveLayerOpID = si.fStartIndex; | 187 slInfo.fSaveLayerOpID = si.fStartIndex; |
191 slInfo.fRestoreOpID = fCurrentOp; | 188 slInfo.fRestoreOpID = fCurrentOp; |
192 slInfo.fHasNestedLayers = si.fHasNestedSaveLayer; | 189 slInfo.fHasNestedLayers = si.fHasNestedSaveLayer; |
193 slInfo.fIsNested = fSaveLayersInStack > 0; | 190 slInfo.fIsNested = fSaveLayersInStack > 0; |
194 } | 191 } |
195 | 192 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 } | 251 } |
255 | 252 |
256 SkAutoTUnref<GrAccelData> data(SkNEW_ARGS(GrAccelData, (key))); | 253 SkAutoTUnref<GrAccelData> data(SkNEW_ARGS(GrAccelData, (key))); |
257 | 254 |
258 pict->EXPERIMENTAL_addAccelData(data); | 255 pict->EXPERIMENTAL_addAccelData(data); |
259 | 256 |
260 CollectLayers collector(pict, data); | 257 CollectLayers collector(pict, data); |
261 | 258 |
262 return data; | 259 return data; |
263 } | 260 } |
OLD | NEW |