Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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 // We can only handle AA in certain cases right now. We also can't handle p erspective rects |
| 275 // at all yet. | |
|
robertphillips
2015/08/14 12:54:56
// The fill path can handle rotation but not skew
| |
| 276 SkASSERT(!viewMatrix.hasPerspective()); | |
|
robertphillips
2015/08/14 12:54:55
Extra space after ':' ?
| |
| 277 bool canApplyAA = width >=0 ? viewMatrix.rectStaysRect() : viewMatrix.prese rvesRightAngles(); | |
| 278 | |
| 279 if (needAA && canApplyAA) { | |
| 280 SkRect devBoundRect; | |
| 281 viewMatrix.mapRect(&devBoundRect, rect); | |
| 307 SkAutoTUnref<GrBatch> batch; | 282 SkAutoTUnref<GrBatch> batch; |
| 308 if (width >= 0) { | 283 if (width >= 0) { |
| 309 batch.reset(GrRectBatchFactory::CreateStrokeAA(color, viewMatrix, re ct, devBoundRect, | 284 batch.reset(GrRectBatchFactory::CreateStrokeAA(color, viewMatrix, re ct, devBoundRect, |
| 310 *strokeInfo)); | 285 *strokeInfo)); |
| 311 } else { | 286 } else { |
| 312 batch.reset(GrRectBatchFactory::CreateFillAA(color, viewMatrix, rect , devBoundRect)); | 287 batch.reset(GrRectBatchFactory::CreateFillAA(color, viewMatrix, rect , devBoundRect)); |
| 313 } | 288 } |
| 314 fDrawTarget->drawBatch(pipelineBuilder, batch); | 289 fDrawTarget->drawBatch(pipelineBuilder, batch); |
| 315 return; | 290 return; |
| 316 } | 291 } |
| (...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 768 RETURN_FALSE_IF_ABANDONED | 743 RETURN_FALSE_IF_ABANDONED |
| 769 | 744 |
| 770 ASSERT_OWNED_RESOURCE(rt); | 745 ASSERT_OWNED_RESOURCE(rt); |
| 771 SkASSERT(rt); | 746 SkASSERT(rt); |
| 772 return true; | 747 return true; |
| 773 } | 748 } |
| 774 | 749 |
| 775 void GrDrawContext::drawBatch(GrPipelineBuilder* pipelineBuilder, GrBatch* batch ) { | 750 void GrDrawContext::drawBatch(GrPipelineBuilder* pipelineBuilder, GrBatch* batch ) { |
| 776 fDrawTarget->drawBatch(*pipelineBuilder, batch); | 751 fDrawTarget->drawBatch(*pipelineBuilder, batch); |
| 777 } | 752 } |
| OLD | NEW |