| 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 | 93 |
| 94 struct Geometry { | 94 struct Geometry { |
| 95 SkMatrix fViewMatrix; | 95 SkMatrix fViewMatrix; |
| 96 SkRect fRect; | 96 SkRect fRect; |
| 97 GrQuad fLocalQuad; | 97 GrQuad fLocalQuad; |
| 98 GrColor fColor; | 98 GrColor fColor; |
| 99 }; | 99 }; |
| 100 | 100 |
| 101 static NonAAFillRectBatch* Create() { return new NonAAFillRectBatch; } | 101 static NonAAFillRectBatch* Create() { return new NonAAFillRectBatch; } |
| 102 | 102 |
| 103 const char* name() const override { return Name(); } | 103 const char* name() const override { return "NonAAFillRectBatch"; } |
| 104 | 104 |
| 105 SkString dumpInfo() const override { | 105 SkString dumpInfo() const override { |
| 106 SkString str; | 106 SkString str; |
| 107 str.appendf("# batched: %d\n", fGeoData.count()); | 107 str.appendf("# batched: %d\n", fGeoData.count()); |
| 108 for (int i = 0; i < fGeoData.count(); ++i) { | 108 for (int i = 0; i < fGeoData.count(); ++i) { |
| 109 str.append(DumpInfo(fGeoData[i], i)); | 109 const Geometry& geo = fGeoData[i]; |
| 110 str.appendf("%d: Color: 0x%08x, Rect [L: %.2f, T: %.2f, R: %.2f, B:
%.2f]\n", |
| 111 i, geo.fColor, |
| 112 geo.fRect.fLeft, geo.fRect.fTop, geo.fRect.fRight, geo.f
Rect.fBottom); |
| 110 } | 113 } |
| 111 str.append(INHERITED::dumpInfo()); | 114 str.append(INHERITED::dumpInfo()); |
| 112 return str; | 115 return str; |
| 113 } | 116 } |
| 114 | 117 |
| 115 void computePipelineOptimizations(GrInitInvariantOutput* color, | 118 void computePipelineOptimizations(GrInitInvariantOutput* color, |
| 116 GrInitInvariantOutput* coverage, | 119 GrInitInvariantOutput* coverage, |
| 117 GrBatchToXPOverrides* overrides) const ove
rride { | 120 GrBatchToXPOverrides* overrides) const ove
rride { |
| 118 // When this is called on a batch, there is only one geometry bundle | 121 // When this is called on a batch, there is only one geometry bundle |
| 119 color->setKnownFourComponents(fGeoData[0].fColor); | 122 color->setKnownFourComponents(fGeoData[0].fColor); |
| 120 InitInvariantOutputCoverage(coverage); | 123 coverage->setKnownSingleComponent(0xff); |
| 121 } | 124 } |
| 122 | 125 |
| 123 void initBatchTracker(const GrXPOverridesForBatch& overrides) override { | 126 void initBatchTracker(const GrXPOverridesForBatch& overrides) override { |
| 124 overrides.getOverrideColorIfSet(&fGeoData[0].fColor); | 127 overrides.getOverrideColorIfSet(&fGeoData[0].fColor); |
| 125 fOverrides = overrides; | 128 fOverrides = overrides; |
| 126 } | 129 } |
| 127 | 130 |
| 128 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } | 131 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } |
| 129 | 132 |
| 130 // After seeding, the client should call init() so the Batch can initialize
itself | 133 // After seeding, the client should call init() so the Batch can initialize
itself |
| 131 void init() { | 134 void init() { fGeoData[0].fViewMatrix.mapRect(&fBounds, fGeoData[0].fRect);
} |
| 132 const Geometry& geo = fGeoData[0]; | |
| 133 SetBounds(geo, &fBounds); | |
| 134 } | |
| 135 | |
| 136 void updateBoundsAfterAppend() { | |
| 137 const Geometry& geo = fGeoData.back(); | |
| 138 UpdateBoundsAfterAppend(geo, &fBounds); | |
| 139 } | |
| 140 | 135 |
| 141 private: | 136 private: |
| 142 static const char* Name() { return "NonAAFillRectBatch"; } | |
| 143 | |
| 144 static SkString DumpInfo(const Geometry& geo, int index) { | |
| 145 SkString str; | |
| 146 str.appendf("%d: Color: 0x%08x, Rect [L: %.2f, T: %.2f, R: %.2f, B: %.2f
]\n", | |
| 147 index, | |
| 148 geo.fColor, | |
| 149 geo.fRect.fLeft, geo.fRect.fTop, geo.fRect.fRight, geo.fRect
.fBottom); | |
| 150 return str; | |
| 151 } | |
| 152 | |
| 153 static bool CanCombine(const Geometry& mine, const Geometry& theirs, | |
| 154 const GrXPOverridesForBatch& overrides) { | |
| 155 return true; | |
| 156 } | |
| 157 | |
| 158 static sk_sp<GrGeometryProcessor> MakeGP(const Geometry& geo, | |
| 159 const GrXPOverridesForBatch& overri
des) { | |
| 160 sk_sp<GrGeometryProcessor> gp = make_gp(geo.fViewMatrix, overrides.reads
Coverage(), true, | |
| 161 nullptr); | |
| 162 | |
| 163 SkASSERT(gp->getVertexStride() == | |
| 164 sizeof(GrDefaultGeoProcFactory::PositionColorLocalCoordAttr)); | |
| 165 return gp; | |
| 166 } | |
| 167 | |
| 168 static void Tesselate(intptr_t vertices, size_t vertexStride, const Geometry
& geo, | |
| 169 const GrXPOverridesForBatch& overrides) { | |
| 170 tesselate(vertices, vertexStride, geo.fColor, geo.fViewMatrix, geo.fRect
, &geo.fLocalQuad); | |
| 171 } | |
| 172 | |
| 173 static void InitInvariantOutputCoverage(GrInitInvariantOutput* out) { | |
| 174 out->setKnownSingleComponent(0xff); | |
| 175 } | |
| 176 | |
| 177 static const GrBuffer* GetIndexBuffer(GrResourceProvider* rp) { | |
| 178 return rp->refQuadIndexBuffer(); | |
| 179 } | |
| 180 | |
| 181 static void SetBounds(const Geometry& geo, SkRect* outBounds) { | |
| 182 geo.fViewMatrix.mapRect(outBounds, geo.fRect); | |
| 183 } | |
| 184 | |
| 185 static void UpdateBoundsAfterAppend(const Geometry& geo, SkRect* outBounds)
{ | |
| 186 SkRect bounds = geo.fRect; | |
| 187 geo.fViewMatrix.mapRect(&bounds); | |
| 188 outBounds->join(bounds); | |
| 189 } | |
| 190 | |
| 191 NonAAFillRectBatch() : INHERITED(ClassID()) {} | 137 NonAAFillRectBatch() : INHERITED(ClassID()) {} |
| 192 | 138 |
| 193 void onPrepareDraws(Target* target) const override { | 139 void onPrepareDraws(Target* target) const override { |
| 194 sk_sp<GrGeometryProcessor> gp(MakeGP(this->seedGeometry(), fOverrides)); | 140 sk_sp<GrGeometryProcessor> gp = make_gp(fGeoData[0].fViewMatrix, fOverri
des.readsCoverage(), |
| 141 true, nullptr); |
| 195 if (!gp) { | 142 if (!gp) { |
| 196 SkDebugf("Couldn't create GrGeometryProcessor\n"); | 143 SkDebugf("Couldn't create GrGeometryProcessor\n"); |
| 197 return; | 144 return; |
| 198 } | 145 } |
| 146 SkASSERT(gp->getVertexStride() == |
| 147 sizeof(GrDefaultGeoProcFactory::PositionColorLocalCoordAttr)); |
| 199 | 148 |
| 200 size_t vertexStride = gp->getVertexStride(); | 149 size_t vertexStride = gp->getVertexStride(); |
| 201 int instanceCount = fGeoData.count(); | 150 int instanceCount = fGeoData.count(); |
| 202 | 151 |
| 203 SkAutoTUnref<const GrBuffer> indexBuffer(GetIndexBuffer(target->resource
Provider())); | 152 SkAutoTUnref<const GrBuffer> indexBuffer(target->resourceProvider()->ref
QuadIndexBuffer()); |
| 204 InstancedHelper helper; | 153 InstancedHelper helper; |
| 205 void* vertices = helper.init(target, kTriangles_GrPrimitiveType, vertexS
tride, | 154 void* vertices = helper.init(target, kTriangles_GrPrimitiveType, vertexS
tride, |
| 206 indexBuffer, kVertsPerInstance, | 155 indexBuffer, kVertsPerInstance, |
| 207 kIndicesPerInstance, instanceCount); | 156 kIndicesPerInstance, instanceCount); |
| 208 if (!vertices || !indexBuffer) { | 157 if (!vertices || !indexBuffer) { |
| 209 SkDebugf("Could not allocate vertices\n"); | 158 SkDebugf("Could not allocate vertices\n"); |
| 210 return; | 159 return; |
| 211 } | 160 } |
| 212 | 161 |
| 213 for (int i = 0; i < instanceCount; i++) { | 162 for (int i = 0; i < instanceCount; i++) { |
| 214 intptr_t verts = reinterpret_cast<intptr_t>(vertices) + | 163 intptr_t verts = reinterpret_cast<intptr_t>(vertices) + |
| 215 i * kVertsPerInstance * vertexStride; | 164 i * kVertsPerInstance * vertexStride; |
| 216 Tesselate(verts, vertexStride, fGeoData[i], fOverrides); | 165 tesselate(verts, vertexStride, fGeoData[i].fColor, fGeoData[i].fView
Matrix, |
| 166 fGeoData[i].fRect, &fGeoData[i].fLocalQuad); |
| 217 } | 167 } |
| 218 helper.recordDraw(target, gp.get()); | 168 helper.recordDraw(target, gp.get()); |
| 219 } | 169 } |
| 220 | 170 |
| 221 const Geometry& seedGeometry() const { return fGeoData[0]; } | |
| 222 | |
| 223 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override { | 171 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override { |
| 224 NonAAFillRectBatch* that = t->cast<NonAAFillRectBatch>(); | 172 NonAAFillRectBatch* that = t->cast<NonAAFillRectBatch>(); |
| 225 if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *that->pi
peline(), | 173 if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *that->pi
peline(), |
| 226 that->bounds(), caps)) { | 174 that->bounds(), caps)) { |
| 227 return false; | 175 return false; |
| 228 } | 176 } |
| 229 | 177 |
| 230 if (!CanCombine(this->seedGeometry(), that->seedGeometry(), fOverrides))
{ | |
| 231 return false; | |
| 232 } | |
| 233 | |
| 234 // In the event of two batches, one who can tweak, one who cannot, we ju
st fall back to | 178 // In the event of two batches, one who can tweak, one who cannot, we ju
st fall back to |
| 235 // not tweaking | 179 // not tweaking |
| 236 if (fOverrides.canTweakAlphaForCoverage() && !that->fOverrides.canTweakA
lphaForCoverage()) { | 180 if (fOverrides.canTweakAlphaForCoverage() && !that->fOverrides.canTweakA
lphaForCoverage()) { |
| 237 fOverrides = that->fOverrides; | 181 fOverrides = that->fOverrides; |
| 238 } | 182 } |
| 239 | 183 |
| 240 fGeoData.push_back_n(that->geoData()->count(), that->geoData()->begin())
; | 184 fGeoData.push_back_n(that->geoData()->count(), that->geoData()->begin())
; |
| 241 this->joinBounds(that->bounds()); | 185 this->joinBounds(that->bounds()); |
| 242 return true; | 186 return true; |
| 243 } | 187 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 258 SkMatrix fLocalMatrix; | 202 SkMatrix fLocalMatrix; |
| 259 SkRect fRect; | 203 SkRect fRect; |
| 260 SkRect fLocalRect; | 204 SkRect fLocalRect; |
| 261 GrColor fColor; | 205 GrColor fColor; |
| 262 bool fHasLocalMatrix; | 206 bool fHasLocalMatrix; |
| 263 bool fHasLocalRect; | 207 bool fHasLocalRect; |
| 264 }; | 208 }; |
| 265 | 209 |
| 266 static NonAAFillRectPerspectiveBatch* Create() { return new NonAAFillRectPer
spectiveBatch; } | 210 static NonAAFillRectPerspectiveBatch* Create() { return new NonAAFillRectPer
spectiveBatch; } |
| 267 | 211 |
| 268 const char* name() const override { return Name(); } | 212 const char* name() const override { return "NonAAFillRectPerspectiveBatch";
} |
| 269 | 213 |
| 270 SkString dumpInfo() const override { | 214 SkString dumpInfo() const override { |
| 271 SkString str; | 215 SkString str; |
| 272 str.appendf("# batched: %d\n", fGeoData.count()); | 216 str.appendf("# batched: %d\n", fGeoData.count()); |
| 273 for (int i = 0; i < fGeoData.count(); ++i) { | 217 for (int i = 0; i < fGeoData.count(); ++i) { |
| 274 str.append(DumpInfo(fGeoData[i], i)); | 218 const Geometry& geo = fGeoData[0]; |
| 219 str.appendf("%d: Color: 0x%08x, Rect [L: %.2f, T: %.2f, R: %.2f, B:
%.2f]\n", |
| 220 i, geo.fColor, |
| 221 geo.fRect.fLeft, geo.fRect.fTop, geo.fRect.fRight, geo.f
Rect.fBottom); |
| 275 } | 222 } |
| 276 str.append(INHERITED::dumpInfo()); | 223 str.append(INHERITED::dumpInfo()); |
| 277 return str; | 224 return str; |
| 278 } | 225 } |
| 279 | 226 |
| 280 void computePipelineOptimizations(GrInitInvariantOutput* color, | 227 void computePipelineOptimizations(GrInitInvariantOutput* color, |
| 281 GrInitInvariantOutput* coverage, | 228 GrInitInvariantOutput* coverage, |
| 282 GrBatchToXPOverrides* overrides) const ove
rride { | 229 GrBatchToXPOverrides* overrides) const ove
rride { |
| 283 // When this is called on a batch, there is only one geometry bundle | 230 // When this is called on a batch, there is only one geometry bundle |
| 284 color->setKnownFourComponents(fGeoData[0].fColor); | 231 color->setKnownFourComponents(fGeoData[0].fColor); |
| 285 InitInvariantOutputCoverage(coverage); | 232 coverage->setKnownSingleComponent(0xff); |
| 286 } | 233 } |
| 287 | 234 |
| 288 void initBatchTracker(const GrXPOverridesForBatch& overrides) override { | 235 void initBatchTracker(const GrXPOverridesForBatch& overrides) override { |
| 289 overrides.getOverrideColorIfSet(&fGeoData[0].fColor); | 236 overrides.getOverrideColorIfSet(&fGeoData[0].fColor); |
| 290 fOverrides = overrides; | 237 fOverrides = overrides; |
| 291 } | 238 } |
| 292 | 239 |
| 293 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } | 240 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } |
| 294 | 241 |
| 295 // After seeding, the client should call init() so the Batch can initialize
itself | 242 // After seeding, the client should call init() so the Batch can initialize
itself |
| 296 void init() { | 243 void init() { fGeoData[0].fViewMatrix.mapRect(&fBounds, fGeoData[0].fRect);
} |
| 297 const Geometry& geo = fGeoData[0]; | |
| 298 SetBounds(geo, &fBounds); | |
| 299 } | |
| 300 | |
| 301 void updateBoundsAfterAppend() { | |
| 302 const Geometry& geo = fGeoData.back(); | |
| 303 UpdateBoundsAfterAppend(geo, &fBounds); | |
| 304 } | |
| 305 | 244 |
| 306 private: | 245 private: |
| 307 static const char* Name() { return "NonAAFillRectPerspectiveBatch"; } | |
| 308 | |
| 309 static SkString DumpInfo(const Geometry& geo, int index) { | |
| 310 SkString str; | |
| 311 str.appendf("%d: Color: 0x%08x, Rect [L: %.2f, T: %.2f, R: %.2f, B: %.2f
]\n", | |
| 312 index, | |
| 313 geo.fColor, | |
| 314 geo.fRect.fLeft, geo.fRect.fTop, geo.fRect.fRight, geo.fRect
.fBottom); | |
| 315 return str; | |
| 316 } | |
| 317 | |
| 318 static bool CanCombine(const Geometry& mine, const Geometry& theirs, | |
| 319 const GrXPOverridesForBatch& overrides) { | |
| 320 // We could batch across perspective vm changes if we really wanted to | |
| 321 return mine.fViewMatrix.cheapEqualTo(theirs.fViewMatrix) && | |
| 322 mine.fHasLocalRect == theirs.fHasLocalRect && | |
| 323 (!mine.fHasLocalMatrix || mine.fLocalMatrix.cheapEqualTo(theirs.f
LocalMatrix)); | |
| 324 } | |
| 325 | |
| 326 static sk_sp<GrGeometryProcessor> MakeGP(const Geometry& geo, | |
| 327 const GrXPOverridesForBatch& overri
des) { | |
| 328 sk_sp<GrGeometryProcessor> gp = make_gp(geo.fViewMatrix, overrides.reads
Coverage(), | |
| 329 geo.fHasLocalRect, | |
| 330 geo.fHasLocalMatrix ? &geo.fLoca
lMatrix | |
| 331 : nullptr); | |
| 332 | |
| 333 SkASSERT(geo.fHasLocalRect ? | |
| 334 gp->getVertexStride() == sizeof(GrDefaultGeoProcFactory::PositionCo
lorLocalCoordAttr) : | |
| 335 gp->getVertexStride() == sizeof(GrDefaultGeoProcFactory::PositionCo
lorAttr)); | |
| 336 return gp; | |
| 337 } | |
| 338 | |
| 339 static void Tesselate(intptr_t vertices, size_t vertexStride, const Geometry
& geo, | |
| 340 const GrXPOverridesForBatch& overrides) { | |
| 341 if (geo.fHasLocalRect) { | |
| 342 GrQuad quad(geo.fLocalRect); | |
| 343 tesselate(vertices, vertexStride, geo.fColor, geo.fViewMatrix, geo.f
Rect, &quad); | |
| 344 } else { | |
| 345 tesselate(vertices, vertexStride, geo.fColor, geo.fViewMatrix, geo.f
Rect, nullptr); | |
| 346 } | |
| 347 } | |
| 348 | |
| 349 static void InitInvariantOutputCoverage(GrInitInvariantOutput* out) { | |
| 350 out->setKnownSingleComponent(0xff); | |
| 351 } | |
| 352 | |
| 353 static const GrBuffer* GetIndexBuffer(GrResourceProvider* rp) { | |
| 354 return rp->refQuadIndexBuffer(); | |
| 355 } | |
| 356 | |
| 357 static void SetBounds(const Geometry& geo, SkRect* outBounds) { | |
| 358 geo.fViewMatrix.mapRect(outBounds, geo.fRect); | |
| 359 } | |
| 360 | |
| 361 static void UpdateBoundsAfterAppend(const Geometry& geo, SkRect* outBounds)
{ | |
| 362 SkRect bounds = geo.fRect; | |
| 363 geo.fViewMatrix.mapRect(&bounds); | |
| 364 outBounds->join(bounds); | |
| 365 } | |
| 366 | |
| 367 NonAAFillRectPerspectiveBatch() : INHERITED(ClassID()) {} | 246 NonAAFillRectPerspectiveBatch() : INHERITED(ClassID()) {} |
| 368 | 247 |
| 369 void onPrepareDraws(Target* target) const override { | 248 void onPrepareDraws(Target* target) const override { |
| 370 sk_sp<GrGeometryProcessor> gp(MakeGP(this->seedGeometry(), fOverrides)); | 249 sk_sp<GrGeometryProcessor> gp = make_gp(fGeoData[0].fViewMatrix, fOverri
des.readsCoverage(), |
| 250 fGeoData[0].fHasLocalRect, |
| 251 fGeoData[0].fHasLocalMatrix |
| 252 ? &fGeoData[0].fLocalMatrix |
| 253 : nullptr); |
| 371 if (!gp) { | 254 if (!gp) { |
| 372 SkDebugf("Couldn't create GrGeometryProcessor\n"); | 255 SkDebugf("Couldn't create GrGeometryProcessor\n"); |
| 373 return; | 256 return; |
| 374 } | 257 } |
| 258 SkASSERT(fGeoData[0].fHasLocalRect |
| 259 ? gp->getVertexStride() == |
| 260 sizeof(GrDefaultGeoProcFactory::PositionColorLocalCoord
Attr) |
| 261 : gp->getVertexStride() == sizeof(GrDefaultGeoProcFactory::
PositionColorAttr)); |
| 375 | 262 |
| 376 size_t vertexStride = gp->getVertexStride(); | 263 size_t vertexStride = gp->getVertexStride(); |
| 377 int instanceCount = fGeoData.count(); | 264 int instanceCount = fGeoData.count(); |
| 378 | 265 |
| 379 SkAutoTUnref<const GrBuffer> indexBuffer(GetIndexBuffer(target->resource
Provider())); | 266 SkAutoTUnref<const GrBuffer> indexBuffer(target->resourceProvider()->ref
QuadIndexBuffer()); |
| 380 InstancedHelper helper; | 267 InstancedHelper helper; |
| 381 void* vertices = helper.init(target, kTriangles_GrPrimitiveType, vertexS
tride, | 268 void* vertices = helper.init(target, kTriangles_GrPrimitiveType, vertexS
tride, |
| 382 indexBuffer, kVertsPerInstance, | 269 indexBuffer, kVertsPerInstance, |
| 383 kIndicesPerInstance, instanceCount); | 270 kIndicesPerInstance, instanceCount); |
| 384 if (!vertices || !indexBuffer) { | 271 if (!vertices || !indexBuffer) { |
| 385 SkDebugf("Could not allocate vertices\n"); | 272 SkDebugf("Could not allocate vertices\n"); |
| 386 return; | 273 return; |
| 387 } | 274 } |
| 388 | 275 |
| 389 for (int i = 0; i < instanceCount; i++) { | 276 for (int i = 0; i < instanceCount; i++) { |
| 277 const Geometry& geo = fGeoData[i]; |
| 390 intptr_t verts = reinterpret_cast<intptr_t>(vertices) + | 278 intptr_t verts = reinterpret_cast<intptr_t>(vertices) + |
| 391 i * kVertsPerInstance * vertexStride; | 279 i * kVertsPerInstance * vertexStride; |
| 392 Tesselate(verts, vertexStride, fGeoData[i], fOverrides); | 280 if (geo.fHasLocalRect) { |
| 281 GrQuad quad(geo.fLocalRect); |
| 282 tesselate(verts, vertexStride, geo.fColor, geo.fViewMatrix, geo.
fRect, &quad); |
| 283 } else { |
| 284 tesselate(verts, vertexStride, geo.fColor, geo.fViewMatrix, geo.
fRect, nullptr); |
| 285 } |
| 393 } | 286 } |
| 394 helper.recordDraw(target, gp.get()); | 287 helper.recordDraw(target, gp.get()); |
| 395 } | 288 } |
| 396 | 289 |
| 397 const Geometry& seedGeometry() const { return fGeoData[0]; } | 290 const Geometry& seedGeometry() const { return fGeoData[0]; } |
| 398 | 291 |
| 399 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override { | 292 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override { |
| 400 NonAAFillRectPerspectiveBatch* that = t->cast<NonAAFillRectPerspectiveBa
tch>(); | 293 NonAAFillRectPerspectiveBatch* that = t->cast<NonAAFillRectPerspectiveBa
tch>(); |
| 401 if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *that->pi
peline(), | 294 if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *that->pi
peline(), |
| 402 that->bounds(), caps)) { | 295 that->bounds(), caps)) { |
| 403 return false; | 296 return false; |
| 404 } | 297 } |
| 405 | 298 |
| 406 if (!CanCombine(this->seedGeometry(), that->seedGeometry(), fOverrides))
{ | 299 // We could batch across perspective vm changes if we really wanted to |
| 300 if (!fGeoData[0].fViewMatrix.cheapEqualTo(that->fGeoData[0].fViewMatrix)
) { |
| 301 return false; |
| 302 } |
| 303 if (fGeoData[0].fHasLocalRect != that->fGeoData[0].fHasLocalRect) { |
| 304 return false; |
| 305 } |
| 306 if (fGeoData[0].fHasLocalMatrix && |
| 307 !fGeoData[0].fLocalMatrix.cheapEqualTo(that->fGeoData[0].fLocalMatri
x)) { |
| 407 return false; | 308 return false; |
| 408 } | 309 } |
| 409 | 310 |
| 410 // In the event of two batches, one who can tweak, one who cannot, we ju
st fall back to | 311 // In the event of two batches, one who can tweak, one who cannot, we ju
st fall back to |
| 411 // not tweaking | 312 // not tweaking |
| 412 if (fOverrides.canTweakAlphaForCoverage() && !that->fOverrides.canTweakA
lphaForCoverage()) { | 313 if (fOverrides.canTweakAlphaForCoverage() && !that->fOverrides.canTweakA
lphaForCoverage()) { |
| 413 fOverrides = that->fOverrides; | 314 fOverrides = that->fOverrides; |
| 414 } | 315 } |
| 415 | 316 |
| 416 fGeoData.push_back_n(that->geoData()->count(), that->geoData()->begin())
; | 317 fGeoData.push_back_n(that->geoData()->count(), that->geoData()->begin())
; |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 492 SkMatrix localMatrix = GrTest::TestMatrix(random); | 393 SkMatrix localMatrix = GrTest::TestMatrix(random); |
| 493 | 394 |
| 494 bool hasLocalRect = random->nextBool(); | 395 bool hasLocalRect = random->nextBool(); |
| 495 bool hasLocalMatrix = random->nextBool(); | 396 bool hasLocalMatrix = random->nextBool(); |
| 496 return GrNonAAFillRectBatch::Create(color, viewMatrix, rect, | 397 return GrNonAAFillRectBatch::Create(color, viewMatrix, rect, |
| 497 hasLocalRect ? &localRect : nullptr, | 398 hasLocalRect ? &localRect : nullptr, |
| 498 hasLocalMatrix ? &localMatrix : nullptr)
; | 399 hasLocalMatrix ? &localMatrix : nullptr)
; |
| 499 } | 400 } |
| 500 | 401 |
| 501 #endif | 402 #endif |
| OLD | NEW |