| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "GrNonAAFillRectBatch.h" | 8 #include "GrNonAAFillRectBatch.h" |
| 9 | 9 |
| 10 #include "GrBatchFlushState.h" | 10 #include "GrBatchFlushState.h" |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 public: | 117 public: |
| 118 struct Geometry { | 118 struct Geometry { |
| 119 SkMatrix fViewMatrix; | 119 SkMatrix fViewMatrix; |
| 120 SkRect fRect; | 120 SkRect fRect; |
| 121 GrQuad fLocalQuad; | 121 GrQuad fLocalQuad; |
| 122 GrColor fColor; | 122 GrColor fColor; |
| 123 }; | 123 }; |
| 124 | 124 |
| 125 static const char* Name() { return "NonAAFillRectBatch"; } | 125 static const char* Name() { return "NonAAFillRectBatch"; } |
| 126 | 126 |
| 127 static SkString DumpInfo(const Geometry& geo) { |
| 128 SkString str; |
| 129 str.appendf("Color: 0x%08x, Rect [L: %.2f, T: %.2f, R: %.2f, B: %.2f]\n"
, |
| 130 geo.fColor, |
| 131 geo.fRect.fLeft, geo.fRect.fTop, geo.fRect.fRight, geo.fRect
.fBottom); |
| 132 return str; |
| 133 } |
| 134 |
| 127 static bool CanCombine(const Geometry& mine, const Geometry& theirs, | 135 static bool CanCombine(const Geometry& mine, const Geometry& theirs, |
| 128 const GrPipelineOptimizations& opts) { | 136 const GrPipelineOptimizations& opts) { |
| 129 return true; | 137 return true; |
| 130 } | 138 } |
| 131 | 139 |
| 132 static const GrGeometryProcessor* CreateGP(const Geometry& geo, | 140 static const GrGeometryProcessor* CreateGP(const Geometry& geo, |
| 133 const GrPipelineOptimizations& op
ts) { | 141 const GrPipelineOptimizations& op
ts) { |
| 134 const GrGeometryProcessor* gp = create_gp(geo.fViewMatrix, opts.readsCov
erage(), true, | 142 const GrGeometryProcessor* gp = create_gp(geo.fViewMatrix, opts.readsCov
erage(), true, |
| 135 nullptr); | 143 nullptr); |
| 136 | 144 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 153 SkMatrix fLocalMatrix; | 161 SkMatrix fLocalMatrix; |
| 154 SkRect fRect; | 162 SkRect fRect; |
| 155 SkRect fLocalRect; | 163 SkRect fLocalRect; |
| 156 GrColor fColor; | 164 GrColor fColor; |
| 157 bool fHasLocalMatrix; | 165 bool fHasLocalMatrix; |
| 158 bool fHasLocalRect; | 166 bool fHasLocalRect; |
| 159 }; | 167 }; |
| 160 | 168 |
| 161 static const char* Name() { return "NonAAFillRectBatchPerspective"; } | 169 static const char* Name() { return "NonAAFillRectBatchPerspective"; } |
| 162 | 170 |
| 171 static SkString DumpInfo(const Geometry& geo) { |
| 172 SkString str; |
| 173 str.appendf("Color: 0x%08x, Rect [L: %.2f, T: %.2f, R: %.2f, B: %.2f]\n"
, |
| 174 geo.fColor, |
| 175 geo.fRect.fLeft, geo.fRect.fTop, geo.fRect.fRight, geo.fRect
.fBottom); |
| 176 return str; |
| 177 } |
| 178 |
| 163 static bool CanCombine(const Geometry& mine, const Geometry& theirs, | 179 static bool CanCombine(const Geometry& mine, const Geometry& theirs, |
| 164 const GrPipelineOptimizations& opts) { | 180 const GrPipelineOptimizations& opts) { |
| 165 // We could batch across perspective vm changes if we really wanted to | 181 // We could batch across perspective vm changes if we really wanted to |
| 166 return mine.fViewMatrix.cheapEqualTo(theirs.fViewMatrix) && | 182 return mine.fViewMatrix.cheapEqualTo(theirs.fViewMatrix) && |
| 167 mine.fHasLocalRect == theirs.fHasLocalRect && | 183 mine.fHasLocalRect == theirs.fHasLocalRect && |
| 168 (!mine.fHasLocalMatrix || mine.fLocalMatrix.cheapEqualTo(theirs.f
LocalMatrix)); | 184 (!mine.fHasLocalMatrix || mine.fLocalMatrix.cheapEqualTo(theirs.f
LocalMatrix)); |
| 169 } | 185 } |
| 170 | 186 |
| 171 static const GrGeometryProcessor* CreateGP(const Geometry& geo, | 187 static const GrGeometryProcessor* CreateGP(const Geometry& geo, |
| 172 const GrPipelineOptimizations& op
ts) { | 188 const GrPipelineOptimizations& op
ts) { |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 SkMatrix localMatrix = GrTest::TestMatrix(random); | 327 SkMatrix localMatrix = GrTest::TestMatrix(random); |
| 312 | 328 |
| 313 bool hasLocalRect = random->nextBool(); | 329 bool hasLocalRect = random->nextBool(); |
| 314 bool hasLocalMatrix = random->nextBool(); | 330 bool hasLocalMatrix = random->nextBool(); |
| 315 return GrNonAAFillRectBatch::Create(color, viewMatrix, rect, | 331 return GrNonAAFillRectBatch::Create(color, viewMatrix, rect, |
| 316 hasLocalRect ? &localRect : nullptr, | 332 hasLocalRect ? &localRect : nullptr, |
| 317 hasLocalMatrix ? &localMatrix : nullptr)
; | 333 hasLocalMatrix ? &localMatrix : nullptr)
; |
| 318 } | 334 } |
| 319 | 335 |
| 320 #endif | 336 #endif |
| OLD | NEW |