Line data Source code
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 :
9 : #ifndef GrGLTextureRenderTarget_DEFINED
10 : #define GrGLTextureRenderTarget_DEFINED
11 :
12 : #include "GrGLGpu.h"
13 : #include "GrGLTexture.h"
14 : #include "GrGLRenderTarget.h"
15 : #include "GrTexturePriv.h"
16 :
17 : class GrGLGpu;
18 :
19 : #ifdef SK_BUILD_FOR_WIN
20 : // Windows gives bogus warnings about inheriting asTexture/asRenderTarget via dominance.
21 : #pragma warning(push)
22 : #pragma warning(disable: 4250)
23 : #endif
24 :
25 0 : class GrGLTextureRenderTarget : public GrGLTexture, public GrGLRenderTarget {
26 : public:
27 : // We're virtually derived from GrSurface (via both GrGLTexture and GrGLRenderTarget) so its
28 : // constructor must be explicitly called.
29 0 : GrGLTextureRenderTarget(GrGLGpu* gpu,
30 : SkBudgeted budgeted,
31 : const GrSurfaceDesc& desc,
32 : const GrGLTexture::IDDesc& texIDDesc,
33 : const GrGLRenderTarget::IDDesc& rtIDDesc,
34 : bool wasMipMapDataProvided)
35 0 : : GrSurface(gpu, desc)
36 : , GrGLTexture(gpu, desc, texIDDesc, wasMipMapDataProvided)
37 0 : , GrGLRenderTarget(gpu, desc, rtIDDesc) {
38 0 : this->registerWithCache(budgeted);
39 0 : }
40 :
41 : bool canAttemptStencilAttachment() const override;
42 :
43 : void dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const override;
44 :
45 : static sk_sp<GrGLTextureRenderTarget> MakeWrapped(GrGLGpu* gpu, const GrSurfaceDesc& desc,
46 : const GrGLTexture::IDDesc& texIDDesc,
47 : const GrGLRenderTarget::IDDesc& rtIDDesc);
48 : protected:
49 0 : void onAbandon() override {
50 0 : GrGLRenderTarget::onAbandon();
51 0 : GrGLTexture::onAbandon();
52 0 : }
53 :
54 0 : void onRelease() override {
55 0 : GrGLRenderTarget::onRelease();
56 0 : GrGLTexture::onRelease();
57 0 : }
58 :
59 : private:
60 : // Constructor for instances wrapping backend objects.
61 0 : GrGLTextureRenderTarget(GrGLGpu* gpu,
62 : const GrSurfaceDesc& desc,
63 : const GrGLTexture::IDDesc& texIDDesc,
64 : const GrGLRenderTarget::IDDesc& rtIDDesc,
65 : bool wasMipMapDataProvided)
66 0 : : GrSurface(gpu, desc)
67 : , GrGLTexture(gpu, desc, texIDDesc, wasMipMapDataProvided)
68 0 : , GrGLRenderTarget(gpu, desc, rtIDDesc) {
69 0 : this->registerWithCacheWrapped();
70 0 : }
71 :
72 0 : size_t onGpuMemorySize() const override {
73 0 : return GrSurface::ComputeSize(fDesc,
74 : this->numSamplesOwnedPerPixel(),
75 0 : this->texturePriv().hasMipMaps());
76 : }
77 :
78 : };
79 :
80 : #ifdef SK_BUILD_FOR_WIN
81 : #pragma warning(pop)
82 : #endif
83 :
84 : #endif
|