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

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: rebase Created 4 years, 3 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
« no previous file with comments | « src/gpu/GrClipStackClip.cpp ('k') | src/gpu/GrDrawContextPriv.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 189
190 void GrDrawContext::clear(const SkIRect* rect, 190 void GrDrawContext::clear(const SkIRect* rect,
191 const GrColor color, 191 const GrColor color,
192 bool canIgnoreRect) { 192 bool canIgnoreRect) {
193 ASSERT_SINGLE_OWNER 193 ASSERT_SINGLE_OWNER
194 RETURN_IF_ABANDONED 194 RETURN_IF_ABANDONED
195 SkDEBUGCODE(this->validate();) 195 SkDEBUGCODE(this->validate();)
196 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::clear"); 196 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::clear");
197 197
198 AutoCheckFlush acf(fDrawingManager); 198 AutoCheckFlush acf(fDrawingManager);
199 this->internalClear(rect ? GrFixedClip(*rect) : GrFixedClip::Disabled(), col or, canIgnoreRect);
200 }
199 201
200 const SkIRect rtRect = SkIRect::MakeWH(this->width(), this->height()); 202 void GrDrawContextPriv::clear(const GrFixedClip& clip,
201 SkIRect clippedRect; 203 const GrColor color,
202 bool isFull = false; 204 bool canIgnoreClip) {
203 if (!rect || 205 ASSERT_SINGLE_OWNER_PRIV
204 (canIgnoreRect && fContext->caps()->fullClearIsFree()) || 206 RETURN_IF_ABANDONED_PRIV
205 rect->contains(rtRect)) { 207 SkDEBUGCODE(fDrawContext->validate();)
206 rect = &rtRect; 208 GR_AUDIT_TRAIL_AUTO_FRAME(fDrawContext->fAuditTrail, "GrDrawContextPriv::cle ar");
207 isFull = true; 209
208 } else { 210 AutoCheckFlush acf(fDrawContext->fDrawingManager);
209 clippedRect = *rect; 211 fDrawContext->internalClear(clip, color, canIgnoreClip);
210 if (!clippedRect.intersect(rtRect)) { 212 }
211 return; 213
212 } 214 void GrDrawContext::internalClear(const GrFixedClip& clip,
213 rect = &clippedRect; 215 const GrColor color,
214 } 216 bool canIgnoreClip) {
217 bool isFull = !clip.scissorEnabled() ||
218 (canIgnoreClip && fContext->caps()->fullClearIsFree()) ||
219 clip.scissorRect().contains(SkIRect::MakeWH(this->width(), thi s->height()));
215 220
216 if (fContext->caps()->useDrawInsteadOfClear()) { 221 if (fContext->caps()->useDrawInsteadOfClear()) {
217 // This works around a driver bug with clear by drawing a rect instead. 222 // This works around a driver bug with clear by drawing a rect instead.
218 // The driver will ignore a clear if it is the only thing rendered to a 223 // The driver will ignore a clear if it is the only thing rendered to a
219 // target before the target is read. 224 // target before the target is read.
220 if (rect == &rtRect) { 225 SkRect clearRect = SkRect::MakeIWH(this->width(), this->height());
226 if (isFull) {
221 this->discard(); 227 this->discard();
228 } else if (!clearRect.intersect(SkRect::Make(clip.scissorRect()))) {
229 return;
222 } 230 }
223 231
224 GrPaint paint; 232 GrPaint paint;
225 paint.setColor4f(GrColor4f::FromGrColor(color)); 233 paint.setColor4f(GrColor4f::FromGrColor(color));
226 paint.setXPFactory(GrPorterDuffXPFactory::Make(SkXfermode::kSrc_Mode)); 234 paint.setXPFactory(GrPorterDuffXPFactory::Make(SkXfermode::kSrc_Mode));
227 235
228 this->drawRect(GrNoClip(), paint, SkMatrix::I(), SkRect::Make(*rect)); 236 this->drawRect(clip, paint, SkMatrix::I(), clearRect);
229 } else if (isFull) { 237 } else if (isFull) {
230 this->getDrawTarget()->fullClear(this->accessRenderTarget(), color); 238 this->getDrawTarget()->fullClear(this->accessRenderTarget(), color);
231 } else { 239 } else {
232 sk_sp<GrBatch> batch(GrClearBatch::Make(*rect, color, this->accessRender Target())); 240 sk_sp<GrBatch> batch(GrClearBatch::Make(clip, color, this->accessRenderT arget()));
241 if (!batch) {
242 return;
243 }
233 this->getDrawTarget()->addBatch(std::move(batch)); 244 this->getDrawTarget()->addBatch(std::move(batch));
234 } 245 }
235 } 246 }
236 247
237
238 void GrDrawContext::drawPaint(const GrClip& clip, 248 void GrDrawContext::drawPaint(const GrClip& clip,
239 const GrPaint& origPaint, 249 const GrPaint& origPaint,
240 const SkMatrix& viewMatrix) { 250 const SkMatrix& viewMatrix) {
241 ASSERT_SINGLE_OWNER 251 ASSERT_SINGLE_OWNER
242 RETURN_IF_ABANDONED 252 RETURN_IF_ABANDONED
243 SkDEBUGCODE(this->validate();) 253 SkDEBUGCODE(this->validate();)
244 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawPaint"); 254 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawPaint");
245 255
246 // set rect to be big enough to fill the space, but not super-huge, so we 256 // set rect to be big enough to fill the space, but not super-huge, so we
247 // don't overflow fixed-point implementations 257 // don't overflow fixed-point implementations
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 return; 546 return;
537 } 547 }
538 } 548 }
539 549
540 SkPath path; 550 SkPath path;
541 path.setIsVolatile(true); 551 path.setIsVolatile(true);
542 path.addRect(rect); 552 path.addRect(rect);
543 this->internalDrawPath(clip, paint, viewMatrix, path, *style); 553 this->internalDrawPath(clip, paint, viewMatrix, path, *style);
544 } 554 }
545 555
546 void GrDrawContextPriv::clearStencilClip(const SkIRect& rect, bool insideClip) { 556 void GrDrawContextPriv::clearStencilClip(const GrFixedClip& clip, bool insideSte ncilMask) {
547 ASSERT_SINGLE_OWNER_PRIV 557 ASSERT_SINGLE_OWNER_PRIV
548 RETURN_IF_ABANDONED_PRIV 558 RETURN_IF_ABANDONED_PRIV
549 SkDEBUGCODE(fDrawContext->validate();) 559 SkDEBUGCODE(fDrawContext->validate();)
550 GR_AUDIT_TRAIL_AUTO_FRAME(fDrawContext->fAuditTrail, "GrDrawContextPriv::cle arStencilClip"); 560 GR_AUDIT_TRAIL_AUTO_FRAME(fDrawContext->fAuditTrail, "GrDrawContextPriv::cle arStencilClip");
551 561
552 AutoCheckFlush acf(fDrawContext->fDrawingManager); 562 AutoCheckFlush acf(fDrawContext->fDrawingManager);
553 fDrawContext->getDrawTarget()->clearStencilClip(rect, insideClip, 563 fDrawContext->getDrawTarget()->clearStencilClip(clip, insideStencilMask,
554 fDrawContext->accessRenderTa rget()); 564 fDrawContext->accessRenderTa rget());
555 } 565 }
556 566
557 void GrDrawContextPriv::stencilPath(const GrClip& clip, 567 void GrDrawContextPriv::stencilPath(const GrClip& clip,
558 bool useHWAA, 568 bool useHWAA,
559 const SkMatrix& viewMatrix, 569 const SkMatrix& viewMatrix,
560 const GrPath* path) { 570 const GrPath* path) {
561 fDrawContext->getDrawTarget()->stencilPath(fDrawContext, clip, useHWAA, view Matrix, path); 571 fDrawContext->getDrawTarget()->stencilPath(fDrawContext, clip, useHWAA, view Matrix, path);
562 } 572 }
563 573
564 void GrDrawContextPriv::stencilRect(const GrFixedClip& clip, 574 void GrDrawContextPriv::stencilRect(const GrClip& clip,
565 const GrUserStencilSettings* ss, 575 const GrUserStencilSettings* ss,
566 bool useHWAA, 576 bool useHWAA,
567 const SkMatrix& viewMatrix, 577 const SkMatrix& viewMatrix,
568 const SkRect& rect) { 578 const SkRect& rect) {
569 ASSERT_SINGLE_OWNER_PRIV 579 ASSERT_SINGLE_OWNER_PRIV
570 RETURN_IF_ABANDONED_PRIV 580 RETURN_IF_ABANDONED_PRIV
571 SkDEBUGCODE(fDrawContext->validate();) 581 SkDEBUGCODE(fDrawContext->validate();)
572 GR_AUDIT_TRAIL_AUTO_FRAME(fDrawContext->fAuditTrail, "GrDrawContext::stencil Rect"); 582 GR_AUDIT_TRAIL_AUTO_FRAME(fDrawContext->fAuditTrail, "GrDrawContext::stencil Rect");
573 583
574 AutoCheckFlush acf(fDrawContext->fDrawingManager); 584 AutoCheckFlush acf(fDrawContext->fDrawingManager);
575 585
576 GrPaint paint; 586 GrPaint paint;
577 paint.setAntiAlias(useHWAA); 587 paint.setAntiAlias(useHWAA);
578 paint.setXPFactory(GrDisableColorXPFactory::Make()); 588 paint.setXPFactory(GrDisableColorXPFactory::Make());
579 589
580 fDrawContext->drawNonAAFilledRect(clip, paint, viewMatrix, rect, nullptr, nu llptr, ss, useHWAA); 590 fDrawContext->drawNonAAFilledRect(clip, paint, viewMatrix, rect, nullptr, nu llptr, ss, useHWAA);
581 } 591 }
582 592
583 bool GrDrawContextPriv::drawAndStencilRect(const GrFixedClip& clip, 593 bool GrDrawContextPriv::drawAndStencilRect(const GrClip& clip,
584 const GrUserStencilSettings* ss, 594 const GrUserStencilSettings* ss,
585 SkRegion::Op op, 595 SkRegion::Op op,
586 bool invert, 596 bool invert,
587 bool doAA, 597 bool doAA,
588 const SkMatrix& viewMatrix, 598 const SkMatrix& viewMatrix,
589 const SkRect& rect) { 599 const SkRect& rect) {
590 ASSERT_SINGLE_OWNER_PRIV 600 ASSERT_SINGLE_OWNER_PRIV
591 RETURN_FALSE_IF_ABANDONED_PRIV 601 RETURN_FALSE_IF_ABANDONED_PRIV
592 SkDEBUGCODE(fDrawContext->validate();) 602 SkDEBUGCODE(fDrawContext->validate();)
593 GR_AUDIT_TRAIL_AUTO_FRAME(fDrawContext->fAuditTrail, "GrDrawContext::drawAnd StencilRect"); 603 GR_AUDIT_TRAIL_AUTO_FRAME(fDrawContext->fAuditTrail, "GrDrawContext::drawAnd StencilRect");
(...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after
1225 } 1235 }
1226 1236
1227 // Note that internalDrawPath may sw-rasterize the path into a scratch textu re. 1237 // Note that internalDrawPath may sw-rasterize the path into a scratch textu re.
1228 // Scratch textures can be recycled after they are returned to the texture 1238 // Scratch textures can be recycled after they are returned to the texture
1229 // cache. This presents a potential hazard for buffered drawing. However, 1239 // cache. This presents a potential hazard for buffered drawing. However,
1230 // the writePixels that uploads to the scratch will perform a flush so we're 1240 // the writePixels that uploads to the scratch will perform a flush so we're
1231 // OK. 1241 // OK.
1232 this->internalDrawPath(clip, paint, viewMatrix, path, style); 1242 this->internalDrawPath(clip, paint, viewMatrix, path, style);
1233 } 1243 }
1234 1244
1235 bool GrDrawContextPriv::drawAndStencilPath(const GrFixedClip& clip, 1245 bool GrDrawContextPriv::drawAndStencilPath(const GrClip& clip,
1236 const GrUserStencilSettings* ss, 1246 const GrUserStencilSettings* ss,
1237 SkRegion::Op op, 1247 SkRegion::Op op,
1238 bool invert, 1248 bool invert,
1239 bool doAA, 1249 bool doAA,
1240 const SkMatrix& viewMatrix, 1250 const SkMatrix& viewMatrix,
1241 const SkPath& path) { 1251 const SkPath& path) {
1242 ASSERT_SINGLE_OWNER_PRIV 1252 ASSERT_SINGLE_OWNER_PRIV
1243 RETURN_FALSE_IF_ABANDONED_PRIV 1253 RETURN_FALSE_IF_ABANDONED_PRIV
1244 SkDEBUGCODE(fDrawContext->validate();) 1254 SkDEBUGCODE(fDrawContext->validate();)
1245 GR_AUDIT_TRAIL_AUTO_FRAME(fDrawContext->fAuditTrail, "GrDrawContext::drawPat h"); 1255 GR_AUDIT_TRAIL_AUTO_FRAME(fDrawContext->fAuditTrail, "GrDrawContext::drawPat h");
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
1383 1393
1384 void GrDrawContext::drawBatch(const GrPipelineBuilder& pipelineBuilder, const Gr Clip& clip, 1394 void GrDrawContext::drawBatch(const GrPipelineBuilder& pipelineBuilder, const Gr Clip& clip,
1385 GrDrawBatch* batch) { 1395 GrDrawBatch* batch) {
1386 ASSERT_SINGLE_OWNER 1396 ASSERT_SINGLE_OWNER
1387 RETURN_IF_ABANDONED 1397 RETURN_IF_ABANDONED
1388 SkDEBUGCODE(this->validate();) 1398 SkDEBUGCODE(this->validate();)
1389 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawBatch"); 1399 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawBatch");
1390 1400
1391 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch); 1401 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch);
1392 } 1402 }
OLDNEW
« no previous file with comments | « src/gpu/GrClipStackClip.cpp ('k') | src/gpu/GrDrawContextPriv.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698