blob: 33189c2885b9d2c6db3586a29ddc654416953aab [file] [log] [blame]
bsalomona44919e2015-08-18 13:28:19 -07001/*
2 * Copyright 2015 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#ifndef GrStencilPathBatch_DEFINED
9#define GrStencilPathBatch_DEFINED
10
11#include "GrBatch.h"
12#include "GrBatchFlushState.h"
13#include "GrGpu.h"
14#include "GrPath.h"
15#include "GrPathRendering.h"
16#include "GrRenderTarget.h"
17
18class GrStencilPathBatch final : public GrBatch {
19public:
reed1b55a962015-09-17 20:16:13 -070020 DEFINE_BATCH_CLASS_ID
21
bsalomona44919e2015-08-18 13:28:19 -070022 static GrBatch* Create(const SkMatrix& viewMatrix,
23 bool useHWAA,
24 const GrStencilSettings& stencil,
25 const GrScissorState& scissor,
26 GrRenderTarget* renderTarget,
27 const GrPath* path) {
halcanary385fe4d2015-08-26 13:07:48 -070028 return new GrStencilPathBatch(viewMatrix, useHWAA, stencil, scissor, renderTarget, path);
bsalomona44919e2015-08-18 13:28:19 -070029 }
30
31 const char* name() const override { return "StencilPath"; }
32
mtkleina4c32442015-08-19 07:11:34 -070033 uint32_t renderTargetUniqueID() const override { return fRenderTarget.get()->getUniqueID(); }
bsalomon6dea83f2015-12-03 12:58:06 -080034 GrRenderTarget* renderTarget() const override { return fRenderTarget.get(); }
bsalomona44919e2015-08-18 13:28:19 -070035
36 SkString dumpInfo() const override {
37 SkString string;
38 string.printf("PATH: 0x%p, AA:%d", fPath.get(), fUseHWAA);
39 return string;
40 }
41
42private:
43 GrStencilPathBatch(const SkMatrix& viewMatrix,
44 bool useHWAA,
45 const GrStencilSettings& stencil,
46 const GrScissorState& scissor,
47 GrRenderTarget* renderTarget,
48 const GrPath* path)
reed1b55a962015-09-17 20:16:13 -070049 : INHERITED(ClassID())
50 , fViewMatrix(viewMatrix)
bsalomona44919e2015-08-18 13:28:19 -070051 , fUseHWAA(useHWAA)
52 , fStencil(stencil)
53 , fScissor(scissor)
54 , fRenderTarget(renderTarget)
Brian Salomon6458b6f2015-08-19 09:44:48 -040055 , fPath(path) {
bsalomon512be532015-09-10 10:42:55 -070056 fBounds = path->getBounds();
Brian Salomon6458b6f2015-08-19 09:44:48 -040057 }
bsalomona44919e2015-08-18 13:28:19 -070058
59 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override { return false; }
60
61 void onPrepare(GrBatchFlushState*) override {}
62
63 void onDraw(GrBatchFlushState* state) override {
64 GrPathRendering::StencilPathArgs args(fUseHWAA, fRenderTarget.get(), &fViewMatrix,
65 &fScissor, &fStencil);
66 state->gpu()->pathRendering()->stencilPath(args, fPath.get());
67 }
68
69 SkMatrix fViewMatrix;
70 bool fUseHWAA;
71 GrStencilSettings fStencil;
72 GrScissorState fScissor;
73 GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> fRenderTarget;
74 GrPendingIOResource<const GrPath, kRead_GrIOType> fPath;
reed1b55a962015-09-17 20:16:13 -070075
76 typedef GrBatch INHERITED;
bsalomona44919e2015-08-18 13:28:19 -070077};
78
79#endif