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 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 RETURN_IF_ABANDONED | 330 RETURN_IF_ABANDONED |
331 SkDEBUGCODE(this->validate();) | 331 SkDEBUGCODE(this->validate();) |
332 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawRect"); | 332 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawRect"); |
333 | 333 |
334 // Path effects should've been devolved to a path in SkGpuDevice | 334 // Path effects should've been devolved to a path in SkGpuDevice |
335 SkASSERT(!style->pathEffect()); | 335 SkASSERT(!style->pathEffect()); |
336 | 336 |
337 AutoCheckFlush acf(fDrawingManager); | 337 AutoCheckFlush acf(fDrawingManager); |
338 | 338 |
339 const SkStrokeRec& stroke = style->strokeRec(); | 339 const SkStrokeRec& stroke = style->strokeRec(); |
340 if (stroke.getStyle() == SkStrokeRec::kFill_Style && | 340 if (stroke.getStyle() == SkStrokeRec::kFill_Style) { |
341 !fContext->caps()->useDrawInsteadOfClear()) { | 341 |
342 // Check if this is a full RT draw and can be replaced with a clear. We
don't bother | 342 if (!fContext->caps()->useDrawInsteadOfClear()) { |
343 // checking cases where the RT is fully inside a stroke. | 343 // Check if this is a full RT draw and can be replaced with a clear.
We don't bother |
344 SkRect rtRect; | 344 // checking cases where the RT is fully inside a stroke. |
345 fRenderTarget->getBoundsRect(&rtRect); | 345 SkRect rtRect; |
346 // Does the clip contain the entire RT? | 346 fRenderTarget->getBoundsRect(&rtRect); |
347 if (clip.quickContains(rtRect)) { | 347 // Does the clip contain the entire RT? |
348 SkMatrix invM; | 348 if (clip.quickContains(rtRect)) { |
349 if (!viewMatrix.invert(&invM)) { | 349 SkMatrix invM; |
350 return; | 350 if (!viewMatrix.invert(&invM)) { |
351 } | |
352 // Does the rect bound the RT? | |
353 SkPoint srcSpaceRTQuad[4]; | |
354 invM.mapRectToQuad(srcSpaceRTQuad, rtRect); | |
355 if (rect_contains_inclusive(rect, srcSpaceRTQuad[0]) && | |
356 rect_contains_inclusive(rect, srcSpaceRTQuad[1]) && | |
357 rect_contains_inclusive(rect, srcSpaceRTQuad[2]) && | |
358 rect_contains_inclusive(rect, srcSpaceRTQuad[3])) { | |
359 // Will it blend? | |
360 GrColor clearColor; | |
361 if (paint.isConstantBlendedColor(&clearColor)) { | |
362 this->getDrawTarget()->clear(nullptr, clearColor, true, this
); | |
363 return; | 351 return; |
364 } | 352 } |
| 353 // Does the rect bound the RT? |
| 354 SkPoint srcSpaceRTQuad[4]; |
| 355 invM.mapRectToQuad(srcSpaceRTQuad, rtRect); |
| 356 if (rect_contains_inclusive(rect, srcSpaceRTQuad[0]) && |
| 357 rect_contains_inclusive(rect, srcSpaceRTQuad[1]) && |
| 358 rect_contains_inclusive(rect, srcSpaceRTQuad[2]) && |
| 359 rect_contains_inclusive(rect, srcSpaceRTQuad[3])) { |
| 360 // Will it blend? |
| 361 GrColor clearColor; |
| 362 if (paint.isConstantBlendedColor(&clearColor)) { |
| 363 this->getDrawTarget()->clear(nullptr, clearColor, true,
this); |
| 364 return; |
| 365 } |
| 366 } |
365 } | 367 } |
366 } | 368 } |
367 | 369 |
368 if (this->drawFilledRect(clip, paint, viewMatrix, rect, nullptr)) { | 370 if (this->drawFilledRect(clip, paint, viewMatrix, rect, nullptr)) { |
369 return; | 371 return; |
370 } | 372 } |
371 } else if (stroke.getStyle() == SkStrokeRec::kStroke_Style || | 373 } else if (stroke.getStyle() == SkStrokeRec::kStroke_Style || |
372 stroke.getStyle() == SkStrokeRec::kHairline_Style) { | 374 stroke.getStyle() == SkStrokeRec::kHairline_Style) { |
373 if ((!rect.width() || !rect.height()) && | 375 if ((!rect.width() || !rect.height()) && |
374 SkStrokeRec::kHairline_Style != stroke.getStyle()) { | 376 SkStrokeRec::kHairline_Style != stroke.getStyle()) { |
(...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1144 | 1146 |
1145 void GrDrawContext::drawBatch(const GrPipelineBuilder& pipelineBuilder, const Gr
Clip& clip, | 1147 void GrDrawContext::drawBatch(const GrPipelineBuilder& pipelineBuilder, const Gr
Clip& clip, |
1146 GrDrawBatch* batch) { | 1148 GrDrawBatch* batch) { |
1147 ASSERT_SINGLE_OWNER | 1149 ASSERT_SINGLE_OWNER |
1148 RETURN_IF_ABANDONED | 1150 RETURN_IF_ABANDONED |
1149 SkDEBUGCODE(this->validate();) | 1151 SkDEBUGCODE(this->validate();) |
1150 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawBatch"); | 1152 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawBatch"); |
1151 | 1153 |
1152 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch); | 1154 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch); |
1153 } | 1155 } |
OLD | NEW |