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