| 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" |
| 11 #include "GrColor.h" | 11 #include "GrColor.h" |
| 12 #include "GrDrawContext.h" | 12 #include "GrDrawContext.h" |
| 13 #include "GrOvalRenderer.h" | 13 #include "GrOvalRenderer.h" |
| 14 #include "GrPathRenderer.h" | 14 #include "GrPathRenderer.h" |
| 15 #include "GrRenderTarget.h" | 15 #include "GrRenderTarget.h" |
| 16 #include "GrRenderTargetPriv.h" | 16 #include "GrRenderTargetPriv.h" |
| 17 #include "GrStencilAndCoverTextContext.h" | 17 #include "GrStencilAndCoverTextContext.h" |
| 18 | 18 |
| 19 #include "batches/GrBatch.h" | 19 #include "batches/GrBatch.h" |
| 20 #include "batches/GrDrawAtlasBatch.h" | 20 #include "batches/GrDrawAtlasBatch.h" |
| 21 #include "batches/GrDrawVerticesBatch.h" | 21 #include "batches/GrDrawVerticesBatch.h" |
| 22 #include "batches/GrRectBatchFactory.h" | 22 #include "batches/GrRectBatchFactory.h" |
| 23 | 23 |
| 24 #include "draws/GrDraw.h" |
| 25 |
| 24 #define ASSERT_OWNED_RESOURCE(R) SkASSERT(!(R) || (R)->getContext() == fContext) | 26 #define ASSERT_OWNED_RESOURCE(R) SkASSERT(!(R) || (R)->getContext() == fContext) |
| 25 #define RETURN_IF_ABANDONED if (!fDrawTarget) { return; } | 27 #define RETURN_IF_ABANDONED if (!fDrawTarget) { return; } |
| 26 #define RETURN_FALSE_IF_ABANDONED if (!fDrawTarget) { return false; } | 28 #define RETURN_FALSE_IF_ABANDONED if (!fDrawTarget) { return false; } |
| 27 #define RETURN_NULL_IF_ABANDONED if (!fDrawTarget) { return nullptr; } | 29 #define RETURN_NULL_IF_ABANDONED if (!fDrawTarget) { return nullptr; } |
| 28 | 30 |
| 29 class AutoCheckFlush { | 31 class AutoCheckFlush { |
| 30 public: | 32 public: |
| 31 AutoCheckFlush(GrContext* context) : fContext(context) { SkASSERT(context);
} | 33 AutoCheckFlush(GrContext* context) : fContext(context) { SkASSERT(context);
} |
| 32 ~AutoCheckFlush() { fContext->flushIfNecessary(); } | 34 ~AutoCheckFlush() { fContext->flushIfNecessary(); } |
| 33 | 35 |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 bool canApplyAA = width >=0 ? viewMatrix.rectStaysRect() : viewMatrix.preser
vesRightAngles(); | 274 bool canApplyAA = width >=0 ? viewMatrix.rectStaysRect() : viewMatrix.preser
vesRightAngles(); |
| 273 | 275 |
| 274 if (needAA && canApplyAA) { | 276 if (needAA && canApplyAA) { |
| 275 SkASSERT(!viewMatrix.hasPerspective()); | 277 SkASSERT(!viewMatrix.hasPerspective()); |
| 276 SkAutoTUnref<GrDrawBatch> batch; | 278 SkAutoTUnref<GrDrawBatch> batch; |
| 277 if (width >= 0) { | 279 if (width >= 0) { |
| 278 batch.reset(GrRectBatchFactory::CreateAAStroke(color, viewMatrix, re
ct, *strokeInfo)); | 280 batch.reset(GrRectBatchFactory::CreateAAStroke(color, viewMatrix, re
ct, *strokeInfo)); |
| 279 } else { | 281 } else { |
| 280 SkRect devBoundRect; | 282 SkRect devBoundRect; |
| 281 viewMatrix.mapRect(&devBoundRect, rect); | 283 viewMatrix.mapRect(&devBoundRect, rect); |
| 282 batch.reset(GrRectBatchFactory::CreateAAFill(color, viewMatrix, rect
, devBoundRect)); | 284 batch.reset(GrRectBatchFactory::CreateAAFill(color, viewMatrix, rect
)); |
| 283 } | 285 } |
| 284 fDrawTarget->drawBatch(pipelineBuilder, batch); | 286 fDrawTarget->drawBatch(pipelineBuilder, batch); |
| 285 return; | 287 return; |
| 286 } | 288 } |
| 287 | 289 |
| 288 if (width >= 0) { | 290 if (width >= 0) { |
| 289 // Non-AA hairlines are snapped to pixel centers to make which pixels ar
e hit deterministic | 291 // Non-AA hairlines are snapped to pixel centers to make which pixels ar
e hit deterministic |
| 290 bool snapToPixelCenters = (0 == width && !rt->isUnifiedMultisampled()); | 292 bool snapToPixelCenters = (0 == width && !rt->isUnifiedMultisampled()); |
| 291 SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateNonAAStroke( | 293 SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateNonAAStroke( |
| 292 color, viewMatrix, rect, width, snapToPi
xelCenters)); | 294 color, viewMatrix, rect, width, snapToPi
xelCenters)); |
| (...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 752 } | 754 } |
| 753 | 755 |
| 754 bool GrDrawContext::prepareToDraw(GrRenderTarget* rt) { | 756 bool GrDrawContext::prepareToDraw(GrRenderTarget* rt) { |
| 755 RETURN_FALSE_IF_ABANDONED | 757 RETURN_FALSE_IF_ABANDONED |
| 756 | 758 |
| 757 ASSERT_OWNED_RESOURCE(rt); | 759 ASSERT_OWNED_RESOURCE(rt); |
| 758 SkASSERT(rt); | 760 SkASSERT(rt); |
| 759 return true; | 761 return true; |
| 760 } | 762 } |
| 761 | 763 |
| 762 void GrDrawContext::drawBatch(GrPipelineBuilder* pipelineBuilder, GrDrawBatch* b
atch) { | 764 void GrDrawContext::drawBatch(const GrPipelineBuilder& pipelineBuilder, GrDrawBa
tch* batch) { |
| 763 fDrawTarget->drawBatch(*pipelineBuilder, batch); | 765 RETURN_IF_ABANDONED |
| 766 |
| 767 AutoCheckFlush acf(fContext); |
| 768 // The caller will assert it owns the rendertarget |
| 769 |
| 770 fDrawTarget->drawBatch(pipelineBuilder, batch); |
| 764 } | 771 } |
| 772 |
| 773 GrBatch* GrDrawContext::lastBatch() { |
| 774 RETURN_NULL_IF_ABANDONED |
| 775 |
| 776 return fDrawTarget->lastBatch(); |
| 777 } |
| OLD | NEW |