| 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 private: | 50 private: |
| 51 GrDrawingManager* fDrawingManager; | 51 GrDrawingManager* fDrawingManager; |
| 52 }; | 52 }; |
| 53 | 53 |
| 54 // In MDB mode the reffing of the 'getLastDrawTarget' call's result allows in-pr
ogress | 54 // In MDB mode the reffing of the 'getLastDrawTarget' call's result allows in-pr
ogress |
| 55 // drawTargets to be picked up and added to by drawContexts lower in the call | 55 // drawTargets to be picked up and added to by drawContexts lower in the call |
| 56 // stack. When this occurs with a closed drawTarget, a new one will be allocated | 56 // stack. When this occurs with a closed drawTarget, a new one will be allocated |
| 57 // when the drawContext attempts to use it (via getDrawTarget). | 57 // when the drawContext attempts to use it (via getDrawTarget). |
| 58 GrDrawContext::GrDrawContext(GrContext* context, | 58 GrDrawContext::GrDrawContext(GrContext* context, |
| 59 GrDrawingManager* drawingMgr, | 59 GrDrawingManager* drawingMgr, |
| 60 GrRenderTarget* rt, | 60 sk_sp<GrRenderTarget> rt, |
| 61 const SkSurfaceProps* surfaceProps, | 61 const SkSurfaceProps* surfaceProps, |
| 62 GrAuditTrail* auditTrail, | 62 GrAuditTrail* auditTrail, |
| 63 GrSingleOwner* singleOwner) | 63 GrSingleOwner* singleOwner) |
| 64 : fDrawingManager(drawingMgr) | 64 : fDrawingManager(drawingMgr) |
| 65 , fRenderTarget(rt) | 65 , fRenderTarget(std::move(rt)) |
| 66 , fDrawTarget(SkSafeRef(rt->getLastDrawTarget())) | 66 , fDrawTarget(SkSafeRef(fRenderTarget->getLastDrawTarget())) |
| 67 , fContext(context) | 67 , fContext(context) |
| 68 , fSurfaceProps(SkSurfacePropsCopyOrDefault(surfaceProps)) | 68 , fSurfaceProps(SkSurfacePropsCopyOrDefault(surfaceProps)) |
| 69 , fAuditTrail(auditTrail) | 69 , fAuditTrail(auditTrail) |
| 70 #ifdef SK_DEBUG | 70 #ifdef SK_DEBUG |
| 71 , fSingleOwner(singleOwner) | 71 , fSingleOwner(singleOwner) |
| 72 #endif | 72 #endif |
| 73 { | 73 { |
| 74 SkDEBUGCODE(this->validate();) | 74 SkDEBUGCODE(this->validate();) |
| 75 } | 75 } |
| 76 | 76 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 88 GrDrawContext::~GrDrawContext() { | 88 GrDrawContext::~GrDrawContext() { |
| 89 ASSERT_SINGLE_OWNER | 89 ASSERT_SINGLE_OWNER |
| 90 SkSafeUnref(fDrawTarget); | 90 SkSafeUnref(fDrawTarget); |
| 91 } | 91 } |
| 92 | 92 |
| 93 GrDrawTarget* GrDrawContext::getDrawTarget() { | 93 GrDrawTarget* GrDrawContext::getDrawTarget() { |
| 94 ASSERT_SINGLE_OWNER | 94 ASSERT_SINGLE_OWNER |
| 95 SkDEBUGCODE(this->validate();) | 95 SkDEBUGCODE(this->validate();) |
| 96 | 96 |
| 97 if (!fDrawTarget || fDrawTarget->isClosed()) { | 97 if (!fDrawTarget || fDrawTarget->isClosed()) { |
| 98 fDrawTarget = fDrawingManager->newDrawTarget(fRenderTarget); | 98 fDrawTarget = fDrawingManager->newDrawTarget(fRenderTarget.get()); |
| 99 } | 99 } |
| 100 | 100 |
| 101 return fDrawTarget; | 101 return fDrawTarget; |
| 102 } | 102 } |
| 103 | 103 |
| 104 bool GrDrawContext::copySurface(GrSurface* src, const SkIRect& srcRect, const Sk
IPoint& dstPoint) { | 104 bool GrDrawContext::copySurface(GrSurface* src, const SkIRect& srcRect, const Sk
IPoint& dstPoint) { |
| 105 ASSERT_SINGLE_OWNER | 105 ASSERT_SINGLE_OWNER |
| 106 RETURN_FALSE_IF_ABANDONED | 106 RETURN_FALSE_IF_ABANDONED |
| 107 SkDEBUGCODE(this->validate();) | 107 SkDEBUGCODE(this->validate();) |
| 108 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::copySurface"); | 108 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::copySurface"); |
| 109 | 109 |
| 110 return this->getDrawTarget()->copySurface(fRenderTarget, src, srcRect, dstPo
int); | 110 return this->getDrawTarget()->copySurface(fRenderTarget.get(), src, srcRect,
dstPoint); |
| 111 } | 111 } |
| 112 | 112 |
| 113 void GrDrawContext::drawText(const GrClip& clip, const GrPaint& grPaint, | 113 void GrDrawContext::drawText(const GrClip& clip, const GrPaint& grPaint, |
| 114 const SkPaint& skPaint, | 114 const SkPaint& skPaint, |
| 115 const SkMatrix& viewMatrix, | 115 const SkMatrix& viewMatrix, |
| 116 const char text[], size_t byteLength, | 116 const char text[], size_t byteLength, |
| 117 SkScalar x, SkScalar y, const SkIRect& clipBounds)
{ | 117 SkScalar x, SkScalar y, const SkIRect& clipBounds)
{ |
| 118 ASSERT_SINGLE_OWNER | 118 ASSERT_SINGLE_OWNER |
| 119 RETURN_IF_ABANDONED | 119 RETURN_IF_ABANDONED |
| 120 SkDEBUGCODE(this->validate();) | 120 SkDEBUGCODE(this->validate();) |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 x, y, filter, clipBounds); | 166 x, y, filter, clipBounds); |
| 167 } | 167 } |
| 168 | 168 |
| 169 void GrDrawContext::discard() { | 169 void GrDrawContext::discard() { |
| 170 ASSERT_SINGLE_OWNER | 170 ASSERT_SINGLE_OWNER |
| 171 RETURN_IF_ABANDONED | 171 RETURN_IF_ABANDONED |
| 172 SkDEBUGCODE(this->validate();) | 172 SkDEBUGCODE(this->validate();) |
| 173 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::discard"); | 173 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::discard"); |
| 174 | 174 |
| 175 AutoCheckFlush acf(fDrawingManager); | 175 AutoCheckFlush acf(fDrawingManager); |
| 176 this->getDrawTarget()->discard(fRenderTarget); | 176 this->getDrawTarget()->discard(fRenderTarget.get()); |
| 177 } | 177 } |
| 178 | 178 |
| 179 void GrDrawContext::clear(const SkIRect* rect, | 179 void GrDrawContext::clear(const SkIRect* rect, |
| 180 const GrColor color, | 180 const GrColor color, |
| 181 bool canIgnoreRect) { | 181 bool canIgnoreRect) { |
| 182 ASSERT_SINGLE_OWNER | 182 ASSERT_SINGLE_OWNER |
| 183 RETURN_IF_ABANDONED | 183 RETURN_IF_ABANDONED |
| 184 SkDEBUGCODE(this->validate();) | 184 SkDEBUGCODE(this->validate();) |
| 185 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::clear"); | 185 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::clear"); |
| 186 | 186 |
| 187 AutoCheckFlush acf(fDrawingManager); | 187 AutoCheckFlush acf(fDrawingManager); |
| 188 this->getDrawTarget()->clear(rect, color, canIgnoreRect, fRenderTarget); | 188 this->getDrawTarget()->clear(rect, color, canIgnoreRect, fRenderTarget.get()
); |
| 189 } | 189 } |
| 190 | 190 |
| 191 | 191 |
| 192 void GrDrawContext::drawPaint(const GrClip& clip, | 192 void GrDrawContext::drawPaint(const GrClip& clip, |
| 193 const GrPaint& origPaint, | 193 const GrPaint& origPaint, |
| 194 const SkMatrix& viewMatrix) { | 194 const SkMatrix& viewMatrix) { |
| 195 ASSERT_SINGLE_OWNER | 195 ASSERT_SINGLE_OWNER |
| 196 RETURN_IF_ABANDONED | 196 RETURN_IF_ABANDONED |
| 197 SkDEBUGCODE(this->validate();) | 197 SkDEBUGCODE(this->validate();) |
| 198 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawPaint"); | 198 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawPaint"); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 228 if (!viewMatrix.invert(&localMatrix)) { | 228 if (!viewMatrix.invert(&localMatrix)) { |
| 229 SkDebugf("Could not invert matrix\n"); | 229 SkDebugf("Could not invert matrix\n"); |
| 230 return; | 230 return; |
| 231 } | 231 } |
| 232 | 232 |
| 233 AutoCheckFlush acf(fDrawingManager); | 233 AutoCheckFlush acf(fDrawingManager); |
| 234 | 234 |
| 235 SkAutoTUnref<GrDrawBatch> batch( | 235 SkAutoTUnref<GrDrawBatch> batch( |
| 236 GrRectBatchFactory::CreateNonAAFill(paint->getColor(), SkMatrix:
:I(), r, nullptr, | 236 GrRectBatchFactory::CreateNonAAFill(paint->getColor(), SkMatrix:
:I(), r, nullptr, |
| 237 &localMatrix)); | 237 &localMatrix)); |
| 238 GrPipelineBuilder pipelineBuilder(*paint, fRenderTarget, clip); | 238 GrPipelineBuilder pipelineBuilder(*paint, fRenderTarget.get(), clip); |
| 239 this->getDrawTarget()->drawBatch(pipelineBuilder, batch); | 239 this->getDrawTarget()->drawBatch(pipelineBuilder, batch); |
| 240 } | 240 } |
| 241 } | 241 } |
| 242 | 242 |
| 243 static inline bool rect_contains_inclusive(const SkRect& rect, const SkPoint& po
int) { | 243 static inline bool rect_contains_inclusive(const SkRect& rect, const SkPoint& po
int) { |
| 244 return point.fX >= rect.fLeft && point.fX <= rect.fRight && | 244 return point.fX >= rect.fLeft && point.fX <= rect.fRight && |
| 245 point.fY >= rect.fTop && point.fY <= rect.fBottom; | 245 point.fY >= rect.fTop && point.fY <= rect.fBottom; |
| 246 } | 246 } |
| 247 | 247 |
| 248 static bool view_matrix_ok_for_aa_fill_rect(const SkMatrix& viewMatrix) { | 248 static bool view_matrix_ok_for_aa_fill_rect(const SkMatrix& viewMatrix) { |
| 249 return viewMatrix.preservesRightAngles(); | 249 return viewMatrix.preservesRightAngles(); |
| 250 } | 250 } |
| 251 | 251 |
| 252 static bool should_apply_coverage_aa(const GrPaint& paint, GrRenderTarget* rt) { | 252 static bool should_apply_coverage_aa(const GrPaint& paint, GrRenderTarget* rt) { |
| 253 return paint.isAntiAlias() && !rt->isUnifiedMultisampled(); | 253 return paint.isAntiAlias() && !rt->isUnifiedMultisampled(); |
| 254 } | 254 } |
| 255 | 255 |
| 256 GrDrawBatch* GrDrawContext::getFillRectBatch(const GrPaint& paint, | 256 GrDrawBatch* GrDrawContext::getFillRectBatch(const GrPaint& paint, |
| 257 const SkMatrix& viewMatrix, | 257 const SkMatrix& viewMatrix, |
| 258 const SkRect& rect) { | 258 const SkRect& rect) { |
| 259 | 259 |
| 260 GrDrawBatch* batch = nullptr; | 260 GrDrawBatch* batch = nullptr; |
| 261 if (should_apply_coverage_aa(paint, fRenderTarget)) { | 261 if (should_apply_coverage_aa(paint, fRenderTarget.get())) { |
| 262 // The fill path can handle rotation but not skew. | 262 // The fill path can handle rotation but not skew. |
| 263 if (view_matrix_ok_for_aa_fill_rect(viewMatrix)) { | 263 if (view_matrix_ok_for_aa_fill_rect(viewMatrix)) { |
| 264 SkRect devBoundRect; | 264 SkRect devBoundRect; |
| 265 viewMatrix.mapRect(&devBoundRect, rect); | 265 viewMatrix.mapRect(&devBoundRect, rect); |
| 266 batch = GrRectBatchFactory::CreateAAFill(paint.getColor(), viewMatri
x, | 266 batch = GrRectBatchFactory::CreateAAFill(paint.getColor(), viewMatri
x, |
| 267 rect, devBoundRect); | 267 rect, devBoundRect); |
| 268 } | 268 } |
| 269 } else { | 269 } else { |
| 270 // filled BW rect | 270 // filled BW rect |
| 271 batch = GrRectBatchFactory::CreateNonAAFill(paint.getColor(), viewMatrix
, rect, | 271 batch = GrRectBatchFactory::CreateNonAAFill(paint.getColor(), viewMatrix
, rect, |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 // Does the rect bound the RT? | 312 // Does the rect bound the RT? |
| 313 SkPoint srcSpaceRTQuad[4]; | 313 SkPoint srcSpaceRTQuad[4]; |
| 314 invM.mapRectToQuad(srcSpaceRTQuad, rtRect); | 314 invM.mapRectToQuad(srcSpaceRTQuad, rtRect); |
| 315 if (rect_contains_inclusive(rect, srcSpaceRTQuad[0]) && | 315 if (rect_contains_inclusive(rect, srcSpaceRTQuad[0]) && |
| 316 rect_contains_inclusive(rect, srcSpaceRTQuad[1]) && | 316 rect_contains_inclusive(rect, srcSpaceRTQuad[1]) && |
| 317 rect_contains_inclusive(rect, srcSpaceRTQuad[2]) && | 317 rect_contains_inclusive(rect, srcSpaceRTQuad[2]) && |
| 318 rect_contains_inclusive(rect, srcSpaceRTQuad[3])) { | 318 rect_contains_inclusive(rect, srcSpaceRTQuad[3])) { |
| 319 // Will it blend? | 319 // Will it blend? |
| 320 GrColor clearColor; | 320 GrColor clearColor; |
| 321 if (paint.isConstantBlendedColor(&clearColor)) { | 321 if (paint.isConstantBlendedColor(&clearColor)) { |
| 322 this->getDrawTarget()->clear(nullptr, clearColor, true, fRen
derTarget); | 322 this->getDrawTarget()->clear(nullptr, clearColor, true, fRen
derTarget.get()); |
| 323 return; | 323 return; |
| 324 } | 324 } |
| 325 } | 325 } |
| 326 } | 326 } |
| 327 } | 327 } |
| 328 | 328 |
| 329 bool snapToPixelCenters = false; | 329 bool snapToPixelCenters = false; |
| 330 SkAutoTUnref<GrDrawBatch> batch; | 330 SkAutoTUnref<GrDrawBatch> batch; |
| 331 if (width < 0) { | 331 if (width < 0) { |
| 332 batch.reset(this->getFillRectBatch(paint, viewMatrix, rect)); | 332 batch.reset(this->getFillRectBatch(paint, viewMatrix, rect)); |
| 333 } else { | 333 } else { |
| 334 GrColor color = paint.getColor(); | 334 GrColor color = paint.getColor(); |
| 335 | 335 |
| 336 if (should_apply_coverage_aa(paint, fRenderTarget)) { | 336 if (should_apply_coverage_aa(paint, fRenderTarget.get())) { |
| 337 // The stroke path needs the rect to remain axis aligned (no rotatio
n or skew). | 337 // The stroke path needs the rect to remain axis aligned (no rotatio
n or skew). |
| 338 if (viewMatrix.rectStaysRect()) { | 338 if (viewMatrix.rectStaysRect()) { |
| 339 batch.reset(GrRectBatchFactory::CreateAAStroke(color, viewMatrix
, rect, | 339 batch.reset(GrRectBatchFactory::CreateAAStroke(color, viewMatrix
, rect, |
| 340 *strokeInfo)); | 340 *strokeInfo)); |
| 341 } | 341 } |
| 342 } else { | 342 } else { |
| 343 // Non-AA hairlines are snapped to pixel centers to make which pixel
s are hit | 343 // Non-AA hairlines are snapped to pixel centers to make which pixel
s are hit |
| 344 // deterministic | 344 // deterministic |
| 345 snapToPixelCenters = (0 == width && !fRenderTarget->isUnifiedMultisa
mpled()); | 345 snapToPixelCenters = (0 == width && !fRenderTarget->isUnifiedMultisa
mpled()); |
| 346 batch.reset(GrRectBatchFactory::CreateNonAAStroke(color, viewMatrix,
rect, | 346 batch.reset(GrRectBatchFactory::CreateNonAAStroke(color, viewMatrix,
rect, |
| 347 width, snapToPixel
Centers)); | 347 width, snapToPixel
Centers)); |
| 348 | 348 |
| 349 // Depending on sub-pixel coordinates and the particular GPU, we may
lose a corner of | 349 // Depending on sub-pixel coordinates and the particular GPU, we may
lose a corner of |
| 350 // hairline rects. We jam all the vertices to pixel centers to avoid
this, but not | 350 // hairline rects. We jam all the vertices to pixel centers to avoid
this, but not |
| 351 // when MSAA is enabled because it can cause ugly artifacts. | 351 // when MSAA is enabled because it can cause ugly artifacts. |
| 352 } | 352 } |
| 353 } | 353 } |
| 354 | 354 |
| 355 if (batch) { | 355 if (batch) { |
| 356 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip); | 356 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget.get(), clip); |
| 357 | 357 |
| 358 if (snapToPixelCenters) { | 358 if (snapToPixelCenters) { |
| 359 pipelineBuilder.setState(GrPipelineBuilder::kSnapVerticesToPixelCent
ers_Flag, | 359 pipelineBuilder.setState(GrPipelineBuilder::kSnapVerticesToPixelCent
ers_Flag, |
| 360 snapToPixelCenters); | 360 snapToPixelCenters); |
| 361 } | 361 } |
| 362 | 362 |
| 363 this->getDrawTarget()->drawBatch(pipelineBuilder, batch); | 363 this->getDrawTarget()->drawBatch(pipelineBuilder, batch); |
| 364 return; | 364 return; |
| 365 } | 365 } |
| 366 | 366 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 384 GR_AUDIT_TRAIL_AUTO_FRAME(fDrawContext->fAuditTrail, "GrDrawContext::stencil
Rect"); | 384 GR_AUDIT_TRAIL_AUTO_FRAME(fDrawContext->fAuditTrail, "GrDrawContext::stencil
Rect"); |
| 385 | 385 |
| 386 AutoCheckFlush acf(fDrawContext->fDrawingManager); | 386 AutoCheckFlush acf(fDrawContext->fDrawingManager); |
| 387 | 387 |
| 388 GrPaint paint; | 388 GrPaint paint; |
| 389 paint.setAntiAlias(doAA); | 389 paint.setAntiAlias(doAA); |
| 390 paint.setCoverageSetOpXPFactory(op, invert); | 390 paint.setCoverageSetOpXPFactory(op, invert); |
| 391 | 391 |
| 392 SkAutoTUnref<GrDrawBatch> batch(fDrawContext->getFillRectBatch(paint, viewMa
trix, rect)); | 392 SkAutoTUnref<GrDrawBatch> batch(fDrawContext->getFillRectBatch(paint, viewMa
trix, rect)); |
| 393 if (batch) { | 393 if (batch) { |
| 394 GrPipelineBuilder pipelineBuilder(paint, fDrawContext->fRenderTarget, Gr
Clip::WideOpen()); | 394 GrPipelineBuilder pipelineBuilder(paint, |
| 395 fDrawContext->accessRenderTarget(), |
| 396 GrClip::WideOpen()); |
| 395 pipelineBuilder.setStencil(ss); | 397 pipelineBuilder.setStencil(ss); |
| 396 | 398 |
| 397 fDrawContext->getDrawTarget()->drawBatch(pipelineBuilder, batch, scissor
Rect); | 399 fDrawContext->getDrawTarget()->drawBatch(pipelineBuilder, batch, scissor
Rect); |
| 398 return true; | 400 return true; |
| 399 } | 401 } |
| 400 | 402 |
| 401 SkPath path; | 403 SkPath path; |
| 402 path.setIsVolatile(true); | 404 path.setIsVolatile(true); |
| 403 path.addRect(rect); | 405 path.addRect(rect); |
| 404 return this->drawAndStencilPath(scissorRect, ss, op, invert, doAA, viewMatri
x, path); | 406 return this->drawAndStencilPath(scissorRect, ss, op, invert, doAA, viewMatri
x, path); |
| 405 } | 407 } |
| 406 | 408 |
| 407 void GrDrawContext::fillRectToRect(const GrClip& clip, | 409 void GrDrawContext::fillRectToRect(const GrClip& clip, |
| 408 const GrPaint& paint, | 410 const GrPaint& paint, |
| 409 const SkMatrix& viewMatrix, | 411 const SkMatrix& viewMatrix, |
| 410 const SkRect& rectToDraw, | 412 const SkRect& rectToDraw, |
| 411 const SkRect& localRect) { | 413 const SkRect& localRect) { |
| 412 ASSERT_SINGLE_OWNER | 414 ASSERT_SINGLE_OWNER |
| 413 RETURN_IF_ABANDONED | 415 RETURN_IF_ABANDONED |
| 414 SkDEBUGCODE(this->validate();) | 416 SkDEBUGCODE(this->validate();) |
| 415 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::fillRectToRect"); | 417 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::fillRectToRect"); |
| 416 | 418 |
| 417 AutoCheckFlush acf(fDrawingManager); | 419 AutoCheckFlush acf(fDrawingManager); |
| 418 | 420 |
| 419 SkAutoTUnref<GrDrawBatch> batch; | 421 SkAutoTUnref<GrDrawBatch> batch; |
| 420 if (should_apply_coverage_aa(paint, fRenderTarget) && | 422 if (should_apply_coverage_aa(paint, fRenderTarget.get()) && |
| 421 view_matrix_ok_for_aa_fill_rect(viewMatrix)) { | 423 view_matrix_ok_for_aa_fill_rect(viewMatrix)) { |
| 422 batch.reset(GrAAFillRectBatch::CreateWithLocalRect(paint.getColor(), vie
wMatrix, rectToDraw, | 424 batch.reset(GrAAFillRectBatch::CreateWithLocalRect(paint.getColor(), vie
wMatrix, rectToDraw, |
| 423 localRect)); | 425 localRect)); |
| 424 } else { | 426 } else { |
| 425 batch.reset(GrRectBatchFactory::CreateNonAAFill(paint.getColor(), viewMa
trix, rectToDraw, | 427 batch.reset(GrRectBatchFactory::CreateNonAAFill(paint.getColor(), viewMa
trix, rectToDraw, |
| 426 &localRect, nullptr)); | 428 &localRect, nullptr)); |
| 427 } | 429 } |
| 428 | 430 |
| 429 if (batch) { | 431 if (batch) { |
| 430 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip); | 432 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget.get(), clip); |
| 431 this->drawBatch(&pipelineBuilder, batch); | 433 this->drawBatch(&pipelineBuilder, batch); |
| 432 } | 434 } |
| 433 } | 435 } |
| 434 | 436 |
| 435 void GrDrawContext::fillRectWithLocalMatrix(const GrClip& clip, | 437 void GrDrawContext::fillRectWithLocalMatrix(const GrClip& clip, |
| 436 const GrPaint& paint, | 438 const GrPaint& paint, |
| 437 const SkMatrix& viewMatrix, | 439 const SkMatrix& viewMatrix, |
| 438 const SkRect& rectToDraw, | 440 const SkRect& rectToDraw, |
| 439 const SkMatrix& localMatrix) { | 441 const SkMatrix& localMatrix) { |
| 440 ASSERT_SINGLE_OWNER | 442 ASSERT_SINGLE_OWNER |
| 441 RETURN_IF_ABANDONED | 443 RETURN_IF_ABANDONED |
| 442 SkDEBUGCODE(this->validate();) | 444 SkDEBUGCODE(this->validate();) |
| 443 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::fillRectWithLocalMatr
ix"); | 445 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::fillRectWithLocalMatr
ix"); |
| 444 | 446 |
| 445 AutoCheckFlush acf(fDrawingManager); | 447 AutoCheckFlush acf(fDrawingManager); |
| 446 | 448 |
| 447 SkAutoTUnref<GrDrawBatch> batch; | 449 SkAutoTUnref<GrDrawBatch> batch; |
| 448 if (should_apply_coverage_aa(paint, fRenderTarget) && | 450 if (should_apply_coverage_aa(paint, fRenderTarget.get()) && |
| 449 view_matrix_ok_for_aa_fill_rect(viewMatrix)) { | 451 view_matrix_ok_for_aa_fill_rect(viewMatrix)) { |
| 450 batch.reset(GrAAFillRectBatch::Create(paint.getColor(), viewMatrix, loca
lMatrix, | 452 batch.reset(GrAAFillRectBatch::Create(paint.getColor(), viewMatrix, loca
lMatrix, |
| 451 rectToDraw)); | 453 rectToDraw)); |
| 452 } else { | 454 } else { |
| 453 batch.reset(GrRectBatchFactory::CreateNonAAFill(paint.getColor(), viewMa
trix, rectToDraw, | 455 batch.reset(GrRectBatchFactory::CreateNonAAFill(paint.getColor(), viewMa
trix, rectToDraw, |
| 454 nullptr, &localMatrix)); | 456 nullptr, &localMatrix)); |
| 455 } | 457 } |
| 456 | 458 |
| 457 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip); | 459 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget.get(), clip); |
| 458 this->getDrawTarget()->drawBatch(pipelineBuilder, batch); | 460 this->getDrawTarget()->drawBatch(pipelineBuilder, batch); |
| 459 } | 461 } |
| 460 | 462 |
| 461 void GrDrawContext::drawVertices(const GrClip& clip, | 463 void GrDrawContext::drawVertices(const GrClip& clip, |
| 462 const GrPaint& paint, | 464 const GrPaint& paint, |
| 463 const SkMatrix& viewMatrix, | 465 const SkMatrix& viewMatrix, |
| 464 GrPrimitiveType primitiveType, | 466 GrPrimitiveType primitiveType, |
| 465 int vertexCount, | 467 int vertexCount, |
| 466 const SkPoint positions[], | 468 const SkPoint positions[], |
| 467 const SkPoint texCoords[], | 469 const SkPoint texCoords[], |
| (...skipping 24 matching lines...) Expand all Loading... |
| 492 bounds.outset(0.5f, 0.5f); | 494 bounds.outset(0.5f, 0.5f); |
| 493 } | 495 } |
| 494 | 496 |
| 495 GrDrawVerticesBatch::Geometry geometry; | 497 GrDrawVerticesBatch::Geometry geometry; |
| 496 geometry.fColor = paint.getColor(); | 498 geometry.fColor = paint.getColor(); |
| 497 SkAutoTUnref<GrDrawBatch> batch(GrDrawVerticesBatch::Create(geometry, primit
iveType, viewMatrix, | 499 SkAutoTUnref<GrDrawBatch> batch(GrDrawVerticesBatch::Create(geometry, primit
iveType, viewMatrix, |
| 498 positions, verte
xCount, indices, | 500 positions, verte
xCount, indices, |
| 499 indexCount, colo
rs, texCoords, | 501 indexCount, colo
rs, texCoords, |
| 500 bounds)); | 502 bounds)); |
| 501 | 503 |
| 502 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip); | 504 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget.get(), clip); |
| 503 this->getDrawTarget()->drawBatch(pipelineBuilder, batch); | 505 this->getDrawTarget()->drawBatch(pipelineBuilder, batch); |
| 504 } | 506 } |
| 505 | 507 |
| 506 /////////////////////////////////////////////////////////////////////////////// | 508 /////////////////////////////////////////////////////////////////////////////// |
| 507 | 509 |
| 508 void GrDrawContext::drawAtlas(const GrClip& clip, | 510 void GrDrawContext::drawAtlas(const GrClip& clip, |
| 509 const GrPaint& paint, | 511 const GrPaint& paint, |
| 510 const SkMatrix& viewMatrix, | 512 const SkMatrix& viewMatrix, |
| 511 int spriteCount, | 513 int spriteCount, |
| 512 const SkRSXform xform[], | 514 const SkRSXform xform[], |
| 513 const SkRect texRect[], | 515 const SkRect texRect[], |
| 514 const SkColor colors[]) { | 516 const SkColor colors[]) { |
| 515 ASSERT_SINGLE_OWNER | 517 ASSERT_SINGLE_OWNER |
| 516 RETURN_IF_ABANDONED | 518 RETURN_IF_ABANDONED |
| 517 SkDEBUGCODE(this->validate();) | 519 SkDEBUGCODE(this->validate();) |
| 518 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawAtlas"); | 520 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawAtlas"); |
| 519 | 521 |
| 520 AutoCheckFlush acf(fDrawingManager); | 522 AutoCheckFlush acf(fDrawingManager); |
| 521 | 523 |
| 522 GrDrawAtlasBatch::Geometry geometry; | 524 GrDrawAtlasBatch::Geometry geometry; |
| 523 geometry.fColor = paint.getColor(); | 525 geometry.fColor = paint.getColor(); |
| 524 SkAutoTUnref<GrDrawBatch> batch(GrDrawAtlasBatch::Create(geometry, viewMatri
x, spriteCount, | 526 SkAutoTUnref<GrDrawBatch> batch(GrDrawAtlasBatch::Create(geometry, viewMatri
x, spriteCount, |
| 525 xform, texRect, col
ors)); | 527 xform, texRect, col
ors)); |
| 526 | 528 |
| 527 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip); | 529 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget.get(), clip); |
| 528 this->getDrawTarget()->drawBatch(pipelineBuilder, batch); | 530 this->getDrawTarget()->drawBatch(pipelineBuilder, batch); |
| 529 } | 531 } |
| 530 | 532 |
| 531 /////////////////////////////////////////////////////////////////////////////// | 533 /////////////////////////////////////////////////////////////////////////////// |
| 532 | 534 |
| 533 void GrDrawContext::drawRRect(const GrClip& clip, | 535 void GrDrawContext::drawRRect(const GrClip& clip, |
| 534 const GrPaint& paint, | 536 const GrPaint& paint, |
| 535 const SkMatrix& viewMatrix, | 537 const SkMatrix& viewMatrix, |
| 536 const SkRRect& rrect, | 538 const SkRRect& rrect, |
| 537 const GrStrokeInfo& strokeInfo) { | 539 const GrStrokeInfo& strokeInfo) { |
| 538 ASSERT_SINGLE_OWNER | 540 ASSERT_SINGLE_OWNER |
| 539 RETURN_IF_ABANDONED | 541 RETURN_IF_ABANDONED |
| 540 SkDEBUGCODE(this->validate();) | 542 SkDEBUGCODE(this->validate();) |
| 541 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawRRect"); | 543 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawRRect"); |
| 542 | 544 |
| 543 if (rrect.isEmpty()) { | 545 if (rrect.isEmpty()) { |
| 544 return; | 546 return; |
| 545 } | 547 } |
| 546 | 548 |
| 547 SkASSERT(!strokeInfo.isDashed()); // this should've been devolved to a path
in SkGpuDevice | 549 SkASSERT(!strokeInfo.isDashed()); // this should've been devolved to a path
in SkGpuDevice |
| 548 | 550 |
| 549 AutoCheckFlush acf(fDrawingManager); | 551 AutoCheckFlush acf(fDrawingManager); |
| 550 | 552 |
| 551 if (should_apply_coverage_aa(paint, fRenderTarget)) { | 553 if (should_apply_coverage_aa(paint, fRenderTarget.get())) { |
| 552 GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps(); | 554 GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps(); |
| 553 | 555 |
| 554 SkAutoTUnref<GrDrawBatch> batch(GrOvalRenderer::CreateRRectBatch(paint.g
etColor(), | 556 SkAutoTUnref<GrDrawBatch> batch(GrOvalRenderer::CreateRRectBatch(paint.g
etColor(), |
| 555 viewMat
rix, | 557 viewMat
rix, |
| 556 rrect, | 558 rrect, |
| 557 strokeI
nfo, | 559 strokeI
nfo, |
| 558 shaderC
aps)); | 560 shaderC
aps)); |
| 559 if (batch) { | 561 if (batch) { |
| 560 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip); | 562 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget.get(), clip); |
| 561 this->getDrawTarget()->drawBatch(pipelineBuilder, batch); | 563 this->getDrawTarget()->drawBatch(pipelineBuilder, batch); |
| 562 return; | 564 return; |
| 563 } | 565 } |
| 564 } | 566 } |
| 565 | 567 |
| 566 SkPath path; | 568 SkPath path; |
| 567 path.setIsVolatile(true); | 569 path.setIsVolatile(true); |
| 568 path.addRRect(rrect); | 570 path.addRRect(rrect); |
| 569 this->internalDrawPath(clip, paint, viewMatrix, path, strokeInfo); | 571 this->internalDrawPath(clip, paint, viewMatrix, path, strokeInfo); |
| 570 } | 572 } |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 644 if (this->drawFilledDRRect(clip, paint, viewMatrix, outer, inner)) { | 646 if (this->drawFilledDRRect(clip, paint, viewMatrix, outer, inner)) { |
| 645 return; | 647 return; |
| 646 } | 648 } |
| 647 | 649 |
| 648 SkPath path; | 650 SkPath path; |
| 649 path.setIsVolatile(true); | 651 path.setIsVolatile(true); |
| 650 path.addRRect(inner); | 652 path.addRRect(inner); |
| 651 path.addRRect(outer); | 653 path.addRRect(outer); |
| 652 path.setFillType(SkPath::kEvenOdd_FillType); | 654 path.setFillType(SkPath::kEvenOdd_FillType); |
| 653 | 655 |
| 654 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip); | 656 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget.get(), clip); |
| 655 this->internalDrawPath(clip, paint, viewMatrix, path, GrStrokeInfo::FillInfo
()); | 657 this->internalDrawPath(clip, paint, viewMatrix, path, GrStrokeInfo::FillInfo
()); |
| 656 } | 658 } |
| 657 | 659 |
| 658 /////////////////////////////////////////////////////////////////////////////// | 660 /////////////////////////////////////////////////////////////////////////////// |
| 659 | 661 |
| 660 void GrDrawContext::drawOval(const GrClip& clip, | 662 void GrDrawContext::drawOval(const GrClip& clip, |
| 661 const GrPaint& paint, | 663 const GrPaint& paint, |
| 662 const SkMatrix& viewMatrix, | 664 const SkMatrix& viewMatrix, |
| 663 const SkRect& oval, | 665 const SkRect& oval, |
| 664 const GrStrokeInfo& strokeInfo) { | 666 const GrStrokeInfo& strokeInfo) { |
| 665 ASSERT_SINGLE_OWNER | 667 ASSERT_SINGLE_OWNER |
| 666 RETURN_IF_ABANDONED | 668 RETURN_IF_ABANDONED |
| 667 SkDEBUGCODE(this->validate();) | 669 SkDEBUGCODE(this->validate();) |
| 668 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawOval"); | 670 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawOval"); |
| 669 | 671 |
| 670 if (oval.isEmpty()) { | 672 if (oval.isEmpty()) { |
| 671 return; | 673 return; |
| 672 } | 674 } |
| 673 | 675 |
| 674 SkASSERT(!strokeInfo.isDashed()); // this should've been devolved to a path
in SkGpuDevice | 676 SkASSERT(!strokeInfo.isDashed()); // this should've been devolved to a path
in SkGpuDevice |
| 675 | 677 |
| 676 AutoCheckFlush acf(fDrawingManager); | 678 AutoCheckFlush acf(fDrawingManager); |
| 677 | 679 |
| 678 if (should_apply_coverage_aa(paint, fRenderTarget)) { | 680 if (should_apply_coverage_aa(paint, fRenderTarget.get())) { |
| 679 GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps(); | 681 GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps(); |
| 680 SkAutoTUnref<GrDrawBatch> batch(GrOvalRenderer::CreateOvalBatch(paint.ge
tColor(), | 682 SkAutoTUnref<GrDrawBatch> batch(GrOvalRenderer::CreateOvalBatch(paint.ge
tColor(), |
| 681 viewMatr
ix, | 683 viewMatr
ix, |
| 682 oval, | 684 oval, |
| 683 strokeIn
fo, | 685 strokeIn
fo, |
| 684 shaderCa
ps)); | 686 shaderCa
ps)); |
| 685 if (batch) { | 687 if (batch) { |
| 686 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip); | 688 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget.get(), clip); |
| 687 this->getDrawTarget()->drawBatch(pipelineBuilder, batch); | 689 this->getDrawTarget()->drawBatch(pipelineBuilder, batch); |
| 688 return; | 690 return; |
| 689 } | 691 } |
| 690 } | 692 } |
| 691 | 693 |
| 692 SkPath path; | 694 SkPath path; |
| 693 path.setIsVolatile(true); | 695 path.setIsVolatile(true); |
| 694 path.addOval(oval); | 696 path.addOval(oval); |
| 695 this->internalDrawPath(clip, paint, viewMatrix, path, strokeInfo); | 697 this->internalDrawPath(clip, paint, viewMatrix, path, strokeInfo); |
| 696 } | 698 } |
| 697 | 699 |
| 698 void GrDrawContext::drawImageNine(const GrClip& clip, | 700 void GrDrawContext::drawImageNine(const GrClip& clip, |
| 699 const GrPaint& paint, | 701 const GrPaint& paint, |
| 700 const SkMatrix& viewMatrix, | 702 const SkMatrix& viewMatrix, |
| 701 int imageWidth, | 703 int imageWidth, |
| 702 int imageHeight, | 704 int imageHeight, |
| 703 const SkIRect& center, | 705 const SkIRect& center, |
| 704 const SkRect& dst) { | 706 const SkRect& dst) { |
| 705 ASSERT_SINGLE_OWNER | 707 ASSERT_SINGLE_OWNER |
| 706 RETURN_IF_ABANDONED | 708 RETURN_IF_ABANDONED |
| 707 SkDEBUGCODE(this->validate();) | 709 SkDEBUGCODE(this->validate();) |
| 708 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawImageNine"); | 710 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawImageNine"); |
| 709 | 711 |
| 710 AutoCheckFlush acf(fDrawingManager); | 712 AutoCheckFlush acf(fDrawingManager); |
| 711 | 713 |
| 712 SkAutoTUnref<GrDrawBatch> batch(GrNinePatch::CreateNonAA(paint.getColor(), v
iewMatrix, | 714 SkAutoTUnref<GrDrawBatch> batch(GrNinePatch::CreateNonAA(paint.getColor(), v
iewMatrix, |
| 713 imageWidth, imageHe
ight, | 715 imageWidth, imageHe
ight, |
| 714 center, dst)); | 716 center, dst)); |
| 715 | 717 |
| 716 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip); | 718 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget.get(), clip); |
| 717 this->getDrawTarget()->drawBatch(pipelineBuilder, batch); | 719 this->getDrawTarget()->drawBatch(pipelineBuilder, batch); |
| 718 } | 720 } |
| 719 | 721 |
| 720 | 722 |
| 721 // Can 'path' be drawn as a pair of filled nested rectangles? | 723 // Can 'path' be drawn as a pair of filled nested rectangles? |
| 722 static bool is_nested_rects(const SkMatrix& viewMatrix, | 724 static bool is_nested_rects(const SkMatrix& viewMatrix, |
| 723 const SkPath& path, | 725 const SkPath& path, |
| 724 const SkStrokeRec& stroke, | 726 const SkStrokeRec& stroke, |
| 725 SkRect rects[2]) { | 727 SkRect rects[2]) { |
| 726 SkASSERT(stroke.isFillStyle()); | 728 SkASSERT(stroke.isFillStyle()); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 770 | 772 |
| 771 void GrDrawContext::drawBatch(const GrClip& clip, | 773 void GrDrawContext::drawBatch(const GrClip& clip, |
| 772 const GrPaint& paint, GrDrawBatch* batch) { | 774 const GrPaint& paint, GrDrawBatch* batch) { |
| 773 ASSERT_SINGLE_OWNER | 775 ASSERT_SINGLE_OWNER |
| 774 RETURN_IF_ABANDONED | 776 RETURN_IF_ABANDONED |
| 775 SkDEBUGCODE(this->validate();) | 777 SkDEBUGCODE(this->validate();) |
| 776 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawBatch"); | 778 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawBatch"); |
| 777 | 779 |
| 778 AutoCheckFlush acf(fDrawingManager); | 780 AutoCheckFlush acf(fDrawingManager); |
| 779 | 781 |
| 780 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip); | 782 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget.get(), clip); |
| 781 this->getDrawTarget()->drawBatch(pipelineBuilder, batch); | 783 this->getDrawTarget()->drawBatch(pipelineBuilder, batch); |
| 782 } | 784 } |
| 783 | 785 |
| 784 void GrDrawContext::drawPathBatch(const GrPipelineBuilder& pipelineBuilder, | 786 void GrDrawContext::drawPathBatch(const GrPipelineBuilder& pipelineBuilder, |
| 785 GrDrawPathBatchBase* batch) { | 787 GrDrawPathBatchBase* batch) { |
| 786 ASSERT_SINGLE_OWNER | 788 ASSERT_SINGLE_OWNER |
| 787 RETURN_IF_ABANDONED | 789 RETURN_IF_ABANDONED |
| 788 SkDEBUGCODE(this->validate();) | 790 SkDEBUGCODE(this->validate();) |
| 789 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawPathBatch"); | 791 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawPathBatch"); |
| 790 | 792 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 805 | 807 |
| 806 if (path.isEmpty()) { | 808 if (path.isEmpty()) { |
| 807 if (path.isInverseFillType()) { | 809 if (path.isInverseFillType()) { |
| 808 this->drawPaint(clip, paint, viewMatrix); | 810 this->drawPaint(clip, paint, viewMatrix); |
| 809 } | 811 } |
| 810 return; | 812 return; |
| 811 } | 813 } |
| 812 | 814 |
| 813 AutoCheckFlush acf(fDrawingManager); | 815 AutoCheckFlush acf(fDrawingManager); |
| 814 | 816 |
| 815 if (should_apply_coverage_aa(paint, fRenderTarget) && !strokeInfo.isDashed()
) { | 817 if (should_apply_coverage_aa(paint, fRenderTarget.get()) && !strokeInfo.isDa
shed()) { |
| 816 if (strokeInfo.getWidth() < 0 && !path.isConvex()) { | 818 if (strokeInfo.getWidth() < 0 && !path.isConvex()) { |
| 817 // Concave AA paths are expensive - try to avoid them for special ca
ses | 819 // Concave AA paths are expensive - try to avoid them for special ca
ses |
| 818 SkRect rects[2]; | 820 SkRect rects[2]; |
| 819 | 821 |
| 820 if (is_nested_rects(viewMatrix, path, strokeInfo, rects)) { | 822 if (is_nested_rects(viewMatrix, path, strokeInfo, rects)) { |
| 821 SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateAAFill
NestedRects( | 823 SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateAAFill
NestedRects( |
| 822 paint.getColor(), viewMatrix, rects)); | 824 paint.getColor(), viewMatrix, rects)); |
| 823 | 825 |
| 824 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip); | 826 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget.get(), cl
ip); |
| 825 this->getDrawTarget()->drawBatch(pipelineBuilder, batch); | 827 this->getDrawTarget()->drawBatch(pipelineBuilder, batch); |
| 826 return; | 828 return; |
| 827 } | 829 } |
| 828 } | 830 } |
| 829 SkRect ovalRect; | 831 SkRect ovalRect; |
| 830 bool isOval = path.isOval(&ovalRect); | 832 bool isOval = path.isOval(&ovalRect); |
| 831 | 833 |
| 832 if (isOval && !path.isInverseFillType()) { | 834 if (isOval && !path.isInverseFillType()) { |
| 833 GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps(); | 835 GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps(); |
| 834 SkAutoTUnref<GrDrawBatch> batch(GrOvalRenderer::CreateOvalBatch(pain
t.getColor(), | 836 SkAutoTUnref<GrDrawBatch> batch(GrOvalRenderer::CreateOvalBatch(pain
t.getColor(), |
| 835 view
Matrix, | 837 view
Matrix, |
| 836 oval
Rect, | 838 oval
Rect, |
| 837 stro
keInfo, | 839 stro
keInfo, |
| 838 shad
erCaps)); | 840 shad
erCaps)); |
| 839 if (batch) { | 841 if (batch) { |
| 840 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip); | 842 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget.get(), cl
ip); |
| 841 this->getDrawTarget()->drawBatch(pipelineBuilder, batch); | 843 this->getDrawTarget()->drawBatch(pipelineBuilder, batch); |
| 842 return; | 844 return; |
| 843 } | 845 } |
| 844 } | 846 } |
| 845 } | 847 } |
| 846 | 848 |
| 847 // Note that internalDrawPath may sw-rasterize the path into a scratch textu
re. | 849 // Note that internalDrawPath may sw-rasterize the path into a scratch textu
re. |
| 848 // Scratch textures can be recycled after they are returned to the texture | 850 // Scratch textures can be recycled after they are returned to the texture |
| 849 // cache. This presents a potential hazard for buffered drawing. However, | 851 // cache. This presents a potential hazard for buffered drawing. However, |
| 850 // the writePixels that uploads to the scratch will perform a flush so we're | 852 // the writePixels that uploads to the scratch will perform a flush so we're |
| 851 // OK. | 853 // OK. |
| 852 this->internalDrawPath(clip, paint, viewMatrix, path, strokeInfo); | 854 this->internalDrawPath(clip, paint, viewMatrix, path, strokeInfo); |
| 853 } | 855 } |
| 854 | 856 |
| 855 bool GrDrawContextPriv::drawAndStencilPath(const SkIRect* scissorRect, | 857 bool GrDrawContextPriv::drawAndStencilPath(const SkIRect* scissorRect, |
| 856 const GrStencilSettings& ss, | 858 const GrStencilSettings& ss, |
| 857 SkRegion::Op op, | 859 SkRegion::Op op, |
| 858 bool invert, | 860 bool invert, |
| 859 bool doAA, | 861 bool doAA, |
| 860 const SkMatrix& viewMatrix, | 862 const SkMatrix& viewMatrix, |
| 861 const SkPath& path) { | 863 const SkPath& path) { |
| 862 ASSERT_SINGLE_OWNER_PRIV | 864 ASSERT_SINGLE_OWNER_PRIV |
| 863 RETURN_FALSE_IF_ABANDONED_PRIV | 865 RETURN_FALSE_IF_ABANDONED_PRIV |
| 864 SkDEBUGCODE(fDrawContext->validate();) | 866 SkDEBUGCODE(fDrawContext->validate();) |
| 865 GR_AUDIT_TRAIL_AUTO_FRAME(fDrawContext->fAuditTrail, "GrDrawContext::drawPat
h"); | 867 GR_AUDIT_TRAIL_AUTO_FRAME(fDrawContext->fAuditTrail, "GrDrawContext::drawPat
h"); |
| 866 | 868 |
| 867 if (path.isEmpty() && path.isInverseFillType()) { | 869 if (path.isEmpty() && path.isInverseFillType()) { |
| 868 this->drawAndStencilRect(scissorRect, ss, op, invert, false, SkMatrix::I
(), | 870 this->drawAndStencilRect(scissorRect, ss, op, invert, false, SkMatrix::I
(), |
| 869 SkRect::MakeIWH(fDrawContext->fRenderTarget->wi
dth(), | 871 SkRect::MakeIWH(fDrawContext->width(), |
| 870 fDrawContext->fRenderTarget->he
ight())); | 872 fDrawContext->height())); |
| 871 return true; | 873 return true; |
| 872 } | 874 } |
| 873 | 875 |
| 874 AutoCheckFlush acf(fDrawContext->fDrawingManager); | 876 AutoCheckFlush acf(fDrawContext->fDrawingManager); |
| 875 | 877 |
| 876 // An Assumption here is that path renderer would use some form of tweaking | 878 // An Assumption here is that path renderer would use some form of tweaking |
| 877 // the src color (either the input alpha or in the frag shader) to implement | 879 // the src color (either the input alpha or in the frag shader) to implement |
| 878 // aa. If we have some future driver-mojo path AA that can do the right | 880 // aa. If we have some future driver-mojo path AA that can do the right |
| 879 // thing WRT to the blend then we'll need some query on the PR. | 881 // thing WRT to the blend then we'll need some query on the PR. |
| 880 bool useCoverageAA = doAA && !fDrawContext->fRenderTarget->isUnifiedMultisam
pled(); | 882 bool useCoverageAA = doAA && !fDrawContext->fRenderTarget->isUnifiedMultisam
pled(); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 903 GrPaint paint; | 905 GrPaint paint; |
| 904 paint.setCoverageSetOpXPFactory(op, invert); | 906 paint.setCoverageSetOpXPFactory(op, invert); |
| 905 | 907 |
| 906 // TODO: it is unfortunate that we have to convert this to a GrClip to | 908 // TODO: it is unfortunate that we have to convert this to a GrClip to |
| 907 // call drawPath. | 909 // call drawPath. |
| 908 GrClip clip; | 910 GrClip clip; |
| 909 if (scissorRect) { | 911 if (scissorRect) { |
| 910 clip.setIRect(*scissorRect); | 912 clip.setIRect(*scissorRect); |
| 911 } | 913 } |
| 912 | 914 |
| 913 GrPipelineBuilder pipelineBuilder(paint, fDrawContext->fRenderTarget, clip); | 915 GrPipelineBuilder pipelineBuilder(paint, fDrawContext->accessRenderTarget(),
clip); |
| 914 pipelineBuilder.setStencil(ss); | 916 pipelineBuilder.setStencil(ss); |
| 915 | 917 |
| 916 GrPathRenderer::DrawPathArgs args; | 918 GrPathRenderer::DrawPathArgs args; |
| 917 args.fTarget = fDrawContext->getDrawTarget(); | 919 args.fTarget = fDrawContext->getDrawTarget(); |
| 918 args.fResourceProvider = fDrawContext->fDrawingManager->getContext()->resour
ceProvider(); | 920 args.fResourceProvider = fDrawContext->fDrawingManager->getContext()->resour
ceProvider(); |
| 919 args.fPipelineBuilder = &pipelineBuilder; | 921 args.fPipelineBuilder = &pipelineBuilder; |
| 920 args.fColor = GrColor_WHITE; | 922 args.fColor = GrColor_WHITE; |
| 921 args.fViewMatrix = &viewMatrix; | 923 args.fViewMatrix = &viewMatrix; |
| 922 args.fPath = &path; | 924 args.fPath = &path; |
| 923 args.fStroke = &GrStrokeInfo::FillInfo(); | 925 args.fStroke = &GrStrokeInfo::FillInfo(); |
| 924 args.fAntiAlias = useCoverageAA; | 926 args.fAntiAlias = useCoverageAA; |
| 925 args.fGammaCorrect = fDrawContext->isGammaCorrect(); | 927 args.fGammaCorrect = fDrawContext->isGammaCorrect(); |
| 926 pr->drawPath(args); | 928 pr->drawPath(args); |
| 927 return true; | 929 return true; |
| 928 } | 930 } |
| 929 | 931 |
| 930 void GrDrawContext::internalDrawPath(const GrClip& clip, | 932 void GrDrawContext::internalDrawPath(const GrClip& clip, |
| 931 const GrPaint& paint, | 933 const GrPaint& paint, |
| 932 const SkMatrix& viewMatrix, | 934 const SkMatrix& viewMatrix, |
| 933 const SkPath& path, | 935 const SkPath& path, |
| 934 const GrStrokeInfo& strokeInfo) { | 936 const GrStrokeInfo& strokeInfo) { |
| 935 ASSERT_SINGLE_OWNER | 937 ASSERT_SINGLE_OWNER |
| 936 RETURN_IF_ABANDONED | 938 RETURN_IF_ABANDONED |
| 937 SkASSERT(!path.isEmpty()); | 939 SkASSERT(!path.isEmpty()); |
| 938 | 940 |
| 939 // An Assumption here is that path renderer would use some form of tweaking | 941 // An Assumption here is that path renderer would use some form of tweaking |
| 940 // the src color (either the input alpha or in the frag shader) to implement | 942 // the src color (either the input alpha or in the frag shader) to implement |
| 941 // aa. If we have some future driver-mojo path AA that can do the right | 943 // aa. If we have some future driver-mojo path AA that can do the right |
| 942 // thing WRT to the blend then we'll need some query on the PR. | 944 // thing WRT to the blend then we'll need some query on the PR. |
| 943 bool useCoverageAA = should_apply_coverage_aa(paint, fRenderTarget); | 945 bool useCoverageAA = should_apply_coverage_aa(paint, fRenderTarget.get()); |
| 944 const bool isStencilDisabled = true; | 946 const bool isStencilDisabled = true; |
| 945 bool isStencilBufferMSAA = fRenderTarget->isStencilBufferMultisampled(); | 947 bool isStencilBufferMSAA = fRenderTarget->isStencilBufferMultisampled(); |
| 946 | 948 |
| 947 const GrPathRendererChain::DrawType type = | 949 const GrPathRendererChain::DrawType type = |
| 948 useCoverageAA ? GrPathRendererChain::kColorAntiAlias_DrawType | 950 useCoverageAA ? GrPathRendererChain::kColorAntiAlias_DrawType |
| 949 : GrPathRendererChain::kColor_DrawType; | 951 : GrPathRendererChain::kColor_DrawType; |
| 950 | 952 |
| 951 const SkPath* pathPtr = &path; | 953 const SkPath* pathPtr = &path; |
| 952 SkTLazy<SkPath> tmpPath; | 954 SkTLazy<SkPath> tmpPath; |
| 953 const GrStrokeInfo* strokeInfoPtr = &strokeInfo; | 955 const GrStrokeInfo* strokeInfoPtr = &strokeInfo; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1008 pr = fDrawingManager->getPathRenderer(canDrawArgs, true, type); | 1010 pr = fDrawingManager->getPathRenderer(canDrawArgs, true, type); |
| 1009 } | 1011 } |
| 1010 | 1012 |
| 1011 if (nullptr == pr) { | 1013 if (nullptr == pr) { |
| 1012 #ifdef SK_DEBUG | 1014 #ifdef SK_DEBUG |
| 1013 SkDebugf("Unable to find path renderer compatible with path.\n"); | 1015 SkDebugf("Unable to find path renderer compatible with path.\n"); |
| 1014 #endif | 1016 #endif |
| 1015 return; | 1017 return; |
| 1016 } | 1018 } |
| 1017 | 1019 |
| 1018 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip); | 1020 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget.get(), clip); |
| 1019 | 1021 |
| 1020 GrPathRenderer::DrawPathArgs args; | 1022 GrPathRenderer::DrawPathArgs args; |
| 1021 args.fTarget = this->getDrawTarget(); | 1023 args.fTarget = this->getDrawTarget(); |
| 1022 args.fResourceProvider = fDrawingManager->getContext()->resourceProvider(); | 1024 args.fResourceProvider = fDrawingManager->getContext()->resourceProvider(); |
| 1023 args.fPipelineBuilder = &pipelineBuilder; | 1025 args.fPipelineBuilder = &pipelineBuilder; |
| 1024 args.fColor = paint.getColor(); | 1026 args.fColor = paint.getColor(); |
| 1025 args.fViewMatrix = &viewMatrix; | 1027 args.fViewMatrix = &viewMatrix; |
| 1026 args.fPath = pathPtr; | 1028 args.fPath = pathPtr; |
| 1027 args.fStroke = strokeInfoPtr; | 1029 args.fStroke = strokeInfoPtr; |
| 1028 args.fAntiAlias = useCoverageAA; | 1030 args.fAntiAlias = useCoverageAA; |
| 1029 args.fGammaCorrect = this->isGammaCorrect(); | 1031 args.fGammaCorrect = this->isGammaCorrect(); |
| 1030 pr->drawPath(args); | 1032 pr->drawPath(args); |
| 1031 } | 1033 } |
| 1032 | 1034 |
| 1033 void GrDrawContext::drawBatch(GrPipelineBuilder* pipelineBuilder, GrDrawBatch* b
atch) { | 1035 void GrDrawContext::drawBatch(GrPipelineBuilder* pipelineBuilder, GrDrawBatch* b
atch) { |
| 1034 ASSERT_SINGLE_OWNER | 1036 ASSERT_SINGLE_OWNER |
| 1035 RETURN_IF_ABANDONED | 1037 RETURN_IF_ABANDONED |
| 1036 SkDEBUGCODE(this->validate();) | 1038 SkDEBUGCODE(this->validate();) |
| 1037 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawBatch"); | 1039 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawBatch"); |
| 1038 | 1040 |
| 1039 this->getDrawTarget()->drawBatch(*pipelineBuilder, batch); | 1041 this->getDrawTarget()->drawBatch(*pipelineBuilder, batch); |
| 1040 } | 1042 } |
| OLD | NEW |