Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
GrAttachment.h
Go to the documentation of this file.
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 GrAttachment_DEFINED
9#define GrAttachment_DEFINED
10
13
14class GrCaps;
15class GrRenderTarget;
16
17/**
18 * This is a generic attachment class for out GrSurfaces. It always represents a single gpu
19 * allocation. It contains usage flags so that we know what the attachment can be used for.
20 *
21 * TODO: Once we can pull out GrRenderTarget to be more of a framebuffer and break apart our
22 * texture render target diamond, we will merge this class with GrSurface. Until then this will
23 * act as the staging class for the new surface and framebuffer world.
24 */
25class GrAttachment : public GrSurface {
26public:
27 enum class UsageFlags : uint8_t {
29 kColorAttachment = 0x2,
30 kTexture = 0x4,
31 };
33
34 ~GrAttachment() override {}
35
36 UsageFlags supportedUsages() const { return fSupportedUsages; }
37
38 int numSamples() const { return fSampleCnt; }
39
40 skgpu::Mipmapped mipmapped() const { return fMipmapped; }
41
42 bool hasPerformedInitialClear() const { return fHasPerformedInitialClear; }
43 void markHasPerformedInitialClear() { fHasPerformedInitialClear = true; }
44
45 // This unique key is used for attachments of the same dimensions, usage, and sample cnt which
46 // are shared between multiple render targets at the same time. Only one usage flag may be
47 // passed in.
48 // TODO: Once attachments start having multiple usages, we'll need to figure out how to search
49 // the cache for an attachment that simply contains the requested usage instead of equaling it.
50 static void ComputeSharedAttachmentUniqueKey(const GrCaps& caps,
53 UsageFlags requiredUsage,
54 int sampleCnt,
57 GrMemoryless memoryless,
59
60 // TODO: Once attachments start having multiple usages, we'll need to figure out how to search
61 // the cache for an attachment that simply contains the requested usage instead of equaling it.
62 static void ComputeScratchKey(const GrCaps& caps,
65 UsageFlags requiredUsage,
66 int sampleCnt,
71
72protected:
76 int sampleCnt,
79 std::string_view label,
81 : INHERITED(gpu, dimensions, isProtected, label)
82 , fSupportedUsages(supportedUsages)
83 , fSampleCnt(sampleCnt)
84 , fMipmapped(mipmapped)
85 , fMemoryless(memoryless) {}
86
87private:
88 size_t onGpuMemorySize() const final;
89
90 void onSetLabel() override{}
91
92 void computeScratchKey(skgpu::ScratchKey*) const final;
93
94 const char* getResourceType() const override {
95 if (fSupportedUsages == UsageFlags::kStencilAttachment) {
96 return "StencilAttachment";
97 }
98
99 // This is a general grouping of all textures and color attachments.
100 return "Surface";
101 }
102
103 UsageFlags fSupportedUsages;
104 int fSampleCnt;
105 skgpu::Mipmapped fMipmapped;
106 bool fHasPerformedInitialClear = false;
107 GrMemoryless fMemoryless;
108
109 using INHERITED = GrSurface;
110};
111
113
114#endif
GrMemoryless
#define GR_MAKE_BITFIELD_CLASS_OPS(X)
Definition GrTypes.h:42
bool hasPerformedInitialClear() const
skgpu::Mipmapped mipmapped() const
int numSamples() const
void computeScratchKey(skgpu::ScratchKey *) const final
GrAttachment(GrGpu *gpu, SkISize dimensions, UsageFlags supportedUsages, int sampleCnt, skgpu::Mipmapped mipmapped, GrProtected isProtected, std::string_view label, GrMemoryless memoryless=GrMemoryless::kNo)
static void ComputeScratchKey(const GrCaps &caps, const GrBackendFormat &format, SkISize dimensions, UsageFlags requiredUsage, int sampleCnt, skgpu::Mipmapped mipmapped, GrProtected, GrMemoryless, skgpu::ScratchKey *key)
UsageFlags supportedUsages() const
size_t onGpuMemorySize() const final
static void ComputeSharedAttachmentUniqueKey(const GrCaps &caps, const GrBackendFormat &format, SkISize dimensions, UsageFlags requiredUsage, int sampleCnt, skgpu::Mipmapped mipmapped, GrProtected isProtected, GrMemoryless memoryless, skgpu::UniqueKey *key)
void markHasPerformedInitialClear()
const char * getResourceType() const override
void onSetLabel() override
~GrAttachment() override
GR_DECL_BITFIELD_CLASS_OPS_FRIENDS(UsageFlags)
Definition GrGpu.h:62
SkISize dimensions() const
Definition GrSurface.h:27
bool isProtected() const
Definition GrSurface.h:87
uint32_t uint32_t * format
Mipmapped
Definition GpuTypes.h:53
Protected
Definition GpuTypes.h:61