epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 1 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 2 | /* |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 3 | * Copyright 2010 Google Inc. |
| 4 | * |
| 5 | * Use of this source code is governed by a BSD-style license that can be |
| 6 | * found in the LICENSE file. |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 7 | */ |
| 8 | |
joshualitt | c2893c5 | 2015-01-28 06:54:30 -0800 | [diff] [blame] | 9 | #include "GrDrawTarget.h" |
joshualitt | 4d8da81 | 2015-01-28 12:53:54 -0800 | [diff] [blame] | 10 | |
bsalomon | eb1cb5c | 2015-05-22 08:01:09 -0700 | [diff] [blame] | 11 | #include "GrCaps.h" |
bsalomon | 4061b12 | 2015-05-29 10:26:19 -0700 | [diff] [blame] | 12 | #include "GrGpu.h" |
commit-bot@chromium.org | c4dc0ad | 2013-10-09 14:11:33 +0000 | [diff] [blame] | 13 | #include "GrPath.h" |
egdaniel | e36914c | 2015-02-13 09:00:33 -0800 | [diff] [blame] | 14 | #include "GrPipeline.h" |
joshualitt | b7133be | 2015-04-08 09:08:31 -0700 | [diff] [blame] | 15 | #include "GrMemoryPool.h" |
bsalomon@google.com | 8f9cbd6 | 2011-12-09 15:55:34 +0000 | [diff] [blame] | 16 | #include "GrRenderTarget.h" |
bsalomon | 4061b12 | 2015-05-29 10:26:19 -0700 | [diff] [blame] | 17 | #include "GrResourceProvider.h" |
bsalomon | 6bc1b5f | 2015-02-23 09:06:38 -0800 | [diff] [blame] | 18 | #include "GrRenderTargetPriv.h" |
bsalomon | afbf2d6 | 2014-09-30 12:18:44 -0700 | [diff] [blame] | 19 | #include "GrSurfacePriv.h" |
bsalomon@google.com | 86afc2a | 2011-02-16 16:12:19 +0000 | [diff] [blame] | 20 | #include "GrTexture.h" |
bsalomon@google.com | 25fb21f | 2011-06-21 18:17:25 +0000 | [diff] [blame] | 21 | #include "GrVertexBuffer.h" |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 22 | |
bsalomon | 5346983 | 2015-08-18 09:20:09 -0700 | [diff] [blame] | 23 | #include "batches/GrClearBatch.h" |
bsalomon | 872062c | 2015-08-18 12:12:35 -0700 | [diff] [blame] | 24 | #include "batches/GrCopySurfaceBatch.h" |
bsalomon | 5346983 | 2015-08-18 09:20:09 -0700 | [diff] [blame] | 25 | #include "batches/GrDiscardBatch.h" |
bsalomon | 16b9913 | 2015-08-13 14:55:50 -0700 | [diff] [blame] | 26 | #include "batches/GrDrawBatch.h" |
bsalomon | add79ef | 2015-08-19 13:26:49 -0700 | [diff] [blame] | 27 | #include "batches/GrDrawPathBatch.h" |
joshualitt | ecd1a69 | 2015-08-10 10:08:26 -0700 | [diff] [blame] | 28 | #include "batches/GrRectBatchFactory.h" |
bsalomon | a44919e | 2015-08-18 13:28:19 -0700 | [diff] [blame] | 29 | #include "batches/GrStencilPathBatch.h" |
joshualitt | 7441782 | 2015-08-07 11:42:16 -0700 | [diff] [blame] | 30 | |
sugoi@google.com | 5f74cf8 | 2012-12-17 21:16:45 +0000 | [diff] [blame] | 31 | #include "SkStrokeRec.h" |
sugoi@google.com | 12b4e27 | 2012-12-06 20:13:11 +0000 | [diff] [blame] | 32 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 33 | //////////////////////////////////////////////////////////////////////////////// |
| 34 | |
bsalomon | 4061b12 | 2015-05-29 10:26:19 -0700 | [diff] [blame] | 35 | GrDrawTarget::GrDrawTarget(GrGpu* gpu, GrResourceProvider* resourceProvider) |
| 36 | : fGpu(SkRef(gpu)) |
bsalomon | 4061b12 | 2015-05-29 10:26:19 -0700 | [diff] [blame] | 37 | , fResourceProvider(resourceProvider) |
joshualitt | f6d259b | 2015-10-02 11:27:14 -0700 | [diff] [blame] | 38 | , fFlushState(fGpu, fResourceProvider, 0) |
bsalomon | 512be53 | 2015-09-10 10:42:55 -0700 | [diff] [blame] | 39 | , fFlushing(false) |
robertphillips | a106c62 | 2015-10-16 09:07:06 -0700 | [diff] [blame] | 40 | , fFirstUnpreparedBatch(0) |
robertphillips | 6a18665 | 2015-10-20 07:37:58 -0700 | [diff] [blame] | 41 | , fFlags(0) { |
bsalomon | b3b9aec | 2015-09-10 11:16:35 -0700 | [diff] [blame] | 42 | // TODO: Stop extracting the context (currently needed by GrClipMaskManager) |
| 43 | fContext = fGpu->getContext(); |
Brian Salomon | e66fec2 | 2015-09-10 14:40:20 -0400 | [diff] [blame] | 44 | fClipMaskManager.reset(new GrClipMaskManager(this)); |
robertphillips | 4beb5c1 | 2015-10-20 07:50:00 -0700 | [diff] [blame^] | 45 | |
| 46 | #ifdef SK_DEBUG |
| 47 | static int debugID = 0; |
| 48 | fDebugID = debugID++; |
| 49 | #endif |
bsalomon | 4061b12 | 2015-05-29 10:26:19 -0700 | [diff] [blame] | 50 | } |
| 51 | |
| 52 | GrDrawTarget::~GrDrawTarget() { |
| 53 | fGpu->unref(); |
bsalomon@google.com | 25fb21f | 2011-06-21 18:17:25 +0000 | [diff] [blame] | 54 | } |
| 55 | |
| 56 | //////////////////////////////////////////////////////////////////////////////// |
| 57 | |
robertphillips | 6a18665 | 2015-10-20 07:37:58 -0700 | [diff] [blame] | 58 | // Add a GrDrawTarget-based dependency |
| 59 | void GrDrawTarget::addDependency(GrDrawTarget* dependedOn) { |
| 60 | SkASSERT(!dependedOn->dependsOn(this)); // loops are bad |
| 61 | |
| 62 | if (this->dependsOn(dependedOn)) { |
| 63 | return; // don't add duplicate dependencies |
| 64 | } |
| 65 | |
| 66 | *fDependencies.push() = dependedOn; |
| 67 | } |
| 68 | |
| 69 | // Convert from a GrSurface-based dependency to a GrDrawTarget one |
| 70 | void GrDrawTarget::addDependency(GrSurface* dependedOn) { |
| 71 | if (dependedOn->asRenderTarget() && dependedOn->asRenderTarget()->getLastDrawTarget()) { |
| 72 | // If it is still receiving dependencies, this DT shouldn't be closed |
| 73 | SkASSERT(!this->isClosed()); |
| 74 | |
| 75 | GrDrawTarget* dt = dependedOn->asRenderTarget()->getLastDrawTarget(); |
| 76 | if (dt == this) { |
| 77 | // self-read - presumably for dst reads |
| 78 | } else { |
| 79 | this->addDependency(dt); |
| 80 | |
| 81 | // Can't make it closed in the self-read case |
| 82 | dt->makeClosed(); |
| 83 | } |
| 84 | } |
| 85 | } |
| 86 | |
robertphillips | 4beb5c1 | 2015-10-20 07:50:00 -0700 | [diff] [blame^] | 87 | #ifdef SK_DEBUG |
| 88 | void GrDrawTarget::dump() const { |
| 89 | SkDebugf("--------------------------------------------------------------\n"); |
| 90 | SkDebugf("node: %d\n"); |
| 91 | SkDebugf("relies On (%d): ", fDependencies.count()); |
| 92 | for (int i = 0; i < fDependencies.count(); ++i) { |
| 93 | SkDebugf("%d, ", fDependencies[i]->fDebugID); |
| 94 | } |
| 95 | SkDebugf("\n"); |
| 96 | SkDebugf("batches (%d):\n", fBatches.count()); |
| 97 | for (int i = 0; i < fBatches.count(); ++i) { |
| 98 | #if 0 |
| 99 | SkDebugf("*******************************\n"); |
| 100 | #endif |
| 101 | SkDebugf("%d: %s\n", i, fBatches[i]->name()); |
| 102 | #if 0 |
| 103 | SkString str = fBatches[i]->dumpInfo(); |
| 104 | SkDebugf("%s\n", str.c_str()); |
| 105 | #endif |
| 106 | } |
| 107 | } |
| 108 | #endif |
| 109 | |
bsalomon | 50785a3 | 2015-02-06 07:02:37 -0800 | [diff] [blame] | 110 | bool GrDrawTarget::setupDstReadIfNecessary(const GrPipelineBuilder& pipelineBuilder, |
egdaniel | e36914c | 2015-02-13 09:00:33 -0800 | [diff] [blame] | 111 | const GrProcOptInfo& colorPOI, |
| 112 | const GrProcOptInfo& coveragePOI, |
bsalomon | 6a44c6a | 2015-05-26 09:49:05 -0700 | [diff] [blame] | 113 | GrXferProcessor::DstTexture* dstTexture, |
bsalomon | ad792c1 | 2015-09-10 11:10:50 -0700 | [diff] [blame] | 114 | const SkRect& batchBounds) { |
| 115 | SkRect bounds = batchBounds; |
| 116 | bounds.outset(0.5f, 0.5f); |
| 117 | |
bsalomon | 6a44c6a | 2015-05-26 09:49:05 -0700 | [diff] [blame] | 118 | if (!pipelineBuilder.willXPNeedDstTexture(*this->caps(), colorPOI, coveragePOI)) { |
bsalomon@google.com | 26e18b5 | 2013-03-29 19:22:36 +0000 | [diff] [blame] | 119 | return true; |
| 120 | } |
cdalton | 9954bc3 | 2015-04-29 14:17:00 -0700 | [diff] [blame] | 121 | |
bsalomon | 50785a3 | 2015-02-06 07:02:37 -0800 | [diff] [blame] | 122 | GrRenderTarget* rt = pipelineBuilder.getRenderTarget(); |
cdalton | 9954bc3 | 2015-04-29 14:17:00 -0700 | [diff] [blame] | 123 | |
| 124 | if (this->caps()->textureBarrierSupport()) { |
| 125 | if (GrTexture* rtTex = rt->asTexture()) { |
bsalomon | dc47ff7 | 2015-05-26 12:16:59 -0700 | [diff] [blame] | 126 | // The render target is a texture, so we can read from it directly in the shader. The XP |
cdalton | 9954bc3 | 2015-04-29 14:17:00 -0700 | [diff] [blame] | 127 | // will be responsible to detect this situation and request a texture barrier. |
bsalomon | 6a44c6a | 2015-05-26 09:49:05 -0700 | [diff] [blame] | 128 | dstTexture->setTexture(rtTex); |
| 129 | dstTexture->setOffset(0, 0); |
cdalton | 9954bc3 | 2015-04-29 14:17:00 -0700 | [diff] [blame] | 130 | return true; |
| 131 | } |
| 132 | } |
| 133 | |
| 134 | SkIRect copyRect; |
joshualitt | 44701df | 2015-02-23 14:44:57 -0800 | [diff] [blame] | 135 | pipelineBuilder.clip().getConservativeBounds(rt, ©Rect); |
commit-bot@chromium.org | c4dc0ad | 2013-10-09 14:11:33 +0000 | [diff] [blame] | 136 | |
bsalomon | ad792c1 | 2015-09-10 11:10:50 -0700 | [diff] [blame] | 137 | SkIRect drawIBounds; |
| 138 | bounds.roundOut(&drawIBounds); |
| 139 | if (!copyRect.intersect(drawIBounds)) { |
commit-bot@chromium.org | 515dcd3 | 2013-08-28 14:17:03 +0000 | [diff] [blame] | 140 | #ifdef SK_DEBUG |
bsalomon | b3b9aec | 2015-09-10 11:16:35 -0700 | [diff] [blame] | 141 | GrCapsDebugf(this->caps(), "Missed an early reject. " |
| 142 | "Bailing on draw from setupDstReadIfNecessary.\n"); |
commit-bot@chromium.org | bb5c465 | 2013-04-01 12:49:31 +0000 | [diff] [blame] | 143 | #endif |
bsalomon | ad792c1 | 2015-09-10 11:10:50 -0700 | [diff] [blame] | 144 | return false; |
commit-bot@chromium.org | bb5c465 | 2013-04-01 12:49:31 +0000 | [diff] [blame] | 145 | } |
skia.committer@gmail.com | 05a2ee0 | 2013-04-02 07:01:34 +0000 | [diff] [blame] | 146 | |
commit-bot@chromium.org | 63150af | 2013-04-11 22:00:22 +0000 | [diff] [blame] | 147 | // MSAA consideration: When there is support for reading MSAA samples in the shader we could |
| 148 | // have per-sample dst values by making the copy multisampled. |
bsalomon | f2703d8 | 2014-10-28 14:33:06 -0700 | [diff] [blame] | 149 | GrSurfaceDesc desc; |
bsalomon | b3b9aec | 2015-09-10 11:16:35 -0700 | [diff] [blame] | 150 | if (!fGpu->initCopySurfaceDstDesc(rt, &desc)) { |
bsalomon | a73239a | 2015-04-28 13:35:17 -0700 | [diff] [blame] | 151 | desc.fOrigin = kDefault_GrSurfaceOrigin; |
| 152 | desc.fFlags = kRenderTarget_GrSurfaceFlag; |
| 153 | desc.fConfig = rt->config(); |
| 154 | } |
| 155 | |
commit-bot@chromium.org | bb5c465 | 2013-04-01 12:49:31 +0000 | [diff] [blame] | 156 | desc.fWidth = copyRect.width(); |
| 157 | desc.fHeight = copyRect.height(); |
bsalomon@google.com | 26e18b5 | 2013-03-29 19:22:36 +0000 | [diff] [blame] | 158 | |
bsalomon | eae6200 | 2015-07-31 13:59:30 -0700 | [diff] [blame] | 159 | static const uint32_t kFlags = 0; |
| 160 | SkAutoTUnref<GrTexture> copy(fResourceProvider->createApproxTexture(desc, kFlags)); |
bsalomon@google.com | 26e18b5 | 2013-03-29 19:22:36 +0000 | [diff] [blame] | 161 | |
bsalomon | e305973 | 2014-10-14 11:47:22 -0700 | [diff] [blame] | 162 | if (!copy) { |
tfarina | 38406c8 | 2014-10-31 07:11:12 -0700 | [diff] [blame] | 163 | SkDebugf("Failed to create temporary copy of destination texture.\n"); |
bsalomon@google.com | 26e18b5 | 2013-03-29 19:22:36 +0000 | [diff] [blame] | 164 | return false; |
| 165 | } |
bsalomon@google.com | e4617bf | 2013-04-03 14:56:40 +0000 | [diff] [blame] | 166 | SkIPoint dstPoint = {0, 0}; |
bsalomon | 6df8640 | 2015-06-01 10:41:49 -0700 | [diff] [blame] | 167 | this->copySurface(copy, rt, copyRect, dstPoint); |
| 168 | dstTexture->setTexture(copy); |
| 169 | dstTexture->setOffset(copyRect.fLeft, copyRect.fTop); |
| 170 | return true; |
bsalomon@google.com | 26e18b5 | 2013-03-29 19:22:36 +0000 | [diff] [blame] | 171 | } |
| 172 | |
bsalomon | a73239a | 2015-04-28 13:35:17 -0700 | [diff] [blame] | 173 | void GrDrawTarget::flush() { |
| 174 | if (fFlushing) { |
| 175 | return; |
| 176 | } |
| 177 | fFlushing = true; |
| 178 | |
robertphillips | a106c62 | 2015-10-16 09:07:06 -0700 | [diff] [blame] | 179 | // Semi-usually the drawTargets are already closed at this point, but sometimes Ganesh |
| 180 | // needs to flush mid-draw. In that case, the SkGpuDevice's drawTargets won't be closed |
| 181 | // but need to be flushed anyway. Closing such drawTargets here will mean new |
| 182 | // drawTargets will be created to replace them if the SkGpuDevice(s) write to them again. |
| 183 | this->makeClosed(); |
| 184 | |
bsalomon | 512be53 | 2015-09-10 10:42:55 -0700 | [diff] [blame] | 185 | // Loop over all batches and generate geometry |
joshualitt | f6d259b | 2015-10-02 11:27:14 -0700 | [diff] [blame] | 186 | for (; fFirstUnpreparedBatch < fBatches.count(); ++fFirstUnpreparedBatch) { |
| 187 | fBatches[fFirstUnpreparedBatch]->prepare(&fFlushState); |
bsalomon | 512be53 | 2015-09-10 10:42:55 -0700 | [diff] [blame] | 188 | } |
| 189 | |
| 190 | // Upload all data to the GPU |
joshualitt | f6d259b | 2015-10-02 11:27:14 -0700 | [diff] [blame] | 191 | fFlushState.preIssueDraws(); |
bsalomon | 512be53 | 2015-09-10 10:42:55 -0700 | [diff] [blame] | 192 | |
| 193 | // Draw all the generated geometry. |
| 194 | for (int i = 0; i < fBatches.count(); ++i) { |
joshualitt | f6d259b | 2015-10-02 11:27:14 -0700 | [diff] [blame] | 195 | fBatches[i]->draw(&fFlushState); |
bsalomon | 512be53 | 2015-09-10 10:42:55 -0700 | [diff] [blame] | 196 | } |
| 197 | |
joshualitt | f6d259b | 2015-10-02 11:27:14 -0700 | [diff] [blame] | 198 | SkASSERT(fFlushState.lastFlushedToken() == fFlushState.currentToken()); |
| 199 | this->reset(); |
bsalomon | a73239a | 2015-04-28 13:35:17 -0700 | [diff] [blame] | 200 | |
bsalomon | a73239a | 2015-04-28 13:35:17 -0700 | [diff] [blame] | 201 | fFlushing = false; |
bsalomon | a73239a | 2015-04-28 13:35:17 -0700 | [diff] [blame] | 202 | } |
| 203 | |
bsalomon | 512be53 | 2015-09-10 10:42:55 -0700 | [diff] [blame] | 204 | void GrDrawTarget::reset() { |
joshualitt | f6d259b | 2015-10-02 11:27:14 -0700 | [diff] [blame] | 205 | fFirstUnpreparedBatch = 0; |
bsalomon | 512be53 | 2015-09-10 10:42:55 -0700 | [diff] [blame] | 206 | fBatches.reset(); |
joshualitt | f6d259b | 2015-10-02 11:27:14 -0700 | [diff] [blame] | 207 | fFlushState.reset(); |
bsalomon | 512be53 | 2015-09-10 10:42:55 -0700 | [diff] [blame] | 208 | } |
| 209 | |
bsalomon | abd30f5 | 2015-08-13 13:34:48 -0700 | [diff] [blame] | 210 | void GrDrawTarget::drawBatch(const GrPipelineBuilder& pipelineBuilder, GrDrawBatch* batch) { |
joshualitt | 4d8da81 | 2015-01-28 12:53:54 -0800 | [diff] [blame] | 211 | // Setup clip |
| 212 | GrScissorState scissorState; |
joshualitt | 4d8da81 | 2015-01-28 12:53:54 -0800 | [diff] [blame] | 213 | GrPipelineBuilder::AutoRestoreStencil ars; |
bsalomon | 0ba8c24 | 2015-10-07 09:20:28 -0700 | [diff] [blame] | 214 | GrAppliedClip clip; |
| 215 | if (!fClipMaskManager->setupClipping(pipelineBuilder, &ars, &scissorState, &batch->bounds(), |
| 216 | &clip)) { |
joshualitt | 4d8da81 | 2015-01-28 12:53:54 -0800 | [diff] [blame] | 217 | return; |
| 218 | } |
bsalomon | 0ba8c24 | 2015-10-07 09:20:28 -0700 | [diff] [blame] | 219 | GrPipelineBuilder::AutoRestoreFragmentProcessorState arfps; |
| 220 | if (clip.clipCoverageFragmentProcessor()) { |
| 221 | arfps.set(&pipelineBuilder); |
| 222 | arfps.addCoverageFragmentProcessor(clip.clipCoverageFragmentProcessor()); |
| 223 | } |
joshualitt | 4d8da81 | 2015-01-28 12:53:54 -0800 | [diff] [blame] | 224 | |
bsalomon | ad792c1 | 2015-09-10 11:10:50 -0700 | [diff] [blame] | 225 | GrPipeline::CreateArgs args; |
| 226 | if (!this->installPipelineInDrawBatch(&pipelineBuilder, &scissorState, batch)) { |
egdaniel | e36914c | 2015-02-13 09:00:33 -0800 | [diff] [blame] | 227 | return; |
| 228 | } |
bsalomon | ad792c1 | 2015-09-10 11:10:50 -0700 | [diff] [blame] | 229 | |
bsalomon | 512be53 | 2015-09-10 10:42:55 -0700 | [diff] [blame] | 230 | this->recordBatch(batch); |
joshualitt | 4d8da81 | 2015-01-28 12:53:54 -0800 | [diff] [blame] | 231 | } |
| 232 | |
joshualitt | 2c93efe | 2014-11-06 12:57:13 -0800 | [diff] [blame] | 233 | static const GrStencilSettings& winding_path_stencil_settings() { |
| 234 | GR_STATIC_CONST_SAME_STENCIL_STRUCT(gSettings, |
| 235 | kIncClamp_StencilOp, |
| 236 | kIncClamp_StencilOp, |
| 237 | kAlwaysIfInClip_StencilFunc, |
| 238 | 0xFFFF, 0xFFFF, 0xFFFF); |
| 239 | return *GR_CONST_STENCIL_SETTINGS_PTR_FROM_STRUCT_PTR(&gSettings); |
| 240 | } |
| 241 | |
| 242 | static const GrStencilSettings& even_odd_path_stencil_settings() { |
| 243 | GR_STATIC_CONST_SAME_STENCIL_STRUCT(gSettings, |
| 244 | kInvert_StencilOp, |
| 245 | kInvert_StencilOp, |
| 246 | kAlwaysIfInClip_StencilFunc, |
| 247 | 0xFFFF, 0xFFFF, 0xFFFF); |
| 248 | return *GR_CONST_STENCIL_SETTINGS_PTR_FROM_STRUCT_PTR(&gSettings); |
| 249 | } |
| 250 | |
| 251 | void GrDrawTarget::getPathStencilSettingsForFilltype(GrPathRendering::FillType fill, |
egdaniel | 8dc7c3a | 2015-04-16 11:22:42 -0700 | [diff] [blame] | 252 | const GrStencilAttachment* sb, |
joshualitt | 2c93efe | 2014-11-06 12:57:13 -0800 | [diff] [blame] | 253 | GrStencilSettings* outStencilSettings) { |
| 254 | |
| 255 | switch (fill) { |
| 256 | default: |
| 257 | SkFAIL("Unexpected path fill."); |
| 258 | case GrPathRendering::kWinding_FillType: |
| 259 | *outStencilSettings = winding_path_stencil_settings(); |
| 260 | break; |
| 261 | case GrPathRendering::kEvenOdd_FillType: |
| 262 | *outStencilSettings = even_odd_path_stencil_settings(); |
| 263 | break; |
| 264 | } |
bsalomon | b3b9aec | 2015-09-10 11:16:35 -0700 | [diff] [blame] | 265 | fClipMaskManager->adjustPathStencilParams(sb, outStencilSettings); |
joshualitt | 2c93efe | 2014-11-06 12:57:13 -0800 | [diff] [blame] | 266 | } |
| 267 | |
joshualitt | 1c73548 | 2015-07-13 08:08:25 -0700 | [diff] [blame] | 268 | void GrDrawTarget::stencilPath(const GrPipelineBuilder& pipelineBuilder, |
joshualitt | f238469 | 2015-09-10 11:00:51 -0700 | [diff] [blame] | 269 | const SkMatrix& viewMatrix, |
joshualitt | 9853cce | 2014-11-17 14:22:48 -0800 | [diff] [blame] | 270 | const GrPath* path, |
| 271 | GrPathRendering::FillType fill) { |
bsalomon@google.com | 64aef2b | 2012-06-11 15:36:13 +0000 | [diff] [blame] | 272 | // TODO: extract portions of checkDraw that are relevant to path stenciling. |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 273 | SkASSERT(path); |
jvanverth | e9c0fc6 | 2015-04-29 11:18:05 -0700 | [diff] [blame] | 274 | SkASSERT(this->caps()->shaderCaps()->pathRenderingSupport()); |
joshualitt | 2c93efe | 2014-11-06 12:57:13 -0800 | [diff] [blame] | 275 | |
| 276 | // Setup clip |
bsalomon | 3e79124 | 2014-12-17 13:43:13 -0800 | [diff] [blame] | 277 | GrScissorState scissorState; |
egdaniel | 8dd688b | 2015-01-22 10:16:09 -0800 | [diff] [blame] | 278 | GrPipelineBuilder::AutoRestoreStencil ars; |
bsalomon | 0ba8c24 | 2015-10-07 09:20:28 -0700 | [diff] [blame] | 279 | GrAppliedClip clip; |
| 280 | if (!fClipMaskManager->setupClipping(pipelineBuilder, &ars, &scissorState, nullptr, &clip)) { |
joshualitt | 2c93efe | 2014-11-06 12:57:13 -0800 | [diff] [blame] | 281 | return; |
| 282 | } |
| 283 | |
bsalomon | 0ba8c24 | 2015-10-07 09:20:28 -0700 | [diff] [blame] | 284 | GrPipelineBuilder::AutoRestoreFragmentProcessorState arfps; |
| 285 | if (clip.clipCoverageFragmentProcessor()) { |
| 286 | arfps.set(&pipelineBuilder); |
| 287 | arfps.addCoverageFragmentProcessor(clip.clipCoverageFragmentProcessor()); |
| 288 | } |
| 289 | |
joshualitt | 2c93efe | 2014-11-06 12:57:13 -0800 | [diff] [blame] | 290 | // set stencil settings for path |
| 291 | GrStencilSettings stencilSettings; |
joshualitt | 1c73548 | 2015-07-13 08:08:25 -0700 | [diff] [blame] | 292 | GrRenderTarget* rt = pipelineBuilder.getRenderTarget(); |
egdaniel | ec00d94 | 2015-09-14 12:56:10 -0700 | [diff] [blame] | 293 | GrStencilAttachment* sb = fResourceProvider->attachStencilAttachment(rt); |
bsalomon | 6bc1b5f | 2015-02-23 09:06:38 -0800 | [diff] [blame] | 294 | this->getPathStencilSettingsForFilltype(fill, sb, &stencilSettings); |
joshualitt | 2c93efe | 2014-11-06 12:57:13 -0800 | [diff] [blame] | 295 | |
joshualitt | f238469 | 2015-09-10 11:00:51 -0700 | [diff] [blame] | 296 | GrBatch* batch = GrStencilPathBatch::Create(viewMatrix, |
bsalomon | a44919e | 2015-08-18 13:28:19 -0700 | [diff] [blame] | 297 | pipelineBuilder.isHWAntialias(), |
| 298 | stencilSettings, scissorState, |
| 299 | pipelineBuilder.getRenderTarget(), |
| 300 | path); |
bsalomon | 512be53 | 2015-09-10 10:42:55 -0700 | [diff] [blame] | 301 | this->recordBatch(batch); |
bsalomon | a44919e | 2015-08-18 13:28:19 -0700 | [diff] [blame] | 302 | batch->unref(); |
bsalomon@google.com | 64aef2b | 2012-06-11 15:36:13 +0000 | [diff] [blame] | 303 | } |
| 304 | |
joshualitt | 1c73548 | 2015-07-13 08:08:25 -0700 | [diff] [blame] | 305 | void GrDrawTarget::drawPath(const GrPipelineBuilder& pipelineBuilder, |
joshualitt | f238469 | 2015-09-10 11:00:51 -0700 | [diff] [blame] | 306 | const SkMatrix& viewMatrix, |
| 307 | GrColor color, |
joshualitt | 9853cce | 2014-11-17 14:22:48 -0800 | [diff] [blame] | 308 | const GrPath* path, |
| 309 | GrPathRendering::FillType fill) { |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 310 | SkASSERT(path); |
jvanverth | e9c0fc6 | 2015-04-29 11:18:05 -0700 | [diff] [blame] | 311 | SkASSERT(this->caps()->shaderCaps()->pathRenderingSupport()); |
commit-bot@chromium.org | c4dc0ad | 2013-10-09 14:11:33 +0000 | [diff] [blame] | 312 | |
joshualitt | f238469 | 2015-09-10 11:00:51 -0700 | [diff] [blame] | 313 | GrDrawPathBatchBase* batch = GrDrawPathBatch::Create(viewMatrix, color, path); |
bsalomon | 1fcc01c | 2015-09-09 09:48:06 -0700 | [diff] [blame] | 314 | this->drawPathBatch(pipelineBuilder, batch, fill); |
| 315 | batch->unref(); |
| 316 | } |
commit-bot@chromium.org | c4dc0ad | 2013-10-09 14:11:33 +0000 | [diff] [blame] | 317 | |
bsalomon | 1fcc01c | 2015-09-09 09:48:06 -0700 | [diff] [blame] | 318 | void GrDrawTarget::drawPathsFromRange(const GrPipelineBuilder& pipelineBuilder, |
joshualitt | f238469 | 2015-09-10 11:00:51 -0700 | [diff] [blame] | 319 | const SkMatrix& viewMatrix, |
| 320 | const SkMatrix& localMatrix, |
| 321 | GrColor color, |
cdalton | 8585dd2 | 2015-10-08 08:04:09 -0700 | [diff] [blame] | 322 | GrPathRange* range, |
bsalomon | 1fcc01c | 2015-09-09 09:48:06 -0700 | [diff] [blame] | 323 | GrPathRangeDraw* draw, |
| 324 | GrPathRendering::FillType fill) { |
cdalton | 8585dd2 | 2015-10-08 08:04:09 -0700 | [diff] [blame] | 325 | GrDrawPathBatchBase* batch = GrDrawPathRangeBatch::Create(viewMatrix, localMatrix, color, |
| 326 | range, draw); |
bsalomon | 1fcc01c | 2015-09-09 09:48:06 -0700 | [diff] [blame] | 327 | this->drawPathBatch(pipelineBuilder, batch, fill); |
| 328 | batch->unref(); |
| 329 | } |
| 330 | |
| 331 | void GrDrawTarget::drawPathBatch(const GrPipelineBuilder& pipelineBuilder, |
| 332 | GrDrawPathBatchBase* batch, |
| 333 | GrPathRendering::FillType fill) { |
bsalomon | add79ef | 2015-08-19 13:26:49 -0700 | [diff] [blame] | 334 | // This looks like drawBatch() but there is an added wrinkle that stencil settings get inserted |
bsalomon | b3b9aec | 2015-09-10 11:16:35 -0700 | [diff] [blame] | 335 | // after setting up clipping but before onDrawBatch(). TODO: Figure out a better model for |
| 336 | // handling stencil settings WRT interactions between pipeline(builder), clipmaskmanager, and |
| 337 | // batches. |
bsalomon | add79ef | 2015-08-19 13:26:49 -0700 | [diff] [blame] | 338 | |
bsalomon | 3e79124 | 2014-12-17 13:43:13 -0800 | [diff] [blame] | 339 | GrScissorState scissorState; |
egdaniel | 8dd688b | 2015-01-22 10:16:09 -0800 | [diff] [blame] | 340 | GrPipelineBuilder::AutoRestoreStencil ars; |
bsalomon | 0ba8c24 | 2015-10-07 09:20:28 -0700 | [diff] [blame] | 341 | GrAppliedClip clip; |
| 342 | if (!fClipMaskManager->setupClipping(pipelineBuilder, &ars, &scissorState, &batch->bounds(), |
| 343 | &clip)) { |
bsalomon | add79ef | 2015-08-19 13:26:49 -0700 | [diff] [blame] | 344 | return; |
joshualitt | 2c93efe | 2014-11-06 12:57:13 -0800 | [diff] [blame] | 345 | } |
| 346 | |
bsalomon | 0ba8c24 | 2015-10-07 09:20:28 -0700 | [diff] [blame] | 347 | GrPipelineBuilder::AutoRestoreFragmentProcessorState arfps; |
| 348 | if (clip.clipCoverageFragmentProcessor()) { |
| 349 | arfps.set(&pipelineBuilder); |
| 350 | arfps.addCoverageFragmentProcessor(clip.clipCoverageFragmentProcessor()); |
| 351 | } |
| 352 | |
bsalomon | add79ef | 2015-08-19 13:26:49 -0700 | [diff] [blame] | 353 | // Ensure the render target has a stencil buffer and get the stencil settings. |
joshualitt | 2c93efe | 2014-11-06 12:57:13 -0800 | [diff] [blame] | 354 | GrStencilSettings stencilSettings; |
joshualitt | 1c73548 | 2015-07-13 08:08:25 -0700 | [diff] [blame] | 355 | GrRenderTarget* rt = pipelineBuilder.getRenderTarget(); |
egdaniel | ec00d94 | 2015-09-14 12:56:10 -0700 | [diff] [blame] | 356 | GrStencilAttachment* sb = fResourceProvider->attachStencilAttachment(rt); |
bsalomon | 6bc1b5f | 2015-02-23 09:06:38 -0800 | [diff] [blame] | 357 | this->getPathStencilSettingsForFilltype(fill, sb, &stencilSettings); |
bsalomon | add79ef | 2015-08-19 13:26:49 -0700 | [diff] [blame] | 358 | batch->setStencilSettings(stencilSettings); |
joshualitt | 2c93efe | 2014-11-06 12:57:13 -0800 | [diff] [blame] | 359 | |
bsalomon | ad792c1 | 2015-09-10 11:10:50 -0700 | [diff] [blame] | 360 | GrPipeline::CreateArgs args; |
| 361 | if (!this->installPipelineInDrawBatch(&pipelineBuilder, &scissorState, batch)) { |
bsalomon | add79ef | 2015-08-19 13:26:49 -0700 | [diff] [blame] | 362 | return; |
| 363 | } |
egdaniel | e36914c | 2015-02-13 09:00:33 -0800 | [diff] [blame] | 364 | |
bsalomon | 512be53 | 2015-09-10 10:42:55 -0700 | [diff] [blame] | 365 | this->recordBatch(batch); |
commit-bot@chromium.org | 9b62aa1 | 2014-03-25 11:59:40 +0000 | [diff] [blame] | 366 | } |
| 367 | |
joshualitt | d2b23e0 | 2015-08-21 10:53:34 -0700 | [diff] [blame] | 368 | void GrDrawTarget::drawNonAARect(const GrPipelineBuilder& pipelineBuilder, |
joshualitt | 1c73548 | 2015-07-13 08:08:25 -0700 | [diff] [blame] | 369 | GrColor color, |
| 370 | const SkMatrix& viewMatrix, |
joshualitt | b6b513b | 2015-08-21 10:25:18 -0700 | [diff] [blame] | 371 | const SkRect& rect) { |
joshualitt | d2b23e0 | 2015-08-21 10:53:34 -0700 | [diff] [blame] | 372 | SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateNonAAFill(color, viewMatrix, rect, |
| 373 | nullptr, nullptr)); |
joshualitt | ad17cfc | 2015-05-05 10:45:57 -0700 | [diff] [blame] | 374 | this->drawBatch(pipelineBuilder, batch); |
| 375 | } |
| 376 | |
joshualitt | d2b23e0 | 2015-08-21 10:53:34 -0700 | [diff] [blame] | 377 | void GrDrawTarget::drawNonAARect(const GrPipelineBuilder& pipelineBuilder, |
joshualitt | b6b513b | 2015-08-21 10:25:18 -0700 | [diff] [blame] | 378 | GrColor color, |
| 379 | const SkMatrix& viewMatrix, |
| 380 | const SkRect& rect, |
| 381 | const SkMatrix& localMatrix) { |
joshualitt | d2b23e0 | 2015-08-21 10:53:34 -0700 | [diff] [blame] | 382 | SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateNonAAFill(color, viewMatrix, rect, |
| 383 | nullptr, &localMatrix)); |
joshualitt | b6b513b | 2015-08-21 10:25:18 -0700 | [diff] [blame] | 384 | this->drawBatch(pipelineBuilder, batch); |
| 385 | } |
| 386 | |
joshualitt | d2b23e0 | 2015-08-21 10:53:34 -0700 | [diff] [blame] | 387 | void GrDrawTarget::drawNonAARect(const GrPipelineBuilder& pipelineBuilder, |
joshualitt | b6b513b | 2015-08-21 10:25:18 -0700 | [diff] [blame] | 388 | GrColor color, |
| 389 | const SkMatrix& viewMatrix, |
| 390 | const SkRect& rect, |
| 391 | const SkRect& localRect) { |
joshualitt | d2b23e0 | 2015-08-21 10:53:34 -0700 | [diff] [blame] | 392 | SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateNonAAFill(color, viewMatrix, rect, |
| 393 | &localRect, nullptr)); |
joshualitt | b6b513b | 2015-08-21 10:25:18 -0700 | [diff] [blame] | 394 | this->drawBatch(pipelineBuilder, batch); |
| 395 | } |
| 396 | |
| 397 | |
joshualitt | 1c73548 | 2015-07-13 08:08:25 -0700 | [diff] [blame] | 398 | void GrDrawTarget::drawAARect(const GrPipelineBuilder& pipelineBuilder, |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 399 | GrColor color, |
| 400 | const SkMatrix& viewMatrix, |
| 401 | const SkRect& rect, |
| 402 | const SkRect& devRect) { |
joshualitt | d2b23e0 | 2015-08-21 10:53:34 -0700 | [diff] [blame] | 403 | SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateAAFill(color, viewMatrix, rect, |
bsalomon | abd30f5 | 2015-08-13 13:34:48 -0700 | [diff] [blame] | 404 | devRect)); |
joshualitt | 14205b1 | 2015-08-10 11:40:56 -0700 | [diff] [blame] | 405 | this->drawBatch(pipelineBuilder, batch); |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 406 | } |
| 407 | |
joshualitt | 9853cce | 2014-11-17 14:22:48 -0800 | [diff] [blame] | 408 | void GrDrawTarget::clear(const SkIRect* rect, |
| 409 | GrColor color, |
| 410 | bool canIgnoreRect, |
bsalomon | 63b2196 | 2014-11-05 07:05:34 -0800 | [diff] [blame] | 411 | GrRenderTarget* renderTarget) { |
egdaniel | 51c8d40 | 2015-08-06 10:54:13 -0700 | [diff] [blame] | 412 | SkIRect rtRect = SkIRect::MakeWH(renderTarget->width(), renderTarget->height()); |
| 413 | SkIRect clippedRect; |
| 414 | if (!rect || |
| 415 | (canIgnoreRect && this->caps()->fullClearIsFree()) || |
| 416 | rect->contains(rtRect)) { |
| 417 | rect = &rtRect; |
| 418 | } else { |
| 419 | clippedRect = *rect; |
| 420 | if (!clippedRect.intersect(rtRect)) { |
| 421 | return; |
| 422 | } |
| 423 | rect = &clippedRect; |
| 424 | } |
| 425 | |
bsalomon | b3b9aec | 2015-09-10 11:16:35 -0700 | [diff] [blame] | 426 | if (this->caps()->useDrawInsteadOfClear()) { |
bsalomon | 63b2196 | 2014-11-05 07:05:34 -0800 | [diff] [blame] | 427 | // This works around a driver bug with clear by drawing a rect instead. |
| 428 | // The driver will ignore a clear if it is the only thing rendered to a |
| 429 | // target before the target is read. |
egdaniel | 51c8d40 | 2015-08-06 10:54:13 -0700 | [diff] [blame] | 430 | if (rect == &rtRect) { |
bsalomon | 63b2196 | 2014-11-05 07:05:34 -0800 | [diff] [blame] | 431 | this->discard(renderTarget); |
| 432 | } |
bsalomon | 63b2196 | 2014-11-05 07:05:34 -0800 | [diff] [blame] | 433 | |
egdaniel | 8dd688b | 2015-01-22 10:16:09 -0800 | [diff] [blame] | 434 | GrPipelineBuilder pipelineBuilder; |
| 435 | pipelineBuilder.setRenderTarget(renderTarget); |
joshualitt | 9853cce | 2014-11-17 14:22:48 -0800 | [diff] [blame] | 436 | |
joshualitt | d2b23e0 | 2015-08-21 10:53:34 -0700 | [diff] [blame] | 437 | this->drawNonAARect(pipelineBuilder, color, SkMatrix::I(), *rect); |
bsalomon | 5346983 | 2015-08-18 09:20:09 -0700 | [diff] [blame] | 438 | } else { |
halcanary | 385fe4d | 2015-08-26 13:07:48 -0700 | [diff] [blame] | 439 | GrBatch* batch = new GrClearBatch(*rect, color, renderTarget); |
bsalomon | 512be53 | 2015-09-10 10:42:55 -0700 | [diff] [blame] | 440 | this->recordBatch(batch); |
bsalomon | 5346983 | 2015-08-18 09:20:09 -0700 | [diff] [blame] | 441 | batch->unref(); |
| 442 | } |
| 443 | } |
| 444 | |
| 445 | void GrDrawTarget::discard(GrRenderTarget* renderTarget) { |
| 446 | if (this->caps()->discardRenderTargetSupport()) { |
halcanary | 385fe4d | 2015-08-26 13:07:48 -0700 | [diff] [blame] | 447 | GrBatch* batch = new GrDiscardBatch(renderTarget); |
bsalomon | 512be53 | 2015-09-10 10:42:55 -0700 | [diff] [blame] | 448 | this->recordBatch(batch); |
bsalomon | 5346983 | 2015-08-18 09:20:09 -0700 | [diff] [blame] | 449 | batch->unref(); |
bsalomon | 63b2196 | 2014-11-05 07:05:34 -0800 | [diff] [blame] | 450 | } |
| 451 | } |
| 452 | |
bsalomon@google.com | 25fb21f | 2011-06-21 18:17:25 +0000 | [diff] [blame] | 453 | //////////////////////////////////////////////////////////////////////////////// |
bsalomon@google.com | 86afc2a | 2011-02-16 16:12:19 +0000 | [diff] [blame] | 454 | |
bsalomon | 6df8640 | 2015-06-01 10:41:49 -0700 | [diff] [blame] | 455 | void GrDrawTarget::copySurface(GrSurface* dst, |
bsalomon@google.com | 116ad84 | 2013-04-09 15:38:19 +0000 | [diff] [blame] | 456 | GrSurface* src, |
| 457 | const SkIRect& srcRect, |
| 458 | const SkIPoint& dstPoint) { |
bsalomon | 872062c | 2015-08-18 12:12:35 -0700 | [diff] [blame] | 459 | GrBatch* batch = GrCopySurfaceBatch::Create(dst, src, srcRect, dstPoint); |
| 460 | if (batch) { |
bsalomon | 512be53 | 2015-09-10 10:42:55 -0700 | [diff] [blame] | 461 | this->recordBatch(batch); |
bsalomon | 872062c | 2015-08-18 12:12:35 -0700 | [diff] [blame] | 462 | batch->unref(); |
bsalomon@google.com | e4617bf | 2013-04-03 14:56:40 +0000 | [diff] [blame] | 463 | } |
bsalomon@google.com | eb85117 | 2013-04-15 13:51:00 +0000 | [diff] [blame] | 464 | } |
| 465 | |
bsalomon | 512be53 | 2015-09-10 10:42:55 -0700 | [diff] [blame] | 466 | template <class Left, class Right> static bool intersect(const Left& a, const Right& b) { |
| 467 | SkASSERT(a.fLeft <= a.fRight && a.fTop <= a.fBottom && |
| 468 | b.fLeft <= b.fRight && b.fTop <= b.fBottom); |
| 469 | return a.fLeft < b.fRight && b.fLeft < a.fRight && a.fTop < b.fBottom && b.fTop < a.fBottom; |
| 470 | } |
| 471 | |
| 472 | void GrDrawTarget::recordBatch(GrBatch* batch) { |
robertphillips | a106c62 | 2015-10-16 09:07:06 -0700 | [diff] [blame] | 473 | // A closed drawTarget should never receive new/more batches |
robertphillips | 6a18665 | 2015-10-20 07:37:58 -0700 | [diff] [blame] | 474 | SkASSERT(!this->isClosed()); |
robertphillips | a106c62 | 2015-10-16 09:07:06 -0700 | [diff] [blame] | 475 | |
bsalomon | 512be53 | 2015-09-10 10:42:55 -0700 | [diff] [blame] | 476 | // Check if there is a Batch Draw we can batch with by linearly searching back until we either |
| 477 | // 1) check every draw |
| 478 | // 2) intersect with something |
| 479 | // 3) find a 'blocker' |
| 480 | // Experimentally we have found that most batching occurs within the first 10 comparisons. |
| 481 | static const int kMaxLookback = 10; |
| 482 | |
| 483 | GrBATCH_INFO("Re-Recording (%s, B%u)\n" |
joshualitt | e2bcec3 | 2015-09-30 06:22:22 -0700 | [diff] [blame] | 484 | "\tBounds LRTB (%f, %f, %f, %f)\n", |
bsalomon | 512be53 | 2015-09-10 10:42:55 -0700 | [diff] [blame] | 485 | batch->name(), |
| 486 | batch->uniqueID(), |
| 487 | batch->bounds().fLeft, batch->bounds().fRight, |
| 488 | batch->bounds().fTop, batch->bounds().fBottom); |
| 489 | GrBATCH_INFO(SkTabString(batch->dumpInfo(), 1).c_str()); |
| 490 | GrBATCH_INFO("\tOutcome:\n"); |
| 491 | int maxCandidates = SkTMin(kMaxLookback, fBatches.count()); |
| 492 | if (maxCandidates) { |
| 493 | int i = 0; |
| 494 | while (true) { |
| 495 | GrBatch* candidate = fBatches.fromBack(i); |
| 496 | // We cannot continue to search backwards if the render target changes |
| 497 | if (candidate->renderTargetUniqueID() != batch->renderTargetUniqueID()) { |
| 498 | GrBATCH_INFO("\t\tBreaking because of (%s, B%u) Rendertarget\n", |
| 499 | candidate->name(), candidate->uniqueID()); |
| 500 | break; |
| 501 | } |
| 502 | if (candidate->combineIfPossible(batch, *this->caps())) { |
| 503 | GrBATCH_INFO("\t\tCombining with (%s, B%u)\n", candidate->name(), |
| 504 | candidate->uniqueID()); |
| 505 | return; |
| 506 | } |
| 507 | // Stop going backwards if we would cause a painter's order violation. |
| 508 | if (intersect(candidate->bounds(), batch->bounds())) { |
| 509 | GrBATCH_INFO("\t\tIntersects with (%s, B%u)\n", candidate->name(), |
| 510 | candidate->uniqueID()); |
| 511 | break; |
| 512 | } |
| 513 | ++i; |
| 514 | if (i == maxCandidates) { |
| 515 | GrBATCH_INFO("\t\tReached max lookback or beginning of batch array %d\n", i); |
| 516 | break; |
| 517 | } |
| 518 | } |
| 519 | } else { |
| 520 | GrBATCH_INFO("\t\tFirstBatch\n"); |
| 521 | } |
| 522 | fBatches.push_back().reset(SkRef(batch)); |
joshualitt | f6d259b | 2015-10-02 11:27:14 -0700 | [diff] [blame] | 523 | if (fBatches.count() > kMaxLookback) { |
| 524 | SkASSERT(fBatches.count() - kMaxLookback - fFirstUnpreparedBatch == 1); |
| 525 | fBatches[fFirstUnpreparedBatch++]->prepare(&fFlushState); |
| 526 | } |
bsalomon | 512be53 | 2015-09-10 10:42:55 -0700 | [diff] [blame] | 527 | } |
| 528 | |
egdaniel | e36914c | 2015-02-13 09:00:33 -0800 | [diff] [blame] | 529 | /////////////////////////////////////////////////////////////////////////////// |
| 530 | |
bsalomon | ad792c1 | 2015-09-10 11:10:50 -0700 | [diff] [blame] | 531 | bool GrDrawTarget::installPipelineInDrawBatch(const GrPipelineBuilder* pipelineBuilder, |
| 532 | const GrScissorState* scissor, |
| 533 | GrDrawBatch* batch) { |
| 534 | GrPipeline::CreateArgs args; |
| 535 | args.fPipelineBuilder = pipelineBuilder; |
| 536 | args.fCaps = this->caps(); |
| 537 | args.fScissor = scissor; |
| 538 | args.fColorPOI = pipelineBuilder->colorProcInfo(batch); |
| 539 | args.fCoveragePOI = pipelineBuilder->coverageProcInfo(batch); |
| 540 | if (!this->setupDstReadIfNecessary(*pipelineBuilder, args.fColorPOI, |
| 541 | args.fCoveragePOI, &args.fDstTexture, |
| 542 | batch->bounds())) { |
| 543 | return false; |
egdaniel | e36914c | 2015-02-13 09:00:33 -0800 | [diff] [blame] | 544 | } |
bsalomon | ad792c1 | 2015-09-10 11:10:50 -0700 | [diff] [blame] | 545 | |
| 546 | if (!batch->installPipeline(args)) { |
| 547 | return false; |
| 548 | } |
| 549 | |
| 550 | return true; |
egdaniel | e36914c | 2015-02-13 09:00:33 -0800 | [diff] [blame] | 551 | } |
| 552 | |
bsalomon | b3b9aec | 2015-09-10 11:16:35 -0700 | [diff] [blame] | 553 | void GrDrawTarget::clearStencilClip(const SkIRect& rect, bool insideClip, GrRenderTarget* rt) { |
halcanary | 385fe4d | 2015-08-26 13:07:48 -0700 | [diff] [blame] | 554 | GrBatch* batch = new GrClearStencilClipBatch(rect, insideClip, rt); |
bsalomon | 512be53 | 2015-09-10 10:42:55 -0700 | [diff] [blame] | 555 | this->recordBatch(batch); |
bsalomon | 5ea0363 | 2015-08-18 10:33:30 -0700 | [diff] [blame] | 556 | batch->unref(); |
| 557 | } |