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 GrSurfaceInfo(const GrD3DSurfaceInfo & d3dInfo)15GrSurfaceInfo::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 ~GrSurfaceInfo()24GrSurfaceInfo::~GrSurfaceInfo() { 25 #ifdef SK_DIRECT3D 26 if (this->isValid() && fBackend == GrBackendApi::kDirect3D) { 27 fD3DSpec.cleanup(); 28 } 29 #endif 30 } 31 32 #ifdef SK_DIRECT3D getD3DSurfaceInfo(GrD3DSurfaceInfo * outSpec) const33bool 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 41