blob: a3b97e328a2183a7ddffe1053d36a5fe4aadc39c [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;
robertphillips1c4c5282014-09-18 12:03:15 -070016class GrReplacements;
robertphillips98d709b2014-09-02 10:20:50 -070017struct SkRect;
18
19// This class collects the layer hoisting functionality in one place.
20// For each picture rendering:
21// FindLayersToHoist should be called once to collect the required layers
22// DrawLayers should be called once to render them
23// UnlockLayers should be called once to allow the texture resources to be recycled
24class GrLayerHoister {
25public:
26 /** Find the layers in 'gpuData' that need hoisting.
robertphillips1c4c5282014-09-18 12:03:15 -070027 @param gpuData Acceleration structure containing layer information for a picture
28 @param query The rectangle that is about to be drawn.
29 @param atlased Out parameter storing the layers that should be hoisted to the atlas
30 @param nonAtlased Out parameter storing the layers that should be hoisted stand alone
31 @param layerCache The source of new layers
robertphillips98d709b2014-09-02 10:20:50 -070032 Return true if any layers are suitable for hoisting; false otherwise
33 */
34 static bool FindLayersToHoist(const GrAccelData *gpuData,
robertphillips98d709b2014-09-02 10:20:50 -070035 const SkRect& query,
robertphillips1c4c5282014-09-18 12:03:15 -070036 SkTDArray<GrCachedLayer*>* altased,
37 SkTDArray<GrCachedLayer*>* nonAtlased,
38 GrLayerCache* layerCache);
robertphillips98d709b2014-09-02 10:20:50 -070039
40 /** Draw the specified layers of 'picture' into either the atlas or free
41 floating textures.
robertphillips1c4c5282014-09-18 12:03:15 -070042 @param picture The picture containing the layers
43 @param atlased The layers to be drawn into the atlas
44 @param nonAtlased The layers to be drawn into their own textures
45 @oaram replacements The replacement structure to fill in with the rendered layer info
robertphillips98d709b2014-09-02 10:20:50 -070046 */
47 static void DrawLayers(const SkPicture* picture,
48 const SkTDArray<GrCachedLayer*>& atlased,
robertphillips1c4c5282014-09-18 12:03:15 -070049 const SkTDArray<GrCachedLayer*>& nonAtlased,
50 GrReplacements* replacements);
robertphillips98d709b2014-09-02 10:20:50 -070051
52 /** Unlock all the layers associated with picture in the layer cache.
53 @param layerCache holder of the locked layers
54 @pmara picture the source of the locked layers
55 */
56 static void UnlockLayers(GrLayerCache* layerCache, const SkPicture* picture);
57};
58
59#endif