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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
/*
* Copyright 2017 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "GrMtlRenderTarget.h"
#include "GrMtlGpu.h"
#include "GrMtlUtil.h"
GrMtlRenderTarget::GrMtlRenderTarget(GrMtlGpu* gpu,
SkBudgeted budgeted,
const GrSurfaceDesc& desc,
id<MTLTexture> renderTexture)
: GrSurface(gpu, desc)
, GrRenderTarget(gpu, desc)
, fRenderTexture(renderTexture)
, fResolveTexture(nil) {
SkASSERT(1 == desc.fSampleCnt);
this->registerWithCache(budgeted);
}
GrMtlRenderTarget::GrMtlRenderTarget(GrMtlGpu* gpu,
const GrSurfaceDesc& desc,
id<MTLTexture> renderTexture)
: GrSurface(gpu, desc)
, GrRenderTarget(gpu, desc)
, fRenderTexture(renderTexture)
, fResolveTexture(nil) {
SkASSERT(1 == desc.fSampleCnt);
}
sk_sp<GrMtlRenderTarget>
GrMtlRenderTarget::MakeWrappedRenderTarget(GrMtlGpu* gpu, const GrSurfaceDesc& desc,
id<MTLTexture> renderTexture) {
SkASSERT(nil != renderTexture);
SkASSERT(1 == renderTexture.mipmapLevelCount);
SkASSERT(MTLTextureUsageRenderTarget & renderTexture.usage);
return sk_sp<GrMtlRenderTarget>(new GrMtlRenderTarget(gpu, SkBudgeted::kNo,
desc, renderTexture));
}
GrMtlRenderTarget::~GrMtlRenderTarget() {
SkASSERT(nil == fRenderTexture);
SkASSERT(nil == fResolveTexture);
}
GrBackendRenderTarget GrMtlRenderTarget::getBackendRenderTarget() const {
GrMtlTextureInfo info;
info.fTexture = GrGetPtrFromId(fRenderTexture);
return GrBackendRenderTarget(this->width(), this->height(), fRenderTexture.sampleCount, info);
}
GrMtlGpu* GrMtlRenderTarget::getMtlGpu() const {
SkASSERT(!this->wasDestroyed());
return static_cast<GrMtlGpu*>(this->getGpu());
}
void GrMtlRenderTarget::onAbandon() {
fRenderTexture = nil;
fResolveTexture = nil;
}
void GrMtlRenderTarget::onRelease() {
fRenderTexture = nil;
fResolveTexture = nil;
}
bool GrMtlRenderTarget::completeStencilAttachment() {
// TODO: fill this out
return true;
}
|