aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/gl/GrGLTextureRenderTarget.h
blob: 0d3b19daed81f36b50fbd969029e5217b8532ae7 (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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/*
 * 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 GrGLTextureRenderTarget_DEFINED
#define GrGLTextureRenderTarget_DEFINED

#include "GrGLGpu.h"
#include "GrGLTexture.h"
#include "GrGLRenderTarget.h"
#include "GrTexturePriv.h"

class GrGLGpu;

#ifdef SK_BUILD_FOR_WIN
// Windows gives bogus warnings about inheriting asTexture/asRenderTarget via dominance.
#pragma warning(push)
#pragma warning(disable: 4250)
#endif

class GrGLTextureRenderTarget : public GrGLTexture, public GrGLRenderTarget {
public:
    // We're virtually derived from GrSurface (via both GrGLTexture and GrGLRenderTarget) so its
    // constructor must be explicitly called.
    GrGLTextureRenderTarget(GrGLGpu* gpu,
                            SkBudgeted budgeted,
                            const GrSurfaceDesc& desc,
                            const GrGLTexture::IDDesc& texIDDesc,
                            const GrGLRenderTarget::IDDesc& rtIDDesc,
                            bool wasMipMapDataProvided)
        : GrSurface(gpu, desc)
        , GrGLTexture(gpu, desc, texIDDesc, wasMipMapDataProvided)
        , GrGLRenderTarget(gpu, desc, rtIDDesc) {
        this->registerWithCache(budgeted);
    }

    bool canAttemptStencilAttachment() const override;

    void dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const override;

    static sk_sp<GrGLTextureRenderTarget> MakeWrapped(GrGLGpu* gpu, const GrSurfaceDesc& desc,
                                                      const GrGLTexture::IDDesc& texIDDesc,
                                                      const GrGLRenderTarget::IDDesc& rtIDDesc);
protected:
    void onAbandon() override {
        GrGLRenderTarget::onAbandon();
        GrGLTexture::onAbandon();
    }

    void onRelease() override {
        GrGLRenderTarget::onRelease();
        GrGLTexture::onRelease();
    }

private:
    // Constructor for instances wrapping backend objects.
    GrGLTextureRenderTarget(GrGLGpu* gpu,
                            const GrSurfaceDesc& desc,
                            const GrGLTexture::IDDesc& texIDDesc,
                            const GrGLRenderTarget::IDDesc& rtIDDesc,
                            bool wasMipMapDataProvided)
        : GrSurface(gpu, desc)
        , GrGLTexture(gpu, desc, texIDDesc, wasMipMapDataProvided)
        , GrGLRenderTarget(gpu, desc, rtIDDesc) {
        this->registerWithCacheWrapped();
    }

    size_t onGpuMemorySize() const override {
        return GrSurface::ComputeSize(this->config(), this->width(), this->height(),
                                      this->numSamplesOwnedPerPixel(),
                                      this->texturePriv().hasMipMaps());
    }

};

#ifdef SK_BUILD_FOR_WIN
#pragma warning(pop)
#endif

#endif