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 #ifndef GrD3DTypesPriv_DEFINED 9 #define GrD3DTypesPriv_DEFINED 10 11 #include "include/core/SkRefCnt.h" 12 #include "include/gpu/d3d/GrD3DTypesMinimal.h" 13 14 class GrD3DResourceState; 15 16 // This struct is to used to store the the actual information about the Direct3D backend image on 17 // GrBackendTexture and GrBackendRenderTarget. When a client calls getD3DTextureInfo on a 18 // GrBackendTexture/RenderTarget, we use the GrD3DBackendSurfaceInfo to create a snapshot 19 // GrD3DTextureResourceInfo object. Internally, this uses a ref count GrD3DResourceState object to 20 // track the current D3D12_RESOURCE_STATES which can be shared with an internal GrD3DTextureResource 21 // so that state updates can be seen by all users of the texture. 22 struct GrD3DBackendSurfaceInfo { 23 GrD3DBackendSurfaceInfo(const GrD3DTextureResourceInfo& info, GrD3DResourceState* state); 24 25 void cleanup(); 26 27 GrD3DBackendSurfaceInfo& operator=(const GrD3DBackendSurfaceInfo&) = delete; 28 29 // Assigns the passed in GrD3DBackendSurfaceInfo to this object. if isValid is true we will also 30 // attempt to unref the old fLayout on this object. 31 void assign(const GrD3DBackendSurfaceInfo&, bool isValid); 32 33 void setResourceState(GrD3DResourceStateEnum state); 34 35 sk_sp<GrD3DResourceState> getGrD3DResourceState() const; 36 37 GrD3DTextureResourceInfo snapTextureResourceInfo() const; 38 39 bool isProtected() const; 40 #if GR_TEST_UTILS 41 bool operator==(const GrD3DBackendSurfaceInfo& that) const; 42 #endif 43 44 private: 45 GrD3DTextureResourceInfo* fTextureResourceInfo; 46 GrD3DResourceState* fResourceState; 47 }; 48 49 #endif 50