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 "experimental/graphite/src/TextureProxy.h" 9 10 #include "experimental/graphite/src/ResourceProvider.h" 11 #include "experimental/graphite/src/Texture.h" 12 13 namespace skgpu { 14 TextureProxy(SkISize dimensions,const TextureInfo & info)15TextureProxy::TextureProxy(SkISize dimensions, const TextureInfo& info) 16 : fDimensions(dimensions), fInfo(info) {} 17 ~TextureProxy()18TextureProxy::~TextureProxy() {} 19 instantiate(ResourceProvider * resourceProvider)20bool TextureProxy::instantiate(ResourceProvider* resourceProvider) { 21 if (fTexture) { 22 return true; 23 } 24 fTexture = resourceProvider->findOrCreateTexture(fDimensions, fInfo); 25 if (!fTexture) { 26 return false; 27 } 28 SkDEBUGCODE(this->validateTexture(fTexture.get())); 29 return true; 30 } 31 refTexture() const32sk_sp<Texture> TextureProxy::refTexture() const { 33 return fTexture; 34 } 35 texture() const36const Texture* TextureProxy::texture() const { 37 return fTexture.get(); 38 } 39 40 #ifdef SK_DEBUG validateTexture(const Texture * texture)41void TextureProxy::validateTexture(const Texture* texture) { 42 SkASSERT(fDimensions == texture->dimensions()); 43 SkASSERT(fInfo == texture->textureInfo()); 44 } 45 #endif 46 47 } // namespace skgpu 48