1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
/*
* 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(const GrSurfaceDesc& srcDesc, SkBackingFit fit, SkBudgeted budgeted,
const void* /*srcData*/, size_t /*rowBytes*/)
: INHERITED(srcDesc, fit, budgeted) {
// TODO: Handle 'srcData' here
}
GrTextureProxy::GrTextureProxy(sk_sp<GrTexture> tex)
: INHERITED(tex->desc(), SkBackingFit::kExact,
tex->resourcePriv().isBudgeted(), tex->uniqueID())
, 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)));
}
|