| 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 |
|
| 8 |
#include "include/private/gpu/ganesh/GrD3DTypesMinimal.h" |
| 9 |
|
| 10 |
#include "include/gpu/ganesh/d3d/GrD3DTypes.h" |
| 11 |
#include "src/gpu/ganesh/d3d/GrD3DResourceState.h" |
| 12 |
#include "src/gpu/ganesh/d3d/GrD3DTypesPriv.h" |
| 13 |
|
| 14 |
GrD3DBackendSurfaceInfo::GrD3DBackendSurfaceInfo() |
| 15 |
: fTextureResourceInfo(nullptr), fResourceState(nullptr) {} |
| 16 |
|
| 17 |
GrD3DBackendSurfaceInfo::GrD3DBackendSurfaceInfo(const GrD3DTextureResourceInfo& info, |
| 18 |
sk_sp<GrD3DResourceState> state) |
| 19 |
: fTextureResourceInfo(new GrD3DTextureResourceInfo(info)) |
| 20 |
, fResourceState(std::move(state)) {} |
| 21 |
|
| 22 |
GrD3DBackendSurfaceInfo::~GrD3DBackendSurfaceInfo() = default; |
| 23 |
|
| 24 |
GrD3DBackendSurfaceInfo::GrD3DBackendSurfaceInfo(const GrD3DBackendSurfaceInfo& that) |
| 25 |
: fTextureResourceInfo(new GrD3DTextureResourceInfo(*that.fTextureResourceInfo)) |
| 26 |
, fResourceState(that.fResourceState) {} |
| 27 |
|
| 28 |
GrD3DBackendSurfaceInfo& GrD3DBackendSurfaceInfo::operator=(const GrD3DBackendSurfaceInfo& that) { |
| 29 |
if (this != &that) { |
| 30 |
fTextureResourceInfo.reset(new GrD3DTextureResourceInfo(*that.fTextureResourceInfo)); |
| 31 |
fResourceState = that.fResourceState; |
| 32 |
} |
| 33 |
return *this; |
| 34 |
} |
| 35 |
|
| 36 |
GrD3DBackendSurfaceInfo::GrD3DBackendSurfaceInfo(GrD3DBackendSurfaceInfo&&) = default; |
| 37 |
GrD3DBackendSurfaceInfo& GrD3DBackendSurfaceInfo::operator=(GrD3DBackendSurfaceInfo&&) = default; |
| 38 |
|
| 39 |
void GrD3DBackendSurfaceInfo::setResourceState(GrD3DResourceStateEnum resourceState) { |
| 40 |
SkASSERT(fResourceState); |
| 41 |
fResourceState->setResourceState(static_cast<D3D12_RESOURCE_STATES>(resourceState)); |
| 42 |
} |
| 43 |
|
| 44 |
sk_sp<GrD3DResourceState> GrD3DBackendSurfaceInfo::getGrD3DResourceState() const { |
| 45 |
SkASSERT(fResourceState); |
| 46 |
return fResourceState; |
| 47 |
} |
| 48 |
|
| 49 |
GrD3DTextureResourceInfo GrD3DBackendSurfaceInfo::snapTextureResourceInfo() const { |
| 50 |
return GrD3DTextureResourceInfo( |
| 51 |
*fTextureResourceInfo, |
| 52 |
static_cast<D3D12_RESOURCE_STATES>(fResourceState->getResourceState())); |
| 53 |
} |
| 54 |
|
| 55 |
bool GrD3DBackendSurfaceInfo::isProtected() const { |
| 56 |
SkASSERT(fTextureResourceInfo); |
| 57 |
return fTextureResourceInfo->fProtected == GrProtected::kYes; |
| 58 |
} |
| 59 |
|
| 60 |
#if defined(GPU_TEST_UTILS) |
| 61 |
bool GrD3DBackendSurfaceInfo::operator==(const GrD3DBackendSurfaceInfo& that) const { |
| 62 |
GrD3DTextureResourceInfo cpyInfoThis = *fTextureResourceInfo; |
| 63 |
GrD3DTextureResourceInfo cpyInfoThat = *that.fTextureResourceInfo; |
| 64 |
// We don't care about the fResourceState here since we require they use the same |
| 65 |
// GrD3DResourceState. |
| 66 |
cpyInfoThis.fResourceState = D3D12_RESOURCE_STATE_COMMON; |
| 67 |
cpyInfoThat.fResourceState = D3D12_RESOURCE_STATE_COMMON; |
| 68 |
return cpyInfoThis == cpyInfoThat && fResourceState == that.fResourceState; |
| 69 |
} |
| 70 |
#endif |