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