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
77
78
79
80
81
82
83
84
|
/*
* Copyright 2015 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef GrStencilPathBatch_DEFINED
#define GrStencilPathBatch_DEFINED
#include "GrBatch.h"
#include "GrBatchFlushState.h"
#include "GrGpu.h"
#include "GrPath.h"
#include "GrPathRendering.h"
#include "GrRenderTarget.h"
class GrStencilPathBatch final : public GrBatch {
public:
DEFINE_BATCH_CLASS_ID
static GrBatch* Create(const SkMatrix& viewMatrix,
bool useHWAA,
GrPathRendering::FillType fillType,
bool hasStencilClip,
int numStencilBits,
const GrScissorState& scissor,
GrRenderTarget* renderTarget,
const GrPath* path) {
return new GrStencilPathBatch(viewMatrix, useHWAA, fillType, hasStencilClip,
numStencilBits, scissor, renderTarget, path);
}
const char* name() const override { return "StencilPath"; }
uint32_t renderTargetUniqueID() const override { return fRenderTarget.get()->getUniqueID(); }
GrRenderTarget* renderTarget() const override { return fRenderTarget.get(); }
SkString dumpInfo() const override {
SkString string;
string.printf("PATH: 0x%p, AA:%d", fPath.get(), fUseHWAA);
return string;
}
private:
GrStencilPathBatch(const SkMatrix& viewMatrix,
bool useHWAA,
GrPathRendering::FillType fillType,
bool hasStencilClip,
int numStencilBits,
const GrScissorState& scissor,
GrRenderTarget* renderTarget,
const GrPath* path)
: INHERITED(ClassID())
, fViewMatrix(viewMatrix)
, fUseHWAA(useHWAA)
, fStencil(GrPathRendering::GetStencilPassSettings(fillType), hasStencilClip, numStencilBits)
, fScissor(scissor)
, fRenderTarget(renderTarget)
, fPath(path) {
fBounds = path->getBounds();
}
bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override { return false; }
void onPrepare(GrBatchFlushState*) override {}
void onDraw(GrBatchFlushState* state) override {
GrPathRendering::StencilPathArgs args(fUseHWAA, fRenderTarget.get(), &fViewMatrix,
&fScissor, &fStencil);
state->gpu()->pathRendering()->stencilPath(args, fPath.get());
}
SkMatrix fViewMatrix;
bool fUseHWAA;
GrStencilSettings fStencil;
GrScissorState fScissor;
GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> fRenderTarget;
GrPendingIOResource<const GrPath, kRead_GrIOType> fPath;
typedef GrBatch INHERITED;
};
#endif
|