Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1065)

Side by Side Diff: src/gpu/batches/GrAAStrokeRectBatch.h

Issue 1282723004: move Stroke Rect and AAFill Rect to their own file (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/batches/GrAAFillRectBatch.cpp ('k') | src/gpu/batches/GrAAStrokeRectBatch.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
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 GrAAStrokeRectBatch_DEFINED
9 #define GrAAStrokeRectBatch_DEFINED
10
11 #include "GrBatch.h"
12 #include "GrColor.h"
13 #include "GrTypes.h"
14 #include "SkMatrix.h"
15 #include "SkRect.h"
16
17 class GrAAStrokeRectBatch : public GrBatch {
18 public:
19 // TODO support AA rotated stroke rects by copying around view matrices
20 struct Geometry {
21 GrColor fColor;
22 SkRect fDevOutside;
23 SkRect fDevOutsideAssist;
24 SkRect fDevInside;
25 bool fMiterStroke;
26 };
27
28 static GrBatch* Create(const Geometry& geometry, const SkMatrix& viewMatrix) {
29 return SkNEW_ARGS(GrAAStrokeRectBatch, (geometry, viewMatrix));
30 }
31
32 const char* name() const override { return "AAStrokeRect"; }
33
34 void getInvariantOutputColor(GrInitInvariantOutput* out) const override {
35 // When this is called on a batch, there is only one geometry bundle
36 out->setKnownFourComponents(fGeoData[0].fColor);
37 }
38
39 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override {
40 out->setUnknownSingleComponent();
41 }
42
43 void initBatchTracker(const GrPipelineInfo& init) override;
44
45 void generateGeometry(GrBatchTarget* batchTarget) override;
46
47 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; }
48
49 private:
50 GrAAStrokeRectBatch(const Geometry& geometry, const SkMatrix& viewMatrix) {
51 this->initClassID<GrAAStrokeRectBatch>();
52 fBatch.fViewMatrix = viewMatrix;
53 fGeoData.push_back(geometry);
54
55 // If we have miterstroke then we inset devOutside and outset devOutside Assist, so we need
56 // the join for proper bounds
57 fBounds = geometry.fDevOutside;
58 fBounds.join(geometry.fDevOutsideAssist);
59 }
60
61
62 static const int kMiterIndexCnt = 3 * 24;
63 static const int kMiterVertexCnt = 16;
64 static const int kNumMiterRectsInIndexBuffer = 256;
65
66 static const int kBevelIndexCnt = 48 + 36 + 24;
67 static const int kBevelVertexCnt = 24;
68 static const int kNumBevelRectsInIndexBuffer = 256;
69
70 static const GrIndexBuffer* GetIndexBuffer(GrResourceProvider* resourceProvi der,
71 bool miterStroke);
72
73 GrColor color() const { return fBatch.fColor; }
74 bool usesLocalCoords() const { return fBatch.fUsesLocalCoords; }
75 bool canTweakAlphaForCoverage() const { return fBatch.fCanTweakAlphaForCover age; }
76 bool colorIgnored() const { return fBatch.fColorIgnored; }
77 const SkMatrix& viewMatrix() const { return fBatch.fViewMatrix; }
78 bool miterStroke() const { return fBatch.fMiterStroke; }
79 bool coverageIgnored() const { return fBatch.fCoverageIgnored; }
80
81 bool onCombineIfPossible(GrBatch* t) override;
82
83 void generateAAStrokeRectGeometry(void* vertices,
84 size_t offset,
85 size_t vertexStride,
86 int outerVertexNum,
87 int innerVertexNum,
88 GrColor color,
89 const SkRect& devOutside,
90 const SkRect& devOutsideAssist,
91 const SkRect& devInside,
92 bool miterStroke,
93 bool tweakAlphaForCoverage) const;
94
95 struct BatchTracker {
96 SkMatrix fViewMatrix;
97 GrColor fColor;
98 bool fUsesLocalCoords;
99 bool fColorIgnored;
100 bool fCoverageIgnored;
101 bool fMiterStroke;
102 bool fCanTweakAlphaForCoverage;
103 };
104
105 BatchTracker fBatch;
106 SkSTArray<1, Geometry, true> fGeoData;
107 };
108
109
110 #endif
OLDNEW
« no previous file with comments | « src/gpu/batches/GrAAFillRectBatch.cpp ('k') | src/gpu/batches/GrAAStrokeRectBatch.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698