OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2015 Google Inc. | 3 * Copyright 2015 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #include "GrAtlasTextContext.h" | 9 #include "GrAtlasTextContext.h" |
10 #include "GrBatchTest.h" | 10 #include "GrBatchTest.h" |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 const SkRect& rect, | 241 const SkRect& rect, |
242 const GrStrokeInfo* strokeInfo) { | 242 const GrStrokeInfo* strokeInfo) { |
243 RETURN_IF_ABANDONED | 243 RETURN_IF_ABANDONED |
244 SkDEBUGCODE(this->validate();) | 244 SkDEBUGCODE(this->validate();) |
245 | 245 |
246 // Dashing should've been devolved to a path in SkGpuDevice | 246 // Dashing should've been devolved to a path in SkGpuDevice |
247 SkASSERT(!strokeInfo || !strokeInfo->isDashed()); | 247 SkASSERT(!strokeInfo || !strokeInfo->isDashed()); |
248 | 248 |
249 AutoCheckFlush acf(fDrawingManager); | 249 AutoCheckFlush acf(fDrawingManager); |
250 | 250 |
251 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip); | |
252 | |
253 SkScalar width = nullptr == strokeInfo ? -1 : strokeInfo->getWidth(); | 251 SkScalar width = nullptr == strokeInfo ? -1 : strokeInfo->getWidth(); |
254 | 252 |
255 // Check if this is a full RT draw and can be replaced with a clear. We don'
t bother checking | 253 // Check if this is a full RT draw and can be replaced with a clear. We don'
t bother checking |
256 // cases where the RT is fully inside a stroke. | 254 // cases where the RT is fully inside a stroke. |
257 if (width < 0) { | 255 if (width < 0) { |
258 SkRect rtRect; | 256 SkRect rtRect; |
259 pipelineBuilder.getRenderTarget()->getBoundsRect(&rtRect); | 257 fRenderTarget->getBoundsRect(&rtRect); |
260 SkRect clipSpaceRTRect = rtRect; | 258 SkRect clipSpaceRTRect = rtRect; |
261 bool checkClip = GrClip::kWideOpen_ClipType != clip.clipType(); | 259 bool checkClip = GrClip::kWideOpen_ClipType != clip.clipType(); |
262 if (checkClip) { | 260 if (checkClip) { |
263 clipSpaceRTRect.offset(SkIntToScalar(clip.origin().fX), | 261 clipSpaceRTRect.offset(SkIntToScalar(clip.origin().fX), |
264 SkIntToScalar(clip.origin().fY)); | 262 SkIntToScalar(clip.origin().fY)); |
265 } | 263 } |
266 // Does the clip contain the entire RT? | 264 // Does the clip contain the entire RT? |
267 if (!checkClip || clip.quickContains(clipSpaceRTRect)) { | 265 if (!checkClip || clip.quickContains(clipSpaceRTRect)) { |
268 SkMatrix invM; | 266 SkMatrix invM; |
269 if (!viewMatrix.invert(&invM)) { | 267 if (!viewMatrix.invert(&invM)) { |
(...skipping 10 matching lines...) Expand all Loading... |
280 GrColor clearColor; | 278 GrColor clearColor; |
281 if (paint.isConstantBlendedColor(&clearColor)) { | 279 if (paint.isConstantBlendedColor(&clearColor)) { |
282 this->getDrawTarget()->clear(nullptr, clearColor, true, fRen
derTarget); | 280 this->getDrawTarget()->clear(nullptr, clearColor, true, fRen
derTarget); |
283 return; | 281 return; |
284 } | 282 } |
285 } | 283 } |
286 } | 284 } |
287 } | 285 } |
288 | 286 |
289 GrColor color = paint.getColor(); | 287 GrColor color = paint.getColor(); |
290 bool needAA = should_apply_coverage_aa(paint, pipelineBuilder.getRenderTarge
t()); | 288 bool needAA = should_apply_coverage_aa(paint, fRenderTarget); |
291 | 289 |
292 // The fill path can handle rotation but not skew | 290 // The fill path can handle rotation but not skew |
293 // The stroke path needs the rect to remain axis aligned (no rotation or ske
w) | 291 // The stroke path needs the rect to remain axis aligned (no rotation or ske
w) |
294 // None of our AA draw rect calls can handle perspective yet | 292 // None of our AA draw rect calls can handle perspective yet |
295 bool canApplyAA = width >=0 ? viewMatrix.rectStaysRect() : | 293 bool canApplyAA = width >=0 ? viewMatrix.rectStaysRect() : |
296 view_matrix_ok_for_aa_fill_rect(viewMatrix); | 294 view_matrix_ok_for_aa_fill_rect(viewMatrix); |
297 | 295 |
| 296 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip); |
| 297 |
298 if (needAA && canApplyAA) { | 298 if (needAA && canApplyAA) { |
299 SkASSERT(!viewMatrix.hasPerspective()); | 299 SkASSERT(!viewMatrix.hasPerspective()); |
300 SkAutoTUnref<GrDrawBatch> batch; | 300 SkAutoTUnref<GrDrawBatch> batch; |
301 if (width >= 0) { | 301 if (width >= 0) { |
302 batch.reset(GrRectBatchFactory::CreateAAStroke(color, viewMatrix, re
ct, *strokeInfo)); | 302 batch.reset(GrRectBatchFactory::CreateAAStroke(color, viewMatrix, re
ct, *strokeInfo)); |
303 } else { | 303 } else { |
304 SkRect devBoundRect; | 304 SkRect devBoundRect; |
305 viewMatrix.mapRect(&devBoundRect, rect); | 305 viewMatrix.mapRect(&devBoundRect, rect); |
306 batch.reset(GrRectBatchFactory::CreateAAFill(color, viewMatrix, rect
, devBoundRect)); | 306 batch.reset(GrRectBatchFactory::CreateAAFill(color, viewMatrix, rect
, devBoundRect)); |
307 } | 307 } |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 const GrPaint& paint, | 358 const GrPaint& paint, |
359 const SkMatrix& viewMatrix, | 359 const SkMatrix& viewMatrix, |
360 const SkRect& rectToDraw, | 360 const SkRect& rectToDraw, |
361 const SkMatrix& localMatrix) { | 361 const SkMatrix& localMatrix) { |
362 RETURN_IF_ABANDONED | 362 RETURN_IF_ABANDONED |
363 SkDEBUGCODE(this->validate();) | 363 SkDEBUGCODE(this->validate();) |
364 | 364 |
365 AutoCheckFlush acf(fDrawingManager); | 365 AutoCheckFlush acf(fDrawingManager); |
366 | 366 |
367 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip); | 367 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip); |
368 if (should_apply_coverage_aa(paint, pipelineBuilder.getRenderTarget()) && | 368 |
| 369 if (should_apply_coverage_aa(paint, fRenderTarget) && |
369 view_matrix_ok_for_aa_fill_rect(viewMatrix)) { | 370 view_matrix_ok_for_aa_fill_rect(viewMatrix)) { |
370 SkAutoTUnref<GrDrawBatch> batch(GrAAFillRectBatch::Create( | 371 SkAutoTUnref<GrDrawBatch> batch(GrAAFillRectBatch::Create( |
371 paint.getColor(), viewMatrix, localMatrix, rectToDraw)); | 372 paint.getColor(), viewMatrix, localMatrix, rectToDraw)); |
372 this->drawBatch(&pipelineBuilder, batch); | 373 this->drawBatch(&pipelineBuilder, batch); |
373 } else { | 374 } else { |
374 this->getDrawTarget()->drawNonAARect(pipelineBuilder, | 375 this->getDrawTarget()->drawNonAARect(pipelineBuilder, |
375 paint.getColor(), | 376 paint.getColor(), |
376 viewMatrix, | 377 viewMatrix, |
377 rectToDraw, | 378 rectToDraw, |
378 localMatrix); | 379 localMatrix); |
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
796 args.fAntiAlias = useCoverageAA; | 797 args.fAntiAlias = useCoverageAA; |
797 pr->drawPath(args); | 798 pr->drawPath(args); |
798 } | 799 } |
799 | 800 |
800 void GrDrawContext::drawBatch(GrPipelineBuilder* pipelineBuilder, GrDrawBatch* b
atch) { | 801 void GrDrawContext::drawBatch(GrPipelineBuilder* pipelineBuilder, GrDrawBatch* b
atch) { |
801 RETURN_IF_ABANDONED | 802 RETURN_IF_ABANDONED |
802 SkDEBUGCODE(this->validate();) | 803 SkDEBUGCODE(this->validate();) |
803 | 804 |
804 this->getDrawTarget()->drawBatch(*pipelineBuilder, batch); | 805 this->getDrawTarget()->drawBatch(*pipelineBuilder, batch); |
805 } | 806 } |
OLD | NEW |