| 1 |
/* |
| 2 |
* Copyright 2011 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 GrGLMtlAttachment_DEFINED |
| 9 |
#define GrGLMtlAttachment_DEFINED |
| 10 |
|
| 11 |
#include "include/core/SkRefCnt.h" |
| 12 |
#include "include/core/SkSize.h" |
| 13 |
#include "include/gpu/GpuTypes.h" |
| 14 |
#include "include/gpu/ganesh/GrBackendSurface.h" |
| 15 |
#include "include/gpu/ganesh/GrTypes.h" |
| 16 |
#include "include/gpu/ganesh/gl/GrGLTypes.h" |
| 17 |
#include "include/private/base/SkAssert.h" |
| 18 |
#include "src/gpu/ganesh/GrAttachment.h" |
| 19 |
|
| 20 |
#include <string_view> |
| 21 |
|
| 22 |
class GrGLGpu; |
| 23 |
class GrGpu; |
| 24 |
class SkString; |
| 25 |
class SkTraceMemoryDump; |
| 26 |
|
| 27 |
class GrGLAttachment : public GrAttachment { |
| 28 |
public: |
| 29 |
static sk_sp<GrGLAttachment> MakeStencil(GrGLGpu* gpu, |
| 30 |
SkISize dimensions, |
| 31 |
int sampleCnt, |
| 32 |
GrGLFormat format); |
| 33 |
|
| 34 |
static sk_sp<GrGLAttachment> MakeMSAA(GrGLGpu* gpu, |
| 35 |
SkISize dimensions, |
| 36 |
int sampleCnt, |
| 37 |
GrGLFormat format); |
| 38 |
|
| 39 |
static sk_sp<GrGLAttachment> MakeWrappedRenderBuffer(GrGpu* gpu, |
| 40 |
GrGLuint renderbufferID, |
| 41 |
SkISize dimensions, |
| 42 |
UsageFlags supportedUsages, |
| 43 |
int sampleCnt, |
| 44 |
GrGLFormat format) { |
| 45 |
return sk_sp<GrGLAttachment>(new GrGLAttachment( |
| 46 |
gpu, renderbufferID, dimensions, supportedUsages, sampleCnt, format, |
| 47 |
/*label=*/"MakeWrappedRenderBuffer")); |
| 48 |
} |
| 49 |
|
| 50 |
GrBackendFormat backendFormat() const override; |
| 51 |
|
| 52 |
GrGLuint renderbufferID() const { return fRenderbufferID; } |
| 53 |
|
| 54 |
GrGLFormat format() const { return fFormat; } |
| 55 |
|
| 56 |
protected: |
| 57 |
// overrides of GrResource |
| 58 |
void onRelease() override; |
| 59 |
void onAbandon() override; |
| 60 |
void setMemoryBacking(SkTraceMemoryDump* traceMemoryDump, |
| 61 |
const SkString& dumpName) const override; |
| 62 |
|
| 63 |
private: |
| 64 |
GrGLAttachment(GrGpu* gpu, |
| 65 |
GrGLuint renderbufferID, |
| 66 |
SkISize dimensions, |
| 67 |
UsageFlags supportedUsages, |
| 68 |
int sampleCnt, |
| 69 |
GrGLFormat format, |
| 70 |
std::string_view label) |
| 71 |
: GrAttachment(gpu, |
| 72 |
dimensions, |
| 73 |
supportedUsages, |
| 74 |
sampleCnt, |
| 75 |
skgpu::Mipmapped::kNo, |
| 76 |
GrProtected::kNo, |
| 77 |
label) |
| 78 |
, fFormat(format) |
| 79 |
, fRenderbufferID(renderbufferID) { |
| 80 |
SkASSERT(supportedUsages == UsageFlags::kStencilAttachment || |
| 81 |
supportedUsages == UsageFlags::kColorAttachment); |
| 82 |
this->registerWithCache(skgpu::Budgeted::kYes); |
| 83 |
} |
| 84 |
|
| 85 |
void onSetLabel() override; |
| 86 |
|
| 87 |
GrGLFormat fFormat; |
| 88 |
|
| 89 |
// may be zero for external SBs associated with external RTs |
| 90 |
// (we don't require the client to give us the id, just tell |
| 91 |
// us how many bits of stencil there are). |
| 92 |
GrGLuint fRenderbufferID; |
| 93 |
|
| 94 |
using INHERITED = GrAttachment; |
| 95 |
}; |
| 96 |
|
| 97 |
#endif |