2 * Copyright 2021 Google LLC
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
8 #include "src/gpu/graphite/TextureProxy.h"
10 #include "src/gpu/graphite/ResourceProvider.h"
11 #include "src/gpu/graphite/Texture.h"
13 namespace skgpu::graphite {
15 TextureProxy::TextureProxy(SkISize dimensions, const TextureInfo& info, SkBudgeted budgeted)
16 : fDimensions(dimensions), fInfo(info), fBudgeted(budgeted) {}
18 TextureProxy::TextureProxy(sk_sp<Texture> texture)
19 : fDimensions(texture->dimensions())
20 , fInfo(texture->textureInfo())
21 , fBudgeted(texture->budgeted())
22 , fTexture(std::move(texture)) {}
24 TextureProxy::~TextureProxy() {}
26 bool TextureProxy::instantiate(ResourceProvider* resourceProvider) {
30 fTexture = resourceProvider->findOrCreateScratchTexture(fDimensions, fInfo, fBudgeted);
34 SkDEBUGCODE(this->validateTexture(fTexture.get()));
38 sk_sp<Texture> TextureProxy::refTexture() const {
42 const Texture* TextureProxy::texture() const {
43 return fTexture.get();
47 void TextureProxy::validateTexture(const Texture* texture) {
48 SkASSERT(fDimensions == texture->dimensions());
49 SkASSERT(fInfo == texture->textureInfo());
53 } // namespace skgpu::graphite