robertphillips | 98d709b | 2014-09-02 10:20:50 -0700 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2014 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #ifndef GrLayerHoister_DEFINED |
| 9 | #define GrLayerHoister_DEFINED |
| 10 | |
| 11 | #include "SkPicture.h" |
| 12 | #include "SkTDArray.h" |
| 13 | |
| 14 | class GrAccelData; |
| 15 | struct GrCachedLayer; |
| 16 | struct SkRect; |
| 17 | |
| 18 | // This class collects the layer hoisting functionality in one place. |
| 19 | // For each picture rendering: |
| 20 | // FindLayersToHoist should be called once to collect the required layers |
| 21 | // DrawLayers should be called once to render them |
| 22 | // UnlockLayers should be called once to allow the texture resources to be recycled |
| 23 | class GrLayerHoister { |
| 24 | public: |
| 25 | /** Find the layers in 'gpuData' that need hoisting. |
| 26 | @param gpuData Acceleration structure containing layer information for a picture |
| 27 | @param ops If a BBH is being used the operations about to be executed; NULL otherwise. |
| 28 | @param query The rectangle that is about to be drawn. |
| 29 | @param pullForward A gpuData->numSaveLayers -sized Boolean array indicating |
| 30 | which layers are to be hoisted |
| 31 | Return true if any layers are suitable for hoisting; false otherwise |
| 32 | */ |
| 33 | static bool FindLayersToHoist(const GrAccelData *gpuData, |
| 34 | const SkPicture::OperationList* ops, |
| 35 | const SkRect& query, |
| 36 | bool pullForward[]); |
| 37 | |
| 38 | /** Draw the specified layers of 'picture' into either the atlas or free |
| 39 | floating textures. |
| 40 | @param picture The picture containing the layers |
| 41 | @param atlased The layers to be drawn into the atlas |
| 42 | @param nonAtlased The layers to be drawn into their own textures |
| 43 | */ |
| 44 | static void DrawLayers(const SkPicture* picture, |
| 45 | const SkTDArray<GrCachedLayer*>& atlased, |
| 46 | const SkTDArray<GrCachedLayer*>& nonAtlased); |
| 47 | |
| 48 | /** Unlock all the layers associated with picture in the layer cache. |
| 49 | @param layerCache holder of the locked layers |
| 50 | @pmara picture the source of the locked layers |
| 51 | */ |
| 52 | static void UnlockLayers(GrLayerCache* layerCache, const SkPicture* picture); |
| 53 | }; |
| 54 | |
| 55 | #endif |