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