Update rive-cpp to 2.0 version
[platform/core/uifw/rive-tizen.git] / submodule / skia / src / gpu / graphite / TextureProxy.cpp
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 "src/gpu/graphite/TextureProxy.h"
9
10 #include "src/gpu/graphite/ResourceProvider.h"
11 #include "src/gpu/graphite/Texture.h"
12
13 namespace skgpu::graphite {
14
15 TextureProxy::TextureProxy(SkISize dimensions, const TextureInfo& info, SkBudgeted budgeted)
16         : fDimensions(dimensions), fInfo(info), fBudgeted(budgeted) {}
17
18 TextureProxy::TextureProxy(sk_sp<Texture> texture)
19         : fDimensions(texture->dimensions())
20         , fInfo(texture->textureInfo())
21         , fBudgeted(texture->budgeted())
22         , fTexture(std::move(texture)) {}
23
24 TextureProxy::~TextureProxy() {}
25
26 bool TextureProxy::instantiate(ResourceProvider* resourceProvider) {
27     if (fTexture) {
28         return true;
29     }
30     fTexture = resourceProvider->findOrCreateScratchTexture(fDimensions, fInfo, fBudgeted);
31     if (!fTexture) {
32         return false;
33     }
34     SkDEBUGCODE(this->validateTexture(fTexture.get()));
35     return true;
36 }
37
38 sk_sp<Texture> TextureProxy::refTexture() const {
39     return fTexture;
40 }
41
42 const Texture* TextureProxy::texture() const {
43     return fTexture.get();
44 }
45
46 #ifdef SK_DEBUG
47 void TextureProxy::validateTexture(const Texture* texture) {
48     SkASSERT(fDimensions == texture->dimensions());
49     SkASSERT(fInfo == texture->textureInfo());
50 }
51 #endif
52
53 } // namespace skgpu::graphite