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 | 16b9913 | 2015-08-13 14:55:50 -0700 | [diff] [blame^] | 23 | #include "batches/GrDrawBatch.h" |
joshualitt | ecd1a69 | 2015-08-10 10:08:26 -0700 | [diff] [blame] | 24 | #include "batches/GrRectBatchFactory.h" |
joshualitt | 7441782 | 2015-08-07 11:42:16 -0700 | [diff] [blame] | 25 | |
sugoi@google.com | 5f74cf8 | 2012-12-17 21:16:45 +0000 | [diff] [blame] | 26 | #include "SkStrokeRec.h" |
sugoi@google.com | 12b4e27 | 2012-12-06 20:13:11 +0000 | [diff] [blame] | 27 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 28 | //////////////////////////////////////////////////////////////////////////////// |
| 29 | |
bsalomon | 4061b12 | 2015-05-29 10:26:19 -0700 | [diff] [blame] | 30 | GrDrawTarget::GrDrawTarget(GrGpu* gpu, GrResourceProvider* resourceProvider) |
| 31 | : fGpu(SkRef(gpu)) |
| 32 | , fCaps(SkRef(gpu->caps())) |
| 33 | , fResourceProvider(resourceProvider) |
bsalomon | a73239a | 2015-04-28 13:35:17 -0700 | [diff] [blame] | 34 | , fGpuTraceMarkerCount(0) |
bsalomon | a73239a | 2015-04-28 13:35:17 -0700 | [diff] [blame] | 35 | , fFlushing(false) { |
bsalomon | 4061b12 | 2015-05-29 10:26:19 -0700 | [diff] [blame] | 36 | } |
| 37 | |
| 38 | GrDrawTarget::~GrDrawTarget() { |
| 39 | fGpu->unref(); |
| 40 | fCaps->unref(); |
bsalomon@google.com | 25fb21f | 2011-06-21 18:17:25 +0000 | [diff] [blame] | 41 | } |
| 42 | |
| 43 | //////////////////////////////////////////////////////////////////////////////// |
| 44 | |
bsalomon | 50785a3 | 2015-02-06 07:02:37 -0800 | [diff] [blame] | 45 | bool GrDrawTarget::setupDstReadIfNecessary(const GrPipelineBuilder& pipelineBuilder, |
egdaniel | e36914c | 2015-02-13 09:00:33 -0800 | [diff] [blame] | 46 | const GrProcOptInfo& colorPOI, |
| 47 | const GrProcOptInfo& coveragePOI, |
bsalomon | 6a44c6a | 2015-05-26 09:49:05 -0700 | [diff] [blame] | 48 | GrXferProcessor::DstTexture* dstTexture, |
joshualitt | 9853cce | 2014-11-17 14:22:48 -0800 | [diff] [blame] | 49 | const SkRect* drawBounds) { |
bsalomon | 6a44c6a | 2015-05-26 09:49:05 -0700 | [diff] [blame] | 50 | if (!pipelineBuilder.willXPNeedDstTexture(*this->caps(), colorPOI, coveragePOI)) { |
bsalomon@google.com | 26e18b5 | 2013-03-29 19:22:36 +0000 | [diff] [blame] | 51 | return true; |
| 52 | } |
cdalton | 9954bc3 | 2015-04-29 14:17:00 -0700 | [diff] [blame] | 53 | |
bsalomon | 50785a3 | 2015-02-06 07:02:37 -0800 | [diff] [blame] | 54 | GrRenderTarget* rt = pipelineBuilder.getRenderTarget(); |
cdalton | 9954bc3 | 2015-04-29 14:17:00 -0700 | [diff] [blame] | 55 | |
| 56 | if (this->caps()->textureBarrierSupport()) { |
| 57 | if (GrTexture* rtTex = rt->asTexture()) { |
bsalomon | dc47ff7 | 2015-05-26 12:16:59 -0700 | [diff] [blame] | 58 | // 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] | 59 | // will be responsible to detect this situation and request a texture barrier. |
bsalomon | 6a44c6a | 2015-05-26 09:49:05 -0700 | [diff] [blame] | 60 | dstTexture->setTexture(rtTex); |
| 61 | dstTexture->setOffset(0, 0); |
cdalton | 9954bc3 | 2015-04-29 14:17:00 -0700 | [diff] [blame] | 62 | return true; |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | SkIRect copyRect; |
joshualitt | 44701df | 2015-02-23 14:44:57 -0800 | [diff] [blame] | 67 | pipelineBuilder.clip().getConservativeBounds(rt, ©Rect); |
commit-bot@chromium.org | c4dc0ad | 2013-10-09 14:11:33 +0000 | [diff] [blame] | 68 | |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 69 | if (drawBounds) { |
commit-bot@chromium.org | c4dc0ad | 2013-10-09 14:11:33 +0000 | [diff] [blame] | 70 | SkIRect drawIBounds; |
| 71 | drawBounds->roundOut(&drawIBounds); |
commit-bot@chromium.org | bb5c465 | 2013-04-01 12:49:31 +0000 | [diff] [blame] | 72 | if (!copyRect.intersect(drawIBounds)) { |
commit-bot@chromium.org | 515dcd3 | 2013-08-28 14:17:03 +0000 | [diff] [blame] | 73 | #ifdef SK_DEBUG |
bsalomon | 682c269 | 2015-05-22 14:01:46 -0700 | [diff] [blame] | 74 | GrCapsDebugf(fCaps, "Missed an early reject. " |
| 75 | "Bailing on draw from setupDstReadIfNecessary.\n"); |
commit-bot@chromium.org | bb5c465 | 2013-04-01 12:49:31 +0000 | [diff] [blame] | 76 | #endif |
| 77 | return false; |
| 78 | } |
| 79 | } else { |
commit-bot@chromium.org | 515dcd3 | 2013-08-28 14:17:03 +0000 | [diff] [blame] | 80 | #ifdef SK_DEBUG |
tfarina | 38406c8 | 2014-10-31 07:11:12 -0700 | [diff] [blame] | 81 | //SkDebugf("No dev bounds when dst copy is made.\n"); |
commit-bot@chromium.org | bb5c465 | 2013-04-01 12:49:31 +0000 | [diff] [blame] | 82 | #endif |
| 83 | } |
skia.committer@gmail.com | 05a2ee0 | 2013-04-02 07:01:34 +0000 | [diff] [blame] | 84 | |
commit-bot@chromium.org | 63150af | 2013-04-11 22:00:22 +0000 | [diff] [blame] | 85 | // MSAA consideration: When there is support for reading MSAA samples in the shader we could |
| 86 | // have per-sample dst values by making the copy multisampled. |
bsalomon | f2703d8 | 2014-10-28 14:33:06 -0700 | [diff] [blame] | 87 | GrSurfaceDesc desc; |
bsalomon | a73239a | 2015-04-28 13:35:17 -0700 | [diff] [blame] | 88 | if (!this->getGpu()->initCopySurfaceDstDesc(rt, &desc)) { |
| 89 | desc.fOrigin = kDefault_GrSurfaceOrigin; |
| 90 | desc.fFlags = kRenderTarget_GrSurfaceFlag; |
| 91 | desc.fConfig = rt->config(); |
| 92 | } |
| 93 | |
| 94 | |
commit-bot@chromium.org | bb5c465 | 2013-04-01 12:49:31 +0000 | [diff] [blame] | 95 | desc.fWidth = copyRect.width(); |
| 96 | desc.fHeight = copyRect.height(); |
bsalomon@google.com | 26e18b5 | 2013-03-29 19:22:36 +0000 | [diff] [blame] | 97 | |
bsalomon | eae6200 | 2015-07-31 13:59:30 -0700 | [diff] [blame] | 98 | static const uint32_t kFlags = 0; |
| 99 | SkAutoTUnref<GrTexture> copy(fResourceProvider->createApproxTexture(desc, kFlags)); |
bsalomon@google.com | 26e18b5 | 2013-03-29 19:22:36 +0000 | [diff] [blame] | 100 | |
bsalomon | e305973 | 2014-10-14 11:47:22 -0700 | [diff] [blame] | 101 | if (!copy) { |
tfarina | 38406c8 | 2014-10-31 07:11:12 -0700 | [diff] [blame] | 102 | SkDebugf("Failed to create temporary copy of destination texture.\n"); |
bsalomon@google.com | 26e18b5 | 2013-03-29 19:22:36 +0000 | [diff] [blame] | 103 | return false; |
| 104 | } |
bsalomon@google.com | e4617bf | 2013-04-03 14:56:40 +0000 | [diff] [blame] | 105 | SkIPoint dstPoint = {0, 0}; |
bsalomon | 6df8640 | 2015-06-01 10:41:49 -0700 | [diff] [blame] | 106 | this->copySurface(copy, rt, copyRect, dstPoint); |
| 107 | dstTexture->setTexture(copy); |
| 108 | dstTexture->setOffset(copyRect.fLeft, copyRect.fTop); |
| 109 | return true; |
bsalomon@google.com | 26e18b5 | 2013-03-29 19:22:36 +0000 | [diff] [blame] | 110 | } |
| 111 | |
bsalomon | a73239a | 2015-04-28 13:35:17 -0700 | [diff] [blame] | 112 | void GrDrawTarget::flush() { |
| 113 | if (fFlushing) { |
| 114 | return; |
| 115 | } |
| 116 | fFlushing = true; |
| 117 | |
| 118 | this->getGpu()->saveActiveTraceMarkers(); |
| 119 | |
| 120 | this->onFlush(); |
| 121 | |
| 122 | this->getGpu()->restoreActiveTraceMarkers(); |
| 123 | |
| 124 | fFlushing = false; |
| 125 | this->reset(); |
| 126 | } |
| 127 | |
bsalomon | abd30f5 | 2015-08-13 13:34:48 -0700 | [diff] [blame] | 128 | void GrDrawTarget::drawBatch(const GrPipelineBuilder& pipelineBuilder, GrDrawBatch* batch) { |
joshualitt | 4d8da81 | 2015-01-28 12:53:54 -0800 | [diff] [blame] | 129 | // TODO some kind of checkdraw, but not at this level |
| 130 | |
| 131 | // Setup clip |
| 132 | GrScissorState scissorState; |
joshualitt | 4421a4c | 2015-07-13 09:36:41 -0700 | [diff] [blame] | 133 | GrPipelineBuilder::AutoRestoreFragmentProcessorState arfps; |
joshualitt | 4d8da81 | 2015-01-28 12:53:54 -0800 | [diff] [blame] | 134 | GrPipelineBuilder::AutoRestoreStencil ars; |
joshualitt | 4421a4c | 2015-07-13 09:36:41 -0700 | [diff] [blame] | 135 | if (!this->setupClip(pipelineBuilder, &arfps, &ars, &scissorState, &batch->bounds())) { |
joshualitt | 4d8da81 | 2015-01-28 12:53:54 -0800 | [diff] [blame] | 136 | return; |
| 137 | } |
| 138 | |
joshualitt | 99c7c07 | 2015-05-01 13:43:30 -0700 | [diff] [blame] | 139 | // Batch bounds are tight, so for dev copies |
| 140 | // TODO move this into setupDstReadIfNecessary when paths are in batch |
| 141 | SkRect bounds = batch->bounds(); |
| 142 | bounds.outset(0.5f, 0.5f); |
| 143 | |
bsalomon | a387a11 | 2015-08-11 14:47:42 -0700 | [diff] [blame] | 144 | GrDrawTarget::PipelineInfo pipelineInfo(&pipelineBuilder, &scissorState, batch, &bounds, |
joshualitt | 99c7c07 | 2015-05-01 13:43:30 -0700 | [diff] [blame] | 145 | this); |
bsalomon | a387a11 | 2015-08-11 14:47:42 -0700 | [diff] [blame] | 146 | if (!pipelineInfo.valid()) { |
egdaniel | e36914c | 2015-02-13 09:00:33 -0800 | [diff] [blame] | 147 | return; |
| 148 | } |
bsalomon | a387a11 | 2015-08-11 14:47:42 -0700 | [diff] [blame] | 149 | if (!batch->installPipeline(pipelineInfo.pipelineCreateArgs())) { |
| 150 | return; |
| 151 | } |
| 152 | this->onDrawBatch(batch); |
joshualitt | 4d8da81 | 2015-01-28 12:53:54 -0800 | [diff] [blame] | 153 | } |
| 154 | |
joshualitt | 2c93efe | 2014-11-06 12:57:13 -0800 | [diff] [blame] | 155 | static const GrStencilSettings& winding_path_stencil_settings() { |
| 156 | GR_STATIC_CONST_SAME_STENCIL_STRUCT(gSettings, |
| 157 | kIncClamp_StencilOp, |
| 158 | kIncClamp_StencilOp, |
| 159 | kAlwaysIfInClip_StencilFunc, |
| 160 | 0xFFFF, 0xFFFF, 0xFFFF); |
| 161 | return *GR_CONST_STENCIL_SETTINGS_PTR_FROM_STRUCT_PTR(&gSettings); |
| 162 | } |
| 163 | |
| 164 | static const GrStencilSettings& even_odd_path_stencil_settings() { |
| 165 | GR_STATIC_CONST_SAME_STENCIL_STRUCT(gSettings, |
| 166 | kInvert_StencilOp, |
| 167 | kInvert_StencilOp, |
| 168 | kAlwaysIfInClip_StencilFunc, |
| 169 | 0xFFFF, 0xFFFF, 0xFFFF); |
| 170 | return *GR_CONST_STENCIL_SETTINGS_PTR_FROM_STRUCT_PTR(&gSettings); |
| 171 | } |
| 172 | |
| 173 | void GrDrawTarget::getPathStencilSettingsForFilltype(GrPathRendering::FillType fill, |
egdaniel | 8dc7c3a | 2015-04-16 11:22:42 -0700 | [diff] [blame] | 174 | const GrStencilAttachment* sb, |
joshualitt | 2c93efe | 2014-11-06 12:57:13 -0800 | [diff] [blame] | 175 | GrStencilSettings* outStencilSettings) { |
| 176 | |
| 177 | switch (fill) { |
| 178 | default: |
| 179 | SkFAIL("Unexpected path fill."); |
| 180 | case GrPathRendering::kWinding_FillType: |
| 181 | *outStencilSettings = winding_path_stencil_settings(); |
| 182 | break; |
| 183 | case GrPathRendering::kEvenOdd_FillType: |
| 184 | *outStencilSettings = even_odd_path_stencil_settings(); |
| 185 | break; |
| 186 | } |
joshualitt | 9853cce | 2014-11-17 14:22:48 -0800 | [diff] [blame] | 187 | this->clipMaskManager()->adjustPathStencilParams(sb, outStencilSettings); |
joshualitt | 2c93efe | 2014-11-06 12:57:13 -0800 | [diff] [blame] | 188 | } |
| 189 | |
joshualitt | 1c73548 | 2015-07-13 08:08:25 -0700 | [diff] [blame] | 190 | void GrDrawTarget::stencilPath(const GrPipelineBuilder& pipelineBuilder, |
joshualitt | 56995b5 | 2014-12-11 15:44:02 -0800 | [diff] [blame] | 191 | const GrPathProcessor* pathProc, |
joshualitt | 9853cce | 2014-11-17 14:22:48 -0800 | [diff] [blame] | 192 | const GrPath* path, |
| 193 | GrPathRendering::FillType fill) { |
bsalomon@google.com | 64aef2b | 2012-06-11 15:36:13 +0000 | [diff] [blame] | 194 | // TODO: extract portions of checkDraw that are relevant to path stenciling. |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 195 | SkASSERT(path); |
jvanverth | e9c0fc6 | 2015-04-29 11:18:05 -0700 | [diff] [blame] | 196 | SkASSERT(this->caps()->shaderCaps()->pathRenderingSupport()); |
joshualitt | 2c93efe | 2014-11-06 12:57:13 -0800 | [diff] [blame] | 197 | |
| 198 | // Setup clip |
bsalomon | 3e79124 | 2014-12-17 13:43:13 -0800 | [diff] [blame] | 199 | GrScissorState scissorState; |
joshualitt | 4421a4c | 2015-07-13 09:36:41 -0700 | [diff] [blame] | 200 | GrPipelineBuilder::AutoRestoreFragmentProcessorState arfps; |
egdaniel | 8dd688b | 2015-01-22 10:16:09 -0800 | [diff] [blame] | 201 | GrPipelineBuilder::AutoRestoreStencil ars; |
joshualitt | 4421a4c | 2015-07-13 09:36:41 -0700 | [diff] [blame] | 202 | if (!this->setupClip(pipelineBuilder, &arfps, &ars, &scissorState, NULL)) { |
joshualitt | 2c93efe | 2014-11-06 12:57:13 -0800 | [diff] [blame] | 203 | return; |
| 204 | } |
| 205 | |
| 206 | // set stencil settings for path |
| 207 | GrStencilSettings stencilSettings; |
joshualitt | 1c73548 | 2015-07-13 08:08:25 -0700 | [diff] [blame] | 208 | GrRenderTarget* rt = pipelineBuilder.getRenderTarget(); |
egdaniel | 8dc7c3a | 2015-04-16 11:22:42 -0700 | [diff] [blame] | 209 | GrStencilAttachment* sb = rt->renderTargetPriv().attachStencilAttachment(); |
bsalomon | 6bc1b5f | 2015-02-23 09:06:38 -0800 | [diff] [blame] | 210 | this->getPathStencilSettingsForFilltype(fill, sb, &stencilSettings); |
joshualitt | 2c93efe | 2014-11-06 12:57:13 -0800 | [diff] [blame] | 211 | |
joshualitt | 1c73548 | 2015-07-13 08:08:25 -0700 | [diff] [blame] | 212 | this->onStencilPath(pipelineBuilder, pathProc, path, scissorState, stencilSettings); |
bsalomon@google.com | 64aef2b | 2012-06-11 15:36:13 +0000 | [diff] [blame] | 213 | } |
| 214 | |
joshualitt | 1c73548 | 2015-07-13 08:08:25 -0700 | [diff] [blame] | 215 | void GrDrawTarget::drawPath(const GrPipelineBuilder& pipelineBuilder, |
joshualitt | 56995b5 | 2014-12-11 15:44:02 -0800 | [diff] [blame] | 216 | const GrPathProcessor* pathProc, |
joshualitt | 9853cce | 2014-11-17 14:22:48 -0800 | [diff] [blame] | 217 | const GrPath* path, |
| 218 | GrPathRendering::FillType fill) { |
commit-bot@chromium.org | c4dc0ad | 2013-10-09 14:11:33 +0000 | [diff] [blame] | 219 | // TODO: extract portions of checkDraw that are relevant to path rendering. |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 220 | SkASSERT(path); |
jvanverth | e9c0fc6 | 2015-04-29 11:18:05 -0700 | [diff] [blame] | 221 | SkASSERT(this->caps()->shaderCaps()->pathRenderingSupport()); |
commit-bot@chromium.org | c4dc0ad | 2013-10-09 14:11:33 +0000 | [diff] [blame] | 222 | |
joshualitt | 92e496f | 2014-10-31 13:56:50 -0700 | [diff] [blame] | 223 | SkRect devBounds = path->getBounds(); |
joshualitt | 8059eb9 | 2014-12-29 15:10:07 -0800 | [diff] [blame] | 224 | pathProc->viewMatrix().mapRect(&devBounds); |
commit-bot@chromium.org | c4dc0ad | 2013-10-09 14:11:33 +0000 | [diff] [blame] | 225 | |
joshualitt | 2c93efe | 2014-11-06 12:57:13 -0800 | [diff] [blame] | 226 | // Setup clip |
bsalomon | 3e79124 | 2014-12-17 13:43:13 -0800 | [diff] [blame] | 227 | GrScissorState scissorState; |
joshualitt | 4421a4c | 2015-07-13 09:36:41 -0700 | [diff] [blame] | 228 | GrPipelineBuilder::AutoRestoreFragmentProcessorState arfps; |
egdaniel | 8dd688b | 2015-01-22 10:16:09 -0800 | [diff] [blame] | 229 | GrPipelineBuilder::AutoRestoreStencil ars; |
joshualitt | 4421a4c | 2015-07-13 09:36:41 -0700 | [diff] [blame] | 230 | if (!this->setupClip(pipelineBuilder, &arfps, &ars, &scissorState, &devBounds)) { |
joshualitt | 2c93efe | 2014-11-06 12:57:13 -0800 | [diff] [blame] | 231 | return; |
| 232 | } |
| 233 | |
| 234 | // set stencil settings for path |
| 235 | GrStencilSettings stencilSettings; |
joshualitt | 1c73548 | 2015-07-13 08:08:25 -0700 | [diff] [blame] | 236 | GrRenderTarget* rt = pipelineBuilder.getRenderTarget(); |
egdaniel | 8dc7c3a | 2015-04-16 11:22:42 -0700 | [diff] [blame] | 237 | GrStencilAttachment* sb = rt->renderTargetPriv().attachStencilAttachment(); |
bsalomon | 6bc1b5f | 2015-02-23 09:06:38 -0800 | [diff] [blame] | 238 | this->getPathStencilSettingsForFilltype(fill, sb, &stencilSettings); |
joshualitt | 2c93efe | 2014-11-06 12:57:13 -0800 | [diff] [blame] | 239 | |
bsalomon | a387a11 | 2015-08-11 14:47:42 -0700 | [diff] [blame] | 240 | GrDrawTarget::PipelineInfo pipelineInfo(&pipelineBuilder, &scissorState, pathProc, &devBounds, |
egdaniel | e36914c | 2015-02-13 09:00:33 -0800 | [diff] [blame] | 241 | this); |
bsalomon | a387a11 | 2015-08-11 14:47:42 -0700 | [diff] [blame] | 242 | if (!pipelineInfo.valid()) { |
egdaniel | e36914c | 2015-02-13 09:00:33 -0800 | [diff] [blame] | 243 | return; |
| 244 | } |
| 245 | |
| 246 | this->onDrawPath(pathProc, path, stencilSettings, pipelineInfo); |
commit-bot@chromium.org | c4dc0ad | 2013-10-09 14:11:33 +0000 | [diff] [blame] | 247 | } |
| 248 | |
joshualitt | 1c73548 | 2015-07-13 08:08:25 -0700 | [diff] [blame] | 249 | void GrDrawTarget::drawPaths(const GrPipelineBuilder& pipelineBuilder, |
joshualitt | 56995b5 | 2014-12-11 15:44:02 -0800 | [diff] [blame] | 250 | const GrPathProcessor* pathProc, |
joshualitt | 9853cce | 2014-11-17 14:22:48 -0800 | [diff] [blame] | 251 | const GrPathRange* pathRange, |
cdalton | 55b24af | 2014-11-25 11:00:56 -0800 | [diff] [blame] | 252 | const void* indices, |
| 253 | PathIndexType indexType, |
| 254 | const float transformValues[], |
| 255 | PathTransformType transformType, |
joshualitt | 9853cce | 2014-11-17 14:22:48 -0800 | [diff] [blame] | 256 | int count, |
joshualitt | 92e496f | 2014-10-31 13:56:50 -0700 | [diff] [blame] | 257 | GrPathRendering::FillType fill) { |
jvanverth | e9c0fc6 | 2015-04-29 11:18:05 -0700 | [diff] [blame] | 258 | SkASSERT(this->caps()->shaderCaps()->pathRenderingSupport()); |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 259 | SkASSERT(pathRange); |
| 260 | SkASSERT(indices); |
bsalomon | ebc1c10 | 2015-08-06 17:33:16 -0700 | [diff] [blame] | 261 | SkASSERT(0 == reinterpret_cast<intptr_t>(indices) % |
| 262 | GrPathRange::PathIndexSizeInBytes(indexType)); |
cdalton | 55b24af | 2014-11-25 11:00:56 -0800 | [diff] [blame] | 263 | SkASSERT(transformValues); |
commit-bot@chromium.org | 9b62aa1 | 2014-03-25 11:59:40 +0000 | [diff] [blame] | 264 | |
joshualitt | 2c93efe | 2014-11-06 12:57:13 -0800 | [diff] [blame] | 265 | // Setup clip |
bsalomon | 3e79124 | 2014-12-17 13:43:13 -0800 | [diff] [blame] | 266 | GrScissorState scissorState; |
joshualitt | 4421a4c | 2015-07-13 09:36:41 -0700 | [diff] [blame] | 267 | GrPipelineBuilder::AutoRestoreFragmentProcessorState arfps; |
egdaniel | 8dd688b | 2015-01-22 10:16:09 -0800 | [diff] [blame] | 268 | GrPipelineBuilder::AutoRestoreStencil ars; |
joshualitt | 4421a4c | 2015-07-13 09:36:41 -0700 | [diff] [blame] | 269 | if (!this->setupClip(pipelineBuilder, &arfps, &ars, &scissorState, NULL)) { |
joshualitt | 2c93efe | 2014-11-06 12:57:13 -0800 | [diff] [blame] | 270 | return; |
| 271 | } |
| 272 | |
| 273 | // set stencil settings for path |
| 274 | GrStencilSettings stencilSettings; |
joshualitt | 1c73548 | 2015-07-13 08:08:25 -0700 | [diff] [blame] | 275 | GrRenderTarget* rt = pipelineBuilder.getRenderTarget(); |
egdaniel | 8dc7c3a | 2015-04-16 11:22:42 -0700 | [diff] [blame] | 276 | GrStencilAttachment* sb = rt->renderTargetPriv().attachStencilAttachment(); |
bsalomon | 6bc1b5f | 2015-02-23 09:06:38 -0800 | [diff] [blame] | 277 | this->getPathStencilSettingsForFilltype(fill, sb, &stencilSettings); |
joshualitt | 2c93efe | 2014-11-06 12:57:13 -0800 | [diff] [blame] | 278 | |
bsalomon | 50785a3 | 2015-02-06 07:02:37 -0800 | [diff] [blame] | 279 | // Don't compute a bounding box for dst copy texture, we'll opt |
cdalton | b85a0aa | 2014-07-21 15:32:44 -0700 | [diff] [blame] | 280 | // instead for it to just copy the entire dst. Realistically this is a moot |
| 281 | // point, because any context that supports NV_path_rendering will also |
| 282 | // support NV_blend_equation_advanced. |
bsalomon | a387a11 | 2015-08-11 14:47:42 -0700 | [diff] [blame] | 283 | GrDrawTarget::PipelineInfo pipelineInfo(&pipelineBuilder, &scissorState, pathProc, NULL, this); |
| 284 | if (!pipelineInfo.valid()) { |
egdaniel | e36914c | 2015-02-13 09:00:33 -0800 | [diff] [blame] | 285 | return; |
| 286 | } |
| 287 | |
| 288 | this->onDrawPaths(pathProc, pathRange, indices, indexType, transformValues, |
| 289 | transformType, count, stencilSettings, pipelineInfo); |
commit-bot@chromium.org | 9b62aa1 | 2014-03-25 11:59:40 +0000 | [diff] [blame] | 290 | } |
| 291 | |
joshualitt | 1c73548 | 2015-07-13 08:08:25 -0700 | [diff] [blame] | 292 | void GrDrawTarget::drawBWRect(const GrPipelineBuilder& pipelineBuilder, |
| 293 | GrColor color, |
| 294 | const SkMatrix& viewMatrix, |
| 295 | const SkRect& rect, |
| 296 | const SkRect* localRect, |
| 297 | const SkMatrix* localMatrix) { |
bsalomon | abd30f5 | 2015-08-13 13:34:48 -0700 | [diff] [blame] | 298 | SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateFillBW(color, viewMatrix, rect, |
| 299 | localRect, localMatrix)); |
joshualitt | ad17cfc | 2015-05-05 10:45:57 -0700 | [diff] [blame] | 300 | this->drawBatch(pipelineBuilder, batch); |
| 301 | } |
| 302 | |
joshualitt | 1c73548 | 2015-07-13 08:08:25 -0700 | [diff] [blame] | 303 | void GrDrawTarget::drawAARect(const GrPipelineBuilder& pipelineBuilder, |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 304 | GrColor color, |
| 305 | const SkMatrix& viewMatrix, |
| 306 | const SkRect& rect, |
| 307 | const SkRect& devRect) { |
bsalomon | abd30f5 | 2015-08-13 13:34:48 -0700 | [diff] [blame] | 308 | SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateFillAA(color, viewMatrix, rect, |
| 309 | devRect)); |
joshualitt | 14205b1 | 2015-08-10 11:40:56 -0700 | [diff] [blame] | 310 | this->drawBatch(pipelineBuilder, batch); |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 311 | } |
| 312 | |
joshualitt | 9853cce | 2014-11-17 14:22:48 -0800 | [diff] [blame] | 313 | void GrDrawTarget::clear(const SkIRect* rect, |
| 314 | GrColor color, |
| 315 | bool canIgnoreRect, |
bsalomon | 63b2196 | 2014-11-05 07:05:34 -0800 | [diff] [blame] | 316 | GrRenderTarget* renderTarget) { |
egdaniel | 51c8d40 | 2015-08-06 10:54:13 -0700 | [diff] [blame] | 317 | SkIRect rtRect = SkIRect::MakeWH(renderTarget->width(), renderTarget->height()); |
| 318 | SkIRect clippedRect; |
| 319 | if (!rect || |
| 320 | (canIgnoreRect && this->caps()->fullClearIsFree()) || |
| 321 | rect->contains(rtRect)) { |
| 322 | rect = &rtRect; |
| 323 | } else { |
| 324 | clippedRect = *rect; |
| 325 | if (!clippedRect.intersect(rtRect)) { |
| 326 | return; |
| 327 | } |
| 328 | rect = &clippedRect; |
| 329 | } |
| 330 | |
bsalomon | 63b2196 | 2014-11-05 07:05:34 -0800 | [diff] [blame] | 331 | if (fCaps->useDrawInsteadOfClear()) { |
| 332 | // This works around a driver bug with clear by drawing a rect instead. |
| 333 | // The driver will ignore a clear if it is the only thing rendered to a |
| 334 | // target before the target is read. |
egdaniel | 51c8d40 | 2015-08-06 10:54:13 -0700 | [diff] [blame] | 335 | if (rect == &rtRect) { |
bsalomon | 63b2196 | 2014-11-05 07:05:34 -0800 | [diff] [blame] | 336 | this->discard(renderTarget); |
| 337 | } |
bsalomon | 63b2196 | 2014-11-05 07:05:34 -0800 | [diff] [blame] | 338 | |
egdaniel | 8dd688b | 2015-01-22 10:16:09 -0800 | [diff] [blame] | 339 | GrPipelineBuilder pipelineBuilder; |
| 340 | pipelineBuilder.setRenderTarget(renderTarget); |
joshualitt | 9853cce | 2014-11-17 14:22:48 -0800 | [diff] [blame] | 341 | |
joshualitt | 1c73548 | 2015-07-13 08:08:25 -0700 | [diff] [blame] | 342 | this->drawSimpleRect(pipelineBuilder, color, SkMatrix::I(), *rect); |
bsalomon | 63b2196 | 2014-11-05 07:05:34 -0800 | [diff] [blame] | 343 | } else { |
egdaniel | 51c8d40 | 2015-08-06 10:54:13 -0700 | [diff] [blame] | 344 | this->onClear(*rect, color, renderTarget); |
bsalomon | 63b2196 | 2014-11-05 07:05:34 -0800 | [diff] [blame] | 345 | } |
| 346 | } |
| 347 | |
egdaniel | 3eee383 | 2014-06-18 13:09:11 -0700 | [diff] [blame] | 348 | typedef GrTraceMarkerSet::Iter TMIter; |
| 349 | void GrDrawTarget::saveActiveTraceMarkers() { |
| 350 | if (this->caps()->gpuTracingSupport()) { |
| 351 | SkASSERT(0 == fStoredTraceMarkers.count()); |
| 352 | fStoredTraceMarkers.addSet(fActiveTraceMarkers); |
| 353 | for (TMIter iter = fStoredTraceMarkers.begin(); iter != fStoredTraceMarkers.end(); ++iter) { |
| 354 | this->removeGpuTraceMarker(&(*iter)); |
| 355 | } |
| 356 | } |
| 357 | } |
| 358 | |
| 359 | void GrDrawTarget::restoreActiveTraceMarkers() { |
| 360 | if (this->caps()->gpuTracingSupport()) { |
| 361 | SkASSERT(0 == fActiveTraceMarkers.count()); |
| 362 | for (TMIter iter = fStoredTraceMarkers.begin(); iter != fStoredTraceMarkers.end(); ++iter) { |
| 363 | this->addGpuTraceMarker(&(*iter)); |
| 364 | } |
| 365 | for (TMIter iter = fActiveTraceMarkers.begin(); iter != fActiveTraceMarkers.end(); ++iter) { |
| 366 | this->fStoredTraceMarkers.remove(*iter); |
| 367 | } |
| 368 | } |
| 369 | } |
| 370 | |
| 371 | void GrDrawTarget::addGpuTraceMarker(const GrGpuTraceMarker* marker) { |
commit-bot@chromium.org | a3baf3b | 2014-02-21 18:45:30 +0000 | [diff] [blame] | 372 | if (this->caps()->gpuTracingSupport()) { |
commit-bot@chromium.org | 2a05de0 | 2014-03-25 15:17:32 +0000 | [diff] [blame] | 373 | SkASSERT(fGpuTraceMarkerCount >= 0); |
| 374 | this->fActiveTraceMarkers.add(*marker); |
commit-bot@chromium.org | 2a05de0 | 2014-03-25 15:17:32 +0000 | [diff] [blame] | 375 | ++fGpuTraceMarkerCount; |
commit-bot@chromium.org | a3baf3b | 2014-02-21 18:45:30 +0000 | [diff] [blame] | 376 | } |
| 377 | } |
| 378 | |
egdaniel | 3eee383 | 2014-06-18 13:09:11 -0700 | [diff] [blame] | 379 | void GrDrawTarget::removeGpuTraceMarker(const GrGpuTraceMarker* marker) { |
commit-bot@chromium.org | a3baf3b | 2014-02-21 18:45:30 +0000 | [diff] [blame] | 380 | if (this->caps()->gpuTracingSupport()) { |
commit-bot@chromium.org | 2a05de0 | 2014-03-25 15:17:32 +0000 | [diff] [blame] | 381 | SkASSERT(fGpuTraceMarkerCount >= 1); |
| 382 | this->fActiveTraceMarkers.remove(*marker); |
commit-bot@chromium.org | 2a05de0 | 2014-03-25 15:17:32 +0000 | [diff] [blame] | 383 | --fGpuTraceMarkerCount; |
commit-bot@chromium.org | a3baf3b | 2014-02-21 18:45:30 +0000 | [diff] [blame] | 384 | } |
| 385 | } |
| 386 | |
bsalomon@google.com | 25fb21f | 2011-06-21 18:17:25 +0000 | [diff] [blame] | 387 | //////////////////////////////////////////////////////////////////////////////// |
bsalomon@google.com | 86afc2a | 2011-02-16 16:12:19 +0000 | [diff] [blame] | 388 | |
bsalomon@google.com | 116ad84 | 2013-04-09 15:38:19 +0000 | [diff] [blame] | 389 | namespace { |
| 390 | // returns true if the read/written rect intersects the src/dst and false if not. |
| 391 | bool clip_srcrect_and_dstpoint(const GrSurface* dst, |
| 392 | const GrSurface* src, |
bsalomon@google.com | e4617bf | 2013-04-03 14:56:40 +0000 | [diff] [blame] | 393 | const SkIRect& srcRect, |
bsalomon@google.com | 116ad84 | 2013-04-09 15:38:19 +0000 | [diff] [blame] | 394 | const SkIPoint& dstPoint, |
| 395 | SkIRect* clippedSrcRect, |
| 396 | SkIPoint* clippedDstPoint) { |
| 397 | *clippedSrcRect = srcRect; |
| 398 | *clippedDstPoint = dstPoint; |
skia.committer@gmail.com | a9493a3 | 2013-04-04 07:01:12 +0000 | [diff] [blame] | 399 | |
bsalomon@google.com | 116ad84 | 2013-04-09 15:38:19 +0000 | [diff] [blame] | 400 | // clip the left edge to src and dst bounds, adjusting dstPoint if necessary |
| 401 | if (clippedSrcRect->fLeft < 0) { |
| 402 | clippedDstPoint->fX -= clippedSrcRect->fLeft; |
| 403 | clippedSrcRect->fLeft = 0; |
bsalomon@google.com | e4617bf | 2013-04-03 14:56:40 +0000 | [diff] [blame] | 404 | } |
bsalomon@google.com | 116ad84 | 2013-04-09 15:38:19 +0000 | [diff] [blame] | 405 | if (clippedDstPoint->fX < 0) { |
| 406 | clippedSrcRect->fLeft -= clippedDstPoint->fX; |
| 407 | clippedDstPoint->fX = 0; |
bsalomon@google.com | e4617bf | 2013-04-03 14:56:40 +0000 | [diff] [blame] | 408 | } |
| 409 | |
bsalomon@google.com | 116ad84 | 2013-04-09 15:38:19 +0000 | [diff] [blame] | 410 | // clip the top edge to src and dst bounds, adjusting dstPoint if necessary |
| 411 | if (clippedSrcRect->fTop < 0) { |
| 412 | clippedDstPoint->fY -= clippedSrcRect->fTop; |
| 413 | clippedSrcRect->fTop = 0; |
bsalomon@google.com | e4617bf | 2013-04-03 14:56:40 +0000 | [diff] [blame] | 414 | } |
bsalomon@google.com | 116ad84 | 2013-04-09 15:38:19 +0000 | [diff] [blame] | 415 | if (clippedDstPoint->fY < 0) { |
| 416 | clippedSrcRect->fTop -= clippedDstPoint->fY; |
| 417 | clippedDstPoint->fY = 0; |
bsalomon@google.com | e4617bf | 2013-04-03 14:56:40 +0000 | [diff] [blame] | 418 | } |
skia.committer@gmail.com | a9493a3 | 2013-04-04 07:01:12 +0000 | [diff] [blame] | 419 | |
bsalomon@google.com | e4617bf | 2013-04-03 14:56:40 +0000 | [diff] [blame] | 420 | // clip the right edge to the src and dst bounds. |
bsalomon@google.com | 116ad84 | 2013-04-09 15:38:19 +0000 | [diff] [blame] | 421 | if (clippedSrcRect->fRight > src->width()) { |
| 422 | clippedSrcRect->fRight = src->width(); |
bsalomon@google.com | e4617bf | 2013-04-03 14:56:40 +0000 | [diff] [blame] | 423 | } |
bsalomon@google.com | 116ad84 | 2013-04-09 15:38:19 +0000 | [diff] [blame] | 424 | if (clippedDstPoint->fX + clippedSrcRect->width() > dst->width()) { |
| 425 | clippedSrcRect->fRight = clippedSrcRect->fLeft + dst->width() - clippedDstPoint->fX; |
bsalomon@google.com | e4617bf | 2013-04-03 14:56:40 +0000 | [diff] [blame] | 426 | } |
| 427 | |
| 428 | // clip the bottom edge to the src and dst bounds. |
bsalomon@google.com | 116ad84 | 2013-04-09 15:38:19 +0000 | [diff] [blame] | 429 | if (clippedSrcRect->fBottom > src->height()) { |
| 430 | clippedSrcRect->fBottom = src->height(); |
bsalomon@google.com | e4617bf | 2013-04-03 14:56:40 +0000 | [diff] [blame] | 431 | } |
bsalomon@google.com | 116ad84 | 2013-04-09 15:38:19 +0000 | [diff] [blame] | 432 | if (clippedDstPoint->fY + clippedSrcRect->height() > dst->height()) { |
| 433 | clippedSrcRect->fBottom = clippedSrcRect->fTop + dst->height() - clippedDstPoint->fY; |
bsalomon@google.com | e4617bf | 2013-04-03 14:56:40 +0000 | [diff] [blame] | 434 | } |
skia.committer@gmail.com | a9493a3 | 2013-04-04 07:01:12 +0000 | [diff] [blame] | 435 | |
bsalomon@google.com | e4617bf | 2013-04-03 14:56:40 +0000 | [diff] [blame] | 436 | // The above clipping steps may have inverted the rect if it didn't intersect either the src or |
| 437 | // dst bounds. |
bsalomon@google.com | 116ad84 | 2013-04-09 15:38:19 +0000 | [diff] [blame] | 438 | return !clippedSrcRect->isEmpty(); |
| 439 | } |
| 440 | } |
| 441 | |
bsalomon | 6df8640 | 2015-06-01 10:41:49 -0700 | [diff] [blame] | 442 | void GrDrawTarget::copySurface(GrSurface* dst, |
bsalomon@google.com | 116ad84 | 2013-04-09 15:38:19 +0000 | [diff] [blame] | 443 | GrSurface* src, |
| 444 | const SkIRect& srcRect, |
| 445 | const SkIPoint& dstPoint) { |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 446 | SkASSERT(dst); |
| 447 | SkASSERT(src); |
bsalomon@google.com | 116ad84 | 2013-04-09 15:38:19 +0000 | [diff] [blame] | 448 | |
| 449 | SkIRect clippedSrcRect; |
| 450 | SkIPoint clippedDstPoint; |
| 451 | // If the rect is outside the src or dst then we've already succeeded. |
| 452 | if (!clip_srcrect_and_dstpoint(dst, |
| 453 | src, |
| 454 | srcRect, |
| 455 | dstPoint, |
| 456 | &clippedSrcRect, |
| 457 | &clippedDstPoint)) { |
bsalomon | 6df8640 | 2015-06-01 10:41:49 -0700 | [diff] [blame] | 458 | return; |
bsalomon@google.com | e4617bf | 2013-04-03 14:56:40 +0000 | [diff] [blame] | 459 | } |
| 460 | |
bsalomon | 6df8640 | 2015-06-01 10:41:49 -0700 | [diff] [blame] | 461 | this->onCopySurface(dst, src, clippedSrcRect, clippedDstPoint); |
bsalomon@google.com | eb85117 | 2013-04-15 13:51:00 +0000 | [diff] [blame] | 462 | } |
| 463 | |
egdaniel | e36914c | 2015-02-13 09:00:33 -0800 | [diff] [blame] | 464 | /////////////////////////////////////////////////////////////////////////////// |
| 465 | |
bsalomon | a387a11 | 2015-08-11 14:47:42 -0700 | [diff] [blame] | 466 | GrDrawTarget::PipelineInfo::PipelineInfo(const GrPipelineBuilder* pipelineBuilder, |
| 467 | const GrScissorState* scissor, |
egdaniel | e36914c | 2015-02-13 09:00:33 -0800 | [diff] [blame] | 468 | const GrPrimitiveProcessor* primProc, |
| 469 | const SkRect* devBounds, |
bsalomon | a387a11 | 2015-08-11 14:47:42 -0700 | [diff] [blame] | 470 | GrDrawTarget* target) { |
| 471 | fArgs.fPipelineBuilder = pipelineBuilder; |
| 472 | fArgs.fCaps = target->caps(); |
| 473 | fArgs.fScissor = scissor; |
| 474 | fArgs.fColorPOI = fArgs.fPipelineBuilder->colorProcInfo(primProc); |
| 475 | fArgs.fCoveragePOI = fArgs.fPipelineBuilder->coverageProcInfo(primProc); |
| 476 | if (!target->setupDstReadIfNecessary(*fArgs.fPipelineBuilder, fArgs.fColorPOI, |
| 477 | fArgs.fCoveragePOI, &fArgs.fDstTexture, devBounds)) { |
| 478 | fArgs.fPipelineBuilder = NULL; |
egdaniel | e36914c | 2015-02-13 09:00:33 -0800 | [diff] [blame] | 479 | } |
| 480 | } |
| 481 | |
bsalomon | a387a11 | 2015-08-11 14:47:42 -0700 | [diff] [blame] | 482 | GrDrawTarget::PipelineInfo::PipelineInfo(const GrPipelineBuilder* pipelineBuilder, |
| 483 | const GrScissorState* scissor, |
bsalomon | abd30f5 | 2015-08-13 13:34:48 -0700 | [diff] [blame] | 484 | const GrDrawBatch* batch, |
egdaniel | e36914c | 2015-02-13 09:00:33 -0800 | [diff] [blame] | 485 | const SkRect* devBounds, |
bsalomon | a387a11 | 2015-08-11 14:47:42 -0700 | [diff] [blame] | 486 | GrDrawTarget* target) { |
| 487 | fArgs.fPipelineBuilder = pipelineBuilder; |
| 488 | fArgs.fCaps = target->caps(); |
| 489 | fArgs.fScissor = scissor; |
| 490 | fArgs.fColorPOI = fArgs.fPipelineBuilder->colorProcInfo(batch); |
| 491 | fArgs.fCoveragePOI = fArgs.fPipelineBuilder->coverageProcInfo(batch); |
| 492 | if (!target->setupDstReadIfNecessary(*fArgs.fPipelineBuilder, fArgs.fColorPOI, |
| 493 | fArgs.fCoveragePOI, &fArgs.fDstTexture, devBounds)) { |
| 494 | fArgs.fPipelineBuilder = NULL; |
egdaniel | e36914c | 2015-02-13 09:00:33 -0800 | [diff] [blame] | 495 | } |
| 496 | } |
| 497 | |
bsalomon@google.com | bcce892 | 2013-03-25 15:38:39 +0000 | [diff] [blame] | 498 | /////////////////////////////////////////////////////////////////////////////// |
bsalomon | 4061b12 | 2015-05-29 10:26:19 -0700 | [diff] [blame] | 499 | GrClipTarget::GrClipTarget(GrContext* context) |
| 500 | : INHERITED(context->getGpu(), context->resourceProvider()) |
| 501 | , fContext(context) { |
bsalomon | edd77a1 | 2015-05-29 09:45:57 -0700 | [diff] [blame] | 502 | fClipMaskManager.reset(SkNEW_ARGS(GrClipMaskManager, (this))); |
| 503 | } |
| 504 | |
bsalomon@google.com | bcce892 | 2013-03-25 15:38:39 +0000 | [diff] [blame] | 505 | |
joshualitt | 1c73548 | 2015-07-13 08:08:25 -0700 | [diff] [blame] | 506 | bool GrClipTarget::setupClip(const GrPipelineBuilder& pipelineBuilder, |
joshualitt | 4421a4c | 2015-07-13 09:36:41 -0700 | [diff] [blame] | 507 | GrPipelineBuilder::AutoRestoreFragmentProcessorState* arfps, |
egdaniel | 8dd688b | 2015-01-22 10:16:09 -0800 | [diff] [blame] | 508 | GrPipelineBuilder::AutoRestoreStencil* ars, |
joshualitt | 8059eb9 | 2014-12-29 15:10:07 -0800 | [diff] [blame] | 509 | GrScissorState* scissorState, |
| 510 | const SkRect* devBounds) { |
joshualitt | 1c73548 | 2015-07-13 08:08:25 -0700 | [diff] [blame] | 511 | return fClipMaskManager->setupClipping(pipelineBuilder, |
joshualitt | 4421a4c | 2015-07-13 09:36:41 -0700 | [diff] [blame] | 512 | arfps, |
joshualitt | 5e6ba21 | 2015-07-13 07:35:05 -0700 | [diff] [blame] | 513 | ars, |
joshualitt | 5e6ba21 | 2015-07-13 07:35:05 -0700 | [diff] [blame] | 514 | scissorState, |
| 515 | devBounds); |
joshualitt | 2c93efe | 2014-11-06 12:57:13 -0800 | [diff] [blame] | 516 | } |
bsalomon | edd77a1 | 2015-05-29 09:45:57 -0700 | [diff] [blame] | 517 | |
| 518 | void GrClipTarget::purgeResources() { |
| 519 | // The clip mask manager can rebuild all its clip masks so just |
| 520 | // get rid of them all. |
| 521 | fClipMaskManager->purgeResources(); |
| 522 | }; |