1 /* 2 * Copyright 2018 Google Inc. 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 GrBackendDrawableInfo_DEFINED 9 #define GrBackendDrawableInfo_DEFINED 10 11 #include "include/gpu/ganesh/GrTypes.h" 12 13 #include "include/gpu/ganesh/vk/GrVkTypes.h" 14 15 // If necessary, this could be pulled into a generic interface, but at this point, we only expect 16 // it to be used by the Ganesh Vulkan backend. 17 class SK_API GrBackendDrawableInfo { 18 public: 19 // Creates an invalid backend drawable info. GrBackendDrawableInfo()20 GrBackendDrawableInfo() : fIsValid(false) {} 21 GrBackendDrawableInfo(const GrVkDrawableInfo & info)22 GrBackendDrawableInfo(const GrVkDrawableInfo& info) 23 : fIsValid(true) 24 , fBackend(GrBackendApi::kVulkan) 25 , fVkInfo(info) {} 26 27 // Returns true if the backend texture has been initialized. isValid()28 bool isValid() const { return fIsValid; } 29 backend()30 GrBackendApi backend() const { return fBackend; } 31 getVkDrawableInfo(GrVkDrawableInfo * outInfo)32 bool getVkDrawableInfo(GrVkDrawableInfo* outInfo) const { 33 if (this->isValid() && GrBackendApi::kVulkan == fBackend) { 34 *outInfo = fVkInfo; 35 return true; 36 } 37 return false; 38 } 39 40 private: 41 bool fIsValid; 42 GrBackendApi fBackend; 43 GrVkDrawableInfo fVkInfo; 44 }; 45 46 #endif 47