blob: f8a5280e63280c5a9edbca2836d5e28309d52567 [file] [log] [blame]
/*
* Copyright 2021 Google LLC
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "experimental/graphite/src/TextureProxy.h"
#include "experimental/graphite/src/ResourceProvider.h"
#include "experimental/graphite/src/Texture.h"
namespace skgpu {
TextureProxy::TextureProxy(SkISize dimensions, const TextureInfo& info)
: fDimensions(dimensions), fInfo(info) {}
TextureProxy::~TextureProxy() {}
bool TextureProxy::instantiate(ResourceProvider* resourceProvider) {
if (fTexture) {
return true;
}
fTexture = resourceProvider->findOrCreateTexture(fDimensions, fInfo);
if (!fTexture) {
return false;
}
SkDEBUGCODE(this->validateTexture(fTexture.get()));
return true;
}
sk_sp<Texture> TextureProxy::refTexture() const {
return fTexture;
}
#ifdef SK_DEBUG
void TextureProxy::validateTexture(const Texture* texture) {
SkASSERT(fDimensions == texture->dimensions());
SkASSERT(fInfo == texture->textureInfo());
}
#endif
} // namespace skgpu