• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2018 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 GrMtlTextureRenderTarget_DEFINED
9 #define GrMtlTextureRenderTarget_DEFINED
10 
11 #include "src/gpu/mtl/GrMtlRenderTarget.h"
12 #include "src/gpu/mtl/GrMtlTexture.h"
13 
14 class GrMtlTextureRenderTarget: public GrMtlTexture, public GrMtlRenderTarget {
15 public:
16     static sk_sp<GrMtlTextureRenderTarget> MakeNewTextureRenderTarget(GrMtlGpu*,
17                                                                       SkBudgeted,
18                                                                       SkISize,
19                                                                       int sampleCnt,
20                                                                       MTLPixelFormat,
21                                                                       uint32_t mipLevels,
22                                                                       GrMipmapStatus);
23 
24     static sk_sp<GrMtlTextureRenderTarget> MakeWrappedTextureRenderTarget(GrMtlGpu*,
25                                                                           SkISize,
26                                                                           int sampleCnt,
27                                                                           id<MTLTexture>,
28                                                                           GrWrapCacheable);
backendFormat()29     GrBackendFormat backendFormat() const override {
30         return GrMtlTexture::backendFormat();
31     }
32 
33 protected:
onAbandon()34     void onAbandon() override {
35         GrMtlRenderTarget::onAbandon();
36         GrMtlTexture::onAbandon();
37     }
38 
onRelease()39     void onRelease() override {
40         GrMtlRenderTarget::onRelease();
41         GrMtlTexture::onRelease();
42     }
43 
44 private:
45     GrMtlTextureRenderTarget(GrMtlGpu* gpu,
46                              SkBudgeted budgeted,
47                              SkISize,
48                              sk_sp<GrMtlAttachment> texture,
49                              sk_sp<GrMtlAttachment> colorAttachment,
50                              sk_sp<GrMtlAttachment> resolveAttachment,
51                              GrMipmapStatus);
52 
53     GrMtlTextureRenderTarget(GrMtlGpu* gpu,
54                              SkISize,
55                              sk_sp<GrMtlAttachment> texture,
56                              sk_sp<GrMtlAttachment> colorAttachment,
57                              sk_sp<GrMtlAttachment> resolveAttachment,
58                              GrMipmapStatus,
59                              GrWrapCacheable cacheable);
60 
61     size_t onGpuMemorySize() const override;
62 };
63 
64 #endif
65