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" |
11 #include "SkRecord.h" | 11 #include "SkRecord.h" |
12 #include "SkRecords.h" | 12 #include "SkRecords.h" |
13 | 13 |
14 SkPicture::AccelData::Key GrAccelData::ComputeAccelDataKey() { | 14 SkPicture::AccelData::Key GrAccelData::ComputeAccelDataKey() { |
15 static const SkPicture::AccelData::Key gGPUID = SkPicture::AccelData::Genera
teDomain(); | 15 static const SkPicture::AccelData::Key gGPUID = SkPicture::AccelData::Genera
teDomain(); |
16 | 16 |
17 return gGPUID; | 17 return gGPUID; |
18 } | 18 } |
19 | 19 |
20 // SkRecord visitor to gather saveLayer/restore information. | 20 // SkRecord visitor to gather saveLayer/restore information. |
21 class CollectLayers { | 21 class CollectLayers { |
22 public: | 22 public: |
23 CollectLayers(const SkPicture* pict, GrAccelData* accelData) | 23 CollectLayers(const SkPicture* pict, GrAccelData* accelData) |
24 : fPictureID(pict->uniqueID()) | 24 : fPictureID(pict->uniqueID()) |
25 , fCTM(&SkMatrix::I()) | 25 , fCTM(&SkMatrix::I()) |
26 , fCurrentClipBounds(SkIRect::MakeXYWH(0, 0, pict->width(), pict->height
())) | |
27 , fSaveLayersInStack(0) | 26 , fSaveLayersInStack(0) |
28 , fAccelData(accelData) { | 27 , fAccelData(accelData) { |
29 | 28 |
| 29 pict->cullRect().roundOut(&fCurrentClipBounds); |
| 30 |
30 if (NULL == pict->fRecord.get()) { | 31 if (NULL == pict->fRecord.get()) { |
31 return; | 32 return; |
32 } | 33 } |
33 | 34 |
34 for (fCurrentOp = 0; fCurrentOp < pict->fRecord->count(); ++fCurrentOp)
{ | 35 for (fCurrentOp = 0; fCurrentOp < pict->fRecord->count(); ++fCurrentOp)
{ |
35 pict->fRecord->visit<void>(fCurrentOp, *this); | 36 pict->fRecord->visit<void>(fCurrentOp, *this); |
36 } | 37 } |
37 | 38 |
38 while (!fSaveStack.isEmpty()) { | 39 while (!fSaveStack.isEmpty()) { |
39 this->popSaveBlock(); | 40 this->popSaveBlock(); |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 // (Only bounded ops call into this method, so oddballs like Clear don't
matter here.) | 249 // (Only bounded ops call into this method, so oddballs like Clear don't
matter here.) |
249 devRect.intersect(fCurrentClipBounds); | 250 devRect.intersect(fCurrentClipBounds); |
250 return devRect; | 251 return devRect; |
251 } | 252 } |
252 }; | 253 }; |
253 | 254 |
254 | 255 |
255 // GPUOptimize is only intended to be called within the context of SkGpuDevice's | 256 // GPUOptimize is only intended to be called within the context of SkGpuDevice's |
256 // EXPERIMENTAL_optimize method. | 257 // EXPERIMENTAL_optimize method. |
257 const GrAccelData* GPUOptimize(const SkPicture* pict) { | 258 const GrAccelData* GPUOptimize(const SkPicture* pict) { |
258 if (NULL == pict || 0 == pict->width() || 0 == pict->height()) { | 259 if (NULL == pict || pict->cullRect().isEmpty()) { |
259 return NULL; | 260 return NULL; |
260 } | 261 } |
261 | 262 |
262 SkPicture::AccelData::Key key = GrAccelData::ComputeAccelDataKey(); | 263 SkPicture::AccelData::Key key = GrAccelData::ComputeAccelDataKey(); |
263 | 264 |
264 const GrAccelData* existing = | 265 const GrAccelData* existing = |
265 static_cast<const GrAccelData*>(pict->EXPERIMENTAL_g
etAccelData(key)); | 266 static_cast<const GrAccelData*>(pict->EXPERIMENTAL_g
etAccelData(key)); |
266 if (NULL != existing) { | 267 if (NULL != existing) { |
267 return existing; | 268 return existing; |
268 } | 269 } |
269 | 270 |
270 SkAutoTUnref<GrAccelData> data(SkNEW_ARGS(GrAccelData, (key))); | 271 SkAutoTUnref<GrAccelData> data(SkNEW_ARGS(GrAccelData, (key))); |
271 | 272 |
272 pict->EXPERIMENTAL_addAccelData(data); | 273 pict->EXPERIMENTAL_addAccelData(data); |
273 | 274 |
274 CollectLayers collector(pict, data); | 275 CollectLayers collector(pict, data); |
275 | 276 |
276 return data; | 277 return data; |
277 } | 278 } |
OLD | NEW |