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

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

Issue 1584703003: Remove two varieties of drawNonAARect from GrDrawTarget (Closed) Base URL: https://skia.googlesource.com/skia.git@hidedrawtargetabit
Patch Set: deprecation message on GrTest Created 4 years, 11 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 | « gm/yuvtorgbeffect.cpp ('k') | 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 /* 2 /*
3 * Copyright 2015 Google Inc. 3 * Copyright 2015 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include "GrBatchTest.h" 9 #include "GrBatchTest.h"
10 #include "GrColor.h" 10 #include "GrColor.h"
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 } else { 207 } else {
208 SkMatrix localMatrix; 208 SkMatrix localMatrix;
209 if (!viewMatrix.invert(&localMatrix)) { 209 if (!viewMatrix.invert(&localMatrix)) {
210 SkDebugf("Could not invert matrix\n"); 210 SkDebugf("Could not invert matrix\n");
211 return; 211 return;
212 } 212 }
213 213
214 AutoCheckFlush acf(fDrawingManager); 214 AutoCheckFlush acf(fDrawingManager);
215 215
216 GrPipelineBuilder pipelineBuilder(*paint, fRenderTarget, clip); 216 GrPipelineBuilder pipelineBuilder(*paint, fRenderTarget, clip);
217 this->getDrawTarget()->drawNonAARect(pipelineBuilder, 217 SkAutoTUnref<GrDrawBatch> batch(
218 paint->getColor(), 218 GrRectBatchFactory::CreateNonAAFill(paint->getColor(), SkMatrix: :I(), r, nullptr,
219 SkMatrix::I(), 219 &localMatrix));
220 r, 220 this->getDrawTarget()->drawBatch(pipelineBuilder, batch);
221 localMatrix);
222 } 221 }
223 } 222 }
224 223
225 static inline bool rect_contains_inclusive(const SkRect& rect, const SkPoint& po int) { 224 static inline bool rect_contains_inclusive(const SkRect& rect, const SkPoint& po int) {
226 return point.fX >= rect.fLeft && point.fX <= rect.fRight && 225 return point.fX >= rect.fLeft && point.fX <= rect.fRight &&
227 point.fY >= rect.fTop && point.fY <= rect.fBottom; 226 point.fY >= rect.fTop && point.fY <= rect.fBottom;
228 } 227 }
229 228
230 static bool view_matrix_ok_for_aa_fill_rect(const SkMatrix& viewMatrix) { 229 static bool view_matrix_ok_for_aa_fill_rect(const SkMatrix& viewMatrix) {
231 return viewMatrix.preservesRightAngles(); 230 return viewMatrix.preservesRightAngles();
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 this->getDrawTarget()->clear(nullptr, clearColor, true, fRen derTarget); 280 this->getDrawTarget()->clear(nullptr, clearColor, true, fRen derTarget);
282 return; 281 return;
283 } 282 }
284 } 283 }
285 } 284 }
286 } 285 }
287 286
288 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip); 287 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip);
289 GrColor color = paint.getColor(); 288 GrColor color = paint.getColor();
290 289
290 SkAutoTUnref<GrDrawBatch> batch;
291 if (should_apply_coverage_aa(paint, fRenderTarget)) { 291 if (should_apply_coverage_aa(paint, fRenderTarget)) {
292 SkAutoTUnref<GrDrawBatch> batch;
293 if (width >= 0) { 292 if (width >= 0) {
294 // The stroke path needs the rect to remain axis aligned (no rotatio n or skew). 293 // The stroke path needs the rect to remain axis aligned (no rotatio n or skew).
295 if (viewMatrix.rectStaysRect()) { 294 if (viewMatrix.rectStaysRect()) {
296 batch.reset(GrRectBatchFactory::CreateAAStroke(color, viewMatrix , rect, 295 batch.reset(GrRectBatchFactory::CreateAAStroke(color, viewMatrix , rect,
297 *strokeInfo)); 296 *strokeInfo));
298 } 297 }
299 } else { 298 } else {
300 // The fill path can handle rotation but not skew. 299 // The fill path can handle rotation but not skew.
301 if (view_matrix_ok_for_aa_fill_rect(viewMatrix)) { 300 if (view_matrix_ok_for_aa_fill_rect(viewMatrix)) {
302 SkRect devBoundRect; 301 SkRect devBoundRect;
303 viewMatrix.mapRect(&devBoundRect, rect); 302 viewMatrix.mapRect(&devBoundRect, rect);
304 batch.reset(GrRectBatchFactory::CreateAAFill(color, viewMatrix, rect, 303 batch.reset(GrRectBatchFactory::CreateAAFill(color, viewMatrix, rect,
305 devBoundRect)); 304 devBoundRect));
306 } 305 }
307 } 306 }
308 if (batch) { 307 if (!batch) {
309 this->getDrawTarget()->drawBatch(pipelineBuilder, batch);
310 } else {
311 SkPath path; 308 SkPath path;
312 path.setIsVolatile(true); 309 path.setIsVolatile(true);
313 path.addRect(rect); 310 path.addRect(rect);
314 this->internalDrawPath(&pipelineBuilder, viewMatrix, color, true, pa th, *strokeInfo); 311 this->internalDrawPath(&pipelineBuilder, viewMatrix, color, true, pa th, *strokeInfo);
315 SkASSERT(paint.isAntiAlias()); 312 SkASSERT(paint.isAntiAlias());
313 return;
316 } 314 }
317 return; 315 } else if (width >= 0) {
318 }
319
320 if (width >= 0) {
321 // Non-AA hairlines are snapped to pixel centers to make which pixels ar e hit deterministic 316 // Non-AA hairlines are snapped to pixel centers to make which pixels ar e hit deterministic
322 bool snapToPixelCenters = (0 == width && !fRenderTarget->isUnifiedMultis ampled()); 317 bool snapToPixelCenters = (0 == width && !fRenderTarget->isUnifiedMultis ampled());
323 SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateNonAAStroke( 318 batch.reset(GrRectBatchFactory::CreateNonAAStroke(color, viewMatrix, rec t, width,
324 color, viewMatrix, rect, width, snapToPi xelCenters)); 319 snapToPixelCenters));
325 320
326 // Depending on sub-pixel coordinates and the particular GPU, we may los e a corner of 321 // Depending on sub-pixel coordinates and the particular GPU, we may los e a corner of
327 // hairline rects. We jam all the vertices to pixel centers to avoid thi s, but not when MSAA 322 // hairline rects. We jam all the vertices to pixel centers to avoid thi s, but not when MSAA
328 // is enabled because it can cause ugly artifacts. 323 // is enabled because it can cause ugly artifacts.
329 pipelineBuilder.setState(GrPipelineBuilder::kSnapVerticesToPixelCenters_ Flag, 324 pipelineBuilder.setState(GrPipelineBuilder::kSnapVerticesToPixelCenters_ Flag,
330 snapToPixelCenters); 325 snapToPixelCenters);
331 this->getDrawTarget()->drawBatch(pipelineBuilder, batch);
332 } else { 326 } else {
333 // filled BW rect 327 // filled BW rect
334 this->getDrawTarget()->drawNonAARect(pipelineBuilder, color, viewMatrix, rect); 328 batch.reset(GrRectBatchFactory::CreateNonAAFill(color, viewMatrix, rect, nullptr, nullptr));
335 } 329 }
330 this->getDrawTarget()->drawBatch(pipelineBuilder, batch);
336 } 331 }
337 332
338 void GrDrawContext::fillRectToRect(const GrClip& clip, 333 void GrDrawContext::fillRectToRect(const GrClip& clip,
339 const GrPaint& paint, 334 const GrPaint& paint,
340 const SkMatrix& viewMatrix, 335 const SkMatrix& viewMatrix,
341 const SkRect& rectToDraw, 336 const SkRect& rectToDraw,
342 const SkRect& localRect) { 337 const SkRect& localRect) {
343 ASSERT_SINGLE_OWNER 338 ASSERT_SINGLE_OWNER
344 RETURN_IF_ABANDONED 339 RETURN_IF_ABANDONED
345 SkDEBUGCODE(this->validate();) 340 SkDEBUGCODE(this->validate();)
346 341
347 AutoCheckFlush acf(fDrawingManager); 342 AutoCheckFlush acf(fDrawingManager);
348 343
349 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip); 344 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip);
345 SkAutoTUnref<GrDrawBatch> batch;
350 if (should_apply_coverage_aa(paint, fRenderTarget) && 346 if (should_apply_coverage_aa(paint, fRenderTarget) &&
351 view_matrix_ok_for_aa_fill_rect(viewMatrix)) { 347 view_matrix_ok_for_aa_fill_rect(viewMatrix)) {
352 SkAutoTUnref<GrDrawBatch> batch(GrAAFillRectBatch::CreateWithLocalRect( 348 batch.reset(GrAAFillRectBatch::CreateWithLocalRect(paint.getColor(), vie wMatrix, rectToDraw,
353 paint.getColor(), viewMatrix, rectToDraw, localRect)); 349 localRect));
354 if (batch) {
355 this->drawBatch(&pipelineBuilder, batch);
356 }
357 } else { 350 } else {
358 this->getDrawTarget()->drawNonAARect(pipelineBuilder, 351 batch.reset(GrRectBatchFactory::CreateNonAAFill(paint.getColor(), viewMa trix, rectToDraw,
359 paint.getColor(), 352 &localRect, nullptr));
360 viewMatrix, 353 }
361 rectToDraw, 354
362 localRect); 355 if (batch) {
356 this->drawBatch(&pipelineBuilder, batch);
363 } 357 }
364 } 358 }
365 359
366 void GrDrawContext::fillRectWithLocalMatrix(const GrClip& clip, 360 void GrDrawContext::fillRectWithLocalMatrix(const GrClip& clip,
367 const GrPaint& paint, 361 const GrPaint& paint,
368 const SkMatrix& viewMatrix, 362 const SkMatrix& viewMatrix,
369 const SkRect& rectToDraw, 363 const SkRect& rectToDraw,
370 const SkMatrix& localMatrix) { 364 const SkMatrix& localMatrix) {
371 ASSERT_SINGLE_OWNER 365 ASSERT_SINGLE_OWNER
372 RETURN_IF_ABANDONED 366 RETURN_IF_ABANDONED
373 SkDEBUGCODE(this->validate();) 367 SkDEBUGCODE(this->validate();)
374 368
375 AutoCheckFlush acf(fDrawingManager); 369 AutoCheckFlush acf(fDrawingManager);
376 370
377 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip); 371 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip);
378 372
373 SkAutoTUnref<GrDrawBatch> batch;
379 if (should_apply_coverage_aa(paint, fRenderTarget) && 374 if (should_apply_coverage_aa(paint, fRenderTarget) &&
380 view_matrix_ok_for_aa_fill_rect(viewMatrix)) { 375 view_matrix_ok_for_aa_fill_rect(viewMatrix)) {
381 SkAutoTUnref<GrDrawBatch> batch(GrAAFillRectBatch::Create( 376 batch.reset(GrAAFillRectBatch::Create(paint.getColor(), viewMatrix, loca lMatrix,
382 paint.getColor(), viewMatrix, localMatrix, rectToDraw)); 377 rectToDraw));
383 this->drawBatch(&pipelineBuilder, batch);
384 } else { 378 } else {
385 this->getDrawTarget()->drawNonAARect(pipelineBuilder, 379 batch.reset(GrRectBatchFactory::CreateNonAAFill(paint.getColor(), viewMa trix, rectToDraw,
386 paint.getColor(), 380 nullptr, &localMatrix));
387 viewMatrix,
388 rectToDraw,
389 localMatrix);
390 } 381 }
382 this->getDrawTarget()->drawBatch(pipelineBuilder, batch);
391 } 383 }
392 384
393 void GrDrawContext::drawVertices(const GrClip& clip, 385 void GrDrawContext::drawVertices(const GrClip& clip,
394 const GrPaint& paint, 386 const GrPaint& paint,
395 const SkMatrix& viewMatrix, 387 const SkMatrix& viewMatrix,
396 GrPrimitiveType primitiveType, 388 GrPrimitiveType primitiveType,
397 int vertexCount, 389 int vertexCount,
398 const SkPoint positions[], 390 const SkPoint positions[],
399 const SkPoint texCoords[], 391 const SkPoint texCoords[],
400 const GrColor colors[], 392 const GrColor colors[],
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
828 pr->drawPath(args); 820 pr->drawPath(args);
829 } 821 }
830 822
831 void GrDrawContext::drawBatch(GrPipelineBuilder* pipelineBuilder, GrDrawBatch* b atch) { 823 void GrDrawContext::drawBatch(GrPipelineBuilder* pipelineBuilder, GrDrawBatch* b atch) {
832 ASSERT_SINGLE_OWNER 824 ASSERT_SINGLE_OWNER
833 RETURN_IF_ABANDONED 825 RETURN_IF_ABANDONED
834 SkDEBUGCODE(this->validate();) 826 SkDEBUGCODE(this->validate();)
835 827
836 this->getDrawTarget()->drawBatch(*pipelineBuilder, batch); 828 this->getDrawTarget()->drawBatch(*pipelineBuilder, batch);
837 } 829 }
OLDNEW
« no previous file with comments | « gm/yuvtorgbeffect.cpp ('k') | src/gpu/GrDrawTarget.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698