diff options
author | 2016-05-04 12:47:41 -0700 | |
---|---|---|
committer | 2016-05-04 12:47:41 -0700 | |
commit | 76948d4faaca9fd7730576e2f79790ca8d93c10b (patch) | |
tree | 702a78ad811ecb9ab0f96d07eee64ecdf8191bd1 /src/gpu/GrTextureProxy.cpp | |
parent | c4025189d31efcb0d54bf14b7712b38725f86c13 (diff) |
Add Gr*Proxy classes
This isn't wired in anywhere yet.
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1937553002
Committed: https://skia.googlesource.com/skia/+/de5bf0cfeca908b81a28cc50065f7bc2da3d2fd1
Committed: https://skia.googlesource.com/skia/+/92605b35efa0155c44d24bd8415b4cc1db8831db
Review-Url: https://codereview.chromium.org/1937553002
Diffstat (limited to 'src/gpu/GrTextureProxy.cpp')
-rw-r--r-- | src/gpu/GrTextureProxy.cpp | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/gpu/GrTextureProxy.cpp b/src/gpu/GrTextureProxy.cpp new file mode 100644 index 0000000000..f28b29eee0 --- /dev/null +++ b/src/gpu/GrTextureProxy.cpp @@ -0,0 +1,44 @@ +/* + * Copyright 2016 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "GrTextureProxy.h" + +#include "GrTextureProvider.h" +#include "GrGpuResourcePriv.h" + +GrTextureProxy::GrTextureProxy(sk_sp<GrTexture> tex) + : INHERITED(tex->desc(), SkBackingFit::kExact, tex->resourcePriv().isBudgeted()) + , fTexture(std::move(tex)) { +} + +GrTexture* GrTextureProxy::instantiate(GrTextureProvider* texProvider) { + if (fTexture) { + return fTexture.get(); + } + + if (SkBackingFit::kApprox == fFit) { + fTexture.reset(texProvider->createApproxTexture(fDesc)); + } else { + fTexture.reset(texProvider->createTexture(fDesc, fBudgeted)); + } + + return fTexture.get(); +} + +sk_sp<GrTextureProxy> GrTextureProxy::Make(const GrSurfaceDesc& desc, + SkBackingFit fit, + SkBudgeted budgeted, + const void* srcData, + size_t rowBytes) { + // TODO: handle 'srcData' (we could use the wrapped version if there is data) + SkASSERT(!srcData && !rowBytes); + return sk_sp<GrTextureProxy>(new GrTextureProxy(desc, fit, budgeted, srcData, rowBytes)); +} + +sk_sp<GrTextureProxy> GrTextureProxy::Make(sk_sp<GrTexture> tex) { + return sk_sp<GrTextureProxy>(new GrTextureProxy(std::move(tex))); +} |