Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(300)

Side by Side Diff: src/gpu/GrDrawContext.cpp

Issue 2262473003: Define clear regions in terms of GrFixedClip (Closed) Base URL: https://skia.googlesource.com/skia.git@upload_fixedcliptosrc
Patch Set: Define clear regions in terms of GrFixedClip Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 185
186 void GrDrawContext::clear(const SkIRect* rect, 186 void GrDrawContext::clear(const SkIRect* rect,
187 const GrColor color, 187 const GrColor color,
188 bool canIgnoreRect) { 188 bool canIgnoreRect) {
189 ASSERT_SINGLE_OWNER 189 ASSERT_SINGLE_OWNER
190 RETURN_IF_ABANDONED 190 RETURN_IF_ABANDONED
191 SkDEBUGCODE(this->validate();) 191 SkDEBUGCODE(this->validate();)
192 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::clear"); 192 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::clear");
193 193
194 AutoCheckFlush acf(fDrawingManager); 194 AutoCheckFlush acf(fDrawingManager);
195 this->internalClear(rect ? GrFixedClip(*rect) : GrFixedClip::disabled(), col or, canIgnoreRect);
196 }
195 197
196 const SkIRect rtRect = SkIRect::MakeWH(this->width(), this->height()); 198 void GrDrawContextPriv::clear(const GrFixedClip& clip,
197 SkIRect clippedRect; 199 const GrColor color,
198 bool isFull = false; 200 bool canIgnoreClip) {
199 if (!rect || 201 ASSERT_SINGLE_OWNER_PRIV
200 (canIgnoreRect && fContext->caps()->fullClearIsFree()) || 202 RETURN_IF_ABANDONED_PRIV
201 rect->contains(rtRect)) { 203 SkDEBUGCODE(fDrawContext->validate();)
202 rect = &rtRect; 204 GR_AUDIT_TRAIL_AUTO_FRAME(fDrawContext->fAuditTrail, "GrDrawContextPriv::cle ar");
203 isFull = true; 205
204 } else { 206 AutoCheckFlush acf(fDrawContext->fDrawingManager);
205 clippedRect = *rect; 207 fDrawContext->internalClear(clip, color, canIgnoreClip);
206 if (!clippedRect.intersect(rtRect)) { 208 }
207 return; 209
208 } 210 void GrDrawContext::internalClear(const GrFixedClip& clip,
209 rect = &clippedRect; 211 const GrColor color,
210 } 212 bool canIgnoreClip) {
213 bool isFull = !clip.scissorEnabled() ||
214 (canIgnoreClip && fContext->caps()->fullClearIsFree()) ||
215 clip.scissorRect().contains(SkIRect::MakeWH(this->width(), thi s->height()));
211 216
212 if (fContext->caps()->useDrawInsteadOfClear()) { 217 if (fContext->caps()->useDrawInsteadOfClear()) {
213 // This works around a driver bug with clear by drawing a rect instead. 218 // This works around a driver bug with clear by drawing a rect instead.
214 // The driver will ignore a clear if it is the only thing rendered to a 219 // The driver will ignore a clear if it is the only thing rendered to a
215 // target before the target is read. 220 // target before the target is read.
216 if (rect == &rtRect) { 221 SkRect clearRect = SkRect::MakeIWH(this->width(), this->height());
222 if (isFull) {
217 this->discard(); 223 this->discard();
224 } else if (!clearRect.intersect(SkRect::Make(clip.scissorRect()))) {
225 return;
218 } 226 }
219 227
220 GrPaint paint; 228 GrPaint paint;
221 paint.setColor4f(GrColor4f::FromGrColor(color)); 229 paint.setColor4f(GrColor4f::FromGrColor(color));
222 paint.setXPFactory(GrPorterDuffXPFactory::Make(SkXfermode::kSrc_Mode)); 230 paint.setXPFactory(GrPorterDuffXPFactory::Make(SkXfermode::kSrc_Mode));
223 231
224 this->drawRect(GrNoClip(), paint, SkMatrix::I(), SkRect::Make(*rect)); 232 this->drawRect(clip, paint, SkMatrix::I(), clearRect);
225 } else if (isFull) { 233 } else if (isFull) {
226 this->getDrawTarget()->fullClear(this->accessRenderTarget(), color); 234 this->getDrawTarget()->fullClear(this->accessRenderTarget(), color);
227 } else { 235 } else {
228 sk_sp<GrBatch> batch(GrClearBatch::Make(*rect, color, this->accessRender Target())); 236 sk_sp<GrBatch> batch(GrClearBatch::Make(clip, color, this->accessRenderT arget()));
237 if (!batch) {
238 return;
239 }
229 this->getDrawTarget()->addBatch(std::move(batch)); 240 this->getDrawTarget()->addBatch(std::move(batch));
230 } 241 }
231 } 242 }
232 243
233
234 void GrDrawContext::drawPaint(const GrClip& clip, 244 void GrDrawContext::drawPaint(const GrClip& clip,
235 const GrPaint& origPaint, 245 const GrPaint& origPaint,
236 const SkMatrix& viewMatrix) { 246 const SkMatrix& viewMatrix) {
237 ASSERT_SINGLE_OWNER 247 ASSERT_SINGLE_OWNER
238 RETURN_IF_ABANDONED 248 RETURN_IF_ABANDONED
239 SkDEBUGCODE(this->validate();) 249 SkDEBUGCODE(this->validate();)
240 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawPaint"); 250 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawPaint");
241 251
242 // set rect to be big enough to fill the space, but not super-huge, so we 252 // set rect to be big enough to fill the space, but not super-huge, so we
243 // don't overflow fixed-point implementations 253 // don't overflow fixed-point implementations
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 return; 534 return;
525 } 535 }
526 } 536 }
527 537
528 SkPath path; 538 SkPath path;
529 path.setIsVolatile(true); 539 path.setIsVolatile(true);
530 path.addRect(rect); 540 path.addRect(rect);
531 this->internalDrawPath(clip, paint, viewMatrix, path, *style); 541 this->internalDrawPath(clip, paint, viewMatrix, path, *style);
532 } 542 }
533 543
534 void GrDrawContextPriv::clearStencilClip(const SkIRect& rect, bool insideClip) { 544 void GrDrawContextPriv::clearStencilClip(const GrFixedClip& clip, bool insideSte ncilMask) {
535 ASSERT_SINGLE_OWNER_PRIV 545 ASSERT_SINGLE_OWNER_PRIV
536 RETURN_IF_ABANDONED_PRIV 546 RETURN_IF_ABANDONED_PRIV
537 SkDEBUGCODE(fDrawContext->validate();) 547 SkDEBUGCODE(fDrawContext->validate();)
538 GR_AUDIT_TRAIL_AUTO_FRAME(fDrawContext->fAuditTrail, "GrDrawContextPriv::cle arStencilClip"); 548 GR_AUDIT_TRAIL_AUTO_FRAME(fDrawContext->fAuditTrail, "GrDrawContextPriv::cle arStencilClip");
539 549
540 AutoCheckFlush acf(fDrawContext->fDrawingManager); 550 AutoCheckFlush acf(fDrawContext->fDrawingManager);
541 fDrawContext->getDrawTarget()->clearStencilClip(rect, insideClip, 551 fDrawContext->getDrawTarget()->clearStencilClip(clip, insideStencilMask,
542 fDrawContext->accessRenderTa rget()); 552 fDrawContext->accessRenderTa rget());
543 } 553 }
544 554
545 void GrDrawContextPriv::stencilPath(const GrClip& clip, 555 void GrDrawContextPriv::stencilPath(const GrClip& clip,
546 bool useHWAA, 556 bool useHWAA,
547 const SkMatrix& viewMatrix, 557 const SkMatrix& viewMatrix,
548 const GrPath* path) { 558 const GrPath* path) {
549 fDrawContext->getDrawTarget()->stencilPath(fDrawContext, clip, useHWAA, view Matrix, path); 559 fDrawContext->getDrawTarget()->stencilPath(fDrawContext, clip, useHWAA, view Matrix, path);
550 } 560 }
551 561
(...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after
1310 1320
1311 void GrDrawContext::drawBatch(const GrPipelineBuilder& pipelineBuilder, const Gr Clip& clip, 1321 void GrDrawContext::drawBatch(const GrPipelineBuilder& pipelineBuilder, const Gr Clip& clip,
1312 GrDrawBatch* batch) { 1322 GrDrawBatch* batch) {
1313 ASSERT_SINGLE_OWNER 1323 ASSERT_SINGLE_OWNER
1314 RETURN_IF_ABANDONED 1324 RETURN_IF_ABANDONED
1315 SkDEBUGCODE(this->validate();) 1325 SkDEBUGCODE(this->validate();)
1316 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawBatch"); 1326 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawBatch");
1317 1327
1318 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch); 1328 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch);
1319 } 1329 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698