Greg Daniel | 8426165 | 2021-09-19 17:53:40 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2021 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/gpu/GrSurfaceInfo.h" |
| 9 | |
| 10 | #ifdef SK_DIRECT3D |
| 11 | #include "include/gpu/d3d/GrD3DTypes.h" |
| 12 | #endif |
| 13 | |
| 14 | #ifdef SK_DIRECT3D |
| 15 | GrSurfaceInfo::GrSurfaceInfo(const GrD3DSurfaceInfo& d3dInfo) |
| 16 | : fBackend(GrBackendApi::kDirect3D) |
| 17 | , fValid(true) |
| 18 | , fSampleCount(d3dInfo.fSampleCount) |
| 19 | , fLevelCount(d3dInfo.fLevelCount) |
| 20 | , fProtected(d3dInfo.fProtected) |
| 21 | , fD3DSpec(d3dInfo) {} |
| 22 | #endif |
| 23 | |
| 24 | GrSurfaceInfo::~GrSurfaceInfo() { |
| 25 | #ifdef SK_DIRECT3D |
| 26 | if (this->isValid() && fBackend == GrBackendApi::kDirect3D) { |
| 27 | fD3DSpec.cleanup(); |
| 28 | } |
| 29 | #endif |
| 30 | } |
| 31 | |
| 32 | #ifdef SK_DIRECT3D |
| 33 | bool GrSurfaceInfo::getD3DSurfaceInfo(GrD3DSurfaceInfo* outSpec) const { |
| 34 | if (!this->isValid() || fBackend != GrBackendApi::kDirect3D) { |
| 35 | return false; |
| 36 | } |
| 37 | *outSpec = fD3DSpec.getSurfaceInfo(fSampleCount, fLevelCount, fProtected); |
| 38 | return true; |
| 39 | } |
| 40 | #endif |