• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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)15 TextureProxy::TextureProxy(SkISize dimensions, const TextureInfo& info)
16         : fDimensions(dimensions), fInfo(info) {}
17 
~TextureProxy()18 TextureProxy::~TextureProxy() {}
19 
instantiate(ResourceProvider * resourceProvider)20 bool 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() const32 sk_sp<Texture> TextureProxy::refTexture() const {
33     return fTexture;
34 }
35 
texture() const36 const Texture* TextureProxy::texture() const {
37     return fTexture.get();
38 }
39 
40 #ifdef SK_DEBUG
validateTexture(const Texture * texture)41 void TextureProxy::validateTexture(const Texture* texture) {
42     SkASSERT(fDimensions == texture->dimensions());
43     SkASSERT(fInfo == texture->textureInfo());
44 }
45 #endif
46 
47 } // namespace skgpu
48