Flutter Engine
The Flutter Engine
GrD3DTypesMinimal.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2020 Google LLC
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
9
13
16 : fTextureResourceInfo(new GrD3DTextureResourceInfo(info))
17 , fResourceState(state) {}
18
20 SkSafeUnref(fResourceState);
21 fResourceState = nullptr;
22 delete fTextureResourceInfo;
23 fTextureResourceInfo = nullptr;
24};
25
26void GrD3DBackendSurfaceInfo::assign(const GrD3DBackendSurfaceInfo& that, bool isThisValid) {
27 GrD3DTextureResourceInfo* oldInfo = fTextureResourceInfo;
28 GrD3DResourceState* oldLayout = fResourceState;
29 fTextureResourceInfo = new GrD3DTextureResourceInfo(*that.fTextureResourceInfo);
30 fResourceState = SkSafeRef(that.fResourceState);
31 if (isThisValid) {
32 delete oldInfo;
33 SkSafeUnref(oldLayout);
34 }
35}
36
38 SkASSERT(fResourceState);
39 fResourceState->setResourceState(static_cast<D3D12_RESOURCE_STATES>(resourceState));
40}
41
43 SkASSERT(fResourceState);
44 return sk_ref_sp(fResourceState);
45}
46
49 *fTextureResourceInfo,
50 static_cast<D3D12_RESOURCE_STATES>(fResourceState->getResourceState()));
51}
52
54 SkASSERT(fTextureResourceInfo);
55 return fTextureResourceInfo->fProtected == GrProtected::kYes;
56}
57
58#if defined(GR_TEST_UTILS)
60 GrD3DTextureResourceInfo cpyInfoThis = *fTextureResourceInfo;
61 GrD3DTextureResourceInfo cpyInfoThat = *that.fTextureResourceInfo;
62 // We don't care about the fResourceState here since we require they use the same
63 // GrD3DResourceState.
64 cpyInfoThis.fResourceState = D3D12_RESOURCE_STATE_COMMON;
65 cpyInfoThat.fResourceState = D3D12_RESOURCE_STATE_COMMON;
66 return cpyInfoThis == cpyInfoThat && fResourceState == that.fResourceState;
67}
68#endif
69
71 : fSpec(new GrD3DTextureResourceSpec(info)) {}
72
74 uint32_t levelCount,
75 GrProtected isProtected) const {
76 SkASSERT(fSpec);
77 return GrD3DTextureResourceSpecToSurfaceInfo(*fSpec, sampleCount, levelCount, isProtected);
78}
79
81 delete fSpec;
82 fSpec = nullptr;
83}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
int GrD3DResourceStateEnum
GrD3DSurfaceInfo GrD3DTextureResourceSpecToSurfaceInfo(const GrD3DTextureResourceSpec &d3dSpec, uint32_t sampleCount, uint32_t levelCount, skgpu::Protected isProtected)
#define SkASSERT(cond)
Definition: SkAssert.h:116
static void SkSafeUnref(T *obj)
Definition: SkRefCnt.h:149
static T * SkSafeRef(T *obj)
Definition: SkRefCnt.h:140
sk_sp< T > sk_ref_sp(T *obj)
Definition: SkRefCnt.h:381
void setResourceState(D3D12_RESOURCE_STATES state)
D3D12_RESOURCE_STATES getResourceState() const
AtkStateType state
bool operator==(C p1, const scoped_nsprotocol< C > &p2)
Protected
Definition: GpuTypes.h:61
GrD3DBackendSurfaceInfo(const GrD3DTextureResourceInfo &info, GrD3DResourceState *state)
void assign(const GrD3DBackendSurfaceInfo &, bool isValid)
void setResourceState(GrD3DResourceStateEnum state)
GrD3DTextureResourceInfo snapTextureResourceInfo() const
sk_sp< GrD3DResourceState > getGrD3DResourceState() const
D3D12_RESOURCE_STATES fResourceState
Definition: GrD3DTypes.h:182
skgpu::Protected fProtected
Definition: GrD3DTypes.h:187
GrD3DSurfaceInfo getSurfaceInfo(uint32_t sampleCount, uint32_t levelCount, skgpu::Protected isProtected) const
GrD3DTextureResourceSpecHolder(const GrD3DSurfaceInfo &)