Line data Source code
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 "GrResourceProvider.h"
11 : #include "GrTexturePriv.h"
12 :
13 0 : GrTextureProxy::GrTextureProxy(const GrSurfaceDesc& srcDesc, SkBackingFit fit, SkBudgeted budgeted,
14 0 : const void* srcData, size_t /*rowBytes*/, uint32_t flags)
15 0 : : INHERITED(srcDesc, fit, budgeted, flags) {
16 0 : SkASSERT(!srcData); // currently handled in Make()
17 0 : }
18 :
19 0 : GrTextureProxy::GrTextureProxy(sk_sp<GrSurface> surf)
20 0 : : INHERITED(std::move(surf), SkBackingFit::kExact) {
21 0 : }
22 :
23 0 : GrTexture* GrTextureProxy::instantiate(GrResourceProvider* resourceProvider) {
24 0 : GrSurface* surf = this->INHERITED::instantiate(resourceProvider);
25 0 : if (!surf) {
26 0 : return nullptr;
27 : }
28 :
29 0 : return fTarget->asTexture();
30 : }
31 :
32 0 : void GrTextureProxy::setMipColorMode(SkDestinationSurfaceColorMode colorMode) {
33 0 : SkASSERT(fTarget || fTarget->asTexture());
34 :
35 0 : if (fTarget) {
36 0 : fTarget->asTexture()->texturePriv().setMipColorMode(colorMode);
37 : }
38 :
39 0 : fMipColorMode = colorMode;
40 0 : }
41 :
42 0 : size_t GrTextureProxy::onGpuMemorySize() const {
43 0 : if (fTarget) {
44 0 : return fTarget->gpuMemorySize();
45 : }
46 :
47 : static const bool kHasMipMaps = true;
48 : // TODO: add tracking of mipmap state to improve the estimate
49 0 : return GrSurface::ComputeSize(fDesc, 1, kHasMipMaps, SkBackingFit::kApprox == fFit);
50 : }
|