• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "src/gpu/gl/GrGLRenderTarget.h"
13 #include "src/gpu/gl/GrGLTexture.h"
14 
15 class GrGLGpu;
16 
17 #ifdef SK_BUILD_FOR_WIN
18 // Windows gives bogus warnings about inheriting asTexture/asRenderTarget via dominance.
19 #pragma warning(push)
20 #pragma warning(disable: 4250)
21 #endif
22 
23 class GrGLTextureRenderTarget : public GrGLTexture, public GrGLRenderTarget {
24 public:
25     // We're virtually derived from GrSurface (via both GrGLTexture and GrGLRenderTarget) so its
26     // constructor must be explicitly called.
27     GrGLTextureRenderTarget(GrGLGpu* gpu,
28                             SkBudgeted budgeted,
29                             int sampleCount,
30                             const GrGLTexture::Desc& texDesc,
31                             const GrGLRenderTarget::IDs&,
32                             GrMipMapsStatus);
33 
34     bool canAttemptStencilAttachment() const override;
35 
36     void dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const override;
37 
38     static sk_sp<GrGLTextureRenderTarget> MakeWrapped(GrGLGpu* gpu,
39                                                       int sampleCount,
40                                                       const GrGLTexture::Desc&,
41                                                       sk_sp<GrGLTextureParameters>,
42                                                       const GrGLRenderTarget::IDs&,
43                                                       GrWrapCacheable,
44                                                       GrMipMapsStatus);
45 
backendFormat()46     GrBackendFormat backendFormat() const override {
47         // It doesn't matter if we take the texture or render target path, so just pick texture.
48         return GrGLTexture::backendFormat();
49     }
50 
51 protected:
onAbandon()52     void onAbandon() override {
53         GrGLRenderTarget::onAbandon();
54         GrGLTexture::onAbandon();
55     }
56 
onRelease()57     void onRelease() override {
58         GrGLRenderTarget::onRelease();
59         GrGLTexture::onRelease();
60     }
61 
62 private:
63     // Constructor for instances wrapping backend objects.
64     GrGLTextureRenderTarget(GrGLGpu* gpu,
65                             int sampleCount,
66                             const GrGLTexture::Desc& texDesc,
67                             sk_sp<GrGLTextureParameters> parameters,
68                             const GrGLRenderTarget::IDs& ids,
69                             GrWrapCacheable,
70                             GrMipMapsStatus);
71 
72     size_t onGpuMemorySize() const override;
73 };
74 
75 #ifdef SK_BUILD_FOR_WIN
76 #pragma warning(pop)
77 #endif
78 
79 #endif
80