| 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 "GrRenderTargetContext.h" | 10 #include "GrRenderTargetContext.h" |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 } | 198 } |
| 199 | 199 |
| 200 void GrRenderTargetContext::discard() { | 200 void GrRenderTargetContext::discard() { |
| 201 ASSERT_SINGLE_OWNER | 201 ASSERT_SINGLE_OWNER |
| 202 RETURN_IF_ABANDONED | 202 RETURN_IF_ABANDONED |
| 203 SkDEBUGCODE(this->validate();) | 203 SkDEBUGCODE(this->validate();) |
| 204 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrRenderTargetContext::discard"); | 204 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrRenderTargetContext::discard"); |
| 205 | 205 |
| 206 AutoCheckFlush acf(fDrawingManager); | 206 AutoCheckFlush acf(fDrawingManager); |
| 207 | 207 |
| 208 // TODO: this needs to be fixed up since it ends the deferrable of the GrRen
derTarget | 208 this->getOpList()->discard(fRenderTargetProxy.get()); |
| 209 sk_sp<GrRenderTarget> rt( | |
| 210 sk_ref_sp(fRenderTargetProxy->instantiate(fContext->text
ureProvider()))); | |
| 211 | |
| 212 this->getOpList()->discard(rt.get()); | |
| 213 } | 209 } |
| 214 | 210 |
| 215 void GrRenderTargetContext::clear(const SkIRect* rect, | 211 void GrRenderTargetContext::clear(const SkIRect* rect, |
| 216 const GrColor color, | 212 const GrColor color, |
| 217 bool canIgnoreRect) { | 213 bool canIgnoreRect) { |
| 218 ASSERT_SINGLE_OWNER | 214 ASSERT_SINGLE_OWNER |
| 219 RETURN_IF_ABANDONED | 215 RETURN_IF_ABANDONED |
| 220 SkDEBUGCODE(this->validate();) | 216 SkDEBUGCODE(this->validate();) |
| 221 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrRenderTargetContext::clear"); | 217 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrRenderTargetContext::clear"); |
| 222 | 218 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 } else if (!clearRect.intersect(SkRect::Make(clip.scissorRect()))) { | 253 } else if (!clearRect.intersect(SkRect::Make(clip.scissorRect()))) { |
| 258 return; | 254 return; |
| 259 } | 255 } |
| 260 | 256 |
| 261 GrPaint paint; | 257 GrPaint paint; |
| 262 paint.setColor4f(GrColor4f::FromGrColor(color)); | 258 paint.setColor4f(GrColor4f::FromGrColor(color)); |
| 263 paint.setXPFactory(GrPorterDuffXPFactory::Make(SkBlendMode::kSrc)); | 259 paint.setXPFactory(GrPorterDuffXPFactory::Make(SkBlendMode::kSrc)); |
| 264 | 260 |
| 265 this->drawRect(clip, paint, SkMatrix::I(), clearRect); | 261 this->drawRect(clip, paint, SkMatrix::I(), clearRect); |
| 266 } else if (isFull) { | 262 } else if (isFull) { |
| 267 this->getOpList()->fullClear(this->accessRenderTarget(), color); | 263 this->getOpList()->fullClear(fRenderTargetProxy.get(), color); |
| 268 } else { | 264 } else { |
| 269 sk_sp<GrBatch> batch(GrClearBatch::Make(clip, color, this->accessRenderT
arget())); | 265 sk_sp<GrBatch> batch(GrClearBatch::Make(clip, color, fRenderTargetProxy.
get())); |
| 270 if (!batch) { | 266 if (!batch) { |
| 271 return; | 267 return; |
| 272 } | 268 } |
| 273 this->getOpList()->addBatch(std::move(batch)); | 269 this->getOpList()->addBatch(std::move(batch)); |
| 274 } | 270 } |
| 275 } | 271 } |
| 276 | 272 |
| 277 void GrRenderTargetContext::drawPaint(const GrClip& clip, | 273 void GrRenderTargetContext::drawPaint(const GrClip& clip, |
| 278 const GrPaint& origPaint, | 274 const GrPaint& origPaint, |
| 279 const SkMatrix& viewMatrix) { | 275 const SkMatrix& viewMatrix) { |
| 280 ASSERT_SINGLE_OWNER | 276 ASSERT_SINGLE_OWNER |
| 281 RETURN_IF_ABANDONED | 277 RETURN_IF_ABANDONED |
| 282 SkDEBUGCODE(this->validate();) | 278 SkDEBUGCODE(this->validate();) |
| 283 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrRenderTargetContext::drawPaint"); | 279 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrRenderTargetContext::drawPaint"); |
| 284 | 280 |
| 285 // set rect to be big enough to fill the space, but not super-huge, so we | 281 // set rect to be big enough to fill the space, but not super-huge, so we |
| 286 // don't overflow fixed-point implementations | 282 // don't overflow fixed-point implementations |
| 287 | |
| 288 SkRect r = fRenderTargetProxy->getBoundsRect(); | 283 SkRect r = fRenderTargetProxy->getBoundsRect(); |
| 289 SkTCopyOnFirstWrite<GrPaint> paint(origPaint); | 284 SkTCopyOnFirstWrite<GrPaint> paint(origPaint); |
| 290 | 285 |
| 291 SkRRect rrect; | 286 SkRRect rrect; |
| 292 bool aaRRect; | 287 bool aaRRect; |
| 293 // Check if we can replace a clipRRect()/drawPaint() with a drawRRect(). We
only do the | 288 // Check if we can replace a clipRRect()/drawPaint() with a drawRRect(). We
only do the |
| 294 // transformation for non-rect rrects. Rects caused a performance regression
on an Android | 289 // transformation for non-rect rrects. Rects caused a performance regression
on an Android |
| 295 // test that needs investigation. We also skip cases where there are fragmen
t processors | 290 // test that needs investigation. We also skip cases where there are fragmen
t processors |
| 296 // because they may depend on having correct local coords and this path draw
s in device space | 291 // because they may depend on having correct local coords and this path draw
s in device space |
| 297 // without a local matrix. | 292 // without a local matrix. |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 581 | 576 |
| 582 void GrRenderTargetContextPriv::clearStencilClip(const GrFixedClip& clip, bool i
nsideStencilMask) { | 577 void GrRenderTargetContextPriv::clearStencilClip(const GrFixedClip& clip, bool i
nsideStencilMask) { |
| 583 ASSERT_SINGLE_OWNER_PRIV | 578 ASSERT_SINGLE_OWNER_PRIV |
| 584 RETURN_IF_ABANDONED_PRIV | 579 RETURN_IF_ABANDONED_PRIV |
| 585 SkDEBUGCODE(fRenderTargetContext->validate();) | 580 SkDEBUGCODE(fRenderTargetContext->validate();) |
| 586 GR_AUDIT_TRAIL_AUTO_FRAME(fRenderTargetContext->fAuditTrail, | 581 GR_AUDIT_TRAIL_AUTO_FRAME(fRenderTargetContext->fAuditTrail, |
| 587 "GrRenderTargetContextPriv::clearStencilClip"); | 582 "GrRenderTargetContextPriv::clearStencilClip"); |
| 588 | 583 |
| 589 AutoCheckFlush acf(fRenderTargetContext->fDrawingManager); | 584 AutoCheckFlush acf(fRenderTargetContext->fDrawingManager); |
| 590 fRenderTargetContext->getOpList()->clearStencilClip(clip, insideStencilMask, | 585 fRenderTargetContext->getOpList()->clearStencilClip(clip, insideStencilMask, |
| 591 fRenderTargetContext->ac
cessRenderTarget()); | 586 fRenderTargetContext->fR
enderTargetProxy.get()); |
| 592 } | 587 } |
| 593 | 588 |
| 594 void GrRenderTargetContextPriv::stencilPath(const GrClip& clip, | 589 void GrRenderTargetContextPriv::stencilPath(const GrClip& clip, |
| 595 bool useHWAA, | 590 bool useHWAA, |
| 596 const SkMatrix& viewMatrix, | 591 const SkMatrix& viewMatrix, |
| 597 const GrPath* path) { | 592 const GrPath* path) { |
| 598 fRenderTargetContext->getOpList()->stencilPath(fRenderTargetContext, clip, u
seHWAA, viewMatrix, | 593 fRenderTargetContext->getOpList()->stencilPath(fRenderTargetContext, clip, u
seHWAA, viewMatrix, |
| 599 path); | 594 path); |
| 600 } | 595 } |
| 601 | 596 |
| (...skipping 865 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1467 | 1462 |
| 1468 void GrRenderTargetContext::drawBatch(const GrPipelineBuilder& pipelineBuilder,
const GrClip& clip, | 1463 void GrRenderTargetContext::drawBatch(const GrPipelineBuilder& pipelineBuilder,
const GrClip& clip, |
| 1469 GrDrawBatch* batch) { | 1464 GrDrawBatch* batch) { |
| 1470 ASSERT_SINGLE_OWNER | 1465 ASSERT_SINGLE_OWNER |
| 1471 RETURN_IF_ABANDONED | 1466 RETURN_IF_ABANDONED |
| 1472 SkDEBUGCODE(this->validate();) | 1467 SkDEBUGCODE(this->validate();) |
| 1473 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrRenderTargetContext::drawBatch"); | 1468 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrRenderTargetContext::drawBatch"); |
| 1474 | 1469 |
| 1475 this->getOpList()->drawBatch(pipelineBuilder, this, clip, batch); | 1470 this->getOpList()->drawBatch(pipelineBuilder, this, clip, batch); |
| 1476 } | 1471 } |
| OLD | NEW |