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 "GrBatchTest.h" | 8 #include "GrBatchTest.h" |
9 #include "GrColor.h" | 9 #include "GrColor.h" |
10 #include "GrDrawContext.h" | 10 #include "GrDrawContext.h" |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
235 this->drawRect(clip, *paint, viewMatrix, r); | 235 this->drawRect(clip, *paint, viewMatrix, r); |
236 } else { | 236 } else { |
237 SkMatrix localMatrix; | 237 SkMatrix localMatrix; |
238 if (!viewMatrix.invert(&localMatrix)) { | 238 if (!viewMatrix.invert(&localMatrix)) { |
239 SkDebugf("Could not invert matrix\n"); | 239 SkDebugf("Could not invert matrix\n"); |
240 return; | 240 return; |
241 } | 241 } |
242 | 242 |
243 AutoCheckFlush acf(fDrawingManager); | 243 AutoCheckFlush acf(fDrawingManager); |
244 | 244 |
245 SkAutoTUnref<GrDrawBatch> batch( | 245 this->drawNonAAFilledRect(clip, *paint, SkMatrix::I(), r, nullptr, &loca lMatrix, nullptr); |
246 GrRectBatchFactory::CreateNonAAFill(paint->getColor(), SkMatrix: :I(), r, nullptr, | |
247 &localMatrix)); | |
248 GrPipelineBuilder pipelineBuilder(*paint); // Create a pipeline builder without hwaa. | |
249 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch); | |
250 } | 246 } |
251 } | 247 } |
252 | 248 |
253 static inline bool rect_contains_inclusive(const SkRect& rect, const SkPoint& po int) { | 249 static inline bool rect_contains_inclusive(const SkRect& rect, const SkPoint& po int) { |
254 return point.fX >= rect.fLeft && point.fX <= rect.fRight && | 250 return point.fX >= rect.fLeft && point.fX <= rect.fRight && |
255 point.fY >= rect.fTop && point.fY <= rect.fBottom; | 251 point.fY >= rect.fTop && point.fY <= rect.fBottom; |
256 } | 252 } |
257 | 253 |
258 static bool view_matrix_ok_for_aa_fill_rect(const SkMatrix& viewMatrix) { | 254 static bool view_matrix_ok_for_aa_fill_rect(const SkMatrix& viewMatrix) { |
259 return viewMatrix.preservesRightAngles(); | 255 return viewMatrix.preservesRightAngles(); |
260 } | 256 } |
261 | 257 |
262 static bool should_apply_coverage_aa(const GrPaint& paint, GrRenderTarget* rt, | 258 static bool should_apply_coverage_aa(const GrPaint& paint, GrRenderTarget* rt, |
263 bool* useHWAA = nullptr) { | 259 bool* useHWAA = nullptr) { |
264 if (!paint.isAntiAlias()) { | 260 if (!paint.isAntiAlias()) { |
265 if (useHWAA) { | 261 if (useHWAA) { |
266 *useHWAA = false; | 262 *useHWAA = false; |
267 } | 263 } |
268 return false; | 264 return false; |
269 } else { | 265 } else { |
270 if (useHWAA) { | 266 if (useHWAA) { |
271 *useHWAA = rt->isUnifiedMultisampled(); | 267 *useHWAA = rt->isUnifiedMultisampled(); |
272 } | 268 } |
273 return !rt->isUnifiedMultisampled(); | 269 return !rt->isUnifiedMultisampled(); |
274 } | 270 } |
275 } | 271 } |
276 | 272 |
277 GrDrawBatch* GrDrawContext::getFillRectBatch(const GrPaint& paint, | 273 bool GrDrawContext::drawFilledRect(const GrClip& clip, |
278 const SkMatrix& viewMatrix, | 274 const GrPaint& paint, |
279 const SkRect& rect, | 275 const SkMatrix& viewMatrix, |
280 bool* useHWAA) { | 276 const SkRect& rect, |
277 const GrUserStencilSettings* ss) { | |
278 | |
279 SkAutoTUnref<GrDrawBatch> batch; | |
280 bool useHWAA; | |
281 | |
281 if (InstancedRendering* ir = this->getDrawTarget()->instancedRendering()) { | 282 if (InstancedRendering* ir = this->getDrawTarget()->instancedRendering()) { |
282 if (GrDrawBatch* batch = ir->recordRect(rect, viewMatrix, paint.getColor (), | 283 batch.reset(ir->recordRect(rect, viewMatrix, paint.getColor(), |
283 paint.isAntiAlias(), fInstancedP ipelineInfo, | 284 paint.isAntiAlias(), fInstancedPipelineInfo, |
284 useHWAA)) { | 285 &useHWAA)); |
285 return batch; | 286 if (batch) { |
287 GrPipelineBuilder pipelineBuilder(paint, useHWAA); | |
288 if (ss) { | |
289 pipelineBuilder.setUserStencil(ss); | |
290 } | |
291 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch) ; | |
292 return true; | |
286 } | 293 } |
287 } | 294 } |
288 | 295 |
289 if (should_apply_coverage_aa(paint, fRenderTarget.get(), useHWAA)) { | 296 if (should_apply_coverage_aa(paint, fRenderTarget.get(), &useHWAA)) { |
290 // The fill path can handle rotation but not skew. | 297 // The fill path can handle rotation but not skew. |
291 if (view_matrix_ok_for_aa_fill_rect(viewMatrix)) { | 298 if (view_matrix_ok_for_aa_fill_rect(viewMatrix)) { |
292 SkRect devBoundRect; | 299 SkRect devBoundRect; |
293 viewMatrix.mapRect(&devBoundRect, rect); | 300 viewMatrix.mapRect(&devBoundRect, rect); |
294 return GrRectBatchFactory::CreateAAFill(paint.getColor(), viewMatrix , | 301 |
295 rect, devBoundRect); | 302 batch.reset(GrRectBatchFactory::CreateAAFill(paint.getColor(), viewM atrix, |
303 rect, devBoundRect)); | |
304 if (batch) { | |
305 GrPipelineBuilder pipelineBuilder(paint, useHWAA); | |
306 if (ss) { | |
307 pipelineBuilder.setUserStencil(ss); | |
308 } | |
309 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, ba tch); | |
310 return true; | |
311 } | |
296 } | 312 } |
297 } else { | 313 } else { |
298 // filled BW rect | 314 this->drawNonAAFilledRect(clip, paint, viewMatrix, rect, nullptr, nullpt r, ss); |
299 return GrRectBatchFactory::CreateNonAAFill(paint.getColor(), viewMatrix, rect, | 315 return true; |
300 nullptr, nullptr); | |
301 } | 316 } |
302 | 317 |
303 return nullptr; | 318 return false; |
bsalomon
2016/07/08 14:42:09
just wondering if this could be
if (instanced ren
robertphillips
2016/07/08 16:40:32
Unfortunately, I believe the instanced rendering s
| |
304 } | 319 } |
305 | 320 |
306 void GrDrawContext::drawRect(const GrClip& clip, | 321 void GrDrawContext::drawRect(const GrClip& clip, |
307 const GrPaint& paint, | 322 const GrPaint& paint, |
308 const SkMatrix& viewMatrix, | 323 const SkMatrix& viewMatrix, |
309 const SkRect& rect, | 324 const SkRect& rect, |
310 const GrStyle* style) { | 325 const GrStyle* style) { |
311 if (!style) { | 326 if (!style) { |
312 style = &GrStyle::SimpleFill(); | 327 style = &GrStyle::SimpleFill(); |
313 } | 328 } |
314 ASSERT_SINGLE_OWNER | 329 ASSERT_SINGLE_OWNER |
315 RETURN_IF_ABANDONED | 330 RETURN_IF_ABANDONED |
316 SkDEBUGCODE(this->validate();) | 331 SkDEBUGCODE(this->validate();) |
317 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawRect"); | 332 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawRect"); |
318 | 333 |
319 // Path effects should've been devolved to a path in SkGpuDevice | 334 // Path effects should've been devolved to a path in SkGpuDevice |
320 SkASSERT(!style->pathEffect()); | 335 SkASSERT(!style->pathEffect()); |
321 | 336 |
322 AutoCheckFlush acf(fDrawingManager); | 337 AutoCheckFlush acf(fDrawingManager); |
323 | 338 |
324 const SkStrokeRec& stroke = style->strokeRec(); | 339 const SkStrokeRec& stroke = style->strokeRec(); |
325 bool useHWAA; | |
326 bool snapToPixelCenters = false; | |
327 SkAutoTUnref<GrDrawBatch> batch; | |
328 if (stroke.getStyle() == SkStrokeRec::kFill_Style) { | 340 if (stroke.getStyle() == SkStrokeRec::kFill_Style) { |
329 // Check if this is a full RT draw and can be replaced with a clear. We don't bother | 341 // Check if this is a full RT draw and can be replaced with a clear. We don't bother |
330 // checking cases where the RT is fully inside a stroke. | 342 // checking cases where the RT is fully inside a stroke. |
331 SkRect rtRect; | 343 SkRect rtRect; |
332 fRenderTarget->getBoundsRect(&rtRect); | 344 fRenderTarget->getBoundsRect(&rtRect); |
333 // Does the clip contain the entire RT? | 345 // Does the clip contain the entire RT? |
334 if (clip.quickContains(rtRect)) { | 346 if (clip.quickContains(rtRect)) { |
335 SkMatrix invM; | 347 SkMatrix invM; |
336 if (!viewMatrix.invert(&invM)) { | 348 if (!viewMatrix.invert(&invM)) { |
337 return; | 349 return; |
338 } | 350 } |
339 // Does the rect bound the RT? | 351 // Does the rect bound the RT? |
340 SkPoint srcSpaceRTQuad[4]; | 352 SkPoint srcSpaceRTQuad[4]; |
341 invM.mapRectToQuad(srcSpaceRTQuad, rtRect); | 353 invM.mapRectToQuad(srcSpaceRTQuad, rtRect); |
342 if (rect_contains_inclusive(rect, srcSpaceRTQuad[0]) && | 354 if (rect_contains_inclusive(rect, srcSpaceRTQuad[0]) && |
343 rect_contains_inclusive(rect, srcSpaceRTQuad[1]) && | 355 rect_contains_inclusive(rect, srcSpaceRTQuad[1]) && |
344 rect_contains_inclusive(rect, srcSpaceRTQuad[2]) && | 356 rect_contains_inclusive(rect, srcSpaceRTQuad[2]) && |
345 rect_contains_inclusive(rect, srcSpaceRTQuad[3])) { | 357 rect_contains_inclusive(rect, srcSpaceRTQuad[3])) { |
346 // Will it blend? | 358 // Will it blend? |
347 GrColor clearColor; | 359 GrColor clearColor; |
348 if (paint.isConstantBlendedColor(&clearColor)) { | 360 if (paint.isConstantBlendedColor(&clearColor)) { |
349 this->getDrawTarget()->clear(nullptr, clearColor, true, this ); | 361 this->getDrawTarget()->clear(nullptr, clearColor, true, this ); |
350 return; | 362 return; |
351 } | 363 } |
352 } | 364 } |
353 } | 365 } |
354 batch.reset(this->getFillRectBatch(paint, viewMatrix, rect, &useHWAA)); | 366 |
367 if (this->drawFilledRect(clip, paint, viewMatrix, rect, nullptr)) { | |
368 return; | |
369 } | |
355 } else if (stroke.getStyle() == SkStrokeRec::kStroke_Style || | 370 } else if (stroke.getStyle() == SkStrokeRec::kStroke_Style || |
356 stroke.getStyle() == SkStrokeRec::kHairline_Style) { | 371 stroke.getStyle() == SkStrokeRec::kHairline_Style) { |
357 if ((!rect.width() || !rect.height()) && | 372 if ((!rect.width() || !rect.height()) && |
358 SkStrokeRec::kHairline_Style != stroke.getStyle()) { | 373 SkStrokeRec::kHairline_Style != stroke.getStyle()) { |
359 SkScalar r = stroke.getWidth() / 2; | 374 SkScalar r = stroke.getWidth() / 2; |
360 // TODO: Move these stroke->fill fallbacks to GrShape? | 375 // TODO: Move these stroke->fill fallbacks to GrShape? |
361 switch (stroke.getJoin()) { | 376 switch (stroke.getJoin()) { |
362 case SkPaint::kMiter_Join: | 377 case SkPaint::kMiter_Join: |
363 this->drawRect(clip, paint, viewMatrix, | 378 this->drawRect(clip, paint, viewMatrix, |
364 {rect.fLeft - r, rect.fTop - r, | 379 {rect.fLeft - r, rect.fTop - r, |
(...skipping 13 matching lines...) Expand all Loading... | |
378 {rect.fLeft - r, rect.fTop, rect.fRight + r, rect.fBottom}, | 393 {rect.fLeft - r, rect.fTop, rect.fRight + r, rect.fBottom}, |
379 &GrStyle::SimpleFill()); | 394 &GrStyle::SimpleFill()); |
380 } else { | 395 } else { |
381 this->drawRect(clip, paint, viewMatrix, | 396 this->drawRect(clip, paint, viewMatrix, |
382 {rect.fLeft, rect.fTop - r, rect.fRight, rect.fBottom + r}, | 397 {rect.fLeft, rect.fTop - r, rect.fRight, rect.fBottom + r}, |
383 &GrStyle::SimpleFill()); | 398 &GrStyle::SimpleFill()); |
384 } | 399 } |
385 return; | 400 return; |
386 } | 401 } |
387 } | 402 } |
403 | |
404 bool useHWAA; | |
405 bool snapToPixelCenters = false; | |
406 SkAutoTUnref<GrDrawBatch> batch; | |
407 | |
388 GrColor color = paint.getColor(); | 408 GrColor color = paint.getColor(); |
389 if (should_apply_coverage_aa(paint, fRenderTarget.get(), &useHWAA)) { | 409 if (should_apply_coverage_aa(paint, fRenderTarget.get(), &useHWAA)) { |
390 // The stroke path needs the rect to remain axis aligned (no rotatio n or skew). | 410 // The stroke path needs the rect to remain axis aligned (no rotatio n or skew). |
391 if (viewMatrix.rectStaysRect()) { | 411 if (viewMatrix.rectStaysRect()) { |
392 batch.reset(GrRectBatchFactory::CreateAAStroke(color, viewMatrix , rect, stroke)); | 412 batch.reset(GrRectBatchFactory::CreateAAStroke(color, viewMatrix , rect, stroke)); |
393 } | 413 } |
394 } else { | 414 } else { |
395 // Depending on sub-pixel coordinates and the particular GPU, we may lose a corner of | 415 // Depending on sub-pixel coordinates and the particular GPU, we may lose a corner of |
396 // hairline rects. We jam all the vertices to pixel centers to avoid this, but not | 416 // hairline rects. We jam all the vertices to pixel centers to avoid this, but not |
397 // when MSAA is enabled because it can cause ugly artifacts. | 417 // when MSAA is enabled because it can cause ugly artifacts. |
398 snapToPixelCenters = stroke.getStyle() == SkStrokeRec::kHairline_Sty le && | 418 snapToPixelCenters = stroke.getStyle() == SkStrokeRec::kHairline_Sty le && |
399 !fRenderTarget->isUnifiedMultisampled(); | 419 !fRenderTarget->isUnifiedMultisampled(); |
400 batch.reset(GrRectBatchFactory::CreateNonAAStroke(color, viewMatrix, rect, | 420 batch.reset(GrRectBatchFactory::CreateNonAAStroke(color, viewMatrix, rect, |
401 stroke, snapToPixe lCenters)); | 421 stroke, snapToPixe lCenters)); |
402 } | 422 } |
403 } | |
404 | 423 |
405 if (batch) { | 424 if (batch) { |
406 GrPipelineBuilder pipelineBuilder(paint, useHWAA); | 425 GrPipelineBuilder pipelineBuilder(paint, useHWAA); |
407 | 426 |
408 if (snapToPixelCenters) { | 427 if (snapToPixelCenters) { |
409 pipelineBuilder.setState(GrPipelineBuilder::kSnapVerticesToPixelCent ers_Flag, | 428 pipelineBuilder.setState(GrPipelineBuilder::kSnapVerticesToPixel Centers_Flag, |
410 snapToPixelCenters); | 429 snapToPixelCenters); |
430 } | |
431 | |
432 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch) ; | |
433 return; | |
411 } | 434 } |
412 | |
413 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch); | |
414 return; | |
415 } | 435 } |
416 | 436 |
417 SkPath path; | 437 SkPath path; |
418 path.setIsVolatile(true); | 438 path.setIsVolatile(true); |
419 path.addRect(rect); | 439 path.addRect(rect); |
420 this->internalDrawPath(clip, paint, viewMatrix, path, *style); | 440 this->internalDrawPath(clip, paint, viewMatrix, path, *style); |
421 } | 441 } |
422 | 442 |
423 void GrDrawContextPriv::clearStencilClip(const SkIRect& rect, bool insideClip) { | 443 void GrDrawContextPriv::clearStencilClip(const SkIRect& rect, bool insideClip) { |
424 ASSERT_SINGLE_OWNER_PRIV | 444 ASSERT_SINGLE_OWNER_PRIV |
(...skipping 26 matching lines...) Expand all Loading... | |
451 GR_AUDIT_TRAIL_AUTO_FRAME(fDrawContext->fAuditTrail, "GrDrawContext::stencil Rect"); | 471 GR_AUDIT_TRAIL_AUTO_FRAME(fDrawContext->fAuditTrail, "GrDrawContext::stencil Rect"); |
452 | 472 |
453 AutoCheckFlush acf(fDrawContext->fDrawingManager); | 473 AutoCheckFlush acf(fDrawContext->fDrawingManager); |
454 | 474 |
455 GrPaint paint; | 475 GrPaint paint; |
456 paint.setAntiAlias(useHWAA); | 476 paint.setAntiAlias(useHWAA); |
457 paint.setXPFactory(GrDisableColorXPFactory::Make()); | 477 paint.setXPFactory(GrDisableColorXPFactory::Make()); |
458 | 478 |
459 SkASSERT(!useHWAA || fDrawContext->isStencilBufferMultisampled()); | 479 SkASSERT(!useHWAA || fDrawContext->isStencilBufferMultisampled()); |
460 | 480 |
461 GrPipelineBuilder pipelineBuilder(paint, useHWAA); | 481 fDrawContext->drawFilledRect(clip, paint, viewMatrix, rect, ss); |
462 pipelineBuilder.setUserStencil(ss); | |
463 | |
464 SkAutoTUnref<GrDrawBatch> batch( | |
465 GrRectBatchFactory::CreateNonAAFill(SK_ColorWHITE, viewMatrix, rect, nul lptr, nullptr)); | |
466 | |
467 fDrawContext->getDrawTarget()->drawBatch(pipelineBuilder, fDrawContext, clip , batch); | |
468 } | 482 } |
469 | 483 |
470 bool GrDrawContextPriv::drawAndStencilRect(const GrFixedClip& clip, | 484 bool GrDrawContextPriv::drawAndStencilRect(const GrFixedClip& clip, |
471 const GrUserStencilSettings* ss, | 485 const GrUserStencilSettings* ss, |
472 SkRegion::Op op, | 486 SkRegion::Op op, |
473 bool invert, | 487 bool invert, |
474 bool doAA, | 488 bool doAA, |
475 const SkMatrix& viewMatrix, | 489 const SkMatrix& viewMatrix, |
476 const SkRect& rect) { | 490 const SkRect& rect) { |
477 ASSERT_SINGLE_OWNER_PRIV | 491 ASSERT_SINGLE_OWNER_PRIV |
478 RETURN_FALSE_IF_ABANDONED_PRIV | 492 RETURN_FALSE_IF_ABANDONED_PRIV |
479 SkDEBUGCODE(fDrawContext->validate();) | 493 SkDEBUGCODE(fDrawContext->validate();) |
480 GR_AUDIT_TRAIL_AUTO_FRAME(fDrawContext->fAuditTrail, "GrDrawContext::drawAnd StencilRect"); | 494 GR_AUDIT_TRAIL_AUTO_FRAME(fDrawContext->fAuditTrail, "GrDrawContext::drawAnd StencilRect"); |
481 | 495 |
482 AutoCheckFlush acf(fDrawContext->fDrawingManager); | 496 AutoCheckFlush acf(fDrawContext->fDrawingManager); |
483 | 497 |
484 GrPaint paint; | 498 GrPaint paint; |
485 paint.setAntiAlias(doAA); | 499 paint.setAntiAlias(doAA); |
486 paint.setCoverageSetOpXPFactory(op, invert); | 500 paint.setCoverageSetOpXPFactory(op, invert); |
487 | 501 |
488 bool useHWAA; | 502 if (fDrawContext->drawFilledRect(clip, paint, viewMatrix, rect, ss)) { |
489 SkAutoTUnref<GrDrawBatch> batch( | |
490 fDrawContext->getFillRectBatch(paint, viewMatrix, rect, &useHWAA)); | |
491 if (batch) { | |
492 GrPipelineBuilder pipelineBuilder(paint, useHWAA); | |
493 pipelineBuilder.setUserStencil(ss); | |
494 | |
495 fDrawContext->getDrawTarget()->drawBatch(pipelineBuilder, fDrawContext, clip, batch); | |
496 return true; | 503 return true; |
497 } | 504 } |
498 | 505 |
499 SkPath path; | 506 SkPath path; |
500 path.setIsVolatile(true); | 507 path.setIsVolatile(true); |
501 path.addRect(rect); | 508 path.addRect(rect); |
502 return this->drawAndStencilPath(clip, ss, op, invert, doAA, viewMatrix, path ); | 509 return this->drawAndStencilPath(clip, ss, op, invert, doAA, viewMatrix, path ); |
503 } | 510 } |
504 | 511 |
505 void GrDrawContext::fillRectToRect(const GrClip& clip, | 512 void GrDrawContext::fillRectToRect(const GrClip& clip, |
(...skipping 17 matching lines...) Expand all Loading... | |
523 GrPipelineBuilder pipelineBuilder(paint, useHWAA); | 530 GrPipelineBuilder pipelineBuilder(paint, useHWAA); |
524 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch) ; | 531 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch) ; |
525 return; | 532 return; |
526 } | 533 } |
527 } | 534 } |
528 | 535 |
529 if (should_apply_coverage_aa(paint, fRenderTarget.get(), &useHWAA) && | 536 if (should_apply_coverage_aa(paint, fRenderTarget.get(), &useHWAA) && |
530 view_matrix_ok_for_aa_fill_rect(viewMatrix)) { | 537 view_matrix_ok_for_aa_fill_rect(viewMatrix)) { |
531 batch.reset(GrAAFillRectBatch::CreateWithLocalRect(paint.getColor(), vie wMatrix, rectToDraw, | 538 batch.reset(GrAAFillRectBatch::CreateWithLocalRect(paint.getColor(), vie wMatrix, rectToDraw, |
532 localRect)); | 539 localRect)); |
540 if (batch) { | |
541 GrPipelineBuilder pipelineBuilder(paint, useHWAA); | |
542 this->drawBatch(pipelineBuilder, clip, batch); | |
543 return; | |
544 } | |
533 } else { | 545 } else { |
534 batch.reset(GrRectBatchFactory::CreateNonAAFill(paint.getColor(), viewMa trix, rectToDraw, | 546 this->drawNonAAFilledRect(clip, paint, viewMatrix, rectToDraw, &localRec t, |
535 &localRect, nullptr)); | 547 nullptr, nullptr); |
536 } | 548 } |
537 | 549 |
538 if (batch) { | |
539 GrPipelineBuilder pipelineBuilder(paint, useHWAA); | |
540 this->drawBatch(pipelineBuilder, clip, batch); | |
541 } | |
542 } | 550 } |
543 | 551 |
544 void GrDrawContext::fillRectWithLocalMatrix(const GrClip& clip, | 552 void GrDrawContext::fillRectWithLocalMatrix(const GrClip& clip, |
545 const GrPaint& paint, | 553 const GrPaint& paint, |
546 const SkMatrix& viewMatrix, | 554 const SkMatrix& viewMatrix, |
547 const SkRect& rectToDraw, | 555 const SkRect& rectToDraw, |
548 const SkMatrix& localMatrix) { | 556 const SkMatrix& localMatrix) { |
549 ASSERT_SINGLE_OWNER | 557 ASSERT_SINGLE_OWNER |
550 RETURN_IF_ABANDONED | 558 RETURN_IF_ABANDONED |
551 SkDEBUGCODE(this->validate();) | 559 SkDEBUGCODE(this->validate();) |
(...skipping 10 matching lines...) Expand all Loading... | |
562 GrPipelineBuilder pipelineBuilder(paint, useHWAA); | 570 GrPipelineBuilder pipelineBuilder(paint, useHWAA); |
563 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch) ; | 571 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch) ; |
564 return; | 572 return; |
565 } | 573 } |
566 } | 574 } |
567 | 575 |
568 if (should_apply_coverage_aa(paint, fRenderTarget.get(), &useHWAA) && | 576 if (should_apply_coverage_aa(paint, fRenderTarget.get(), &useHWAA) && |
569 view_matrix_ok_for_aa_fill_rect(viewMatrix)) { | 577 view_matrix_ok_for_aa_fill_rect(viewMatrix)) { |
570 batch.reset(GrAAFillRectBatch::Create(paint.getColor(), viewMatrix, loca lMatrix, | 578 batch.reset(GrAAFillRectBatch::Create(paint.getColor(), viewMatrix, loca lMatrix, |
571 rectToDraw)); | 579 rectToDraw)); |
580 GrPipelineBuilder pipelineBuilder(paint, useHWAA); | |
581 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch); | |
572 } else { | 582 } else { |
573 batch.reset(GrRectBatchFactory::CreateNonAAFill(paint.getColor(), viewMa trix, rectToDraw, | 583 this->drawNonAAFilledRect(clip, paint, viewMatrix, rectToDraw, nullptr, |
574 nullptr, &localMatrix)); | 584 &localMatrix, nullptr); |
575 } | 585 } |
576 | 586 |
577 GrPipelineBuilder pipelineBuilder(paint, useHWAA); | |
578 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch); | |
579 } | 587 } |
580 | 588 |
581 void GrDrawContext::drawVertices(const GrClip& clip, | 589 void GrDrawContext::drawVertices(const GrClip& clip, |
582 const GrPaint& paint, | 590 const GrPaint& paint, |
583 const SkMatrix& viewMatrix, | 591 const SkMatrix& viewMatrix, |
584 GrPrimitiveType primitiveType, | 592 GrPrimitiveType primitiveType, |
585 int vertexCount, | 593 int vertexCount, |
586 const SkPoint positions[], | 594 const SkPoint positions[], |
587 const SkPoint texCoords[], | 595 const SkPoint texCoords[], |
588 const GrColor colors[], | 596 const GrColor colors[], |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
865 | 873 |
866 SkAutoTUnref<GrDrawBatch> batch(GrNinePatch::CreateNonAA(paint.getColor(), v iewMatrix, | 874 SkAutoTUnref<GrDrawBatch> batch(GrNinePatch::CreateNonAA(paint.getColor(), v iewMatrix, |
867 imageWidth, imageHe ight, | 875 imageWidth, imageHe ight, |
868 center, dst)); | 876 center, dst)); |
869 | 877 |
870 GrPipelineBuilder pipelineBuilder(paint, this->mustUseHWAA(paint)); | 878 GrPipelineBuilder pipelineBuilder(paint, this->mustUseHWAA(paint)); |
871 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch); | 879 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch); |
872 } | 880 } |
873 | 881 |
874 | 882 |
883 void GrDrawContext::drawNonAAFilledRect(const GrClip& clip, | |
884 const GrPaint& paint, | |
885 const SkMatrix& viewMatrix, | |
886 const SkRect& rect, | |
887 const SkRect* localRect, | |
888 const SkMatrix* localMatrix, | |
889 const GrUserStencilSettings* ss) { | |
890 SkAutoTUnref<GrDrawBatch> batch( | |
891 GrRectBatchFactory::CreateNonAAFill(paint.getColor(), viewMatrix, re ct, localRect, | |
892 localMatrix)); | |
893 GrPipelineBuilder pipelineBuilder(paint, this->mustUseHWAA(paint)); | |
894 if (ss) { | |
895 pipelineBuilder.setUserStencil(ss); | |
896 } | |
897 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch); | |
898 } | |
899 | |
875 // Can 'path' be drawn as a pair of filled nested rectangles? | 900 // Can 'path' be drawn as a pair of filled nested rectangles? |
876 static bool fills_as_nested_rects(const SkMatrix& viewMatrix, const SkPath& path , SkRect rects[2]) { | 901 static bool fills_as_nested_rects(const SkMatrix& viewMatrix, const SkPath& path , SkRect rects[2]) { |
877 | 902 |
878 if (path.isInverseFillType()) { | 903 if (path.isInverseFillType()) { |
879 return false; | 904 return false; |
880 } | 905 } |
881 | 906 |
882 // TODO: this restriction could be lifted if we were willing to apply | 907 // TODO: this restriction could be lifted if we were willing to apply |
883 // the matrix to all the points individually rather than just to the rect | 908 // the matrix to all the points individually rather than just to the rect |
884 if (!viewMatrix.rectStaysRect()) { | 909 if (!viewMatrix.rectStaysRect()) { |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1118 | 1143 |
1119 void GrDrawContext::drawBatch(const GrPipelineBuilder& pipelineBuilder, const Gr Clip& clip, | 1144 void GrDrawContext::drawBatch(const GrPipelineBuilder& pipelineBuilder, const Gr Clip& clip, |
1120 GrDrawBatch* batch) { | 1145 GrDrawBatch* batch) { |
1121 ASSERT_SINGLE_OWNER | 1146 ASSERT_SINGLE_OWNER |
1122 RETURN_IF_ABANDONED | 1147 RETURN_IF_ABANDONED |
1123 SkDEBUGCODE(this->validate();) | 1148 SkDEBUGCODE(this->validate();) |
1124 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawBatch"); | 1149 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawBatch"); |
1125 | 1150 |
1126 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch); | 1151 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch); |
1127 } | 1152 } |
OLD | NEW |