OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2016 Google Inc. |
| 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 "GrTextureProxy.h" |
| 9 |
| 10 #include "GrTextureProvider.h" |
| 11 #include "GrGpuResourcePriv.h" |
| 12 |
| 13 GrTextureProxy::GrTextureProxy(sk_sp<GrTexture> tex) |
| 14 : INHERITED(tex->desc(), SkBackingFit::kExact, tex->resourcePriv().isBudgete
d()) |
| 15 , fTexture(std::move(tex)) { |
| 16 } |
| 17 |
| 18 GrTexture* GrTextureProxy::instantiate(GrTextureProvider* texProvider) { |
| 19 if (fTexture) { |
| 20 return fTexture.get(); |
| 21 } |
| 22 |
| 23 if (SkBackingFit::kApprox == fFit) { |
| 24 fTexture.reset(texProvider->createApproxTexture(fDesc)); |
| 25 } else { |
| 26 fTexture.reset(texProvider->createTexture(fDesc, fBudgeted)); |
| 27 } |
| 28 |
| 29 return fTexture.get(); |
| 30 } |
| 31 |
| 32 sk_sp<GrTextureProxy> GrTextureProxy::Make(const GrSurfaceDesc& desc, |
| 33 SkBackingFit fit, |
| 34 SkBudgeted budgeted, |
| 35 const void* srcData, |
| 36 size_t rowBytes) { |
| 37 // TODO: handle 'srcData' (we could use the wrapped version if there is data
) |
| 38 SkASSERT(!srcData && !rowBytes); |
| 39 return sk_sp<GrTextureProxy>(new GrTextureProxy(desc, fit, budgeted, srcData
, rowBytes)); |
| 40 } |
| 41 |
| 42 sk_sp<GrTextureProxy> GrTextureProxy::Make(sk_sp<GrTexture> tex) { |
| 43 return sk_sp<GrTextureProxy>(new GrTextureProxy(std::move(tex))); |
| 44 } |
OLD | NEW |