robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 8 | #include "GrBatchTest.h" |
jvanverth | 31ff762 | 2015-08-07 10:09:28 -0700 | [diff] [blame] | 9 | #include "GrColor.h" |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 10 | #include "GrDrawContext.h" |
robertphillips | 391395d | 2016-03-02 09:26:36 -0800 | [diff] [blame] | 11 | #include "GrDrawContextPriv.h" |
robertphillips | 77a2e52 | 2015-10-17 07:43:27 -0700 | [diff] [blame] | 12 | #include "GrDrawingManager.h" |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 13 | #include "GrOvalRenderer.h" |
| 14 | #include "GrPathRenderer.h" |
robertphillips | 2334fb6 | 2015-06-17 05:43:33 -0700 | [diff] [blame] | 15 | #include "GrRenderTarget.h" |
| 16 | #include "GrRenderTargetPriv.h" |
bsalomon | 473addf | 2015-10-02 07:49:05 -0700 | [diff] [blame] | 17 | #include "GrResourceProvider.h" |
robertphillips | 2d70dcb | 2015-10-06 07:38:23 -0700 | [diff] [blame] | 18 | #include "SkSurfacePriv.h" |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 19 | |
joshualitt | 7441782 | 2015-08-07 11:42:16 -0700 | [diff] [blame] | 20 | #include "batches/GrBatch.h" |
jvanverth | 14b8803 | 2015-08-07 12:18:54 -0700 | [diff] [blame] | 21 | #include "batches/GrDrawAtlasBatch.h" |
joshualitt | 2771b56 | 2015-08-07 12:46:26 -0700 | [diff] [blame] | 22 | #include "batches/GrDrawVerticesBatch.h" |
joshualitt | 7fc2a26 | 2015-08-10 10:30:14 -0700 | [diff] [blame] | 23 | #include "batches/GrRectBatchFactory.h" |
joshualitt | 33a5fce | 2015-11-18 13:28:51 -0800 | [diff] [blame] | 24 | #include "batches/GrNinePatch.h" // TODO Factory |
joshualitt | 7441782 | 2015-08-07 11:42:16 -0700 | [diff] [blame] | 25 | |
robertphillips | 0009589 | 2016-02-29 13:50:40 -0800 | [diff] [blame] | 26 | #include "effects/GrRRectEffect.h" |
| 27 | |
joshualitt | e804292 | 2015-12-11 06:11:21 -0800 | [diff] [blame] | 28 | #include "text/GrAtlasTextContext.h" |
| 29 | #include "text/GrStencilAndCoverTextContext.h" |
| 30 | |
joshualitt | bc90735 | 2016-01-13 06:45:40 -0800 | [diff] [blame] | 31 | #include "../private/GrAuditTrail.h" |
| 32 | |
robertphillips | 77a2e52 | 2015-10-17 07:43:27 -0700 | [diff] [blame] | 33 | #define ASSERT_OWNED_RESOURCE(R) SkASSERT(!(R) || (R)->getContext() == fDrawingManager->getContext()) |
joshualitt | 1de610a | 2016-01-06 08:26:09 -0800 | [diff] [blame] | 34 | #define ASSERT_SINGLE_OWNER \ |
joshualitt | de8dc7e | 2016-01-08 10:09:13 -0800 | [diff] [blame] | 35 | SkDEBUGCODE(GrSingleOwner::AutoEnforce debug_SingleOwner(fSingleOwner);) |
robertphillips | 391395d | 2016-03-02 09:26:36 -0800 | [diff] [blame] | 36 | #define ASSERT_SINGLE_OWNER_PRIV \ |
| 37 | SkDEBUGCODE(GrSingleOwner::AutoEnforce debug_SingleOwner(fDrawContext->fSingleOwner);) |
robertphillips | 77a2e52 | 2015-10-17 07:43:27 -0700 | [diff] [blame] | 38 | #define RETURN_IF_ABANDONED if (fDrawingManager->abandoned()) { return; } |
| 39 | #define RETURN_FALSE_IF_ABANDONED if (fDrawingManager->abandoned()) { return false; } |
robertphillips | 391395d | 2016-03-02 09:26:36 -0800 | [diff] [blame] | 40 | #define RETURN_FALSE_IF_ABANDONED_PRIV if (fDrawContext->fDrawingManager->abandoned()) { return false; } |
robertphillips | 77a2e52 | 2015-10-17 07:43:27 -0700 | [diff] [blame] | 41 | #define RETURN_NULL_IF_ABANDONED if (fDrawingManager->abandoned()) { return nullptr; } |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 42 | |
| 43 | class AutoCheckFlush { |
| 44 | public: |
halcanary | 9d524f2 | 2016-03-29 09:03:52 -0700 | [diff] [blame] | 45 | AutoCheckFlush(GrDrawingManager* drawingManager) : fDrawingManager(drawingManager) { |
robertphillips | 77a2e52 | 2015-10-17 07:43:27 -0700 | [diff] [blame] | 46 | SkASSERT(fDrawingManager); |
| 47 | } |
| 48 | ~AutoCheckFlush() { fDrawingManager->getContext()->flushIfNecessary(); } |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 49 | |
| 50 | private: |
robertphillips | 77a2e52 | 2015-10-17 07:43:27 -0700 | [diff] [blame] | 51 | GrDrawingManager* fDrawingManager; |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 52 | }; |
| 53 | |
robertphillips | a106c62 | 2015-10-16 09:07:06 -0700 | [diff] [blame] | 54 | // In MDB mode the reffing of the 'getLastDrawTarget' call's result allows in-progress |
| 55 | // drawTargets to be picked up and added to by drawContexts lower in the call |
| 56 | // stack. When this occurs with a closed drawTarget, a new one will be allocated |
| 57 | // when the drawContext attempts to use it (via getDrawTarget). |
joshualitt | 1b39f43 | 2016-02-11 06:46:52 -0800 | [diff] [blame] | 58 | GrDrawContext::GrDrawContext(GrContext* context, |
| 59 | GrDrawingManager* drawingMgr, |
robertphillips | 6c7e325 | 2016-04-27 10:47:51 -0700 | [diff] [blame] | 60 | sk_sp<GrRenderTarget> rt, |
joshualitt | de8dc7e | 2016-01-08 10:09:13 -0800 | [diff] [blame] | 61 | const SkSurfaceProps* surfaceProps, |
joshualitt | bc90735 | 2016-01-13 06:45:40 -0800 | [diff] [blame] | 62 | GrAuditTrail* auditTrail, |
joshualitt | de8dc7e | 2016-01-08 10:09:13 -0800 | [diff] [blame] | 63 | GrSingleOwner* singleOwner) |
robertphillips | 77a2e52 | 2015-10-17 07:43:27 -0700 | [diff] [blame] | 64 | : fDrawingManager(drawingMgr) |
robertphillips | 6c7e325 | 2016-04-27 10:47:51 -0700 | [diff] [blame] | 65 | , fRenderTarget(std::move(rt)) |
| 66 | , fDrawTarget(SkSafeRef(fRenderTarget->getLastDrawTarget())) |
joshualitt | 1b39f43 | 2016-02-11 06:46:52 -0800 | [diff] [blame] | 67 | , fContext(context) |
joshualitt | de8dc7e | 2016-01-08 10:09:13 -0800 | [diff] [blame] | 68 | , fSurfaceProps(SkSurfacePropsCopyOrDefault(surfaceProps)) |
joshualitt | bc90735 | 2016-01-13 06:45:40 -0800 | [diff] [blame] | 69 | , fAuditTrail(auditTrail) |
joshualitt | 6d0872d | 2016-01-11 08:27:48 -0800 | [diff] [blame] | 70 | #ifdef SK_DEBUG |
| 71 | , fSingleOwner(singleOwner) |
| 72 | #endif |
| 73 | { |
robertphillips | 2e1e51f | 2015-10-15 08:01:48 -0700 | [diff] [blame] | 74 | SkDEBUGCODE(this->validate();) |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 75 | } |
| 76 | |
robertphillips | 2e1e51f | 2015-10-15 08:01:48 -0700 | [diff] [blame] | 77 | #ifdef SK_DEBUG |
| 78 | void GrDrawContext::validate() const { |
| 79 | SkASSERT(fRenderTarget); |
| 80 | ASSERT_OWNED_RESOURCE(fRenderTarget); |
robertphillips | a106c62 | 2015-10-16 09:07:06 -0700 | [diff] [blame] | 81 | |
| 82 | if (fDrawTarget && !fDrawTarget->isClosed()) { |
| 83 | SkASSERT(fRenderTarget->getLastDrawTarget() == fDrawTarget); |
| 84 | } |
robertphillips | 2e1e51f | 2015-10-15 08:01:48 -0700 | [diff] [blame] | 85 | } |
| 86 | #endif |
| 87 | |
robertphillips | a106c62 | 2015-10-16 09:07:06 -0700 | [diff] [blame] | 88 | GrDrawContext::~GrDrawContext() { |
joshualitt | 1de610a | 2016-01-06 08:26:09 -0800 | [diff] [blame] | 89 | ASSERT_SINGLE_OWNER |
robertphillips | a106c62 | 2015-10-16 09:07:06 -0700 | [diff] [blame] | 90 | SkSafeUnref(fDrawTarget); |
| 91 | } |
| 92 | |
| 93 | GrDrawTarget* GrDrawContext::getDrawTarget() { |
joshualitt | 1de610a | 2016-01-06 08:26:09 -0800 | [diff] [blame] | 94 | ASSERT_SINGLE_OWNER |
robertphillips | a106c62 | 2015-10-16 09:07:06 -0700 | [diff] [blame] | 95 | SkDEBUGCODE(this->validate();) |
| 96 | |
| 97 | if (!fDrawTarget || fDrawTarget->isClosed()) { |
robertphillips | 6c7e325 | 2016-04-27 10:47:51 -0700 | [diff] [blame] | 98 | fDrawTarget = fDrawingManager->newDrawTarget(fRenderTarget.get()); |
robertphillips | a106c62 | 2015-10-16 09:07:06 -0700 | [diff] [blame] | 99 | } |
| 100 | |
| 101 | return fDrawTarget; |
| 102 | } |
| 103 | |
bsalomon | b8fea97 | 2016-02-16 07:34:17 -0800 | [diff] [blame] | 104 | bool GrDrawContext::copySurface(GrSurface* src, const SkIRect& srcRect, const SkIPoint& dstPoint) { |
joshualitt | 1de610a | 2016-01-06 08:26:09 -0800 | [diff] [blame] | 105 | ASSERT_SINGLE_OWNER |
bsalomon | b8fea97 | 2016-02-16 07:34:17 -0800 | [diff] [blame] | 106 | RETURN_FALSE_IF_ABANDONED |
robertphillips | 2e1e51f | 2015-10-15 08:01:48 -0700 | [diff] [blame] | 107 | SkDEBUGCODE(this->validate();) |
joshualitt | bc90735 | 2016-01-13 06:45:40 -0800 | [diff] [blame] | 108 | GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::copySurface"); |
robertphillips | 2d70dcb | 2015-10-06 07:38:23 -0700 | [diff] [blame] | 109 | |
robertphillips | 6c7e325 | 2016-04-27 10:47:51 -0700 | [diff] [blame] | 110 | return this->getDrawTarget()->copySurface(fRenderTarget.get(), src, srcRect, dstPoint); |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 111 | } |
| 112 | |
robertphillips | 2e1e51f | 2015-10-15 08:01:48 -0700 | [diff] [blame] | 113 | void GrDrawContext::drawText(const GrClip& clip, const GrPaint& grPaint, |
robertphillips | 2334fb6 | 2015-06-17 05:43:33 -0700 | [diff] [blame] | 114 | const SkPaint& skPaint, |
| 115 | const SkMatrix& viewMatrix, |
| 116 | const char text[], size_t byteLength, |
| 117 | SkScalar x, SkScalar y, const SkIRect& clipBounds) { |
joshualitt | 1de610a | 2016-01-06 08:26:09 -0800 | [diff] [blame] | 118 | ASSERT_SINGLE_OWNER |
robertphillips | 2d70dcb | 2015-10-06 07:38:23 -0700 | [diff] [blame] | 119 | RETURN_IF_ABANDONED |
robertphillips | 2e1e51f | 2015-10-15 08:01:48 -0700 | [diff] [blame] | 120 | SkDEBUGCODE(this->validate();) |
joshualitt | bc90735 | 2016-01-13 06:45:40 -0800 | [diff] [blame] | 121 | GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawText"); |
robertphillips | 2d70dcb | 2015-10-06 07:38:23 -0700 | [diff] [blame] | 122 | |
joshualitt | 96880d9 | 2016-02-16 10:36:53 -0800 | [diff] [blame] | 123 | if (!fAtlasTextContext) { |
joshualitt | 8db8678 | 2016-02-17 05:40:00 -0800 | [diff] [blame] | 124 | fAtlasTextContext.reset(GrAtlasTextContext::Create()); |
robertphillips | 2334fb6 | 2015-06-17 05:43:33 -0700 | [diff] [blame] | 125 | } |
| 126 | |
joshualitt | 96880d9 | 2016-02-16 10:36:53 -0800 | [diff] [blame] | 127 | fAtlasTextContext->drawText(fContext, this, clip, grPaint, skPaint, viewMatrix, fSurfaceProps, |
| 128 | text, byteLength, x, y, clipBounds); |
robertphillips | 2334fb6 | 2015-06-17 05:43:33 -0700 | [diff] [blame] | 129 | } |
robertphillips | caef345 | 2015-11-11 13:18:11 -0800 | [diff] [blame] | 130 | |
robertphillips | 2e1e51f | 2015-10-15 08:01:48 -0700 | [diff] [blame] | 131 | void GrDrawContext::drawPosText(const GrClip& clip, const GrPaint& grPaint, |
robertphillips | 2334fb6 | 2015-06-17 05:43:33 -0700 | [diff] [blame] | 132 | const SkPaint& skPaint, |
| 133 | const SkMatrix& viewMatrix, |
| 134 | const char text[], size_t byteLength, |
| 135 | const SkScalar pos[], int scalarsPerPosition, |
| 136 | const SkPoint& offset, const SkIRect& clipBounds) { |
joshualitt | 1de610a | 2016-01-06 08:26:09 -0800 | [diff] [blame] | 137 | ASSERT_SINGLE_OWNER |
robertphillips | 2d70dcb | 2015-10-06 07:38:23 -0700 | [diff] [blame] | 138 | RETURN_IF_ABANDONED |
robertphillips | 2e1e51f | 2015-10-15 08:01:48 -0700 | [diff] [blame] | 139 | SkDEBUGCODE(this->validate();) |
joshualitt | bc90735 | 2016-01-13 06:45:40 -0800 | [diff] [blame] | 140 | GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawPosText"); |
robertphillips | 2d70dcb | 2015-10-06 07:38:23 -0700 | [diff] [blame] | 141 | |
joshualitt | 96880d9 | 2016-02-16 10:36:53 -0800 | [diff] [blame] | 142 | if (!fAtlasTextContext) { |
joshualitt | 8db8678 | 2016-02-17 05:40:00 -0800 | [diff] [blame] | 143 | fAtlasTextContext.reset(GrAtlasTextContext::Create()); |
robertphillips | 2334fb6 | 2015-06-17 05:43:33 -0700 | [diff] [blame] | 144 | } |
| 145 | |
joshualitt | 96880d9 | 2016-02-16 10:36:53 -0800 | [diff] [blame] | 146 | fAtlasTextContext->drawPosText(fContext, this, clip, grPaint, skPaint, viewMatrix, |
| 147 | fSurfaceProps, text, byteLength, pos, scalarsPerPosition, |
| 148 | offset, clipBounds); |
robertphillips | 2334fb6 | 2015-06-17 05:43:33 -0700 | [diff] [blame] | 149 | |
| 150 | } |
robertphillips | caef345 | 2015-11-11 13:18:11 -0800 | [diff] [blame] | 151 | |
robertphillips | 2e1e51f | 2015-10-15 08:01:48 -0700 | [diff] [blame] | 152 | void GrDrawContext::drawTextBlob(const GrClip& clip, const SkPaint& skPaint, |
robertphillips | 2334fb6 | 2015-06-17 05:43:33 -0700 | [diff] [blame] | 153 | const SkMatrix& viewMatrix, const SkTextBlob* blob, |
| 154 | SkScalar x, SkScalar y, |
| 155 | SkDrawFilter* filter, const SkIRect& clipBounds) { |
joshualitt | 1de610a | 2016-01-06 08:26:09 -0800 | [diff] [blame] | 156 | ASSERT_SINGLE_OWNER |
robertphillips | 2d70dcb | 2015-10-06 07:38:23 -0700 | [diff] [blame] | 157 | RETURN_IF_ABANDONED |
robertphillips | 2e1e51f | 2015-10-15 08:01:48 -0700 | [diff] [blame] | 158 | SkDEBUGCODE(this->validate();) |
joshualitt | bc90735 | 2016-01-13 06:45:40 -0800 | [diff] [blame] | 159 | GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawTextBlob"); |
robertphillips | 2d70dcb | 2015-10-06 07:38:23 -0700 | [diff] [blame] | 160 | |
joshualitt | 96880d9 | 2016-02-16 10:36:53 -0800 | [diff] [blame] | 161 | if (!fAtlasTextContext) { |
joshualitt | 8db8678 | 2016-02-17 05:40:00 -0800 | [diff] [blame] | 162 | fAtlasTextContext.reset(GrAtlasTextContext::Create()); |
robertphillips | 2334fb6 | 2015-06-17 05:43:33 -0700 | [diff] [blame] | 163 | } |
| 164 | |
joshualitt | 96880d9 | 2016-02-16 10:36:53 -0800 | [diff] [blame] | 165 | fAtlasTextContext->drawTextBlob(fContext, this, clip, skPaint, viewMatrix, fSurfaceProps, blob, |
| 166 | x, y, filter, clipBounds); |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 167 | } |
| 168 | |
robertphillips | 2e1e51f | 2015-10-15 08:01:48 -0700 | [diff] [blame] | 169 | void GrDrawContext::discard() { |
joshualitt | 1de610a | 2016-01-06 08:26:09 -0800 | [diff] [blame] | 170 | ASSERT_SINGLE_OWNER |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 171 | RETURN_IF_ABANDONED |
robertphillips | 2e1e51f | 2015-10-15 08:01:48 -0700 | [diff] [blame] | 172 | SkDEBUGCODE(this->validate();) |
joshualitt | bc90735 | 2016-01-13 06:45:40 -0800 | [diff] [blame] | 173 | GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::discard"); |
robertphillips | 2e1e51f | 2015-10-15 08:01:48 -0700 | [diff] [blame] | 174 | |
robertphillips | 77a2e52 | 2015-10-17 07:43:27 -0700 | [diff] [blame] | 175 | AutoCheckFlush acf(fDrawingManager); |
robertphillips | 6c7e325 | 2016-04-27 10:47:51 -0700 | [diff] [blame] | 176 | this->getDrawTarget()->discard(fRenderTarget.get()); |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 177 | } |
| 178 | |
robertphillips | 2e1e51f | 2015-10-15 08:01:48 -0700 | [diff] [blame] | 179 | void GrDrawContext::clear(const SkIRect* rect, |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 180 | const GrColor color, |
| 181 | bool canIgnoreRect) { |
joshualitt | 1de610a | 2016-01-06 08:26:09 -0800 | [diff] [blame] | 182 | ASSERT_SINGLE_OWNER |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 183 | RETURN_IF_ABANDONED |
robertphillips | 2e1e51f | 2015-10-15 08:01:48 -0700 | [diff] [blame] | 184 | SkDEBUGCODE(this->validate();) |
joshualitt | bc90735 | 2016-01-13 06:45:40 -0800 | [diff] [blame] | 185 | GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::clear"); |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 186 | |
robertphillips | 77a2e52 | 2015-10-17 07:43:27 -0700 | [diff] [blame] | 187 | AutoCheckFlush acf(fDrawingManager); |
robertphillips | 6c7e325 | 2016-04-27 10:47:51 -0700 | [diff] [blame] | 188 | this->getDrawTarget()->clear(rect, color, canIgnoreRect, fRenderTarget.get()); |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 189 | } |
| 190 | |
| 191 | |
robertphillips | 2e1e51f | 2015-10-15 08:01:48 -0700 | [diff] [blame] | 192 | void GrDrawContext::drawPaint(const GrClip& clip, |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 193 | const GrPaint& origPaint, |
| 194 | const SkMatrix& viewMatrix) { |
joshualitt | 1de610a | 2016-01-06 08:26:09 -0800 | [diff] [blame] | 195 | ASSERT_SINGLE_OWNER |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 196 | RETURN_IF_ABANDONED |
robertphillips | 2e1e51f | 2015-10-15 08:01:48 -0700 | [diff] [blame] | 197 | SkDEBUGCODE(this->validate();) |
joshualitt | bc90735 | 2016-01-13 06:45:40 -0800 | [diff] [blame] | 198 | GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawPaint"); |
robertphillips | 2e1e51f | 2015-10-15 08:01:48 -0700 | [diff] [blame] | 199 | |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 200 | // set rect to be big enough to fill the space, but not super-huge, so we |
| 201 | // don't overflow fixed-point implementations |
| 202 | SkRect r; |
| 203 | r.setLTRB(0, 0, |
robertphillips | 2e1e51f | 2015-10-15 08:01:48 -0700 | [diff] [blame] | 204 | SkIntToScalar(fRenderTarget->width()), |
| 205 | SkIntToScalar(fRenderTarget->height())); |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 206 | SkTCopyOnFirstWrite<GrPaint> paint(origPaint); |
| 207 | |
| 208 | // by definition this fills the entire clip, no need for AA |
| 209 | if (paint->isAntiAlias()) { |
| 210 | paint.writable()->setAntiAlias(false); |
| 211 | } |
| 212 | |
| 213 | bool isPerspective = viewMatrix.hasPerspective(); |
| 214 | |
| 215 | // We attempt to map r by the inverse matrix and draw that. mapRect will |
| 216 | // map the four corners and bound them with a new rect. This will not |
| 217 | // produce a correct result for some perspective matrices. |
| 218 | if (!isPerspective) { |
| 219 | SkMatrix inverse; |
| 220 | if (!viewMatrix.invert(&inverse)) { |
| 221 | SkDebugf("Could not invert matrix\n"); |
| 222 | return; |
| 223 | } |
| 224 | inverse.mapRect(&r); |
robertphillips | 2e1e51f | 2015-10-15 08:01:48 -0700 | [diff] [blame] | 225 | this->drawRect(clip, *paint, viewMatrix, r); |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 226 | } else { |
| 227 | SkMatrix localMatrix; |
| 228 | if (!viewMatrix.invert(&localMatrix)) { |
| 229 | SkDebugf("Could not invert matrix\n"); |
| 230 | return; |
| 231 | } |
| 232 | |
robertphillips | 77a2e52 | 2015-10-17 07:43:27 -0700 | [diff] [blame] | 233 | AutoCheckFlush acf(fDrawingManager); |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 234 | |
joshualitt | 04194f3 | 2016-01-13 10:08:27 -0800 | [diff] [blame] | 235 | SkAutoTUnref<GrDrawBatch> batch( |
| 236 | GrRectBatchFactory::CreateNonAAFill(paint->getColor(), SkMatrix::I(), r, nullptr, |
| 237 | &localMatrix)); |
cdalton | 862cff3 | 2016-05-12 15:09:48 -0700 | [diff] [blame] | 238 | GrPipelineBuilder pipelineBuilder(*paint, fRenderTarget.get()); |
| 239 | this->getDrawTarget()->drawBatch(pipelineBuilder, clip, batch); |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 240 | } |
| 241 | } |
| 242 | |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 243 | static inline bool rect_contains_inclusive(const SkRect& rect, const SkPoint& point) { |
| 244 | return point.fX >= rect.fLeft && point.fX <= rect.fRight && |
| 245 | point.fY >= rect.fTop && point.fY <= rect.fBottom; |
| 246 | } |
| 247 | |
bsalomon | c55271f | 2015-11-09 11:55:57 -0800 | [diff] [blame] | 248 | static bool view_matrix_ok_for_aa_fill_rect(const SkMatrix& viewMatrix) { |
| 249 | return viewMatrix.preservesRightAngles(); |
| 250 | } |
| 251 | |
| 252 | static bool should_apply_coverage_aa(const GrPaint& paint, GrRenderTarget* rt) { |
| 253 | return paint.isAntiAlias() && !rt->isUnifiedMultisampled(); |
| 254 | } |
| 255 | |
robertphillips | 391395d | 2016-03-02 09:26:36 -0800 | [diff] [blame] | 256 | GrDrawBatch* GrDrawContext::getFillRectBatch(const GrPaint& paint, |
| 257 | const SkMatrix& viewMatrix, |
| 258 | const SkRect& rect) { |
| 259 | |
| 260 | GrDrawBatch* batch = nullptr; |
robertphillips | 6c7e325 | 2016-04-27 10:47:51 -0700 | [diff] [blame] | 261 | if (should_apply_coverage_aa(paint, fRenderTarget.get())) { |
robertphillips | 391395d | 2016-03-02 09:26:36 -0800 | [diff] [blame] | 262 | // The fill path can handle rotation but not skew. |
| 263 | if (view_matrix_ok_for_aa_fill_rect(viewMatrix)) { |
| 264 | SkRect devBoundRect; |
| 265 | viewMatrix.mapRect(&devBoundRect, rect); |
| 266 | batch = GrRectBatchFactory::CreateAAFill(paint.getColor(), viewMatrix, |
| 267 | rect, devBoundRect); |
| 268 | } |
| 269 | } else { |
| 270 | // filled BW rect |
| 271 | batch = GrRectBatchFactory::CreateNonAAFill(paint.getColor(), viewMatrix, rect, |
halcanary | 9d524f2 | 2016-03-29 09:03:52 -0700 | [diff] [blame] | 272 | nullptr, nullptr); |
robertphillips | 391395d | 2016-03-02 09:26:36 -0800 | [diff] [blame] | 273 | } |
| 274 | |
| 275 | return batch; |
| 276 | } |
| 277 | |
robertphillips | 2e1e51f | 2015-10-15 08:01:48 -0700 | [diff] [blame] | 278 | void GrDrawContext::drawRect(const GrClip& clip, |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 279 | const GrPaint& paint, |
| 280 | const SkMatrix& viewMatrix, |
| 281 | const SkRect& rect, |
bsalomon | 6663acf | 2016-05-10 09:14:17 -0700 | [diff] [blame] | 282 | const GrStyle* style) { |
| 283 | if (!style) { |
| 284 | style = &GrStyle::SimpleFill(); |
| 285 | } |
joshualitt | 1de610a | 2016-01-06 08:26:09 -0800 | [diff] [blame] | 286 | ASSERT_SINGLE_OWNER |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 287 | RETURN_IF_ABANDONED |
robertphillips | 2e1e51f | 2015-10-15 08:01:48 -0700 | [diff] [blame] | 288 | SkDEBUGCODE(this->validate();) |
joshualitt | bc90735 | 2016-01-13 06:45:40 -0800 | [diff] [blame] | 289 | GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawRect"); |
robertphillips | 2e1e51f | 2015-10-15 08:01:48 -0700 | [diff] [blame] | 290 | |
bsalomon | 6663acf | 2016-05-10 09:14:17 -0700 | [diff] [blame] | 291 | // Path effects should've been devolved to a path in SkGpuDevice |
| 292 | SkASSERT(!style->pathEffect()); |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 293 | |
robertphillips | 77a2e52 | 2015-10-17 07:43:27 -0700 | [diff] [blame] | 294 | AutoCheckFlush acf(fDrawingManager); |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 295 | |
bsalomon | 6663acf | 2016-05-10 09:14:17 -0700 | [diff] [blame] | 296 | const SkStrokeRec& stroke = style->strokeRec(); |
| 297 | SkScalar width = stroke.getWidth(); |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 298 | |
| 299 | // Check if this is a full RT draw and can be replaced with a clear. We don't bother checking |
| 300 | // cases where the RT is fully inside a stroke. |
| 301 | if (width < 0) { |
| 302 | SkRect rtRect; |
robertphillips | 954cbc1 | 2015-12-02 10:33:46 -0800 | [diff] [blame] | 303 | fRenderTarget->getBoundsRect(&rtRect); |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 304 | // Does the clip contain the entire RT? |
cdalton | 846c051 | 2016-05-13 10:25:00 -0700 | [diff] [blame] | 305 | if (clip.quickContains(rtRect)) { |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 306 | SkMatrix invM; |
| 307 | if (!viewMatrix.invert(&invM)) { |
| 308 | return; |
| 309 | } |
| 310 | // Does the rect bound the RT? |
| 311 | SkPoint srcSpaceRTQuad[4]; |
| 312 | invM.mapRectToQuad(srcSpaceRTQuad, rtRect); |
| 313 | if (rect_contains_inclusive(rect, srcSpaceRTQuad[0]) && |
| 314 | rect_contains_inclusive(rect, srcSpaceRTQuad[1]) && |
| 315 | rect_contains_inclusive(rect, srcSpaceRTQuad[2]) && |
| 316 | rect_contains_inclusive(rect, srcSpaceRTQuad[3])) { |
| 317 | // Will it blend? |
| 318 | GrColor clearColor; |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 319 | if (paint.isConstantBlendedColor(&clearColor)) { |
robertphillips | 6c7e325 | 2016-04-27 10:47:51 -0700 | [diff] [blame] | 320 | this->getDrawTarget()->clear(nullptr, clearColor, true, fRenderTarget.get()); |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 321 | return; |
| 322 | } |
| 323 | } |
| 324 | } |
| 325 | } |
| 326 | |
robertphillips | 4bc3181 | 2016-03-01 12:22:49 -0800 | [diff] [blame] | 327 | bool snapToPixelCenters = false; |
joshualitt | 04194f3 | 2016-01-13 10:08:27 -0800 | [diff] [blame] | 328 | SkAutoTUnref<GrDrawBatch> batch; |
robertphillips | 391395d | 2016-03-02 09:26:36 -0800 | [diff] [blame] | 329 | if (width < 0) { |
| 330 | batch.reset(this->getFillRectBatch(paint, viewMatrix, rect)); |
| 331 | } else { |
| 332 | GrColor color = paint.getColor(); |
| 333 | |
robertphillips | 6c7e325 | 2016-04-27 10:47:51 -0700 | [diff] [blame] | 334 | if (should_apply_coverage_aa(paint, fRenderTarget.get())) { |
cdalton | bb53948 | 2016-01-04 09:48:25 -0800 | [diff] [blame] | 335 | // The stroke path needs the rect to remain axis aligned (no rotation or skew). |
| 336 | if (viewMatrix.rectStaysRect()) { |
robertphillips | 391395d | 2016-03-02 09:26:36 -0800 | [diff] [blame] | 337 | batch.reset(GrRectBatchFactory::CreateAAStroke(color, viewMatrix, rect, |
bsalomon | 6663acf | 2016-05-10 09:14:17 -0700 | [diff] [blame] | 338 | stroke)); |
cdalton | bb53948 | 2016-01-04 09:48:25 -0800 | [diff] [blame] | 339 | } |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 340 | } else { |
robertphillips | 391395d | 2016-03-02 09:26:36 -0800 | [diff] [blame] | 341 | // Non-AA hairlines are snapped to pixel centers to make which pixels are hit |
| 342 | // deterministic |
| 343 | snapToPixelCenters = (0 == width && !fRenderTarget->isUnifiedMultisampled()); |
| 344 | batch.reset(GrRectBatchFactory::CreateNonAAStroke(color, viewMatrix, rect, |
| 345 | width, snapToPixelCenters)); |
robertphillips | 8b8f36f | 2016-03-02 08:53:12 -0800 | [diff] [blame] | 346 | |
robertphillips | 391395d | 2016-03-02 09:26:36 -0800 | [diff] [blame] | 347 | // Depending on sub-pixel coordinates and the particular GPU, we may lose a corner of |
halcanary | 9d524f2 | 2016-03-29 09:03:52 -0700 | [diff] [blame] | 348 | // hairline rects. We jam all the vertices to pixel centers to avoid this, but not |
robertphillips | 391395d | 2016-03-02 09:26:36 -0800 | [diff] [blame] | 349 | // when MSAA is enabled because it can cause ugly artifacts. |
| 350 | } |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 351 | } |
robertphillips | 4bc3181 | 2016-03-01 12:22:49 -0800 | [diff] [blame] | 352 | |
| 353 | if (batch) { |
cdalton | 862cff3 | 2016-05-12 15:09:48 -0700 | [diff] [blame] | 354 | GrPipelineBuilder pipelineBuilder(paint, fRenderTarget.get()); |
robertphillips | 4bc3181 | 2016-03-01 12:22:49 -0800 | [diff] [blame] | 355 | |
| 356 | if (snapToPixelCenters) { |
| 357 | pipelineBuilder.setState(GrPipelineBuilder::kSnapVerticesToPixelCenters_Flag, |
| 358 | snapToPixelCenters); |
| 359 | } |
| 360 | |
cdalton | 862cff3 | 2016-05-12 15:09:48 -0700 | [diff] [blame] | 361 | this->getDrawTarget()->drawBatch(pipelineBuilder, clip, batch); |
robertphillips | 4bc3181 | 2016-03-01 12:22:49 -0800 | [diff] [blame] | 362 | return; |
| 363 | } |
halcanary | 9d524f2 | 2016-03-29 09:03:52 -0700 | [diff] [blame] | 364 | |
robertphillips | 4bc3181 | 2016-03-01 12:22:49 -0800 | [diff] [blame] | 365 | SkPath path; |
| 366 | path.setIsVolatile(true); |
| 367 | path.addRect(rect); |
bsalomon | 6663acf | 2016-05-10 09:14:17 -0700 | [diff] [blame] | 368 | this->internalDrawPath(clip, paint, viewMatrix, path, *style); |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 369 | } |
| 370 | |
cdalton | 846c051 | 2016-05-13 10:25:00 -0700 | [diff] [blame] | 371 | bool GrDrawContextPriv::drawAndStencilRect(const GrFixedClip& clip, |
cdalton | 93a379b | 2016-05-11 13:58:08 -0700 | [diff] [blame] | 372 | const GrUserStencilSettings* ss, |
robertphillips | 391395d | 2016-03-02 09:26:36 -0800 | [diff] [blame] | 373 | SkRegion::Op op, |
| 374 | bool invert, |
| 375 | bool doAA, |
| 376 | const SkMatrix& viewMatrix, |
| 377 | const SkRect& rect) { |
| 378 | ASSERT_SINGLE_OWNER_PRIV |
| 379 | RETURN_FALSE_IF_ABANDONED_PRIV |
| 380 | SkDEBUGCODE(fDrawContext->validate();) |
| 381 | GR_AUDIT_TRAIL_AUTO_FRAME(fDrawContext->fAuditTrail, "GrDrawContext::stencilRect"); |
| 382 | |
| 383 | AutoCheckFlush acf(fDrawContext->fDrawingManager); |
| 384 | |
| 385 | GrPaint paint; |
| 386 | paint.setAntiAlias(doAA); |
| 387 | paint.setCoverageSetOpXPFactory(op, invert); |
| 388 | |
| 389 | SkAutoTUnref<GrDrawBatch> batch(fDrawContext->getFillRectBatch(paint, viewMatrix, rect)); |
| 390 | if (batch) { |
cdalton | 862cff3 | 2016-05-12 15:09:48 -0700 | [diff] [blame] | 391 | GrPipelineBuilder pipelineBuilder(paint, fDrawContext->accessRenderTarget()); |
cdalton | 93a379b | 2016-05-11 13:58:08 -0700 | [diff] [blame] | 392 | pipelineBuilder.setUserStencil(ss); |
robertphillips | 391395d | 2016-03-02 09:26:36 -0800 | [diff] [blame] | 393 | |
cdalton | 862cff3 | 2016-05-12 15:09:48 -0700 | [diff] [blame] | 394 | fDrawContext->getDrawTarget()->drawBatch(pipelineBuilder, clip, batch); |
robertphillips | 391395d | 2016-03-02 09:26:36 -0800 | [diff] [blame] | 395 | return true; |
| 396 | } |
| 397 | |
| 398 | SkPath path; |
| 399 | path.setIsVolatile(true); |
| 400 | path.addRect(rect); |
cdalton | 862cff3 | 2016-05-12 15:09:48 -0700 | [diff] [blame] | 401 | return this->drawAndStencilPath(clip, ss, op, invert, doAA, viewMatrix, path); |
robertphillips | 391395d | 2016-03-02 09:26:36 -0800 | [diff] [blame] | 402 | } |
| 403 | |
bsalomon | a2e69fc | 2015-11-05 10:41:43 -0800 | [diff] [blame] | 404 | void GrDrawContext::fillRectToRect(const GrClip& clip, |
| 405 | const GrPaint& paint, |
| 406 | const SkMatrix& viewMatrix, |
| 407 | const SkRect& rectToDraw, |
| 408 | const SkRect& localRect) { |
joshualitt | 1de610a | 2016-01-06 08:26:09 -0800 | [diff] [blame] | 409 | ASSERT_SINGLE_OWNER |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 410 | RETURN_IF_ABANDONED |
robertphillips | 2e1e51f | 2015-10-15 08:01:48 -0700 | [diff] [blame] | 411 | SkDEBUGCODE(this->validate();) |
joshualitt | bc90735 | 2016-01-13 06:45:40 -0800 | [diff] [blame] | 412 | GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::fillRectToRect"); |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 413 | |
robertphillips | 77a2e52 | 2015-10-17 07:43:27 -0700 | [diff] [blame] | 414 | AutoCheckFlush acf(fDrawingManager); |
robertphillips | 2e1e51f | 2015-10-15 08:01:48 -0700 | [diff] [blame] | 415 | |
joshualitt | 04194f3 | 2016-01-13 10:08:27 -0800 | [diff] [blame] | 416 | SkAutoTUnref<GrDrawBatch> batch; |
robertphillips | 6c7e325 | 2016-04-27 10:47:51 -0700 | [diff] [blame] | 417 | if (should_apply_coverage_aa(paint, fRenderTarget.get()) && |
bsalomon | c55271f | 2015-11-09 11:55:57 -0800 | [diff] [blame] | 418 | view_matrix_ok_for_aa_fill_rect(viewMatrix)) { |
joshualitt | 04194f3 | 2016-01-13 10:08:27 -0800 | [diff] [blame] | 419 | batch.reset(GrAAFillRectBatch::CreateWithLocalRect(paint.getColor(), viewMatrix, rectToDraw, |
| 420 | localRect)); |
bsalomon | c55271f | 2015-11-09 11:55:57 -0800 | [diff] [blame] | 421 | } else { |
joshualitt | 04194f3 | 2016-01-13 10:08:27 -0800 | [diff] [blame] | 422 | batch.reset(GrRectBatchFactory::CreateNonAAFill(paint.getColor(), viewMatrix, rectToDraw, |
| 423 | &localRect, nullptr)); |
| 424 | } |
| 425 | |
| 426 | if (batch) { |
cdalton | 862cff3 | 2016-05-12 15:09:48 -0700 | [diff] [blame] | 427 | GrPipelineBuilder pipelineBuilder(paint, fRenderTarget.get()); |
| 428 | this->drawBatch(&pipelineBuilder, clip, batch); |
bsalomon | c55271f | 2015-11-09 11:55:57 -0800 | [diff] [blame] | 429 | } |
joshualitt | b6b513b | 2015-08-21 10:25:18 -0700 | [diff] [blame] | 430 | } |
| 431 | |
bsalomon | a2e69fc | 2015-11-05 10:41:43 -0800 | [diff] [blame] | 432 | void GrDrawContext::fillRectWithLocalMatrix(const GrClip& clip, |
| 433 | const GrPaint& paint, |
| 434 | const SkMatrix& viewMatrix, |
| 435 | const SkRect& rectToDraw, |
| 436 | const SkMatrix& localMatrix) { |
joshualitt | 1de610a | 2016-01-06 08:26:09 -0800 | [diff] [blame] | 437 | ASSERT_SINGLE_OWNER |
joshualitt | b6b513b | 2015-08-21 10:25:18 -0700 | [diff] [blame] | 438 | RETURN_IF_ABANDONED |
robertphillips | 2e1e51f | 2015-10-15 08:01:48 -0700 | [diff] [blame] | 439 | SkDEBUGCODE(this->validate();) |
joshualitt | bc90735 | 2016-01-13 06:45:40 -0800 | [diff] [blame] | 440 | GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::fillRectWithLocalMatrix"); |
joshualitt | b6b513b | 2015-08-21 10:25:18 -0700 | [diff] [blame] | 441 | |
robertphillips | 77a2e52 | 2015-10-17 07:43:27 -0700 | [diff] [blame] | 442 | AutoCheckFlush acf(fDrawingManager); |
robertphillips | 2e1e51f | 2015-10-15 08:01:48 -0700 | [diff] [blame] | 443 | |
joshualitt | 04194f3 | 2016-01-13 10:08:27 -0800 | [diff] [blame] | 444 | SkAutoTUnref<GrDrawBatch> batch; |
robertphillips | 6c7e325 | 2016-04-27 10:47:51 -0700 | [diff] [blame] | 445 | if (should_apply_coverage_aa(paint, fRenderTarget.get()) && |
bsalomon | c55271f | 2015-11-09 11:55:57 -0800 | [diff] [blame] | 446 | view_matrix_ok_for_aa_fill_rect(viewMatrix)) { |
joshualitt | 04194f3 | 2016-01-13 10:08:27 -0800 | [diff] [blame] | 447 | batch.reset(GrAAFillRectBatch::Create(paint.getColor(), viewMatrix, localMatrix, |
| 448 | rectToDraw)); |
bsalomon | c55271f | 2015-11-09 11:55:57 -0800 | [diff] [blame] | 449 | } else { |
joshualitt | 04194f3 | 2016-01-13 10:08:27 -0800 | [diff] [blame] | 450 | batch.reset(GrRectBatchFactory::CreateNonAAFill(paint.getColor(), viewMatrix, rectToDraw, |
| 451 | nullptr, &localMatrix)); |
bsalomon | c55271f | 2015-11-09 11:55:57 -0800 | [diff] [blame] | 452 | } |
robertphillips | 4bc3181 | 2016-03-01 12:22:49 -0800 | [diff] [blame] | 453 | |
cdalton | 862cff3 | 2016-05-12 15:09:48 -0700 | [diff] [blame] | 454 | GrPipelineBuilder pipelineBuilder(paint, fRenderTarget.get()); |
| 455 | this->getDrawTarget()->drawBatch(pipelineBuilder, clip, batch); |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 456 | } |
| 457 | |
robertphillips | 2e1e51f | 2015-10-15 08:01:48 -0700 | [diff] [blame] | 458 | void GrDrawContext::drawVertices(const GrClip& clip, |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 459 | const GrPaint& paint, |
| 460 | const SkMatrix& viewMatrix, |
| 461 | GrPrimitiveType primitiveType, |
| 462 | int vertexCount, |
| 463 | const SkPoint positions[], |
| 464 | const SkPoint texCoords[], |
| 465 | const GrColor colors[], |
| 466 | const uint16_t indices[], |
| 467 | int indexCount) { |
joshualitt | 1de610a | 2016-01-06 08:26:09 -0800 | [diff] [blame] | 468 | ASSERT_SINGLE_OWNER |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 469 | RETURN_IF_ABANDONED |
robertphillips | 2e1e51f | 2015-10-15 08:01:48 -0700 | [diff] [blame] | 470 | SkDEBUGCODE(this->validate();) |
joshualitt | bc90735 | 2016-01-13 06:45:40 -0800 | [diff] [blame] | 471 | GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawVertices"); |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 472 | |
robertphillips | 77a2e52 | 2015-10-17 07:43:27 -0700 | [diff] [blame] | 473 | AutoCheckFlush acf(fDrawingManager); |
robertphillips | 2e1e51f | 2015-10-15 08:01:48 -0700 | [diff] [blame] | 474 | |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 475 | // TODO clients should give us bounds |
| 476 | SkRect bounds; |
| 477 | if (!bounds.setBoundsCheck(positions, vertexCount)) { |
| 478 | SkDebugf("drawVertices call empty bounds\n"); |
| 479 | return; |
| 480 | } |
| 481 | |
| 482 | viewMatrix.mapRect(&bounds); |
| 483 | |
| 484 | // If we don't have AA then we outset for a half pixel in each direction to account for |
bsalomon | db4758c | 2015-11-23 11:14:20 -0800 | [diff] [blame] | 485 | // snapping. We also do this for the "hair" primitive types: lines and points since they have |
| 486 | // a 1 pixel thickness in device space. |
| 487 | if (!paint.isAntiAlias() || GrIsPrimTypeLines(primitiveType) || |
| 488 | kPoints_GrPrimitiveType == primitiveType) { |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 489 | bounds.outset(0.5f, 0.5f); |
| 490 | } |
| 491 | |
joshualitt | 2771b56 | 2015-08-07 12:46:26 -0700 | [diff] [blame] | 492 | GrDrawVerticesBatch::Geometry geometry; |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 493 | geometry.fColor = paint.getColor(); |
bsalomon | abd30f5 | 2015-08-13 13:34:48 -0700 | [diff] [blame] | 494 | SkAutoTUnref<GrDrawBatch> batch(GrDrawVerticesBatch::Create(geometry, primitiveType, viewMatrix, |
| 495 | positions, vertexCount, indices, |
| 496 | indexCount, colors, texCoords, |
| 497 | bounds)); |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 498 | |
cdalton | 862cff3 | 2016-05-12 15:09:48 -0700 | [diff] [blame] | 499 | GrPipelineBuilder pipelineBuilder(paint, fRenderTarget.get()); |
| 500 | this->getDrawTarget()->drawBatch(pipelineBuilder, clip, batch); |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 501 | } |
| 502 | |
| 503 | /////////////////////////////////////////////////////////////////////////////// |
| 504 | |
robertphillips | 2e1e51f | 2015-10-15 08:01:48 -0700 | [diff] [blame] | 505 | void GrDrawContext::drawAtlas(const GrClip& clip, |
jvanverth | 31ff762 | 2015-08-07 10:09:28 -0700 | [diff] [blame] | 506 | const GrPaint& paint, |
| 507 | const SkMatrix& viewMatrix, |
| 508 | int spriteCount, |
| 509 | const SkRSXform xform[], |
| 510 | const SkRect texRect[], |
| 511 | const SkColor colors[]) { |
joshualitt | 1de610a | 2016-01-06 08:26:09 -0800 | [diff] [blame] | 512 | ASSERT_SINGLE_OWNER |
jvanverth | 31ff762 | 2015-08-07 10:09:28 -0700 | [diff] [blame] | 513 | RETURN_IF_ABANDONED |
robertphillips | 2e1e51f | 2015-10-15 08:01:48 -0700 | [diff] [blame] | 514 | SkDEBUGCODE(this->validate();) |
joshualitt | bc90735 | 2016-01-13 06:45:40 -0800 | [diff] [blame] | 515 | GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawAtlas"); |
robertphillips | 2e1e51f | 2015-10-15 08:01:48 -0700 | [diff] [blame] | 516 | |
robertphillips | 77a2e52 | 2015-10-17 07:43:27 -0700 | [diff] [blame] | 517 | AutoCheckFlush acf(fDrawingManager); |
halcanary | 9d524f2 | 2016-03-29 09:03:52 -0700 | [diff] [blame] | 518 | |
jvanverth | 14b8803 | 2015-08-07 12:18:54 -0700 | [diff] [blame] | 519 | GrDrawAtlasBatch::Geometry geometry; |
jvanverth | 31ff762 | 2015-08-07 10:09:28 -0700 | [diff] [blame] | 520 | geometry.fColor = paint.getColor(); |
bsalomon | abd30f5 | 2015-08-13 13:34:48 -0700 | [diff] [blame] | 521 | SkAutoTUnref<GrDrawBatch> batch(GrDrawAtlasBatch::Create(geometry, viewMatrix, spriteCount, |
| 522 | xform, texRect, colors)); |
halcanary | 9d524f2 | 2016-03-29 09:03:52 -0700 | [diff] [blame] | 523 | |
cdalton | 862cff3 | 2016-05-12 15:09:48 -0700 | [diff] [blame] | 524 | GrPipelineBuilder pipelineBuilder(paint, fRenderTarget.get()); |
| 525 | this->getDrawTarget()->drawBatch(pipelineBuilder, clip, batch); |
jvanverth | 31ff762 | 2015-08-07 10:09:28 -0700 | [diff] [blame] | 526 | } |
| 527 | |
| 528 | /////////////////////////////////////////////////////////////////////////////// |
| 529 | |
robertphillips | 2e1e51f | 2015-10-15 08:01:48 -0700 | [diff] [blame] | 530 | void GrDrawContext::drawRRect(const GrClip& clip, |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 531 | const GrPaint& paint, |
| 532 | const SkMatrix& viewMatrix, |
| 533 | const SkRRect& rrect, |
bsalomon | 6663acf | 2016-05-10 09:14:17 -0700 | [diff] [blame] | 534 | const GrStyle& style) { |
joshualitt | 1de610a | 2016-01-06 08:26:09 -0800 | [diff] [blame] | 535 | ASSERT_SINGLE_OWNER |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 536 | RETURN_IF_ABANDONED |
robertphillips | 2e1e51f | 2015-10-15 08:01:48 -0700 | [diff] [blame] | 537 | SkDEBUGCODE(this->validate();) |
joshualitt | bc90735 | 2016-01-13 06:45:40 -0800 | [diff] [blame] | 538 | GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawRRect"); |
robertphillips | 2e1e51f | 2015-10-15 08:01:48 -0700 | [diff] [blame] | 539 | |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 540 | if (rrect.isEmpty()) { |
| 541 | return; |
| 542 | } |
| 543 | |
bsalomon | 6663acf | 2016-05-10 09:14:17 -0700 | [diff] [blame] | 544 | SkASSERT(!style.pathEffect()); // this should've been devolved to a path in SkGpuDevice |
| 545 | const SkStrokeRec stroke = style.strokeRec(); |
robertphillips | 77a2e52 | 2015-10-17 07:43:27 -0700 | [diff] [blame] | 546 | AutoCheckFlush acf(fDrawingManager); |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 547 | |
robertphillips | 6c7e325 | 2016-04-27 10:47:51 -0700 | [diff] [blame] | 548 | if (should_apply_coverage_aa(paint, fRenderTarget.get())) { |
robertphillips | b56f927 | 2016-02-25 11:03:52 -0800 | [diff] [blame] | 549 | GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps(); |
| 550 | |
robertphillips | 4bc3181 | 2016-03-01 12:22:49 -0800 | [diff] [blame] | 551 | SkAutoTUnref<GrDrawBatch> batch(GrOvalRenderer::CreateRRectBatch(paint.getColor(), |
robertphillips | b56f927 | 2016-02-25 11:03:52 -0800 | [diff] [blame] | 552 | viewMatrix, |
| 553 | rrect, |
bsalomon | 6663acf | 2016-05-10 09:14:17 -0700 | [diff] [blame] | 554 | stroke, |
robertphillips | b56f927 | 2016-02-25 11:03:52 -0800 | [diff] [blame] | 555 | shaderCaps)); |
| 556 | if (batch) { |
cdalton | 862cff3 | 2016-05-12 15:09:48 -0700 | [diff] [blame] | 557 | GrPipelineBuilder pipelineBuilder(paint, fRenderTarget.get()); |
| 558 | this->getDrawTarget()->drawBatch(pipelineBuilder, clip, batch); |
robertphillips | b56f927 | 2016-02-25 11:03:52 -0800 | [diff] [blame] | 559 | return; |
| 560 | } |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 561 | } |
robertphillips | b56f927 | 2016-02-25 11:03:52 -0800 | [diff] [blame] | 562 | |
| 563 | SkPath path; |
| 564 | path.setIsVolatile(true); |
| 565 | path.addRRect(rrect); |
bsalomon | 6663acf | 2016-05-10 09:14:17 -0700 | [diff] [blame] | 566 | this->internalDrawPath(clip, paint, viewMatrix, path, style); |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 567 | } |
| 568 | |
robertphillips | 0009589 | 2016-02-29 13:50:40 -0800 | [diff] [blame] | 569 | bool GrDrawContext::drawFilledDRRect(const GrClip& clip, |
| 570 | const GrPaint& paintIn, |
| 571 | const SkMatrix& viewMatrix, |
| 572 | const SkRRect& origOuter, |
| 573 | const SkRRect& origInner) { |
| 574 | SkASSERT(!origInner.isEmpty()); |
| 575 | SkASSERT(!origOuter.isEmpty()); |
| 576 | |
| 577 | bool applyAA = paintIn.isAntiAlias() && !fRenderTarget->isUnifiedMultisampled(); |
| 578 | |
| 579 | GrPrimitiveEdgeType innerEdgeType = applyAA ? kInverseFillAA_GrProcessorEdgeType : |
| 580 | kInverseFillBW_GrProcessorEdgeType; |
| 581 | GrPrimitiveEdgeType outerEdgeType = applyAA ? kFillAA_GrProcessorEdgeType : |
| 582 | kFillBW_GrProcessorEdgeType; |
| 583 | |
| 584 | SkTCopyOnFirstWrite<SkRRect> inner(origInner), outer(origOuter); |
| 585 | SkMatrix inverseVM; |
| 586 | if (!viewMatrix.isIdentity()) { |
| 587 | if (!origInner.transform(viewMatrix, inner.writable())) { |
| 588 | return false; |
| 589 | } |
| 590 | if (!origOuter.transform(viewMatrix, outer.writable())) { |
| 591 | return false; |
| 592 | } |
| 593 | if (!viewMatrix.invert(&inverseVM)) { |
| 594 | return false; |
| 595 | } |
| 596 | } else { |
| 597 | inverseVM.reset(); |
halcanary | 9d524f2 | 2016-03-29 09:03:52 -0700 | [diff] [blame] | 598 | } |
robertphillips | 0009589 | 2016-02-29 13:50:40 -0800 | [diff] [blame] | 599 | |
| 600 | GrPaint grPaint(paintIn); |
| 601 | grPaint.setAntiAlias(false); |
| 602 | |
| 603 | // TODO these need to be a geometry processors |
| 604 | SkAutoTUnref<GrFragmentProcessor> innerEffect(GrRRectEffect::Create(innerEdgeType, *inner)); |
| 605 | if (!innerEffect) { |
| 606 | return false; |
| 607 | } |
| 608 | |
| 609 | SkAutoTUnref<GrFragmentProcessor> outerEffect(GrRRectEffect::Create(outerEdgeType, *outer)); |
| 610 | if (!outerEffect) { |
| 611 | return false; |
| 612 | } |
| 613 | |
| 614 | grPaint.addCoverageFragmentProcessor(innerEffect); |
| 615 | grPaint.addCoverageFragmentProcessor(outerEffect); |
| 616 | |
| 617 | SkRect bounds = outer->getBounds(); |
| 618 | if (applyAA) { |
| 619 | bounds.outset(SK_ScalarHalf, SK_ScalarHalf); |
| 620 | } |
halcanary | 9d524f2 | 2016-03-29 09:03:52 -0700 | [diff] [blame] | 621 | |
robertphillips | 0009589 | 2016-02-29 13:50:40 -0800 | [diff] [blame] | 622 | this->fillRectWithLocalMatrix(clip, grPaint, SkMatrix::I(), bounds, inverseVM); |
| 623 | return true; |
| 624 | } |
| 625 | |
| 626 | void GrDrawContext::drawDRRect(const GrClip& clip, |
| 627 | const GrPaint& paint, |
| 628 | const SkMatrix& viewMatrix, |
| 629 | const SkRRect& outer, |
| 630 | const SkRRect& inner) { |
| 631 | ASSERT_SINGLE_OWNER |
| 632 | RETURN_IF_ABANDONED |
| 633 | SkDEBUGCODE(this->validate();) |
| 634 | GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawDRRect"); |
| 635 | |
| 636 | SkASSERT(!outer.isEmpty()); |
| 637 | SkASSERT(!inner.isEmpty()); |
| 638 | |
| 639 | AutoCheckFlush acf(fDrawingManager); |
| 640 | |
| 641 | if (this->drawFilledDRRect(clip, paint, viewMatrix, outer, inner)) { |
| 642 | return; |
| 643 | } |
| 644 | |
| 645 | SkPath path; |
| 646 | path.setIsVolatile(true); |
| 647 | path.addRRect(inner); |
| 648 | path.addRRect(outer); |
| 649 | path.setFillType(SkPath::kEvenOdd_FillType); |
| 650 | |
bsalomon | 6663acf | 2016-05-10 09:14:17 -0700 | [diff] [blame] | 651 | this->internalDrawPath(clip, paint, viewMatrix, path, GrStyle::SimpleFill()); |
robertphillips | 0009589 | 2016-02-29 13:50:40 -0800 | [diff] [blame] | 652 | } |
| 653 | |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 654 | /////////////////////////////////////////////////////////////////////////////// |
| 655 | |
robertphillips | 2e1e51f | 2015-10-15 08:01:48 -0700 | [diff] [blame] | 656 | void GrDrawContext::drawOval(const GrClip& clip, |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 657 | const GrPaint& paint, |
| 658 | const SkMatrix& viewMatrix, |
| 659 | const SkRect& oval, |
bsalomon | 6663acf | 2016-05-10 09:14:17 -0700 | [diff] [blame] | 660 | const GrStyle& style) { |
joshualitt | 1de610a | 2016-01-06 08:26:09 -0800 | [diff] [blame] | 661 | ASSERT_SINGLE_OWNER |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 662 | RETURN_IF_ABANDONED |
robertphillips | 2e1e51f | 2015-10-15 08:01:48 -0700 | [diff] [blame] | 663 | SkDEBUGCODE(this->validate();) |
joshualitt | bc90735 | 2016-01-13 06:45:40 -0800 | [diff] [blame] | 664 | GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawOval"); |
robertphillips | 2e1e51f | 2015-10-15 08:01:48 -0700 | [diff] [blame] | 665 | |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 666 | if (oval.isEmpty()) { |
| 667 | return; |
| 668 | } |
| 669 | |
bsalomon | 6663acf | 2016-05-10 09:14:17 -0700 | [diff] [blame] | 670 | SkASSERT(!style.pathEffect()); // this should've been devolved to a path in SkGpuDevice |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 671 | |
robertphillips | 77a2e52 | 2015-10-17 07:43:27 -0700 | [diff] [blame] | 672 | AutoCheckFlush acf(fDrawingManager); |
bsalomon | 6663acf | 2016-05-10 09:14:17 -0700 | [diff] [blame] | 673 | const SkStrokeRec& stroke = style.strokeRec(); |
robertphillips | 6c7e325 | 2016-04-27 10:47:51 -0700 | [diff] [blame] | 674 | if (should_apply_coverage_aa(paint, fRenderTarget.get())) { |
robertphillips | b56f927 | 2016-02-25 11:03:52 -0800 | [diff] [blame] | 675 | GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps(); |
robertphillips | 4bc3181 | 2016-03-01 12:22:49 -0800 | [diff] [blame] | 676 | SkAutoTUnref<GrDrawBatch> batch(GrOvalRenderer::CreateOvalBatch(paint.getColor(), |
robertphillips | b56f927 | 2016-02-25 11:03:52 -0800 | [diff] [blame] | 677 | viewMatrix, |
| 678 | oval, |
bsalomon | 6663acf | 2016-05-10 09:14:17 -0700 | [diff] [blame] | 679 | stroke, |
robertphillips | b56f927 | 2016-02-25 11:03:52 -0800 | [diff] [blame] | 680 | shaderCaps)); |
| 681 | if (batch) { |
cdalton | 862cff3 | 2016-05-12 15:09:48 -0700 | [diff] [blame] | 682 | GrPipelineBuilder pipelineBuilder(paint, fRenderTarget.get()); |
| 683 | this->getDrawTarget()->drawBatch(pipelineBuilder, clip, batch); |
robertphillips | b56f927 | 2016-02-25 11:03:52 -0800 | [diff] [blame] | 684 | return; |
| 685 | } |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 686 | } |
robertphillips | b56f927 | 2016-02-25 11:03:52 -0800 | [diff] [blame] | 687 | |
| 688 | SkPath path; |
| 689 | path.setIsVolatile(true); |
| 690 | path.addOval(oval); |
bsalomon | 6663acf | 2016-05-10 09:14:17 -0700 | [diff] [blame] | 691 | this->internalDrawPath(clip, paint, viewMatrix, path, style); |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 692 | } |
| 693 | |
joshualitt | 33a5fce | 2015-11-18 13:28:51 -0800 | [diff] [blame] | 694 | void GrDrawContext::drawImageNine(const GrClip& clip, |
| 695 | const GrPaint& paint, |
| 696 | const SkMatrix& viewMatrix, |
| 697 | int imageWidth, |
| 698 | int imageHeight, |
| 699 | const SkIRect& center, |
| 700 | const SkRect& dst) { |
joshualitt | 1de610a | 2016-01-06 08:26:09 -0800 | [diff] [blame] | 701 | ASSERT_SINGLE_OWNER |
joshualitt | 33a5fce | 2015-11-18 13:28:51 -0800 | [diff] [blame] | 702 | RETURN_IF_ABANDONED |
| 703 | SkDEBUGCODE(this->validate();) |
joshualitt | bc90735 | 2016-01-13 06:45:40 -0800 | [diff] [blame] | 704 | GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawImageNine"); |
joshualitt | 33a5fce | 2015-11-18 13:28:51 -0800 | [diff] [blame] | 705 | |
| 706 | AutoCheckFlush acf(fDrawingManager); |
| 707 | |
| 708 | SkAutoTUnref<GrDrawBatch> batch(GrNinePatch::CreateNonAA(paint.getColor(), viewMatrix, |
| 709 | imageWidth, imageHeight, |
| 710 | center, dst)); |
| 711 | |
cdalton | 862cff3 | 2016-05-12 15:09:48 -0700 | [diff] [blame] | 712 | GrPipelineBuilder pipelineBuilder(paint, fRenderTarget.get()); |
| 713 | this->getDrawTarget()->drawBatch(pipelineBuilder, clip, batch); |
joshualitt | 33a5fce | 2015-11-18 13:28:51 -0800 | [diff] [blame] | 714 | } |
| 715 | |
| 716 | |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 717 | // Can 'path' be drawn as a pair of filled nested rectangles? |
bsalomon | 6663acf | 2016-05-10 09:14:17 -0700 | [diff] [blame] | 718 | static bool fills_as_nested_rects(const SkMatrix& viewMatrix, const SkPath& path, SkRect rects[2]) { |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 719 | |
| 720 | if (path.isInverseFillType()) { |
| 721 | return false; |
| 722 | } |
| 723 | |
| 724 | // TODO: this restriction could be lifted if we were willing to apply |
| 725 | // the matrix to all the points individually rather than just to the rect |
robertphillips | 0e7029e | 2015-11-30 05:45:06 -0800 | [diff] [blame] | 726 | if (!viewMatrix.rectStaysRect()) { |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 727 | return false; |
| 728 | } |
| 729 | |
| 730 | SkPath::Direction dirs[2]; |
| 731 | if (!path.isNestedFillRects(rects, dirs)) { |
| 732 | return false; |
| 733 | } |
| 734 | |
| 735 | if (SkPath::kWinding_FillType == path.getFillType() && dirs[0] == dirs[1]) { |
| 736 | // The two rects need to be wound opposite to each other |
| 737 | return false; |
| 738 | } |
| 739 | |
| 740 | // Right now, nested rects where the margin is not the same width |
| 741 | // all around do not render correctly |
| 742 | const SkScalar* outer = rects[0].asScalars(); |
| 743 | const SkScalar* inner = rects[1].asScalars(); |
| 744 | |
| 745 | bool allEq = true; |
| 746 | |
| 747 | SkScalar margin = SkScalarAbs(outer[0] - inner[0]); |
| 748 | bool allGoE1 = margin >= SK_Scalar1; |
| 749 | |
| 750 | for (int i = 1; i < 4; ++i) { |
| 751 | SkScalar temp = SkScalarAbs(outer[i] - inner[i]); |
| 752 | if (temp < SK_Scalar1) { |
| 753 | allGoE1 = false; |
| 754 | } |
| 755 | if (!SkScalarNearlyEqual(margin, temp)) { |
| 756 | allEq = false; |
| 757 | } |
| 758 | } |
| 759 | |
| 760 | return allEq || allGoE1; |
| 761 | } |
| 762 | |
robertphillips | 2e1e51f | 2015-10-15 08:01:48 -0700 | [diff] [blame] | 763 | void GrDrawContext::drawBatch(const GrClip& clip, |
bsalomon | abd30f5 | 2015-08-13 13:34:48 -0700 | [diff] [blame] | 764 | const GrPaint& paint, GrDrawBatch* batch) { |
joshualitt | 1de610a | 2016-01-06 08:26:09 -0800 | [diff] [blame] | 765 | ASSERT_SINGLE_OWNER |
joshualitt | b7ee1bf | 2015-08-10 11:59:02 -0700 | [diff] [blame] | 766 | RETURN_IF_ABANDONED |
robertphillips | 2e1e51f | 2015-10-15 08:01:48 -0700 | [diff] [blame] | 767 | SkDEBUGCODE(this->validate();) |
joshualitt | bc90735 | 2016-01-13 06:45:40 -0800 | [diff] [blame] | 768 | GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawBatch"); |
joshualitt | b7ee1bf | 2015-08-10 11:59:02 -0700 | [diff] [blame] | 769 | |
robertphillips | 77a2e52 | 2015-10-17 07:43:27 -0700 | [diff] [blame] | 770 | AutoCheckFlush acf(fDrawingManager); |
joshualitt | b7ee1bf | 2015-08-10 11:59:02 -0700 | [diff] [blame] | 771 | |
cdalton | 862cff3 | 2016-05-12 15:09:48 -0700 | [diff] [blame] | 772 | GrPipelineBuilder pipelineBuilder(paint, fRenderTarget.get()); |
| 773 | this->getDrawTarget()->drawBatch(pipelineBuilder, clip, batch); |
joshualitt | b7ee1bf | 2015-08-10 11:59:02 -0700 | [diff] [blame] | 774 | } |
| 775 | |
robertphillips | 2e1e51f | 2015-10-15 08:01:48 -0700 | [diff] [blame] | 776 | void GrDrawContext::drawPath(const GrClip& clip, |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 777 | const GrPaint& paint, |
| 778 | const SkMatrix& viewMatrix, |
| 779 | const SkPath& path, |
bsalomon | 6663acf | 2016-05-10 09:14:17 -0700 | [diff] [blame] | 780 | const GrStyle& style) { |
joshualitt | 1de610a | 2016-01-06 08:26:09 -0800 | [diff] [blame] | 781 | ASSERT_SINGLE_OWNER |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 782 | RETURN_IF_ABANDONED |
robertphillips | 2e1e51f | 2015-10-15 08:01:48 -0700 | [diff] [blame] | 783 | SkDEBUGCODE(this->validate();) |
joshualitt | bc90735 | 2016-01-13 06:45:40 -0800 | [diff] [blame] | 784 | GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawPath"); |
robertphillips | 2e1e51f | 2015-10-15 08:01:48 -0700 | [diff] [blame] | 785 | |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 786 | if (path.isEmpty()) { |
| 787 | if (path.isInverseFillType()) { |
robertphillips | 2e1e51f | 2015-10-15 08:01:48 -0700 | [diff] [blame] | 788 | this->drawPaint(clip, paint, viewMatrix); |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 789 | } |
| 790 | return; |
| 791 | } |
| 792 | |
robertphillips | 77a2e52 | 2015-10-17 07:43:27 -0700 | [diff] [blame] | 793 | AutoCheckFlush acf(fDrawingManager); |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 794 | |
bsalomon | 6663acf | 2016-05-10 09:14:17 -0700 | [diff] [blame] | 795 | if (should_apply_coverage_aa(paint, fRenderTarget.get()) && !style.pathEffect()) { |
| 796 | if (style.isSimpleFill() && !path.isConvex()) { |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 797 | // Concave AA paths are expensive - try to avoid them for special cases |
| 798 | SkRect rects[2]; |
| 799 | |
bsalomon | 6663acf | 2016-05-10 09:14:17 -0700 | [diff] [blame] | 800 | if (fills_as_nested_rects(viewMatrix, path, rects)) { |
joshualitt | d2b23e0 | 2015-08-21 10:53:34 -0700 | [diff] [blame] | 801 | SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateAAFillNestedRects( |
robertphillips | 4bc3181 | 2016-03-01 12:22:49 -0800 | [diff] [blame] | 802 | paint.getColor(), viewMatrix, rects)); |
bsalomon | 40ef485 | 2016-05-02 13:22:13 -0700 | [diff] [blame] | 803 | if (batch) { |
cdalton | 862cff3 | 2016-05-12 15:09:48 -0700 | [diff] [blame] | 804 | GrPipelineBuilder pipelineBuilder(paint, fRenderTarget.get()); |
| 805 | this->getDrawTarget()->drawBatch(pipelineBuilder, clip, batch); |
bsalomon | 40ef485 | 2016-05-02 13:22:13 -0700 | [diff] [blame] | 806 | } |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 807 | return; |
| 808 | } |
| 809 | } |
| 810 | SkRect ovalRect; |
| 811 | bool isOval = path.isOval(&ovalRect); |
| 812 | |
| 813 | if (isOval && !path.isInverseFillType()) { |
robertphillips | 0cc2f85 | 2016-02-24 13:36:56 -0800 | [diff] [blame] | 814 | GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps(); |
robertphillips | 4bc3181 | 2016-03-01 12:22:49 -0800 | [diff] [blame] | 815 | SkAutoTUnref<GrDrawBatch> batch(GrOvalRenderer::CreateOvalBatch(paint.getColor(), |
robertphillips | 0cc2f85 | 2016-02-24 13:36:56 -0800 | [diff] [blame] | 816 | viewMatrix, |
robertphillips | 0cc2f85 | 2016-02-24 13:36:56 -0800 | [diff] [blame] | 817 | ovalRect, |
bsalomon | 6663acf | 2016-05-10 09:14:17 -0700 | [diff] [blame] | 818 | style.strokeRec(), |
robertphillips | 0cc2f85 | 2016-02-24 13:36:56 -0800 | [diff] [blame] | 819 | shaderCaps)); |
| 820 | if (batch) { |
cdalton | 862cff3 | 2016-05-12 15:09:48 -0700 | [diff] [blame] | 821 | GrPipelineBuilder pipelineBuilder(paint, fRenderTarget.get()); |
| 822 | this->getDrawTarget()->drawBatch(pipelineBuilder, clip, batch); |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 823 | return; |
| 824 | } |
| 825 | } |
| 826 | } |
robertphillips | 4bc3181 | 2016-03-01 12:22:49 -0800 | [diff] [blame] | 827 | |
| 828 | // Note that internalDrawPath may sw-rasterize the path into a scratch texture. |
| 829 | // Scratch textures can be recycled after they are returned to the texture |
| 830 | // cache. This presents a potential hazard for buffered drawing. However, |
| 831 | // the writePixels that uploads to the scratch will perform a flush so we're |
| 832 | // OK. |
bsalomon | 6663acf | 2016-05-10 09:14:17 -0700 | [diff] [blame] | 833 | this->internalDrawPath(clip, paint, viewMatrix, path, style); |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 834 | } |
| 835 | |
cdalton | 846c051 | 2016-05-13 10:25:00 -0700 | [diff] [blame] | 836 | bool GrDrawContextPriv::drawAndStencilPath(const GrFixedClip& clip, |
cdalton | 93a379b | 2016-05-11 13:58:08 -0700 | [diff] [blame] | 837 | const GrUserStencilSettings* ss, |
robertphillips | 391395d | 2016-03-02 09:26:36 -0800 | [diff] [blame] | 838 | SkRegion::Op op, |
| 839 | bool invert, |
| 840 | bool doAA, |
| 841 | const SkMatrix& viewMatrix, |
| 842 | const SkPath& path) { |
| 843 | ASSERT_SINGLE_OWNER_PRIV |
| 844 | RETURN_FALSE_IF_ABANDONED_PRIV |
| 845 | SkDEBUGCODE(fDrawContext->validate();) |
| 846 | GR_AUDIT_TRAIL_AUTO_FRAME(fDrawContext->fAuditTrail, "GrDrawContext::drawPath"); |
| 847 | |
| 848 | if (path.isEmpty() && path.isInverseFillType()) { |
cdalton | 862cff3 | 2016-05-12 15:09:48 -0700 | [diff] [blame] | 849 | this->drawAndStencilRect(clip, ss, op, invert, false, SkMatrix::I(), |
robertphillips | 6c7e325 | 2016-04-27 10:47:51 -0700 | [diff] [blame] | 850 | SkRect::MakeIWH(fDrawContext->width(), |
| 851 | fDrawContext->height())); |
robertphillips | 391395d | 2016-03-02 09:26:36 -0800 | [diff] [blame] | 852 | return true; |
| 853 | } |
| 854 | |
| 855 | AutoCheckFlush acf(fDrawContext->fDrawingManager); |
| 856 | |
| 857 | // An Assumption here is that path renderer would use some form of tweaking |
| 858 | // the src color (either the input alpha or in the frag shader) to implement |
| 859 | // aa. If we have some future driver-mojo path AA that can do the right |
| 860 | // thing WRT to the blend then we'll need some query on the PR. |
| 861 | bool useCoverageAA = doAA && !fDrawContext->fRenderTarget->isUnifiedMultisampled(); |
cdalton | 93a379b | 2016-05-11 13:58:08 -0700 | [diff] [blame] | 862 | bool hasUserStencilSettings = (&GrUserStencilSettings::kUnused != ss); |
robertphillips | 391395d | 2016-03-02 09:26:36 -0800 | [diff] [blame] | 863 | bool isStencilBufferMSAA = fDrawContext->fRenderTarget->isStencilBufferMultisampled(); |
| 864 | |
| 865 | const GrPathRendererChain::DrawType type = |
| 866 | useCoverageAA ? GrPathRendererChain::kColorAntiAlias_DrawType |
| 867 | : GrPathRendererChain::kColor_DrawType; |
| 868 | |
| 869 | GrPathRenderer::CanDrawPathArgs canDrawArgs; |
| 870 | canDrawArgs.fShaderCaps = fDrawContext->fDrawingManager->getContext()->caps()->shaderCaps(); |
| 871 | canDrawArgs.fViewMatrix = &viewMatrix; |
| 872 | canDrawArgs.fPath = &path; |
bsalomon | 6663acf | 2016-05-10 09:14:17 -0700 | [diff] [blame] | 873 | canDrawArgs.fStyle = &GrStyle::SimpleFill(); |
robertphillips | 391395d | 2016-03-02 09:26:36 -0800 | [diff] [blame] | 874 | canDrawArgs.fAntiAlias = useCoverageAA; |
cdalton | 93a379b | 2016-05-11 13:58:08 -0700 | [diff] [blame] | 875 | canDrawArgs.fHasUserStencilSettings = hasUserStencilSettings; |
robertphillips | 391395d | 2016-03-02 09:26:36 -0800 | [diff] [blame] | 876 | canDrawArgs.fIsStencilBufferMSAA = isStencilBufferMSAA; |
| 877 | |
| 878 | // Don't allow the SW renderer |
| 879 | GrPathRenderer* pr = fDrawContext->fDrawingManager->getPathRenderer(canDrawArgs, false, type); |
| 880 | if (!pr) { |
| 881 | return false; |
| 882 | } |
| 883 | |
| 884 | GrPaint paint; |
| 885 | paint.setCoverageSetOpXPFactory(op, invert); |
| 886 | |
cdalton | 862cff3 | 2016-05-12 15:09:48 -0700 | [diff] [blame] | 887 | GrPipelineBuilder pipelineBuilder(paint, fDrawContext->accessRenderTarget()); |
cdalton | 93a379b | 2016-05-11 13:58:08 -0700 | [diff] [blame] | 888 | pipelineBuilder.setUserStencil(ss); |
robertphillips | 391395d | 2016-03-02 09:26:36 -0800 | [diff] [blame] | 889 | |
| 890 | GrPathRenderer::DrawPathArgs args; |
| 891 | args.fTarget = fDrawContext->getDrawTarget(); |
| 892 | args.fResourceProvider = fDrawContext->fDrawingManager->getContext()->resourceProvider(); |
| 893 | args.fPipelineBuilder = &pipelineBuilder; |
cdalton | 862cff3 | 2016-05-12 15:09:48 -0700 | [diff] [blame] | 894 | args.fClip = &clip; |
robertphillips | 391395d | 2016-03-02 09:26:36 -0800 | [diff] [blame] | 895 | args.fColor = GrColor_WHITE; |
| 896 | args.fViewMatrix = &viewMatrix; |
| 897 | args.fPath = &path; |
bsalomon | 6663acf | 2016-05-10 09:14:17 -0700 | [diff] [blame] | 898 | args.fStyle = &GrStyle::SimpleFill(); |
robertphillips | 391395d | 2016-03-02 09:26:36 -0800 | [diff] [blame] | 899 | args.fAntiAlias = useCoverageAA; |
brianosman | 0e3c554 | 2016-04-13 13:56:21 -0700 | [diff] [blame] | 900 | args.fGammaCorrect = fDrawContext->isGammaCorrect(); |
robertphillips | 391395d | 2016-03-02 09:26:36 -0800 | [diff] [blame] | 901 | pr->drawPath(args); |
| 902 | return true; |
| 903 | } |
| 904 | |
robertphillips | 4bc3181 | 2016-03-01 12:22:49 -0800 | [diff] [blame] | 905 | void GrDrawContext::internalDrawPath(const GrClip& clip, |
| 906 | const GrPaint& paint, |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 907 | const SkMatrix& viewMatrix, |
bsalomon | 6663acf | 2016-05-10 09:14:17 -0700 | [diff] [blame] | 908 | const SkPath& origPath, |
| 909 | const GrStyle& origStyle) { |
joshualitt | 1de610a | 2016-01-06 08:26:09 -0800 | [diff] [blame] | 910 | ASSERT_SINGLE_OWNER |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 911 | RETURN_IF_ABANDONED |
bsalomon | 6663acf | 2016-05-10 09:14:17 -0700 | [diff] [blame] | 912 | SkASSERT(!origPath.isEmpty()); |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 913 | |
robertphillips | 6c7e325 | 2016-04-27 10:47:51 -0700 | [diff] [blame] | 914 | bool useCoverageAA = should_apply_coverage_aa(paint, fRenderTarget.get()); |
cdalton | 93a379b | 2016-05-11 13:58:08 -0700 | [diff] [blame] | 915 | constexpr bool kHasUserStencilSettings = false; |
robertphillips | 4bc3181 | 2016-03-01 12:22:49 -0800 | [diff] [blame] | 916 | bool isStencilBufferMSAA = fRenderTarget->isStencilBufferMultisampled(); |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 917 | |
robertphillips | 6873782 | 2015-10-29 12:12:21 -0700 | [diff] [blame] | 918 | const GrPathRendererChain::DrawType type = |
| 919 | useCoverageAA ? GrPathRendererChain::kColorAntiAlias_DrawType |
| 920 | : GrPathRendererChain::kColor_DrawType; |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 921 | |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 922 | SkTLazy<SkPath> tmpPath; |
bsalomon | 6663acf | 2016-05-10 09:14:17 -0700 | [diff] [blame] | 923 | SkTLazy<GrStyle> tmpStyle; |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 924 | |
robertphillips | 6873782 | 2015-10-29 12:12:21 -0700 | [diff] [blame] | 925 | GrPathRenderer::CanDrawPathArgs canDrawArgs; |
| 926 | canDrawArgs.fShaderCaps = fDrawingManager->getContext()->caps()->shaderCaps(); |
| 927 | canDrawArgs.fViewMatrix = &viewMatrix; |
bsalomon | 6663acf | 2016-05-10 09:14:17 -0700 | [diff] [blame] | 928 | canDrawArgs.fPath = &origPath; |
| 929 | canDrawArgs.fStyle = &origStyle; |
robertphillips | 6873782 | 2015-10-29 12:12:21 -0700 | [diff] [blame] | 930 | canDrawArgs.fAntiAlias = useCoverageAA; |
cdalton | 93a379b | 2016-05-11 13:58:08 -0700 | [diff] [blame] | 931 | canDrawArgs.fHasUserStencilSettings = kHasUserStencilSettings; |
robertphillips | 6873782 | 2015-10-29 12:12:21 -0700 | [diff] [blame] | 932 | canDrawArgs.fIsStencilBufferMSAA = isStencilBufferMSAA; |
| 933 | |
bsalomon | 6663acf | 2016-05-10 09:14:17 -0700 | [diff] [blame] | 934 | // Try a 1st time without applying any of the style to the geometry (and barring sw) |
robertphillips | 6873782 | 2015-10-29 12:12:21 -0700 | [diff] [blame] | 935 | GrPathRenderer* pr = fDrawingManager->getPathRenderer(canDrawArgs, false, type); |
bsalomon | 6663acf | 2016-05-10 09:14:17 -0700 | [diff] [blame] | 936 | SkScalar styleScale = GrStyle::MatrixToScaleFactor(viewMatrix); |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 937 | |
bsalomon | 6663acf | 2016-05-10 09:14:17 -0700 | [diff] [blame] | 938 | if (!pr && canDrawArgs.fStyle->pathEffect()) { |
| 939 | // It didn't work above, so try again with the path effect applied. |
| 940 | SkStrokeRec rec(SkStrokeRec::kFill_InitStyle); |
| 941 | if (!canDrawArgs.fStyle->applyPathEffectToPath(tmpPath.init(), &rec, *canDrawArgs.fPath, |
| 942 | styleScale)) { |
| 943 | GrStyle noPathEffect(canDrawArgs.fStyle->strokeRec(), nullptr); |
| 944 | this->internalDrawPath(clip, paint, viewMatrix, *canDrawArgs.fPath, noPathEffect); |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 945 | return; |
| 946 | } |
bsalomon | 6663acf | 2016-05-10 09:14:17 -0700 | [diff] [blame] | 947 | tmpStyle.init(rec, nullptr); |
| 948 | canDrawArgs.fPath = tmpPath.get(); |
| 949 | canDrawArgs.fStyle = tmpStyle.get(); |
| 950 | if (canDrawArgs.fPath->isEmpty()) { |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 951 | return; |
| 952 | } |
robertphillips | 6873782 | 2015-10-29 12:12:21 -0700 | [diff] [blame] | 953 | |
| 954 | pr = fDrawingManager->getPathRenderer(canDrawArgs, false, type); |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 955 | } |
bsalomon | 6663acf | 2016-05-10 09:14:17 -0700 | [diff] [blame] | 956 | if (!pr) { |
| 957 | SkASSERT(!canDrawArgs.fStyle->pathEffect()); |
| 958 | if (canDrawArgs.fStyle->strokeRec().needToApply()) { |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 959 | if (!tmpPath.isValid()) { |
| 960 | tmpPath.init(); |
| 961 | } |
bsalomon | 6663acf | 2016-05-10 09:14:17 -0700 | [diff] [blame] | 962 | // It didn't work above, so try again by applying the stroke to the geometry. |
| 963 | SkStrokeRec::InitStyle fillOrHairline; |
| 964 | if (!canDrawArgs.fStyle->applyToPath(tmpPath.get(), &fillOrHairline, |
| 965 | *canDrawArgs.fPath, styleScale)) { |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 966 | return; |
| 967 | } |
bsalomon | 6663acf | 2016-05-10 09:14:17 -0700 | [diff] [blame] | 968 | if (!tmpStyle.isValid()) { |
| 969 | tmpStyle.init(fillOrHairline); |
| 970 | } else { |
| 971 | tmpStyle.get()->resetToInitStyle(fillOrHairline); |
| 972 | } |
| 973 | canDrawArgs.fPath = tmpPath.get(); |
| 974 | canDrawArgs.fStyle = tmpStyle.get(); |
| 975 | if (canDrawArgs.fPath->isEmpty()) { |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 976 | return; |
| 977 | } |
robertphillips | 6873782 | 2015-10-29 12:12:21 -0700 | [diff] [blame] | 978 | |
bsalomon | 6663acf | 2016-05-10 09:14:17 -0700 | [diff] [blame] | 979 | pr = fDrawingManager->getPathRenderer(canDrawArgs, false, type); |
| 980 | } |
bsalomon | 85d9667 | 2016-05-10 06:19:21 -0700 | [diff] [blame] | 981 | |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 982 | // This time, allow SW renderer |
robertphillips | 6873782 | 2015-10-29 12:12:21 -0700 | [diff] [blame] | 983 | pr = fDrawingManager->getPathRenderer(canDrawArgs, true, type); |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 984 | } |
| 985 | |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 986 | if (nullptr == pr) { |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 987 | #ifdef SK_DEBUG |
| 988 | SkDebugf("Unable to find path renderer compatible with path.\n"); |
| 989 | #endif |
| 990 | return; |
| 991 | } |
| 992 | |
cdalton | 862cff3 | 2016-05-12 15:09:48 -0700 | [diff] [blame] | 993 | GrPipelineBuilder pipelineBuilder(paint, fRenderTarget.get()); |
robertphillips | 4bc3181 | 2016-03-01 12:22:49 -0800 | [diff] [blame] | 994 | |
bsalomon | 0aff2fa | 2015-07-31 06:48:27 -0700 | [diff] [blame] | 995 | GrPathRenderer::DrawPathArgs args; |
robertphillips | b83bec5 | 2015-10-23 09:38:03 -0700 | [diff] [blame] | 996 | args.fTarget = this->getDrawTarget(); |
robertphillips | 77a2e52 | 2015-10-17 07:43:27 -0700 | [diff] [blame] | 997 | args.fResourceProvider = fDrawingManager->getContext()->resourceProvider(); |
robertphillips | 4bc3181 | 2016-03-01 12:22:49 -0800 | [diff] [blame] | 998 | args.fPipelineBuilder = &pipelineBuilder; |
cdalton | 862cff3 | 2016-05-12 15:09:48 -0700 | [diff] [blame] | 999 | args.fClip = &clip; |
robertphillips | 4bc3181 | 2016-03-01 12:22:49 -0800 | [diff] [blame] | 1000 | args.fColor = paint.getColor(); |
bsalomon | 0aff2fa | 2015-07-31 06:48:27 -0700 | [diff] [blame] | 1001 | args.fViewMatrix = &viewMatrix; |
bsalomon | 6663acf | 2016-05-10 09:14:17 -0700 | [diff] [blame] | 1002 | args.fPath = canDrawArgs.fPath; |
| 1003 | args.fStyle = canDrawArgs.fStyle; |
bsalomon | 0aff2fa | 2015-07-31 06:48:27 -0700 | [diff] [blame] | 1004 | args.fAntiAlias = useCoverageAA; |
brianosman | 0e3c554 | 2016-04-13 13:56:21 -0700 | [diff] [blame] | 1005 | args.fGammaCorrect = this->isGammaCorrect(); |
bsalomon | 0aff2fa | 2015-07-31 06:48:27 -0700 | [diff] [blame] | 1006 | pr->drawPath(args); |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 1007 | } |
| 1008 | |
cdalton | 862cff3 | 2016-05-12 15:09:48 -0700 | [diff] [blame] | 1009 | void GrDrawContext::drawBatch(GrPipelineBuilder* pipelineBuilder, const GrClip& clip, |
| 1010 | GrDrawBatch* batch) { |
joshualitt | 1de610a | 2016-01-06 08:26:09 -0800 | [diff] [blame] | 1011 | ASSERT_SINGLE_OWNER |
robertphillips | 2d70dcb | 2015-10-06 07:38:23 -0700 | [diff] [blame] | 1012 | RETURN_IF_ABANDONED |
robertphillips | 2e1e51f | 2015-10-15 08:01:48 -0700 | [diff] [blame] | 1013 | SkDEBUGCODE(this->validate();) |
joshualitt | bc90735 | 2016-01-13 06:45:40 -0800 | [diff] [blame] | 1014 | GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawBatch"); |
robertphillips | 2d70dcb | 2015-10-06 07:38:23 -0700 | [diff] [blame] | 1015 | |
cdalton | 862cff3 | 2016-05-12 15:09:48 -0700 | [diff] [blame] | 1016 | this->getDrawTarget()->drawBatch(*pipelineBuilder, clip, batch); |
robertphillips | 2334fb6 | 2015-06-17 05:43:33 -0700 | [diff] [blame] | 1017 | } |