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

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

Issue 2233043002: Add a full clear method to GrDrawTarget. (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: include order 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
« no previous file with comments | « no previous file | src/gpu/GrDrawTarget.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 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 bool canIgnoreRect) { 196 bool canIgnoreRect) {
197 ASSERT_SINGLE_OWNER 197 ASSERT_SINGLE_OWNER
198 RETURN_IF_ABANDONED 198 RETURN_IF_ABANDONED
199 SkDEBUGCODE(this->validate();) 199 SkDEBUGCODE(this->validate();)
200 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::clear"); 200 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::clear");
201 201
202 AutoCheckFlush acf(fDrawingManager); 202 AutoCheckFlush acf(fDrawingManager);
203 203
204 const SkIRect rtRect = SkIRect::MakeWH(this->width(), this->height()); 204 const SkIRect rtRect = SkIRect::MakeWH(this->width(), this->height());
205 SkIRect clippedRect; 205 SkIRect clippedRect;
206 bool isFull = false;
206 if (!rect || 207 if (!rect ||
207 (canIgnoreRect && fContext->caps()->fullClearIsFree()) || 208 (canIgnoreRect && fContext->caps()->fullClearIsFree()) ||
208 rect->contains(rtRect)) { 209 rect->contains(rtRect)) {
209 rect = &rtRect; 210 rect = &rtRect;
211 isFull = true;
210 } else { 212 } else {
211 clippedRect = *rect; 213 clippedRect = *rect;
212 if (!clippedRect.intersect(rtRect)) { 214 if (!clippedRect.intersect(rtRect)) {
213 return; 215 return;
214 } 216 }
215 rect = &clippedRect; 217 rect = &clippedRect;
216 } 218 }
217 219
218 if (fContext->caps()->useDrawInsteadOfClear()) { 220 if (fContext->caps()->useDrawInsteadOfClear()) {
219 // This works around a driver bug with clear by drawing a rect instead. 221 // This works around a driver bug with clear by drawing a rect instead.
220 // The driver will ignore a clear if it is the only thing rendered to a 222 // The driver will ignore a clear if it is the only thing rendered to a
221 // target before the target is read. 223 // target before the target is read.
222 if (rect == &rtRect) { 224 if (rect == &rtRect) {
223 this->discard(); 225 this->discard();
224 } 226 }
225 227
226 GrPaint paint; 228 GrPaint paint;
227 paint.setColor4f(GrColor4f::FromGrColor(color)); 229 paint.setColor4f(GrColor4f::FromGrColor(color));
228 paint.setXPFactory(GrPorterDuffXPFactory::Make(SkXfermode::kSrc_Mode)); 230 paint.setXPFactory(GrPorterDuffXPFactory::Make(SkXfermode::kSrc_Mode));
229 231
230 this->drawRect(GrNoClip(), paint, SkMatrix::I(), SkRect::Make(*rect)); 232 this->drawRect(GrNoClip(), paint, SkMatrix::I(), SkRect::Make(*rect));
233 } else if (isFull) {
234 this->getDrawTarget()->fullClear(this->accessRenderTarget(), color);
231 } else { 235 } else {
232 sk_sp<GrBatch> batch = GrClearBatch::Make(*rect, color, this->accessRend erTarget()); 236 sk_sp<GrBatch> batch = GrClearBatch::Make(*rect, color, this->accessRend erTarget());
233 this->getDrawTarget()->addBatch(std::move(batch)); 237 this->getDrawTarget()->addBatch(std::move(batch));
234 } 238 }
235 } 239 }
236 240
237 241
238 void GrDrawContext::drawPaint(const GrClip& clip, 242 void GrDrawContext::drawPaint(const GrClip& clip,
239 const GrPaint& origPaint, 243 const GrPaint& origPaint,
240 const SkMatrix& viewMatrix) { 244 const SkMatrix& viewMatrix) {
(...skipping 1062 matching lines...) Expand 10 before | Expand all | Expand 10 after
1303 1307
1304 void GrDrawContext::drawBatch(const GrPipelineBuilder& pipelineBuilder, const Gr Clip& clip, 1308 void GrDrawContext::drawBatch(const GrPipelineBuilder& pipelineBuilder, const Gr Clip& clip,
1305 GrDrawBatch* batch) { 1309 GrDrawBatch* batch) {
1306 ASSERT_SINGLE_OWNER 1310 ASSERT_SINGLE_OWNER
1307 RETURN_IF_ABANDONED 1311 RETURN_IF_ABANDONED
1308 SkDEBUGCODE(this->validate();) 1312 SkDEBUGCODE(this->validate();)
1309 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawBatch"); 1313 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawBatch");
1310 1314
1311 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch); 1315 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch);
1312 } 1316 }
OLDNEW
« no previous file with comments | « no previous file | src/gpu/GrDrawTarget.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698