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

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

Issue 1295813005: Revert of stop dropping AA when rect stays rect (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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
207 static inline bool rect_contains_inclusive(const SkRect& rect, const SkPoint& po int) { 236 static inline bool rect_contains_inclusive(const SkRect& rect, const SkPoint& po int) {
208 return point.fX >= rect.fLeft && point.fX <= rect.fRight && 237 return point.fX >= rect.fLeft && point.fX <= rect.fRight &&
209 point.fY >= rect.fTop && point.fY <= rect.fBottom; 238 point.fY >= rect.fTop && point.fY <= rect.fBottom;
210 } 239 }
211 240
212 void GrDrawContext::drawRect(GrRenderTarget* rt, 241 void GrDrawContext::drawRect(GrRenderTarget* rt,
213 const GrClip& clip, 242 const GrClip& clip,
214 const GrPaint& paint, 243 const GrPaint& paint,
215 const SkMatrix& viewMatrix, 244 const SkMatrix& viewMatrix,
216 const SkRect& rect, 245 const SkRect& rect,
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 GrColor clearColor; 290 GrColor clearColor;
262 if (paint.isConstantBlendedColor(&clearColor)) { 291 if (paint.isConstantBlendedColor(&clearColor)) {
263 fDrawTarget->clear(NULL, clearColor, true, rt); 292 fDrawTarget->clear(NULL, clearColor, true, rt);
264 return; 293 return;
265 } 294 }
266 } 295 }
267 } 296 }
268 } 297 }
269 298
270 GrColor color = paint.getColor(); 299 GrColor color = paint.getColor();
300 SkRect devBoundRect;
271 bool needAA = paint.isAntiAlias() && 301 bool needAA = paint.isAntiAlias() &&
272 !pipelineBuilder.getRenderTarget()->isUnifiedMultisampled(); 302 !pipelineBuilder.getRenderTarget()->isUnifiedMultisampled();
303 bool doAA = needAA && apply_aa_to_rect(fDrawTarget, &pipelineBuilder, &devBo undRect, rect,
304 width, viewMatrix, color);
273 305
274 // The fill path can handle rotation but not skew 306 if (doAA) {
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);
283 SkAutoTUnref<GrDrawBatch> batch; 307 SkAutoTUnref<GrDrawBatch> batch;
284 if (width >= 0) { 308 if (width >= 0) {
285 batch.reset(GrRectBatchFactory::CreateStrokeAA(color, viewMatrix, re ct, devBoundRect, 309 batch.reset(GrRectBatchFactory::CreateStrokeAA(color, viewMatrix, re ct, devBoundRect,
286 *strokeInfo)); 310 *strokeInfo));
287 } else { 311 } else {
288 batch.reset(GrRectBatchFactory::CreateFillAA(color, viewMatrix, rect , devBoundRect)); 312 batch.reset(GrRectBatchFactory::CreateFillAA(color, viewMatrix, rect , devBoundRect));
289 } 313 }
290 fDrawTarget->drawBatch(pipelineBuilder, batch); 314 fDrawTarget->drawBatch(pipelineBuilder, batch);
291 return; 315 return;
292 } 316 }
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
743 RETURN_FALSE_IF_ABANDONED 767 RETURN_FALSE_IF_ABANDONED
744 768
745 ASSERT_OWNED_RESOURCE(rt); 769 ASSERT_OWNED_RESOURCE(rt);
746 SkASSERT(rt); 770 SkASSERT(rt);
747 return true; 771 return true;
748 } 772 }
749 773
750 void GrDrawContext::drawBatch(GrPipelineBuilder* pipelineBuilder, GrDrawBatch* b atch) { 774 void GrDrawContext::drawBatch(GrPipelineBuilder* pipelineBuilder, GrDrawBatch* b atch) {
751 fDrawTarget->drawBatch(*pipelineBuilder, batch); 775 fDrawTarget->drawBatch(*pipelineBuilder, batch);
752 } 776 }
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