| 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 bool GrDrawContext::wasAbandoned() const { | 60 bool GrDrawContext::wasAbandoned() const { |
| 61 return fDrawingManager->wasAbandoned(); | 61 return fDrawingManager->wasAbandoned(); |
| 62 } | 62 } |
| 63 | 63 |
| 64 // In MDB mode the reffing of the 'getLastDrawTarget' call's result allows in-pr
ogress | 64 // In MDB mode the reffing of the 'getLastDrawTarget' call's result allows in-pr
ogress |
| 65 // drawTargets to be picked up and added to by drawContexts lower in the call | 65 // drawTargets to be picked up and added to by drawContexts lower in the call |
| 66 // stack. When this occurs with a closed drawTarget, a new one will be allocated | 66 // stack. When this occurs with a closed drawTarget, a new one will be allocated |
| 67 // when the drawContext attempts to use it (via getDrawTarget). | 67 // when the drawContext attempts to use it (via getDrawTarget). |
| 68 GrDrawContext::GrDrawContext(GrContext* context, | 68 GrDrawContext::GrDrawContext(GrContext* context, |
| 69 GrDrawingManager* drawingMgr, | 69 GrDrawingManager* drawingMgr, |
| 70 int width, int height, |
| 70 sk_sp<GrRenderTarget> rt, | 71 sk_sp<GrRenderTarget> rt, |
| 71 const SkSurfaceProps* surfaceProps, | 72 const SkSurfaceProps* surfaceProps, |
| 72 GrAuditTrail* auditTrail, | 73 GrAuditTrail* auditTrail, |
| 73 GrSingleOwner* singleOwner) | 74 GrSingleOwner* singleOwner) |
| 74 : fDrawingManager(drawingMgr) | 75 : fDrawingManager(drawingMgr) |
| 76 , fWidth(width) |
| 77 , fHeight(height) |
| 75 , fRenderTarget(std::move(rt)) | 78 , fRenderTarget(std::move(rt)) |
| 76 , fDrawTarget(SkSafeRef(fRenderTarget->getLastDrawTarget())) | 79 , fDrawTarget(SkSafeRef(fRenderTarget->getLastDrawTarget())) |
| 77 , fContext(context) | 80 , fContext(context) |
| 78 , fInstancedPipelineInfo(fRenderTarget.get()) | 81 , fInstancedPipelineInfo(fRenderTarget.get()) |
| 79 , fSurfaceProps(SkSurfacePropsCopyOrDefault(surfaceProps)) | 82 , fSurfaceProps(SkSurfacePropsCopyOrDefault(surfaceProps)) |
| 80 , fAuditTrail(auditTrail) | 83 , fAuditTrail(auditTrail) |
| 81 #ifdef SK_DEBUG | 84 #ifdef SK_DEBUG |
| 82 , fSingleOwner(singleOwner) | 85 , fSingleOwner(singleOwner) |
| 83 #endif | 86 #endif |
| 84 { | 87 { |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 void GrDrawContext::clear(const SkIRect* rect, | 193 void GrDrawContext::clear(const SkIRect* rect, |
| 191 const GrColor color, | 194 const GrColor color, |
| 192 bool canIgnoreRect) { | 195 bool canIgnoreRect) { |
| 193 ASSERT_SINGLE_OWNER | 196 ASSERT_SINGLE_OWNER |
| 194 RETURN_IF_ABANDONED | 197 RETURN_IF_ABANDONED |
| 195 SkDEBUGCODE(this->validate();) | 198 SkDEBUGCODE(this->validate();) |
| 196 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::clear"); | 199 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::clear"); |
| 197 | 200 |
| 198 AutoCheckFlush acf(fDrawingManager); | 201 AutoCheckFlush acf(fDrawingManager); |
| 199 | 202 |
| 200 const SkIRect rtRect = SkIRect::MakeWH(this->width(), this->height()); | 203 const SkIRect rtRect = SkIRect::MakeWH(this->accessRenderTarget()->width(), |
| 204 this->accessRenderTarget()->height())
; |
| 201 SkIRect clippedRect; | 205 SkIRect clippedRect; |
| 202 if (!rect || | 206 if (!rect || |
| 203 (canIgnoreRect && fContext->caps()->fullClearIsFree()) || | 207 (canIgnoreRect && fContext->caps()->fullClearIsFree()) || |
| 204 rect->contains(rtRect)) { | 208 rect->contains(rtRect)) { |
| 205 rect = &rtRect; | 209 rect = &rtRect; |
| 206 } else { | 210 } else { |
| 207 clippedRect = *rect; | 211 clippedRect = *rect; |
| 208 if (!clippedRect.intersect(rtRect)) { | 212 if (!clippedRect.intersect(rtRect)) { |
| 209 return; | 213 return; |
| 210 } | 214 } |
| (...skipping 898 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1109 bool doAA, | 1113 bool doAA, |
| 1110 const SkMatrix& viewMatrix, | 1114 const SkMatrix& viewMatrix, |
| 1111 const SkPath& path) { | 1115 const SkPath& path) { |
| 1112 ASSERT_SINGLE_OWNER_PRIV | 1116 ASSERT_SINGLE_OWNER_PRIV |
| 1113 RETURN_FALSE_IF_ABANDONED_PRIV | 1117 RETURN_FALSE_IF_ABANDONED_PRIV |
| 1114 SkDEBUGCODE(fDrawContext->validate();) | 1118 SkDEBUGCODE(fDrawContext->validate();) |
| 1115 GR_AUDIT_TRAIL_AUTO_FRAME(fDrawContext->fAuditTrail, "GrDrawContext::drawPat
h"); | 1119 GR_AUDIT_TRAIL_AUTO_FRAME(fDrawContext->fAuditTrail, "GrDrawContext::drawPat
h"); |
| 1116 | 1120 |
| 1117 if (path.isEmpty() && path.isInverseFillType()) { | 1121 if (path.isEmpty() && path.isInverseFillType()) { |
| 1118 this->drawAndStencilRect(clip, ss, op, invert, false, SkMatrix::I(), | 1122 this->drawAndStencilRect(clip, ss, op, invert, false, SkMatrix::I(), |
| 1119 SkRect::MakeIWH(fDrawContext->width(), | 1123 SkRect::MakeIWH(fDrawContext->width(), fDrawCon
text->height())); |
| 1120 fDrawContext->height())); | |
| 1121 return true; | 1124 return true; |
| 1122 } | 1125 } |
| 1123 | 1126 |
| 1124 AutoCheckFlush acf(fDrawContext->fDrawingManager); | 1127 AutoCheckFlush acf(fDrawContext->fDrawingManager); |
| 1125 | 1128 |
| 1126 // An Assumption here is that path renderer would use some form of tweaking | 1129 // An Assumption here is that path renderer would use some form of tweaking |
| 1127 // the src color (either the input alpha or in the frag shader) to implement | 1130 // the src color (either the input alpha or in the frag shader) to implement |
| 1128 // aa. If we have some future driver-mojo path AA that can do the right | 1131 // aa. If we have some future driver-mojo path AA that can do the right |
| 1129 // thing WRT to the blend then we'll need some query on the PR. | 1132 // thing WRT to the blend then we'll need some query on the PR. |
| 1130 bool useCoverageAA = doAA && !fDrawContext->fRenderTarget->isUnifiedMultisam
pled(); | 1133 bool useCoverageAA = doAA && !fDrawContext->fRenderTarget->isUnifiedMultisam
pled(); |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1241 | 1244 |
| 1242 void GrDrawContext::drawBatch(const GrPipelineBuilder& pipelineBuilder, const Gr
Clip& clip, | 1245 void GrDrawContext::drawBatch(const GrPipelineBuilder& pipelineBuilder, const Gr
Clip& clip, |
| 1243 GrDrawBatch* batch) { | 1246 GrDrawBatch* batch) { |
| 1244 ASSERT_SINGLE_OWNER | 1247 ASSERT_SINGLE_OWNER |
| 1245 RETURN_IF_ABANDONED | 1248 RETURN_IF_ABANDONED |
| 1246 SkDEBUGCODE(this->validate();) | 1249 SkDEBUGCODE(this->validate();) |
| 1247 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawBatch"); | 1250 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawBatch"); |
| 1248 | 1251 |
| 1249 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch); | 1252 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch); |
| 1250 } | 1253 } |
| OLD | NEW |