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 "GrLayerCache.h" | 8 #include "GrLayerCache.h" |
9 #include "GrLayerHoister.h" | 9 #include "GrLayerHoister.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
11 #include "SkRecordDraw.h" | 11 #include "SkRecordDraw.h" |
12 #include "GrRecordReplaceDraw.h" | 12 #include "GrRecordReplaceDraw.h" |
13 #include "SkGrPixelRef.h" | 13 #include "SkGrPixelRef.h" |
14 #include "SkSurface.h" | 14 #include "SkSurface.h" |
15 | 15 |
16 // Create the layer information for the hoisted layer and secure the | 16 // Create the layer information for the hoisted layer and secure the |
17 // required texture/render target resources. | 17 // required texture/render target resources. |
18 static void prepare_for_hoisting(GrLayerCache* layerCache, | 18 static void prepare_for_hoisting(GrLayerCache* layerCache, |
19 const SkPicture* topLevelPicture, | 19 const SkPicture* topLevelPicture, |
20 const GrAccelData::SaveLayerInfo& info, | 20 const GrAccelData::SaveLayerInfo& info, |
21 SkTDArray<GrHoistedLayer>* atlased, | 21 SkTDArray<GrHoistedLayer>* atlased, |
22 SkTDArray<GrHoistedLayer>* nonAtlased, | 22 SkTDArray<GrHoistedLayer>* nonAtlased, |
23 SkTDArray<GrHoistedLayer>* recycled) { | 23 SkTDArray<GrHoistedLayer>* recycled) { |
24 const SkPicture* pict = info.fPicture ? info.fPicture : topLevelPicture; | 24 const SkPicture* pict = info.fPicture ? info.fPicture : topLevelPicture; |
25 | 25 |
26 GrCachedLayer* layer = layerCache->findLayerOrCreate(pict->uniqueID(), | 26 GrCachedLayer* layer = layerCache->findLayerOrCreate(pict->uniqueID(), |
27 info.fSaveLayerOpID, | 27 info.fSaveLayerOpID, |
28 info.fRestoreOpID, | 28 info.fRestoreOpID, |
29 info.fOriginXform, | 29 info.fOriginXform, |
30 info.fPaint); | 30 info.fPaint); |
31 | 31 |
32 GrTextureDesc desc; | 32 GrTextureDesc desc; |
33 desc.fFlags = kRenderTarget_GrTextureFlagBit; | 33 desc.fFlags = kRenderTarget_GrTextureFlagBit; |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 SkIntToScalar(info.fSize.fWidth), | 106 SkIntToScalar(info.fSize.fWidth), |
107 SkIntToScalar(info.fSize.fHeight)); | 107 SkIntToScalar(info.fSize.fHeight)); |
108 | 108 |
109 if (!SkRect::Intersects(query, layerRect)) { | 109 if (!SkRect::Intersects(query, layerRect)) { |
110 continue; | 110 continue; |
111 } | 111 } |
112 | 112 |
113 // TODO: ignore perspective projected layers here! | 113 // TODO: ignore perspective projected layers here! |
114 // TODO: once this code is more stable unsuitable layers can | 114 // TODO: once this code is more stable unsuitable layers can |
115 // just be omitted during the optimization stage | 115 // just be omitted during the optimization stage |
116 if (!info.fValid || info.fIsNested) { | 116 if (info.fIsNested) { |
117 continue; | 117 continue; |
118 } | 118 } |
119 | 119 |
120 prepare_for_hoisting(layerCache, topLevelPicture, info, atlased, nonAtla
sed, recycled); | 120 prepare_for_hoisting(layerCache, topLevelPicture, info, atlased, nonAtla
sed, recycled); |
121 anyHoisted = true; | 121 anyHoisted = true; |
122 } | 122 } |
123 | 123 |
124 return anyHoisted; | 124 return anyHoisted; |
125 } | 125 } |
126 | 126 |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 } | 295 } |
296 | 296 |
297 #if DISABLE_CACHING | 297 #if DISABLE_CACHING |
298 // This code completely clears out the atlas. It is required when | 298 // This code completely clears out the atlas. It is required when |
299 // caching is disabled so the atlas doesn't fill up and force more | 299 // caching is disabled so the atlas doesn't fill up and force more |
300 // free floating layers | 300 // free floating layers |
301 layerCache->purgeAll(); | 301 layerCache->purgeAll(); |
302 #endif | 302 #endif |
303 } | 303 } |
304 | 304 |
OLD | NEW |