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

Side by Side Diff: src/gpu/GrDrawContext.cpp

Issue 2125333002: Add choke point for modifying non-AA rect draws (e.g., applying clipping) (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix infinite optimization loop Created 4 years, 5 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/GrClipMaskManager.h ('k') | src/gpu/GrDrawTarget.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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;
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; 340 if (stroke.getStyle() == SkStrokeRec::kFill_Style &&
326 bool snapToPixelCenters = false; 341 !fContext->caps()->useDrawInsteadOfClear()) {
327 SkAutoTUnref<GrDrawBatch> batch;
328 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 342 // 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. 343 // checking cases where the RT is fully inside a stroke.
331 SkRect rtRect; 344 SkRect rtRect;
332 fRenderTarget->getBoundsRect(&rtRect); 345 fRenderTarget->getBoundsRect(&rtRect);
333 // Does the clip contain the entire RT? 346 // Does the clip contain the entire RT?
334 if (clip.quickContains(rtRect)) { 347 if (clip.quickContains(rtRect)) {
335 SkMatrix invM; 348 SkMatrix invM;
336 if (!viewMatrix.invert(&invM)) { 349 if (!viewMatrix.invert(&invM)) {
337 return; 350 return;
338 } 351 }
339 // Does the rect bound the RT? 352 // Does the rect bound the RT?
340 SkPoint srcSpaceRTQuad[4]; 353 SkPoint srcSpaceRTQuad[4];
341 invM.mapRectToQuad(srcSpaceRTQuad, rtRect); 354 invM.mapRectToQuad(srcSpaceRTQuad, rtRect);
342 if (rect_contains_inclusive(rect, srcSpaceRTQuad[0]) && 355 if (rect_contains_inclusive(rect, srcSpaceRTQuad[0]) &&
343 rect_contains_inclusive(rect, srcSpaceRTQuad[1]) && 356 rect_contains_inclusive(rect, srcSpaceRTQuad[1]) &&
344 rect_contains_inclusive(rect, srcSpaceRTQuad[2]) && 357 rect_contains_inclusive(rect, srcSpaceRTQuad[2]) &&
345 rect_contains_inclusive(rect, srcSpaceRTQuad[3])) { 358 rect_contains_inclusive(rect, srcSpaceRTQuad[3])) {
346 // Will it blend? 359 // Will it blend?
347 GrColor clearColor; 360 GrColor clearColor;
348 if (paint.isConstantBlendedColor(&clearColor)) { 361 if (paint.isConstantBlendedColor(&clearColor)) {
349 this->getDrawTarget()->clear(nullptr, clearColor, true, this ); 362 this->getDrawTarget()->clear(nullptr, clearColor, true, this );
350 return; 363 return;
351 } 364 }
352 } 365 }
353 } 366 }
354 batch.reset(this->getFillRectBatch(paint, viewMatrix, rect, &useHWAA)); 367
368 if (this->drawFilledRect(clip, paint, viewMatrix, rect, nullptr)) {
369 return;
370 }
355 } else if (stroke.getStyle() == SkStrokeRec::kStroke_Style || 371 } else if (stroke.getStyle() == SkStrokeRec::kStroke_Style ||
356 stroke.getStyle() == SkStrokeRec::kHairline_Style) { 372 stroke.getStyle() == SkStrokeRec::kHairline_Style) {
357 if ((!rect.width() || !rect.height()) && 373 if ((!rect.width() || !rect.height()) &&
358 SkStrokeRec::kHairline_Style != stroke.getStyle()) { 374 SkStrokeRec::kHairline_Style != stroke.getStyle()) {
359 SkScalar r = stroke.getWidth() / 2; 375 SkScalar r = stroke.getWidth() / 2;
360 // TODO: Move these stroke->fill fallbacks to GrShape? 376 // TODO: Move these stroke->fill fallbacks to GrShape?
361 switch (stroke.getJoin()) { 377 switch (stroke.getJoin()) {
362 case SkPaint::kMiter_Join: 378 case SkPaint::kMiter_Join:
363 this->drawRect(clip, paint, viewMatrix, 379 this->drawRect(clip, paint, viewMatrix,
364 {rect.fLeft - r, rect.fTop - r, 380 {rect.fLeft - r, rect.fTop - r,
(...skipping 13 matching lines...) Expand all
378 {rect.fLeft - r, rect.fTop, rect.fRight + r, rect.fBottom}, 394 {rect.fLeft - r, rect.fTop, rect.fRight + r, rect.fBottom},
379 &GrStyle::SimpleFill()); 395 &GrStyle::SimpleFill());
380 } else { 396 } else {
381 this->drawRect(clip, paint, viewMatrix, 397 this->drawRect(clip, paint, viewMatrix,
382 {rect.fLeft, rect.fTop - r, rect.fRight, rect.fBottom + r}, 398 {rect.fLeft, rect.fTop - r, rect.fRight, rect.fBottom + r},
383 &GrStyle::SimpleFill()); 399 &GrStyle::SimpleFill());
384 } 400 }
385 return; 401 return;
386 } 402 }
387 } 403 }
404
405 bool useHWAA;
406 bool snapToPixelCenters = false;
407 SkAutoTUnref<GrDrawBatch> batch;
408
388 GrColor color = paint.getColor(); 409 GrColor color = paint.getColor();
389 if (should_apply_coverage_aa(paint, fRenderTarget.get(), &useHWAA)) { 410 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). 411 // The stroke path needs the rect to remain axis aligned (no rotatio n or skew).
391 if (viewMatrix.rectStaysRect()) { 412 if (viewMatrix.rectStaysRect()) {
392 batch.reset(GrRectBatchFactory::CreateAAStroke(color, viewMatrix , rect, stroke)); 413 batch.reset(GrRectBatchFactory::CreateAAStroke(color, viewMatrix , rect, stroke));
393 } 414 }
394 } else { 415 } else {
395 // Depending on sub-pixel coordinates and the particular GPU, we may lose a corner of 416 // 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 417 // 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. 418 // when MSAA is enabled because it can cause ugly artifacts.
398 snapToPixelCenters = stroke.getStyle() == SkStrokeRec::kHairline_Sty le && 419 snapToPixelCenters = stroke.getStyle() == SkStrokeRec::kHairline_Sty le &&
399 !fRenderTarget->isUnifiedMultisampled(); 420 !fRenderTarget->isUnifiedMultisampled();
400 batch.reset(GrRectBatchFactory::CreateNonAAStroke(color, viewMatrix, rect, 421 batch.reset(GrRectBatchFactory::CreateNonAAStroke(color, viewMatrix, rect,
401 stroke, snapToPixe lCenters)); 422 stroke, snapToPixe lCenters));
402 } 423 }
403 }
404 424
405 if (batch) { 425 if (batch) {
406 GrPipelineBuilder pipelineBuilder(paint, useHWAA); 426 GrPipelineBuilder pipelineBuilder(paint, useHWAA);
407 427
408 if (snapToPixelCenters) { 428 if (snapToPixelCenters) {
409 pipelineBuilder.setState(GrPipelineBuilder::kSnapVerticesToPixelCent ers_Flag, 429 pipelineBuilder.setState(GrPipelineBuilder::kSnapVerticesToPixel Centers_Flag,
410 snapToPixelCenters); 430 snapToPixelCenters);
431 }
432
433 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch) ;
434 return;
411 } 435 }
412
413 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch);
414 return;
415 } 436 }
416 437
417 SkPath path; 438 SkPath path;
418 path.setIsVolatile(true); 439 path.setIsVolatile(true);
419 path.addRect(rect); 440 path.addRect(rect);
420 this->internalDrawPath(clip, paint, viewMatrix, path, *style); 441 this->internalDrawPath(clip, paint, viewMatrix, path, *style);
421 } 442 }
422 443
423 void GrDrawContextPriv::clearStencilClip(const SkIRect& rect, bool insideClip) { 444 void GrDrawContextPriv::clearStencilClip(const SkIRect& rect, bool insideClip) {
424 ASSERT_SINGLE_OWNER_PRIV 445 ASSERT_SINGLE_OWNER_PRIV
(...skipping 26 matching lines...) Expand all
451 GR_AUDIT_TRAIL_AUTO_FRAME(fDrawContext->fAuditTrail, "GrDrawContext::stencil Rect"); 472 GR_AUDIT_TRAIL_AUTO_FRAME(fDrawContext->fAuditTrail, "GrDrawContext::stencil Rect");
452 473
453 AutoCheckFlush acf(fDrawContext->fDrawingManager); 474 AutoCheckFlush acf(fDrawContext->fDrawingManager);
454 475
455 GrPaint paint; 476 GrPaint paint;
456 paint.setAntiAlias(useHWAA); 477 paint.setAntiAlias(useHWAA);
457 paint.setXPFactory(GrDisableColorXPFactory::Make()); 478 paint.setXPFactory(GrDisableColorXPFactory::Make());
458 479
459 SkASSERT(!useHWAA || fDrawContext->isStencilBufferMultisampled()); 480 SkASSERT(!useHWAA || fDrawContext->isStencilBufferMultisampled());
460 481
461 GrPipelineBuilder pipelineBuilder(paint, useHWAA); 482 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 } 483 }
469 484
470 bool GrDrawContextPriv::drawAndStencilRect(const GrFixedClip& clip, 485 bool GrDrawContextPriv::drawAndStencilRect(const GrFixedClip& clip,
471 const GrUserStencilSettings* ss, 486 const GrUserStencilSettings* ss,
472 SkRegion::Op op, 487 SkRegion::Op op,
473 bool invert, 488 bool invert,
474 bool doAA, 489 bool doAA,
475 const SkMatrix& viewMatrix, 490 const SkMatrix& viewMatrix,
476 const SkRect& rect) { 491 const SkRect& rect) {
477 ASSERT_SINGLE_OWNER_PRIV 492 ASSERT_SINGLE_OWNER_PRIV
478 RETURN_FALSE_IF_ABANDONED_PRIV 493 RETURN_FALSE_IF_ABANDONED_PRIV
479 SkDEBUGCODE(fDrawContext->validate();) 494 SkDEBUGCODE(fDrawContext->validate();)
480 GR_AUDIT_TRAIL_AUTO_FRAME(fDrawContext->fAuditTrail, "GrDrawContext::drawAnd StencilRect"); 495 GR_AUDIT_TRAIL_AUTO_FRAME(fDrawContext->fAuditTrail, "GrDrawContext::drawAnd StencilRect");
481 496
482 AutoCheckFlush acf(fDrawContext->fDrawingManager); 497 AutoCheckFlush acf(fDrawContext->fDrawingManager);
483 498
484 GrPaint paint; 499 GrPaint paint;
485 paint.setAntiAlias(doAA); 500 paint.setAntiAlias(doAA);
486 paint.setCoverageSetOpXPFactory(op, invert); 501 paint.setCoverageSetOpXPFactory(op, invert);
487 502
488 bool useHWAA; 503 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; 504 return true;
497 } 505 }
498 506
499 SkPath path; 507 SkPath path;
500 path.setIsVolatile(true); 508 path.setIsVolatile(true);
501 path.addRect(rect); 509 path.addRect(rect);
502 return this->drawAndStencilPath(clip, ss, op, invert, doAA, viewMatrix, path ); 510 return this->drawAndStencilPath(clip, ss, op, invert, doAA, viewMatrix, path );
503 } 511 }
504 512
505 void GrDrawContext::fillRectToRect(const GrClip& clip, 513 void GrDrawContext::fillRectToRect(const GrClip& clip,
(...skipping 17 matching lines...) Expand all
523 GrPipelineBuilder pipelineBuilder(paint, useHWAA); 531 GrPipelineBuilder pipelineBuilder(paint, useHWAA);
524 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch) ; 532 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch) ;
525 return; 533 return;
526 } 534 }
527 } 535 }
528 536
529 if (should_apply_coverage_aa(paint, fRenderTarget.get(), &useHWAA) && 537 if (should_apply_coverage_aa(paint, fRenderTarget.get(), &useHWAA) &&
530 view_matrix_ok_for_aa_fill_rect(viewMatrix)) { 538 view_matrix_ok_for_aa_fill_rect(viewMatrix)) {
531 batch.reset(GrAAFillRectBatch::CreateWithLocalRect(paint.getColor(), vie wMatrix, rectToDraw, 539 batch.reset(GrAAFillRectBatch::CreateWithLocalRect(paint.getColor(), vie wMatrix, rectToDraw,
532 localRect)); 540 localRect));
541 if (batch) {
542 GrPipelineBuilder pipelineBuilder(paint, useHWAA);
543 this->drawBatch(pipelineBuilder, clip, batch);
544 return;
545 }
533 } else { 546 } else {
534 batch.reset(GrRectBatchFactory::CreateNonAAFill(paint.getColor(), viewMa trix, rectToDraw, 547 this->drawNonAAFilledRect(clip, paint, viewMatrix, rectToDraw, &localRec t,
535 &localRect, nullptr)); 548 nullptr, nullptr);
536 } 549 }
537 550
538 if (batch) {
539 GrPipelineBuilder pipelineBuilder(paint, useHWAA);
540 this->drawBatch(pipelineBuilder, clip, batch);
541 }
542 } 551 }
543 552
544 void GrDrawContext::fillRectWithLocalMatrix(const GrClip& clip, 553 void GrDrawContext::fillRectWithLocalMatrix(const GrClip& clip,
545 const GrPaint& paint, 554 const GrPaint& paint,
546 const SkMatrix& viewMatrix, 555 const SkMatrix& viewMatrix,
547 const SkRect& rectToDraw, 556 const SkRect& rectToDraw,
548 const SkMatrix& localMatrix) { 557 const SkMatrix& localMatrix) {
549 ASSERT_SINGLE_OWNER 558 ASSERT_SINGLE_OWNER
550 RETURN_IF_ABANDONED 559 RETURN_IF_ABANDONED
551 SkDEBUGCODE(this->validate();) 560 SkDEBUGCODE(this->validate();)
(...skipping 10 matching lines...) Expand all
562 GrPipelineBuilder pipelineBuilder(paint, useHWAA); 571 GrPipelineBuilder pipelineBuilder(paint, useHWAA);
563 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch) ; 572 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch) ;
564 return; 573 return;
565 } 574 }
566 } 575 }
567 576
568 if (should_apply_coverage_aa(paint, fRenderTarget.get(), &useHWAA) && 577 if (should_apply_coverage_aa(paint, fRenderTarget.get(), &useHWAA) &&
569 view_matrix_ok_for_aa_fill_rect(viewMatrix)) { 578 view_matrix_ok_for_aa_fill_rect(viewMatrix)) {
570 batch.reset(GrAAFillRectBatch::Create(paint.getColor(), viewMatrix, loca lMatrix, 579 batch.reset(GrAAFillRectBatch::Create(paint.getColor(), viewMatrix, loca lMatrix,
571 rectToDraw)); 580 rectToDraw));
581 GrPipelineBuilder pipelineBuilder(paint, useHWAA);
582 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch);
572 } else { 583 } else {
573 batch.reset(GrRectBatchFactory::CreateNonAAFill(paint.getColor(), viewMa trix, rectToDraw, 584 this->drawNonAAFilledRect(clip, paint, viewMatrix, rectToDraw, nullptr,
574 nullptr, &localMatrix)); 585 &localMatrix, nullptr);
575 } 586 }
576 587
577 GrPipelineBuilder pipelineBuilder(paint, useHWAA);
578 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch);
579 } 588 }
580 589
581 void GrDrawContext::drawVertices(const GrClip& clip, 590 void GrDrawContext::drawVertices(const GrClip& clip,
582 const GrPaint& paint, 591 const GrPaint& paint,
583 const SkMatrix& viewMatrix, 592 const SkMatrix& viewMatrix,
584 GrPrimitiveType primitiveType, 593 GrPrimitiveType primitiveType,
585 int vertexCount, 594 int vertexCount,
586 const SkPoint positions[], 595 const SkPoint positions[],
587 const SkPoint texCoords[], 596 const SkPoint texCoords[],
588 const GrColor colors[], 597 const GrColor colors[],
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
865 874
866 SkAutoTUnref<GrDrawBatch> batch(GrNinePatch::CreateNonAA(paint.getColor(), v iewMatrix, 875 SkAutoTUnref<GrDrawBatch> batch(GrNinePatch::CreateNonAA(paint.getColor(), v iewMatrix,
867 imageWidth, imageHe ight, 876 imageWidth, imageHe ight,
868 center, dst)); 877 center, dst));
869 878
870 GrPipelineBuilder pipelineBuilder(paint, this->mustUseHWAA(paint)); 879 GrPipelineBuilder pipelineBuilder(paint, this->mustUseHWAA(paint));
871 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch); 880 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch);
872 } 881 }
873 882
874 883
884 void GrDrawContext::drawNonAAFilledRect(const GrClip& clip,
885 const GrPaint& paint,
886 const SkMatrix& viewMatrix,
887 const SkRect& rect,
888 const SkRect* localRect,
889 const SkMatrix* localMatrix,
890 const GrUserStencilSettings* ss) {
891 SkAutoTUnref<GrDrawBatch> batch(
892 GrRectBatchFactory::CreateNonAAFill(paint.getColor(), viewMatrix, re ct, localRect,
893 localMatrix));
894 GrPipelineBuilder pipelineBuilder(paint, this->mustUseHWAA(paint));
895 if (ss) {
896 pipelineBuilder.setUserStencil(ss);
897 }
898 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch);
899 }
900
875 // Can 'path' be drawn as a pair of filled nested rectangles? 901 // 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]) { 902 static bool fills_as_nested_rects(const SkMatrix& viewMatrix, const SkPath& path , SkRect rects[2]) {
877 903
878 if (path.isInverseFillType()) { 904 if (path.isInverseFillType()) {
879 return false; 905 return false;
880 } 906 }
881 907
882 // TODO: this restriction could be lifted if we were willing to apply 908 // 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 909 // the matrix to all the points individually rather than just to the rect
884 if (!viewMatrix.rectStaysRect()) { 910 if (!viewMatrix.rectStaysRect()) {
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
1118 1144
1119 void GrDrawContext::drawBatch(const GrPipelineBuilder& pipelineBuilder, const Gr Clip& clip, 1145 void GrDrawContext::drawBatch(const GrPipelineBuilder& pipelineBuilder, const Gr Clip& clip,
1120 GrDrawBatch* batch) { 1146 GrDrawBatch* batch) {
1121 ASSERT_SINGLE_OWNER 1147 ASSERT_SINGLE_OWNER
1122 RETURN_IF_ABANDONED 1148 RETURN_IF_ABANDONED
1123 SkDEBUGCODE(this->validate();) 1149 SkDEBUGCODE(this->validate();)
1124 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawBatch"); 1150 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawBatch");
1125 1151
1126 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch); 1152 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch);
1127 } 1153 }
OLDNEW
« no previous file with comments | « src/gpu/GrClipMaskManager.h ('k') | src/gpu/GrDrawTarget.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698