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 #ifndef GrLayerHoister_DEFINED | 8 #ifndef GrLayerHoister_DEFINED |
9 #define GrLayerHoister_DEFINED | 9 #define GrLayerHoister_DEFINED |
10 | 10 |
11 #include "SkPicture.h" | 11 #include "SkPicture.h" |
12 #include "SkTDArray.h" | 12 #include "SkTDArray.h" |
13 | 13 |
14 class GrAccelData; | 14 class GrAccelData; |
15 struct GrCachedLayer; | 15 struct GrCachedLayer; |
16 class GrReplacements; | 16 class GrReplacements; |
17 struct SkRect; | 17 struct SkRect; |
18 | 18 |
| 19 class GrHoistedLayer { |
| 20 public: |
| 21 const SkPicture* fPicture; |
| 22 GrCachedLayer* fLayer; |
| 23 SkIPoint fOffset; |
| 24 SkMatrix fCTM; |
| 25 }; |
| 26 |
19 // This class collects the layer hoisting functionality in one place. | 27 // This class collects the layer hoisting functionality in one place. |
20 // For each picture rendering: | 28 // For each picture rendering: |
21 // FindLayersToHoist should be called once to collect the required layers | 29 // FindLayersToHoist should be called once to collect the required layers |
22 // DrawLayers should be called once to render them | 30 // DrawLayers should be called once to render them |
23 // UnlockLayers should be called once to allow the texture resources to be recy
cled | 31 // UnlockLayers should be called once to allow the texture resources to be recy
cled |
24 class GrLayerHoister { | 32 class GrLayerHoister { |
25 public: | 33 public: |
26 struct HoistedLayer { | |
27 const SkPicture* fPicture; | |
28 GrCachedLayer* fLayer; | |
29 SkIPoint fOffset; | |
30 SkMatrix fCTM; | |
31 }; | |
32 | 34 |
33 /** Find the layers in 'topLevelPicture' that need hoisting. Note that the d
iscovered | 35 /** Find the layers in 'topLevelPicture' that need hoisting. Note that the d
iscovered |
34 layers can be inside nested sub-pictures. | 36 layers can be inside nested sub-pictures. |
| 37 @param context Owner of the layer cache (the source of new layers) |
35 @param topLevelPicture The top-level picture that is about to be rendere
d | 38 @param topLevelPicture The top-level picture that is about to be rendere
d |
36 @param query The rectangle that is about to be drawn. | 39 @param query The rectangle that is about to be drawn. |
37 @param atlased Out parameter storing the layers that should be hoist
ed to the atlas | 40 @param atlased Out parameter storing the layers that should be hoist
ed to the atlas |
38 @param nonAtlased Out parameter storing the layers that should be hoist
ed stand alone | 41 @param nonAtlased Out parameter storing the layers that should be hoist
ed stand alone |
39 @param recycled Out parameter storing layers that need hoisting but n
ot rendering | 42 @param recycled Out parameter storing layers that need hoisting but n
ot rendering |
40 @param layerCache The source of new layers | |
41 Return true if any layers are suitable for hoisting; false otherwise | 43 Return true if any layers are suitable for hoisting; false otherwise |
42 */ | 44 */ |
43 static bool FindLayersToHoist(const SkPicture* topLevelPicture, | 45 static bool FindLayersToHoist(GrContext* context, |
| 46 const SkPicture* topLevelPicture, |
44 const SkRect& query, | 47 const SkRect& query, |
45 SkTDArray<HoistedLayer>* altased, | 48 SkTDArray<GrHoistedLayer>* atlased, |
46 SkTDArray<HoistedLayer>* nonAtlased, | 49 SkTDArray<GrHoistedLayer>* nonAtlased, |
47 SkTDArray<HoistedLayer>* recycled, | 50 SkTDArray<GrHoistedLayer>* recycled); |
48 GrLayerCache* layerCache); | |
49 | 51 |
50 /** Draw the specified layers into either the atlas or free floating texture
s. | 52 /** Draw the specified layers into either the atlas or free floating texture
s. |
51 @param atlased The layers to be drawn into the atlas | 53 @param atlased The layers to be drawn into the atlas |
52 @param nonAtlased The layers to be drawn into their own textures | 54 @param nonAtlased The layers to be drawn into their own textures |
53 @param recycled Layers that don't need rendering but do need to go i
nto the | 55 @param recycled Layers that don't need rendering but do need to go i
nto the |
54 replacements object | 56 replacements object |
55 @param replacements The replacement structure to fill in with the render
ed layer info | 57 @param replacements The replacement structure to fill in with the render
ed layer info |
56 */ | 58 */ |
57 static void DrawLayers(const SkTDArray<HoistedLayer>& atlased, | 59 static void DrawLayers(const SkTDArray<GrHoistedLayer>& atlased, |
58 const SkTDArray<HoistedLayer>& nonAtlased, | 60 const SkTDArray<GrHoistedLayer>& nonAtlased, |
59 const SkTDArray<HoistedLayer>& recycled, | 61 const SkTDArray<GrHoistedLayer>& recycled, |
60 GrReplacements* replacements); | 62 GrReplacements* replacements); |
61 | 63 |
62 /** Unlock unneeded layers in the layer cache. | 64 /** Unlock unneeded layers in the layer cache. |
63 @param layerCache holder of the locked layers | 65 @param context Owner of the layer cache (and thus the layers) |
64 @param atlased Unneeded layers in the atlas | 66 @param atlased Unneeded layers in the atlas |
65 @param nonAtlased Unneeded layers in their own textures | 67 @param nonAtlased Unneeded layers in their own textures |
66 @param recycled Unneeded layers that did not require rendering | 68 @param recycled Unneeded layers that did not require rendering |
67 */ | 69 */ |
68 static void UnlockLayers(GrLayerCache* layerCache, | 70 static void UnlockLayers(GrContext* context, |
69 const SkTDArray<HoistedLayer>& atlased, | 71 const SkTDArray<GrHoistedLayer>& atlased, |
70 const SkTDArray<HoistedLayer>& nonAtlased, | 72 const SkTDArray<GrHoistedLayer>& nonAtlased, |
71 const SkTDArray<HoistedLayer>& recycled); | 73 const SkTDArray<GrHoistedLayer>& recycled); |
72 }; | 74 }; |
73 | 75 |
74 #endif | 76 #endif |
OLD | NEW |