summaryrefslogtreecommitdiff
path: root/gpu/GrPictureUtils.h
blob: 6b4d901cc14ab1eed97613e7ffd5175523b3e3f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*
 * Copyright 2014 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#ifndef GrPictureUtils_DEFINED
#define GrPictureUtils_DEFINED

#include "SkPicture.h"
#include "SkTDArray.h"

// This class encapsulates the GPU-backend-specific acceleration data
// for a single SkPicture
class GPUAccelData : public SkPicture::AccelData {
public:
    // Information about a given saveLayer in an SkPicture
    struct SaveLayerInfo {
        // The size of the saveLayer
        SkISize fSize;
        // The ID of this saveLayer in the picture. 0 is an invalid ID.
        size_t  fSaveLayerOpID;
        // The ID of the matching restore in the picture. 0 is an invalid ID.
        size_t  fRestoreOpID;
        // True if this saveLayer has at least one other saveLayer nested within it.
        // False otherwise.
        bool    fHasNestedLayers;
    };

    GPUAccelData(Key key) : INHERITED(key) { }

    void addSaveLayerInfo(const SaveLayerInfo& info) {
        SkASSERT(info.fSaveLayerOpID < info.fRestoreOpID);
        *fSaveLayerInfo.push() = info;
    }

    int numSaveLayers() const { return fSaveLayerInfo.count(); }

    const SaveLayerInfo& saveLayerInfo(int index) const {
        SkASSERT(index < fSaveLayerInfo.count());

        return fSaveLayerInfo[index];
    }

protected:
    SkTDArray<SaveLayerInfo> fSaveLayerInfo;

private:
    typedef SkPicture::AccelData INHERITED;
};

void GatherGPUInfo(SkPicture* pict, GPUAccelData* accelData);

#endif // GrPictureUtils_DEFINED