| 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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 AutoCheckFlush acf(fContext); | 192 AutoCheckFlush acf(fContext); |
| 193 if (!this->prepareToDraw(rt)) { | 193 if (!this->prepareToDraw(rt)) { |
| 194 return; | 194 return; |
| 195 } | 195 } |
| 196 | 196 |
| 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 localMatrix); |
| 203 &localMatrix); | |
| 204 } | 203 } |
| 205 } | 204 } |
| 206 | 205 |
| 207 static inline bool rect_contains_inclusive(const SkRect& rect, const SkPoint& po
int) { | 206 static inline bool rect_contains_inclusive(const SkRect& rect, const SkPoint& po
int) { |
| 208 return point.fX >= rect.fLeft && point.fX <= rect.fRight && | 207 return point.fX >= rect.fLeft && point.fX <= rect.fRight && |
| 209 point.fY >= rect.fTop && point.fY <= rect.fBottom; | 208 point.fY >= rect.fTop && point.fY <= rect.fBottom; |
| 210 } | 209 } |
| 211 | 210 |
| 212 void GrDrawContext::drawRect(GrRenderTarget* rt, | 211 void GrDrawContext::drawRect(GrRenderTarget* rt, |
| 213 const GrClip& clip, | 212 const GrClip& clip, |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 color, viewMatrix, rect, width, snapToPi
xelCenters)); | 297 color, viewMatrix, rect, width, snapToPi
xelCenters)); |
| 299 | 298 |
| 300 // Depending on sub-pixel coordinates and the particular GPU, we may los
e a corner of | 299 // Depending on sub-pixel coordinates and the particular GPU, we may los
e a corner of |
| 301 // hairline rects. We jam all the vertices to pixel centers to avoid thi
s, but not when MSAA | 300 // hairline rects. We jam all the vertices to pixel centers to avoid thi
s, but not when MSAA |
| 302 // is enabled because it can cause ugly artifacts. | 301 // is enabled because it can cause ugly artifacts. |
| 303 pipelineBuilder.setState(GrPipelineBuilder::kSnapVerticesToPixelCenters_
Flag, | 302 pipelineBuilder.setState(GrPipelineBuilder::kSnapVerticesToPixelCenters_
Flag, |
| 304 snapToPixelCenters); | 303 snapToPixelCenters); |
| 305 fDrawTarget->drawBatch(pipelineBuilder, batch); | 304 fDrawTarget->drawBatch(pipelineBuilder, batch); |
| 306 } else { | 305 } else { |
| 307 // filled BW rect | 306 // filled BW rect |
| 308 fDrawTarget->drawSimpleRect(pipelineBuilder, color, viewMatrix, rect); | 307 fDrawTarget->drawBWRect(pipelineBuilder, color, viewMatrix, rect); |
| 309 } | 308 } |
| 310 } | 309 } |
| 311 | 310 |
| 312 void GrDrawContext::drawNonAARectToRect(GrRenderTarget* rt, | 311 void GrDrawContext::drawNonAARectToRect(GrRenderTarget* rt, |
| 313 const GrClip& clip, | 312 const GrClip& clip, |
| 314 const GrPaint& paint, | 313 const GrPaint& paint, |
| 315 const SkMatrix& viewMatrix, | 314 const SkMatrix& viewMatrix, |
| 316 const SkRect& rectToDraw, | 315 const SkRect& rectToDraw, |
| 317 const SkRect& localRect, | 316 const SkRect& localRect) { |
| 318 const SkMatrix* localMatrix) { | |
| 319 RETURN_IF_ABANDONED | 317 RETURN_IF_ABANDONED |
| 320 AutoCheckFlush acf(fContext); | 318 AutoCheckFlush acf(fContext); |
| 321 if (!this->prepareToDraw(rt)) { | 319 if (!this->prepareToDraw(rt)) { |
| 320 return; |
| 321 } |
| 322 |
| 323 GrPipelineBuilder pipelineBuilder(paint, rt, clip); |
| 324 fDrawTarget->drawBWRect(pipelineBuilder, |
| 325 paint.getColor(), |
| 326 viewMatrix, |
| 327 rectToDraw, |
| 328 localRect); |
| 329 } |
| 330 |
| 331 void GrDrawContext::drawNonAARectWithLocalMatrix(GrRenderTarget* rt, |
| 332 const GrClip& clip, |
| 333 const GrPaint& paint, |
| 334 const SkMatrix& viewMatrix, |
| 335 const SkRect& rectToDraw, |
| 336 const SkMatrix& localMatrix) { |
| 337 RETURN_IF_ABANDONED |
| 338 AutoCheckFlush acf(fContext); |
| 339 if (!this->prepareToDraw(rt)) { |
| 322 return; | 340 return; |
| 323 } | 341 } |
| 324 | 342 |
| 325 GrPipelineBuilder pipelineBuilder(paint, rt, clip); | 343 GrPipelineBuilder pipelineBuilder(paint, rt, clip); |
| 326 fDrawTarget->drawBWRect(pipelineBuilder, | 344 fDrawTarget->drawBWRect(pipelineBuilder, |
| 327 paint.getColor(), | 345 paint.getColor(), |
| 328 viewMatrix, | 346 viewMatrix, |
| 329 rectToDraw, | 347 rectToDraw, |
| 330 &localRect, | |
| 331 localMatrix); | 348 localMatrix); |
| 332 } | 349 } |
| 333 | 350 |
| 334 void GrDrawContext::drawVertices(GrRenderTarget* rt, | 351 void GrDrawContext::drawVertices(GrRenderTarget* rt, |
| 335 const GrClip& clip, | 352 const GrClip& clip, |
| 336 const GrPaint& paint, | 353 const GrPaint& paint, |
| 337 const SkMatrix& viewMatrix, | 354 const SkMatrix& viewMatrix, |
| 338 GrPrimitiveType primitiveType, | 355 GrPrimitiveType primitiveType, |
| 339 int vertexCount, | 356 int vertexCount, |
| 340 const SkPoint positions[], | 357 const SkPoint positions[], |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 743 RETURN_FALSE_IF_ABANDONED | 760 RETURN_FALSE_IF_ABANDONED |
| 744 | 761 |
| 745 ASSERT_OWNED_RESOURCE(rt); | 762 ASSERT_OWNED_RESOURCE(rt); |
| 746 SkASSERT(rt); | 763 SkASSERT(rt); |
| 747 return true; | 764 return true; |
| 748 } | 765 } |
| 749 | 766 |
| 750 void GrDrawContext::drawBatch(GrPipelineBuilder* pipelineBuilder, GrDrawBatch* b
atch) { | 767 void GrDrawContext::drawBatch(GrPipelineBuilder* pipelineBuilder, GrDrawBatch* b
atch) { |
| 751 fDrawTarget->drawBatch(*pipelineBuilder, batch); | 768 fDrawTarget->drawBatch(*pipelineBuilder, batch); |
| 752 } | 769 } |
| OLD | NEW |