blob: 4116aef84deb3c7249e4671d7acc00a971affca6 [file] [log] [blame]
robertphillips98d709b2014-09-02 10:20:50 -07001/*
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
14class GrAccelData;
15struct GrCachedLayer;
16struct 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
23class GrLayerHoister {
24public:
25 /** Find the layers in 'gpuData' that need hoisting.
26 @param gpuData Acceleration structure containing layer information for a picture
robertphillips98d709b2014-09-02 10:20:50 -070027 @param query The rectangle that is about to be drawn.
28 @param pullForward A gpuData->numSaveLayers -sized Boolean array indicating
29 which layers are to be hoisted
30 Return true if any layers are suitable for hoisting; false otherwise
31 */
32 static bool FindLayersToHoist(const GrAccelData *gpuData,
robertphillips98d709b2014-09-02 10:20:50 -070033 const SkRect& query,
34 bool pullForward[]);
35
36 /** Draw the specified layers of 'picture' into either the atlas or free
37 floating textures.
38 @param picture The picture containing the layers
39 @param atlased The layers to be drawn into the atlas
40 @param nonAtlased The layers to be drawn into their own textures
41 */
42 static void DrawLayers(const SkPicture* picture,
43 const SkTDArray<GrCachedLayer*>& atlased,
44 const SkTDArray<GrCachedLayer*>& nonAtlased);
45
46 /** Unlock all the layers associated with picture in the layer cache.
47 @param layerCache holder of the locked layers
48 @pmara picture the source of the locked layers
49 */
50 static void UnlockLayers(GrLayerCache* layerCache, const SkPicture* picture);
51};
52
53#endif