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

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

Issue 1295523002: stop dropping AA when rect stays rect (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: clean Created 5 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 | no next file » | 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 "GrAtlasTextContext.h" 9 #include "GrAtlasTextContext.h"
10 #include "GrBatchTest.h" 10 #include "GrBatchTest.h"
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 GrPipelineBuilder pipelineBuilder(*paint, rt, clip); 197 GrPipelineBuilder pipelineBuilder(*paint, rt, clip);
198 fDrawTarget->drawBWRect(pipelineBuilder, 198 fDrawTarget->drawBWRect(pipelineBuilder,
199 paint->getColor(), 199 paint->getColor(),
200 SkMatrix::I(), 200 SkMatrix::I(),
201 r, 201 r,
202 NULL, 202 NULL,
203 &localMatrix); 203 &localMatrix);
204 } 204 }
205 } 205 }
206 206
207 static inline bool is_irect(const SkRect& r) {
208 return SkScalarIsInt(r.fLeft) && SkScalarIsInt(r.fTop) &&
209 SkScalarIsInt(r.fRight) && SkScalarIsInt(r.fBottom);
210 }
211
212 static bool apply_aa_to_rect(GrDrawTarget* target,
213 GrPipelineBuilder* pipelineBuilder,
214 SkRect* devBoundRect,
215 const SkRect& rect,
216 SkScalar strokeWidth,
217 const SkMatrix& combinedMatrix,
218 GrColor color) {
219 if (pipelineBuilder->getRenderTarget()->isUnifiedMultisampled() ||
220 !combinedMatrix.preservesAxisAlignment()) {
221 return false;
222 }
223
224 combinedMatrix.mapRect(devBoundRect, rect);
225 if (!combinedMatrix.rectStaysRect()) {
226 return true;
227 }
228
229 if (strokeWidth < 0) {
230 return !is_irect(*devBoundRect);
231 }
232
233 return true;
234 }
235
236 static inline bool rect_contains_inclusive(const SkRect& rect, const SkPoint& po int) { 207 static inline bool rect_contains_inclusive(const SkRect& rect, const SkPoint& po int) {
237 return point.fX >= rect.fLeft && point.fX <= rect.fRight && 208 return point.fX >= rect.fLeft && point.fX <= rect.fRight &&
238 point.fY >= rect.fTop && point.fY <= rect.fBottom; 209 point.fY >= rect.fTop && point.fY <= rect.fBottom;
239 } 210 }
240 211
241 void GrDrawContext::drawRect(GrRenderTarget* rt, 212 void GrDrawContext::drawRect(GrRenderTarget* rt,
242 const GrClip& clip, 213 const GrClip& clip,
243 const GrPaint& paint, 214 const GrPaint& paint,
244 const SkMatrix& viewMatrix, 215 const SkMatrix& viewMatrix,
245 const SkRect& rect, 216 const SkRect& rect,
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 GrColor clearColor; 261 GrColor clearColor;
291 if (paint.isConstantBlendedColor(&clearColor)) { 262 if (paint.isConstantBlendedColor(&clearColor)) {
292 fDrawTarget->clear(NULL, clearColor, true, rt); 263 fDrawTarget->clear(NULL, clearColor, true, rt);
293 return; 264 return;
294 } 265 }
295 } 266 }
296 } 267 }
297 } 268 }
298 269
299 GrColor color = paint.getColor(); 270 GrColor color = paint.getColor();
300 SkRect devBoundRect;
301 bool needAA = paint.isAntiAlias() && 271 bool needAA = paint.isAntiAlias() &&
302 !pipelineBuilder.getRenderTarget()->isUnifiedMultisampled(); 272 !pipelineBuilder.getRenderTarget()->isUnifiedMultisampled();
303 bool doAA = needAA && apply_aa_to_rect(fDrawTarget, &pipelineBuilder, &devBo undRect, rect,
304 width, viewMatrix, color);
305 273
306 if (doAA) { 274 // The fill path can handle rotation but not skew
275 // The stroke path needs the rect to remain axis aligned (no rotation or ske w)
276 // None of our draw rect calls can handle perspective yet
277 SkASSERT(!viewMatrix.hasPerspective());
278 bool canApplyAA = width >=0 ? viewMatrix.rectStaysRect() : viewMatrix.preser vesRightAngles();
279
280 if (needAA && canApplyAA) {
281 SkRect devBoundRect;
282 viewMatrix.mapRect(&devBoundRect, rect);
307 SkAutoTUnref<GrDrawBatch> batch; 283 SkAutoTUnref<GrDrawBatch> batch;
308 if (width >= 0) { 284 if (width >= 0) {
309 batch.reset(GrRectBatchFactory::CreateStrokeAA(color, viewMatrix, re ct, devBoundRect, 285 batch.reset(GrRectBatchFactory::CreateStrokeAA(color, viewMatrix, re ct, devBoundRect,
310 *strokeInfo)); 286 *strokeInfo));
311 } else { 287 } else {
312 batch.reset(GrRectBatchFactory::CreateFillAA(color, viewMatrix, rect , devBoundRect)); 288 batch.reset(GrRectBatchFactory::CreateFillAA(color, viewMatrix, rect , devBoundRect));
313 } 289 }
314 fDrawTarget->drawBatch(pipelineBuilder, batch); 290 fDrawTarget->drawBatch(pipelineBuilder, batch);
315 return; 291 return;
316 } 292 }
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 RETURN_FALSE_IF_ABANDONED 743 RETURN_FALSE_IF_ABANDONED
768 744
769 ASSERT_OWNED_RESOURCE(rt); 745 ASSERT_OWNED_RESOURCE(rt);
770 SkASSERT(rt); 746 SkASSERT(rt);
771 return true; 747 return true;
772 } 748 }
773 749
774 void GrDrawContext::drawBatch(GrPipelineBuilder* pipelineBuilder, GrDrawBatch* b atch) { 750 void GrDrawContext::drawBatch(GrPipelineBuilder* pipelineBuilder, GrDrawBatch* b atch) {
775 fDrawTarget->drawBatch(*pipelineBuilder, batch); 751 fDrawTarget->drawBatch(*pipelineBuilder, batch);
776 } 752 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698