blob: 644161f4d98e156287ceb1feddd4dfa9ffbdb30a [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001
reed@google.comac10a2d2010-12-22 21:39:39 +00002/*
epoger@google.comec3ed6a2011-07-28 14:26:00 +00003 * 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.comac10a2d2010-12-22 21:39:39 +00007 */
8
joshualittc2893c52015-01-28 06:54:30 -08009#include "GrDrawTarget.h"
joshualitt4d8da812015-01-28 12:53:54 -080010
11#include "GrBatch.h"
bsalomoneb1cb5c2015-05-22 08:01:09 -070012#include "GrCaps.h"
bsalomon@google.com26e18b52013-03-29 19:22:36 +000013#include "GrContext.h"
bsalomon682c2692015-05-22 14:01:46 -070014#include "GrContextOptions.h"
commit-bot@chromium.orgc4dc0ad2013-10-09 14:11:33 +000015#include "GrPath.h"
egdaniele36914c2015-02-13 09:00:33 -080016#include "GrPipeline.h"
joshualittb7133be2015-04-08 09:08:31 -070017#include "GrMemoryPool.h"
joshualittad17cfc2015-05-05 10:45:57 -070018#include "GrRectBatch.h"
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +000019#include "GrRenderTarget.h"
bsalomon6bc1b5f2015-02-23 09:06:38 -080020#include "GrRenderTargetPriv.h"
bsalomonafbf2d62014-09-30 12:18:44 -070021#include "GrSurfacePriv.h"
bsalomon62c447d2014-08-08 08:08:50 -070022#include "GrTemplates.h"
bsalomon@google.com86afc2a2011-02-16 16:12:19 +000023#include "GrTexture.h"
bsalomon@google.com25fb21f2011-06-21 18:17:25 +000024#include "GrVertexBuffer.h"
reed@google.comac10a2d2010-12-22 21:39:39 +000025
sugoi@google.com5f74cf82012-12-17 21:16:45 +000026#include "SkStrokeRec.h"
sugoi@google.com12b4e272012-12-06 20:13:11 +000027
reed@google.comac10a2d2010-12-22 21:39:39 +000028////////////////////////////////////////////////////////////////////////////////
29
bsalomon@google.com25fb21f2011-06-21 18:17:25 +000030#define DEBUG_INVAL_BUFFER 0xdeadcafe
31#define DEBUG_INVAL_START_IDX -1
32
robertphillipse40d3972015-05-07 09:51:43 -070033GrDrawTarget::GrDrawTarget(GrContext* context)
joshualitt44701df2015-02-23 14:44:57 -080034 : fContext(context)
bsalomona73239a2015-04-28 13:35:17 -070035 , fCaps(SkRef(context->getGpu()->caps()))
36 , fGpuTraceMarkerCount(0)
bsalomona73239a2015-04-28 13:35:17 -070037 , fFlushing(false) {
bsalomon49f085d2014-09-05 13:34:00 -070038 SkASSERT(context);
bsalomon@google.com25fb21f2011-06-21 18:17:25 +000039}
40
41////////////////////////////////////////////////////////////////////////////////
42
bsalomon50785a32015-02-06 07:02:37 -080043bool GrDrawTarget::setupDstReadIfNecessary(const GrPipelineBuilder& pipelineBuilder,
egdaniele36914c2015-02-13 09:00:33 -080044 const GrProcOptInfo& colorPOI,
45 const GrProcOptInfo& coveragePOI,
bsalomon6a44c6a2015-05-26 09:49:05 -070046 GrXferProcessor::DstTexture* dstTexture,
joshualitt9853cce2014-11-17 14:22:48 -080047 const SkRect* drawBounds) {
bsalomon6a44c6a2015-05-26 09:49:05 -070048 if (!pipelineBuilder.willXPNeedDstTexture(*this->caps(), colorPOI, coveragePOI)) {
bsalomon@google.com26e18b52013-03-29 19:22:36 +000049 return true;
50 }
cdalton9954bc32015-04-29 14:17:00 -070051
bsalomon50785a32015-02-06 07:02:37 -080052 GrRenderTarget* rt = pipelineBuilder.getRenderTarget();
cdalton9954bc32015-04-29 14:17:00 -070053
54 if (this->caps()->textureBarrierSupport()) {
55 if (GrTexture* rtTex = rt->asTexture()) {
56 // The render target is a texture, se we can read from it directly in the shader. The XP
57 // will be responsible to detect this situation and request a texture barrier.
bsalomon6a44c6a2015-05-26 09:49:05 -070058 dstTexture->setTexture(rtTex);
59 dstTexture->setOffset(0, 0);
cdalton9954bc32015-04-29 14:17:00 -070060 return true;
61 }
62 }
63
64 SkIRect copyRect;
joshualitt44701df2015-02-23 14:44:57 -080065 pipelineBuilder.clip().getConservativeBounds(rt, &copyRect);
commit-bot@chromium.orgc4dc0ad2013-10-09 14:11:33 +000066
bsalomon49f085d2014-09-05 13:34:00 -070067 if (drawBounds) {
commit-bot@chromium.orgc4dc0ad2013-10-09 14:11:33 +000068 SkIRect drawIBounds;
69 drawBounds->roundOut(&drawIBounds);
commit-bot@chromium.orgbb5c4652013-04-01 12:49:31 +000070 if (!copyRect.intersect(drawIBounds)) {
commit-bot@chromium.org515dcd32013-08-28 14:17:03 +000071#ifdef SK_DEBUG
bsalomon682c2692015-05-22 14:01:46 -070072 GrCapsDebugf(fCaps, "Missed an early reject. "
73 "Bailing on draw from setupDstReadIfNecessary.\n");
commit-bot@chromium.orgbb5c4652013-04-01 12:49:31 +000074#endif
75 return false;
76 }
77 } else {
commit-bot@chromium.org515dcd32013-08-28 14:17:03 +000078#ifdef SK_DEBUG
tfarina38406c82014-10-31 07:11:12 -070079 //SkDebugf("No dev bounds when dst copy is made.\n");
commit-bot@chromium.orgbb5c4652013-04-01 12:49:31 +000080#endif
81 }
skia.committer@gmail.com05a2ee02013-04-02 07:01:34 +000082
commit-bot@chromium.org63150af2013-04-11 22:00:22 +000083 // MSAA consideration: When there is support for reading MSAA samples in the shader we could
84 // have per-sample dst values by making the copy multisampled.
bsalomonf2703d82014-10-28 14:33:06 -070085 GrSurfaceDesc desc;
bsalomona73239a2015-04-28 13:35:17 -070086 if (!this->getGpu()->initCopySurfaceDstDesc(rt, &desc)) {
87 desc.fOrigin = kDefault_GrSurfaceOrigin;
88 desc.fFlags = kRenderTarget_GrSurfaceFlag;
89 desc.fConfig = rt->config();
90 }
91
92
commit-bot@chromium.orgbb5c4652013-04-01 12:49:31 +000093 desc.fWidth = copyRect.width();
94 desc.fHeight = copyRect.height();
bsalomon@google.com26e18b52013-03-29 19:22:36 +000095
bsalomond309e7a2015-04-30 14:18:54 -070096 SkAutoTUnref<GrTexture> copy(fContext->textureProvider()->refScratchTexture(desc,
97 GrTextureProvider::kApprox_ScratchTexMatch));
bsalomon@google.com26e18b52013-03-29 19:22:36 +000098
bsalomone3059732014-10-14 11:47:22 -070099 if (!copy) {
tfarina38406c82014-10-31 07:11:12 -0700100 SkDebugf("Failed to create temporary copy of destination texture.\n");
bsalomon@google.com26e18b52013-03-29 19:22:36 +0000101 return false;
102 }
bsalomon@google.come4617bf2013-04-03 14:56:40 +0000103 SkIPoint dstPoint = {0, 0};
mtklein404b3b22015-05-18 09:29:10 -0700104 if (this->copySurface(copy, rt, copyRect, dstPoint)) {
bsalomon6a44c6a2015-05-26 09:49:05 -0700105 dstTexture->setTexture(copy);
106 dstTexture->setOffset(copyRect.fLeft, copyRect.fTop);
mtklein404b3b22015-05-18 09:29:10 -0700107 return true;
108 } else {
109 return false;
110 }
bsalomon@google.com26e18b52013-03-29 19:22:36 +0000111}
112
bsalomona73239a2015-04-28 13:35:17 -0700113void GrDrawTarget::flush() {
114 if (fFlushing) {
115 return;
116 }
117 fFlushing = true;
118
119 this->getGpu()->saveActiveTraceMarkers();
120
121 this->onFlush();
122
123 this->getGpu()->restoreActiveTraceMarkers();
124
125 fFlushing = false;
126 this->reset();
127}
128
joshualitt4d8da812015-01-28 12:53:54 -0800129void GrDrawTarget::drawBatch(GrPipelineBuilder* pipelineBuilder,
joshualitt99c7c072015-05-01 13:43:30 -0700130 GrBatch* batch) {
joshualitt4d8da812015-01-28 12:53:54 -0800131 SkASSERT(pipelineBuilder);
132 // TODO some kind of checkdraw, but not at this level
133
134 // Setup clip
135 GrScissorState scissorState;
bsalomon6be6f7c2015-02-26 13:05:21 -0800136 GrPipelineBuilder::AutoRestoreFragmentProcessors arfp;
joshualitt4d8da812015-01-28 12:53:54 -0800137 GrPipelineBuilder::AutoRestoreStencil ars;
joshualitt99c7c072015-05-01 13:43:30 -0700138 if (!this->setupClip(pipelineBuilder, &arfp, &ars, &scissorState, &batch->bounds())) {
joshualitt4d8da812015-01-28 12:53:54 -0800139 return;
140 }
141
joshualitt99c7c072015-05-01 13:43:30 -0700142 // Batch bounds are tight, so for dev copies
143 // TODO move this into setupDstReadIfNecessary when paths are in batch
144 SkRect bounds = batch->bounds();
145 bounds.outset(0.5f, 0.5f);
146
147 GrDrawTarget::PipelineInfo pipelineInfo(pipelineBuilder, &scissorState, batch, &bounds,
148 this);
egdaniele36914c2015-02-13 09:00:33 -0800149 if (pipelineInfo.mustSkipDraw()) {
150 return;
151 }
152
153 this->onDrawBatch(batch, pipelineInfo);
joshualitt4d8da812015-01-28 12:53:54 -0800154}
155
joshualitt2c93efe2014-11-06 12:57:13 -0800156static const GrStencilSettings& winding_path_stencil_settings() {
157 GR_STATIC_CONST_SAME_STENCIL_STRUCT(gSettings,
158 kIncClamp_StencilOp,
159 kIncClamp_StencilOp,
160 kAlwaysIfInClip_StencilFunc,
161 0xFFFF, 0xFFFF, 0xFFFF);
162 return *GR_CONST_STENCIL_SETTINGS_PTR_FROM_STRUCT_PTR(&gSettings);
163}
164
165static const GrStencilSettings& even_odd_path_stencil_settings() {
166 GR_STATIC_CONST_SAME_STENCIL_STRUCT(gSettings,
167 kInvert_StencilOp,
168 kInvert_StencilOp,
169 kAlwaysIfInClip_StencilFunc,
170 0xFFFF, 0xFFFF, 0xFFFF);
171 return *GR_CONST_STENCIL_SETTINGS_PTR_FROM_STRUCT_PTR(&gSettings);
172}
173
174void GrDrawTarget::getPathStencilSettingsForFilltype(GrPathRendering::FillType fill,
egdaniel8dc7c3a2015-04-16 11:22:42 -0700175 const GrStencilAttachment* sb,
joshualitt2c93efe2014-11-06 12:57:13 -0800176 GrStencilSettings* outStencilSettings) {
177
178 switch (fill) {
179 default:
180 SkFAIL("Unexpected path fill.");
181 case GrPathRendering::kWinding_FillType:
182 *outStencilSettings = winding_path_stencil_settings();
183 break;
184 case GrPathRendering::kEvenOdd_FillType:
185 *outStencilSettings = even_odd_path_stencil_settings();
186 break;
187 }
joshualitt9853cce2014-11-17 14:22:48 -0800188 this->clipMaskManager()->adjustPathStencilParams(sb, outStencilSettings);
joshualitt2c93efe2014-11-06 12:57:13 -0800189}
190
egdaniel8dd688b2015-01-22 10:16:09 -0800191void GrDrawTarget::stencilPath(GrPipelineBuilder* pipelineBuilder,
joshualitt56995b52014-12-11 15:44:02 -0800192 const GrPathProcessor* pathProc,
joshualitt9853cce2014-11-17 14:22:48 -0800193 const GrPath* path,
194 GrPathRendering::FillType fill) {
bsalomon@google.com64aef2b2012-06-11 15:36:13 +0000195 // TODO: extract portions of checkDraw that are relevant to path stenciling.
bsalomon49f085d2014-09-05 13:34:00 -0700196 SkASSERT(path);
jvanverthe9c0fc62015-04-29 11:18:05 -0700197 SkASSERT(this->caps()->shaderCaps()->pathRenderingSupport());
egdaniel8dd688b2015-01-22 10:16:09 -0800198 SkASSERT(pipelineBuilder);
joshualitt2c93efe2014-11-06 12:57:13 -0800199
200 // Setup clip
bsalomon3e791242014-12-17 13:43:13 -0800201 GrScissorState scissorState;
bsalomon6be6f7c2015-02-26 13:05:21 -0800202 GrPipelineBuilder::AutoRestoreFragmentProcessors arfp;
egdaniel8dd688b2015-01-22 10:16:09 -0800203 GrPipelineBuilder::AutoRestoreStencil ars;
bsalomon6be6f7c2015-02-26 13:05:21 -0800204 if (!this->setupClip(pipelineBuilder, &arfp, &ars, &scissorState, NULL)) {
joshualitt2c93efe2014-11-06 12:57:13 -0800205 return;
206 }
207
208 // set stencil settings for path
209 GrStencilSettings stencilSettings;
bsalomon6bc1b5f2015-02-23 09:06:38 -0800210 GrRenderTarget* rt = pipelineBuilder->getRenderTarget();
egdaniel8dc7c3a2015-04-16 11:22:42 -0700211 GrStencilAttachment* sb = rt->renderTargetPriv().attachStencilAttachment();
bsalomon6bc1b5f2015-02-23 09:06:38 -0800212 this->getPathStencilSettingsForFilltype(fill, sb, &stencilSettings);
joshualitt2c93efe2014-11-06 12:57:13 -0800213
egdaniel8dd688b2015-01-22 10:16:09 -0800214 this->onStencilPath(*pipelineBuilder, pathProc, path, scissorState, stencilSettings);
bsalomon@google.com64aef2b2012-06-11 15:36:13 +0000215}
216
egdaniel8dd688b2015-01-22 10:16:09 -0800217void GrDrawTarget::drawPath(GrPipelineBuilder* pipelineBuilder,
joshualitt56995b52014-12-11 15:44:02 -0800218 const GrPathProcessor* pathProc,
joshualitt9853cce2014-11-17 14:22:48 -0800219 const GrPath* path,
220 GrPathRendering::FillType fill) {
commit-bot@chromium.orgc4dc0ad2013-10-09 14:11:33 +0000221 // TODO: extract portions of checkDraw that are relevant to path rendering.
bsalomon49f085d2014-09-05 13:34:00 -0700222 SkASSERT(path);
jvanverthe9c0fc62015-04-29 11:18:05 -0700223 SkASSERT(this->caps()->shaderCaps()->pathRenderingSupport());
egdaniel8dd688b2015-01-22 10:16:09 -0800224 SkASSERT(pipelineBuilder);
commit-bot@chromium.orgc4dc0ad2013-10-09 14:11:33 +0000225
joshualitt92e496f2014-10-31 13:56:50 -0700226 SkRect devBounds = path->getBounds();
joshualitt8059eb92014-12-29 15:10:07 -0800227 pathProc->viewMatrix().mapRect(&devBounds);
commit-bot@chromium.orgc4dc0ad2013-10-09 14:11:33 +0000228
joshualitt2c93efe2014-11-06 12:57:13 -0800229 // Setup clip
bsalomon3e791242014-12-17 13:43:13 -0800230 GrScissorState scissorState;
bsalomon6be6f7c2015-02-26 13:05:21 -0800231 GrPipelineBuilder::AutoRestoreFragmentProcessors arfp;
egdaniel8dd688b2015-01-22 10:16:09 -0800232 GrPipelineBuilder::AutoRestoreStencil ars;
bsalomon6be6f7c2015-02-26 13:05:21 -0800233 if (!this->setupClip(pipelineBuilder, &arfp, &ars, &scissorState, &devBounds)) {
joshualitt2c93efe2014-11-06 12:57:13 -0800234 return;
235 }
236
237 // set stencil settings for path
238 GrStencilSettings stencilSettings;
bsalomon6bc1b5f2015-02-23 09:06:38 -0800239 GrRenderTarget* rt = pipelineBuilder->getRenderTarget();
egdaniel8dc7c3a2015-04-16 11:22:42 -0700240 GrStencilAttachment* sb = rt->renderTargetPriv().attachStencilAttachment();
bsalomon6bc1b5f2015-02-23 09:06:38 -0800241 this->getPathStencilSettingsForFilltype(fill, sb, &stencilSettings);
joshualitt2c93efe2014-11-06 12:57:13 -0800242
egdaniele36914c2015-02-13 09:00:33 -0800243 GrDrawTarget::PipelineInfo pipelineInfo(pipelineBuilder, &scissorState, pathProc, &devBounds,
244 this);
245 if (pipelineInfo.mustSkipDraw()) {
246 return;
247 }
248
249 this->onDrawPath(pathProc, path, stencilSettings, pipelineInfo);
commit-bot@chromium.orgc4dc0ad2013-10-09 14:11:33 +0000250}
251
egdaniel8dd688b2015-01-22 10:16:09 -0800252void GrDrawTarget::drawPaths(GrPipelineBuilder* pipelineBuilder,
joshualitt56995b52014-12-11 15:44:02 -0800253 const GrPathProcessor* pathProc,
joshualitt9853cce2014-11-17 14:22:48 -0800254 const GrPathRange* pathRange,
cdalton55b24af2014-11-25 11:00:56 -0800255 const void* indices,
256 PathIndexType indexType,
257 const float transformValues[],
258 PathTransformType transformType,
joshualitt9853cce2014-11-17 14:22:48 -0800259 int count,
joshualitt92e496f2014-10-31 13:56:50 -0700260 GrPathRendering::FillType fill) {
jvanverthe9c0fc62015-04-29 11:18:05 -0700261 SkASSERT(this->caps()->shaderCaps()->pathRenderingSupport());
bsalomon49f085d2014-09-05 13:34:00 -0700262 SkASSERT(pathRange);
263 SkASSERT(indices);
cdalton55b24af2014-11-25 11:00:56 -0800264 SkASSERT(0 == reinterpret_cast<long>(indices) % GrPathRange::PathIndexSizeInBytes(indexType));
265 SkASSERT(transformValues);
egdaniel8dd688b2015-01-22 10:16:09 -0800266 SkASSERT(pipelineBuilder);
commit-bot@chromium.org9b62aa12014-03-25 11:59:40 +0000267
joshualitt2c93efe2014-11-06 12:57:13 -0800268 // Setup clip
bsalomon3e791242014-12-17 13:43:13 -0800269 GrScissorState scissorState;
bsalomon6be6f7c2015-02-26 13:05:21 -0800270 GrPipelineBuilder::AutoRestoreFragmentProcessors arfp;
egdaniel8dd688b2015-01-22 10:16:09 -0800271 GrPipelineBuilder::AutoRestoreStencil ars;
joshualitt2c93efe2014-11-06 12:57:13 -0800272
bsalomon6be6f7c2015-02-26 13:05:21 -0800273 if (!this->setupClip(pipelineBuilder, &arfp, &ars, &scissorState, NULL)) {
joshualitt2c93efe2014-11-06 12:57:13 -0800274 return;
275 }
276
277 // set stencil settings for path
278 GrStencilSettings stencilSettings;
bsalomon6bc1b5f2015-02-23 09:06:38 -0800279 GrRenderTarget* rt = pipelineBuilder->getRenderTarget();
egdaniel8dc7c3a2015-04-16 11:22:42 -0700280 GrStencilAttachment* sb = rt->renderTargetPriv().attachStencilAttachment();
bsalomon6bc1b5f2015-02-23 09:06:38 -0800281 this->getPathStencilSettingsForFilltype(fill, sb, &stencilSettings);
joshualitt2c93efe2014-11-06 12:57:13 -0800282
bsalomon50785a32015-02-06 07:02:37 -0800283 // Don't compute a bounding box for dst copy texture, we'll opt
cdaltonb85a0aa2014-07-21 15:32:44 -0700284 // instead for it to just copy the entire dst. Realistically this is a moot
285 // point, because any context that supports NV_path_rendering will also
286 // support NV_blend_equation_advanced.
egdaniele36914c2015-02-13 09:00:33 -0800287 GrDrawTarget::PipelineInfo pipelineInfo(pipelineBuilder, &scissorState, pathProc, NULL, this);
288 if (pipelineInfo.mustSkipDraw()) {
289 return;
290 }
291
292 this->onDrawPaths(pathProc, pathRange, indices, indexType, transformValues,
293 transformType, count, stencilSettings, pipelineInfo);
commit-bot@chromium.org9b62aa12014-03-25 11:59:40 +0000294}
295
joshualittad17cfc2015-05-05 10:45:57 -0700296void GrDrawTarget::drawRect(GrPipelineBuilder* pipelineBuilder,
297 GrColor color,
298 const SkMatrix& viewMatrix,
299 const SkRect& rect,
300 const SkRect* localRect,
301 const SkMatrix* localMatrix) {
302 SkAutoTUnref<GrBatch> batch(GrRectBatch::Create(color, viewMatrix, rect, localRect,
303 localMatrix));
304 this->drawBatch(pipelineBuilder, batch);
305}
306
joshualitt9853cce2014-11-17 14:22:48 -0800307void GrDrawTarget::clear(const SkIRect* rect,
308 GrColor color,
309 bool canIgnoreRect,
bsalomon63b21962014-11-05 07:05:34 -0800310 GrRenderTarget* renderTarget) {
311 if (fCaps->useDrawInsteadOfClear()) {
312 // This works around a driver bug with clear by drawing a rect instead.
313 // The driver will ignore a clear if it is the only thing rendered to a
314 // target before the target is read.
315 SkIRect rtRect = SkIRect::MakeWH(renderTarget->width(), renderTarget->height());
316 if (NULL == rect || canIgnoreRect || rect->contains(rtRect)) {
317 rect = &rtRect;
318 // We first issue a discard() since that may help tilers.
319 this->discard(renderTarget);
320 }
bsalomon63b21962014-11-05 07:05:34 -0800321
egdaniel8dd688b2015-01-22 10:16:09 -0800322 GrPipelineBuilder pipelineBuilder;
323 pipelineBuilder.setRenderTarget(renderTarget);
joshualitt9853cce2014-11-17 14:22:48 -0800324
egdaniel8dd688b2015-01-22 10:16:09 -0800325 this->drawSimpleRect(&pipelineBuilder, color, SkMatrix::I(), *rect);
bsalomon63b21962014-11-05 07:05:34 -0800326 } else {
327 this->onClear(rect, color, canIgnoreRect, renderTarget);
328 }
329}
330
egdaniel3eee3832014-06-18 13:09:11 -0700331typedef GrTraceMarkerSet::Iter TMIter;
332void GrDrawTarget::saveActiveTraceMarkers() {
333 if (this->caps()->gpuTracingSupport()) {
334 SkASSERT(0 == fStoredTraceMarkers.count());
335 fStoredTraceMarkers.addSet(fActiveTraceMarkers);
336 for (TMIter iter = fStoredTraceMarkers.begin(); iter != fStoredTraceMarkers.end(); ++iter) {
337 this->removeGpuTraceMarker(&(*iter));
338 }
339 }
340}
341
342void GrDrawTarget::restoreActiveTraceMarkers() {
343 if (this->caps()->gpuTracingSupport()) {
344 SkASSERT(0 == fActiveTraceMarkers.count());
345 for (TMIter iter = fStoredTraceMarkers.begin(); iter != fStoredTraceMarkers.end(); ++iter) {
346 this->addGpuTraceMarker(&(*iter));
347 }
348 for (TMIter iter = fActiveTraceMarkers.begin(); iter != fActiveTraceMarkers.end(); ++iter) {
349 this->fStoredTraceMarkers.remove(*iter);
350 }
351 }
352}
353
354void GrDrawTarget::addGpuTraceMarker(const GrGpuTraceMarker* marker) {
commit-bot@chromium.orga3baf3b2014-02-21 18:45:30 +0000355 if (this->caps()->gpuTracingSupport()) {
commit-bot@chromium.org2a05de02014-03-25 15:17:32 +0000356 SkASSERT(fGpuTraceMarkerCount >= 0);
357 this->fActiveTraceMarkers.add(*marker);
commit-bot@chromium.org2a05de02014-03-25 15:17:32 +0000358 ++fGpuTraceMarkerCount;
commit-bot@chromium.orga3baf3b2014-02-21 18:45:30 +0000359 }
360}
361
egdaniel3eee3832014-06-18 13:09:11 -0700362void GrDrawTarget::removeGpuTraceMarker(const GrGpuTraceMarker* marker) {
commit-bot@chromium.orga3baf3b2014-02-21 18:45:30 +0000363 if (this->caps()->gpuTracingSupport()) {
commit-bot@chromium.org2a05de02014-03-25 15:17:32 +0000364 SkASSERT(fGpuTraceMarkerCount >= 1);
365 this->fActiveTraceMarkers.remove(*marker);
commit-bot@chromium.org2a05de02014-03-25 15:17:32 +0000366 --fGpuTraceMarkerCount;
commit-bot@chromium.orga3baf3b2014-02-21 18:45:30 +0000367 }
368}
369
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000370////////////////////////////////////////////////////////////////////////////////
bsalomon@google.com86afc2a2011-02-16 16:12:19 +0000371
bsalomon@google.com116ad842013-04-09 15:38:19 +0000372namespace {
373// returns true if the read/written rect intersects the src/dst and false if not.
374bool clip_srcrect_and_dstpoint(const GrSurface* dst,
375 const GrSurface* src,
bsalomon@google.come4617bf2013-04-03 14:56:40 +0000376 const SkIRect& srcRect,
bsalomon@google.com116ad842013-04-09 15:38:19 +0000377 const SkIPoint& dstPoint,
378 SkIRect* clippedSrcRect,
379 SkIPoint* clippedDstPoint) {
380 *clippedSrcRect = srcRect;
381 *clippedDstPoint = dstPoint;
skia.committer@gmail.coma9493a32013-04-04 07:01:12 +0000382
bsalomon@google.com116ad842013-04-09 15:38:19 +0000383 // clip the left edge to src and dst bounds, adjusting dstPoint if necessary
384 if (clippedSrcRect->fLeft < 0) {
385 clippedDstPoint->fX -= clippedSrcRect->fLeft;
386 clippedSrcRect->fLeft = 0;
bsalomon@google.come4617bf2013-04-03 14:56:40 +0000387 }
bsalomon@google.com116ad842013-04-09 15:38:19 +0000388 if (clippedDstPoint->fX < 0) {
389 clippedSrcRect->fLeft -= clippedDstPoint->fX;
390 clippedDstPoint->fX = 0;
bsalomon@google.come4617bf2013-04-03 14:56:40 +0000391 }
392
bsalomon@google.com116ad842013-04-09 15:38:19 +0000393 // clip the top edge to src and dst bounds, adjusting dstPoint if necessary
394 if (clippedSrcRect->fTop < 0) {
395 clippedDstPoint->fY -= clippedSrcRect->fTop;
396 clippedSrcRect->fTop = 0;
bsalomon@google.come4617bf2013-04-03 14:56:40 +0000397 }
bsalomon@google.com116ad842013-04-09 15:38:19 +0000398 if (clippedDstPoint->fY < 0) {
399 clippedSrcRect->fTop -= clippedDstPoint->fY;
400 clippedDstPoint->fY = 0;
bsalomon@google.come4617bf2013-04-03 14:56:40 +0000401 }
skia.committer@gmail.coma9493a32013-04-04 07:01:12 +0000402
bsalomon@google.come4617bf2013-04-03 14:56:40 +0000403 // clip the right edge to the src and dst bounds.
bsalomon@google.com116ad842013-04-09 15:38:19 +0000404 if (clippedSrcRect->fRight > src->width()) {
405 clippedSrcRect->fRight = src->width();
bsalomon@google.come4617bf2013-04-03 14:56:40 +0000406 }
bsalomon@google.com116ad842013-04-09 15:38:19 +0000407 if (clippedDstPoint->fX + clippedSrcRect->width() > dst->width()) {
408 clippedSrcRect->fRight = clippedSrcRect->fLeft + dst->width() - clippedDstPoint->fX;
bsalomon@google.come4617bf2013-04-03 14:56:40 +0000409 }
410
411 // clip the bottom edge to the src and dst bounds.
bsalomon@google.com116ad842013-04-09 15:38:19 +0000412 if (clippedSrcRect->fBottom > src->height()) {
413 clippedSrcRect->fBottom = src->height();
bsalomon@google.come4617bf2013-04-03 14:56:40 +0000414 }
bsalomon@google.com116ad842013-04-09 15:38:19 +0000415 if (clippedDstPoint->fY + clippedSrcRect->height() > dst->height()) {
416 clippedSrcRect->fBottom = clippedSrcRect->fTop + dst->height() - clippedDstPoint->fY;
bsalomon@google.come4617bf2013-04-03 14:56:40 +0000417 }
skia.committer@gmail.coma9493a32013-04-04 07:01:12 +0000418
bsalomon@google.come4617bf2013-04-03 14:56:40 +0000419 // The above clipping steps may have inverted the rect if it didn't intersect either the src or
420 // dst bounds.
bsalomon@google.com116ad842013-04-09 15:38:19 +0000421 return !clippedSrcRect->isEmpty();
422}
423}
424
mtklein404b3b22015-05-18 09:29:10 -0700425bool GrDrawTarget::copySurface(GrSurface* dst,
bsalomon@google.com116ad842013-04-09 15:38:19 +0000426 GrSurface* src,
427 const SkIRect& srcRect,
428 const SkIPoint& dstPoint) {
bsalomon49f085d2014-09-05 13:34:00 -0700429 SkASSERT(dst);
430 SkASSERT(src);
bsalomon@google.com116ad842013-04-09 15:38:19 +0000431
432 SkIRect clippedSrcRect;
433 SkIPoint clippedDstPoint;
434 // If the rect is outside the src or dst then we've already succeeded.
435 if (!clip_srcrect_and_dstpoint(dst,
436 src,
437 srcRect,
438 dstPoint,
439 &clippedSrcRect,
440 &clippedDstPoint)) {
mtklein404b3b22015-05-18 09:29:10 -0700441 return true;
bsalomon@google.come4617bf2013-04-03 14:56:40 +0000442 }
443
mtklein404b3b22015-05-18 09:29:10 -0700444 if (this->getGpu()->canCopySurface(dst, src, clippedSrcRect, clippedDstPoint)) {
445 this->onCopySurface(dst, src, clippedSrcRect, clippedDstPoint);
446 return true;
447 }
448
449 GrRenderTarget* rt = dst->asRenderTarget();
450 GrTexture* tex = src->asTexture();
451
452 if ((dst == src) || !rt || !tex) {
453 return false;
454 }
455
456 GrPipelineBuilder pipelineBuilder;
457 pipelineBuilder.setRenderTarget(rt);
458 SkMatrix matrix;
459 matrix.setTranslate(SkIntToScalar(clippedSrcRect.fLeft - clippedDstPoint.fX),
460 SkIntToScalar(clippedSrcRect.fTop - clippedDstPoint.fY));
461 matrix.postIDiv(tex->width(), tex->height());
462 pipelineBuilder.addColorTextureProcessor(tex, matrix);
463 SkIRect dstRect = SkIRect::MakeXYWH(clippedDstPoint.fX,
464 clippedDstPoint.fY,
465 clippedSrcRect.width(),
466 clippedSrcRect.height());
467 this->drawSimpleRect(&pipelineBuilder, GrColor_WHITE, SkMatrix::I(), dstRect);
468 return true;
469}
470
471bool GrDrawTarget::canCopySurface(const GrSurface* dst,
472 const GrSurface* src,
473 const SkIRect& srcRect,
474 const SkIPoint& dstPoint) {
475 SkASSERT(dst);
476 SkASSERT(src);
477
478 SkIRect clippedSrcRect;
479 SkIPoint clippedDstPoint;
480 // If the rect is outside the src or dst then we're guaranteed success
481 if (!clip_srcrect_and_dstpoint(dst,
482 src,
483 srcRect,
484 dstPoint,
485 &clippedSrcRect,
486 &clippedDstPoint)) {
487 return true;
488 }
489 return ((dst != src) && dst->asRenderTarget() && src->asTexture()) ||
490 this->getGpu()->canCopySurface(dst, src, clippedSrcRect, clippedDstPoint);
bsalomon@google.comeb851172013-04-15 13:51:00 +0000491}
492
egdaniele36914c2015-02-13 09:00:33 -0800493void GrDrawTarget::setupPipeline(const PipelineInfo& pipelineInfo,
494 GrPipeline* pipeline) {
495 SkNEW_PLACEMENT_ARGS(pipeline, GrPipeline, (*pipelineInfo.fPipelineBuilder,
496 pipelineInfo.fColorPOI,
497 pipelineInfo.fCoveragePOI,
498 *this->caps(),
499 *pipelineInfo.fScissor,
bsalomon6a44c6a2015-05-26 09:49:05 -0700500 &pipelineInfo.fDstTexture));
egdaniele36914c2015-02-13 09:00:33 -0800501}
502///////////////////////////////////////////////////////////////////////////////
503
504GrDrawTarget::PipelineInfo::PipelineInfo(GrPipelineBuilder* pipelineBuilder,
505 GrScissorState* scissor,
506 const GrPrimitiveProcessor* primProc,
507 const SkRect* devBounds,
508 GrDrawTarget* target)
509 : fPipelineBuilder(pipelineBuilder)
510 , fScissor(scissor) {
511 fColorPOI = fPipelineBuilder->colorProcInfo(primProc);
512 fCoveragePOI = fPipelineBuilder->coverageProcInfo(primProc);
513 if (!target->setupDstReadIfNecessary(*fPipelineBuilder, fColorPOI, fCoveragePOI,
bsalomon6a44c6a2015-05-26 09:49:05 -0700514 &fDstTexture, devBounds)) {
egdaniele36914c2015-02-13 09:00:33 -0800515 fPipelineBuilder = NULL;
516 }
517}
518
519GrDrawTarget::PipelineInfo::PipelineInfo(GrPipelineBuilder* pipelineBuilder,
520 GrScissorState* scissor,
521 const GrBatch* batch,
522 const SkRect* devBounds,
523 GrDrawTarget* target)
524 : fPipelineBuilder(pipelineBuilder)
525 , fScissor(scissor) {
526 fColorPOI = fPipelineBuilder->colorProcInfo(batch);
527 fCoveragePOI = fPipelineBuilder->coverageProcInfo(batch);
528 if (!target->setupDstReadIfNecessary(*fPipelineBuilder, fColorPOI, fCoveragePOI,
bsalomon6a44c6a2015-05-26 09:49:05 -0700529 &fDstTexture, devBounds)) {
egdaniele36914c2015-02-13 09:00:33 -0800530 fPipelineBuilder = NULL;
531 }
532}
533
bsalomon@google.combcce8922013-03-25 15:38:39 +0000534///////////////////////////////////////////////////////////////////////////////
535
bsalomon424cc262015-05-22 10:37:30 -0700536GrShaderCaps::GrShaderCaps() {
jvanverthe9c0fc62015-04-29 11:18:05 -0700537 fShaderDerivativeSupport = false;
538 fGeometryShaderSupport = false;
539 fPathRenderingSupport = false;
540 fDstReadInShaderSupport = false;
541 fDualSourceBlendingSupport = false;
cdalton0edea2c2015-05-21 08:27:44 -0700542 fMixedSamplesSupport = false;
jvanverthe9c0fc62015-04-29 11:18:05 -0700543 fShaderPrecisionVaries = false;
544}
545
jvanverthe9c0fc62015-04-29 11:18:05 -0700546static const char* shader_type_to_string(GrShaderType type) {
547 switch (type) {
548 case kVertex_GrShaderType:
549 return "vertex";
550 case kGeometry_GrShaderType:
551 return "geometry";
552 case kFragment_GrShaderType:
553 return "fragment";
554 }
555 return "";
556}
557
558static const char* precision_to_string(GrSLPrecision p) {
559 switch (p) {
560 case kLow_GrSLPrecision:
561 return "low";
562 case kMedium_GrSLPrecision:
563 return "medium";
564 case kHigh_GrSLPrecision:
565 return "high";
566 }
567 return "";
568}
569
570SkString GrShaderCaps::dump() const {
571 SkString r;
572 static const char* gNY[] = { "NO", "YES" };
573 r.appendf("Shader Derivative Support : %s\n", gNY[fShaderDerivativeSupport]);
574 r.appendf("Geometry Shader Support : %s\n", gNY[fGeometryShaderSupport]);
575 r.appendf("Path Rendering Support : %s\n", gNY[fPathRenderingSupport]);
576 r.appendf("Dst Read In Shader Support : %s\n", gNY[fDstReadInShaderSupport]);
577 r.appendf("Dual Source Blending Support : %s\n", gNY[fDualSourceBlendingSupport]);
cdalton0edea2c2015-05-21 08:27:44 -0700578 r.appendf("Mixed Samples Support : %s\n", gNY[fMixedSamplesSupport]);
jvanverthe9c0fc62015-04-29 11:18:05 -0700579
580 r.appendf("Shader Float Precisions (varies: %s):\n", gNY[fShaderPrecisionVaries]);
581
582 for (int s = 0; s < kGrShaderTypeCount; ++s) {
583 GrShaderType shaderType = static_cast<GrShaderType>(s);
584 r.appendf("\t%s:\n", shader_type_to_string(shaderType));
585 for (int p = 0; p < kGrSLPrecisionCount; ++p) {
586 if (fFloatPrecisions[s][p].supported()) {
587 GrSLPrecision precision = static_cast<GrSLPrecision>(p);
588 r.appendf("\t\t%s: log_low: %d log_high: %d bits: %d\n",
589 precision_to_string(precision),
590 fFloatPrecisions[s][p].fLogRangeLow,
591 fFloatPrecisions[s][p].fLogRangeHigh,
592 fFloatPrecisions[s][p].fBits);
593 }
594 }
595 }
596
597 return r;
598}
599
600///////////////////////////////////////////////////////////////////////////////
601
bsalomon682c2692015-05-22 14:01:46 -0700602GrCaps::GrCaps(const GrContextOptions& options) {
commit-bot@chromium.org47442312013-12-19 16:18:01 +0000603 fMipMapSupport = false;
bsalomon@google.combcce8922013-03-25 15:38:39 +0000604 fNPOTTextureTileSupport = false;
605 fTwoSidedStencilSupport = false;
606 fStencilWrapOpsSupport = false;
commit-bot@chromium.org28361fa2014-03-28 16:08:05 +0000607 fDiscardRenderTargetSupport = false;
commit-bot@chromium.orgb8356522013-07-18 22:26:39 +0000608 fReuseScratchTextures = true;
commit-bot@chromium.orga3baf3b2014-02-21 18:45:30 +0000609 fGpuTracingSupport = false;
krajcevski786978162014-07-30 11:25:44 -0700610 fCompressedTexSubImageSupport = false;
bsalomond08ea5f2015-02-20 06:58:13 -0800611 fOversizedStencilSupport = false;
cdaltonfd4167d2015-04-21 11:45:56 -0700612 fTextureBarrierSupport = false;
bsalomon@google.combcce8922013-03-25 15:38:39 +0000613
bsalomon63b21962014-11-05 07:05:34 -0800614 fUseDrawInsteadOfClear = false;
615
cdalton8917d622015-05-06 13:40:21 -0700616 fBlendEquationSupport = kBasic_BlendEquationSupport;
commit-bot@chromium.org160b4782014-05-05 12:32:37 +0000617 fMapBufferFlags = kNone_MapFlags;
618
bsalomon@google.combcce8922013-03-25 15:38:39 +0000619 fMaxRenderTargetSize = 0;
620 fMaxTextureSize = 0;
621 fMaxSampleCount = 0;
commit-bot@chromium.org73880512013-10-14 15:33:45 +0000622
623 memset(fConfigRenderSupport, 0, sizeof(fConfigRenderSupport));
commit-bot@chromium.org6e7ddaa2014-05-30 13:55:58 +0000624 memset(fConfigTextureSupport, 0, sizeof(fConfigTextureSupport));
bsalomon682c2692015-05-22 14:01:46 -0700625
626 fSupressPrints = options.fSuppressPrints;
627 fDrawPathMasksToCompressedTextureSupport = options.fDrawPathToCompressedTexture;
bsalomon@google.combcce8922013-03-25 15:38:39 +0000628}
629
commit-bot@chromium.org160b4782014-05-05 12:32:37 +0000630static SkString map_flags_to_string(uint32_t flags) {
631 SkString str;
bsalomon4b91f762015-05-19 09:29:46 -0700632 if (GrCaps::kNone_MapFlags == flags) {
commit-bot@chromium.org160b4782014-05-05 12:32:37 +0000633 str = "none";
634 } else {
bsalomon4b91f762015-05-19 09:29:46 -0700635 SkASSERT(GrCaps::kCanMap_MapFlag & flags);
636 SkDEBUGCODE(flags &= ~GrCaps::kCanMap_MapFlag);
commit-bot@chromium.org160b4782014-05-05 12:32:37 +0000637 str = "can_map";
638
bsalomon4b91f762015-05-19 09:29:46 -0700639 if (GrCaps::kSubset_MapFlag & flags) {
commit-bot@chromium.org160b4782014-05-05 12:32:37 +0000640 str.append(" partial");
641 } else {
642 str.append(" full");
643 }
bsalomon4b91f762015-05-19 09:29:46 -0700644 SkDEBUGCODE(flags &= ~GrCaps::kSubset_MapFlag);
commit-bot@chromium.org160b4782014-05-05 12:32:37 +0000645 }
646 SkASSERT(0 == flags); // Make sure we handled all the flags.
647 return str;
648}
649
bsalomon4b91f762015-05-19 09:29:46 -0700650SkString GrCaps::dump() const {
commit-bot@chromium.org8b656c62013-11-21 15:23:15 +0000651 SkString r;
bsalomon@google.com18c9c192011-09-22 21:01:31 +0000652 static const char* gNY[] = {"NO", "YES"};
bsalomon63b21962014-11-05 07:05:34 -0800653 r.appendf("MIP Map Support : %s\n", gNY[fMipMapSupport]);
654 r.appendf("NPOT Texture Tile Support : %s\n", gNY[fNPOTTextureTileSupport]);
655 r.appendf("Two Sided Stencil Support : %s\n", gNY[fTwoSidedStencilSupport]);
656 r.appendf("Stencil Wrap Ops Support : %s\n", gNY[fStencilWrapOpsSupport]);
bsalomon63b21962014-11-05 07:05:34 -0800657 r.appendf("Discard Render Target Support : %s\n", gNY[fDiscardRenderTargetSupport]);
658 r.appendf("Reuse Scratch Textures : %s\n", gNY[fReuseScratchTextures]);
659 r.appendf("Gpu Tracing Support : %s\n", gNY[fGpuTracingSupport]);
660 r.appendf("Compressed Update Support : %s\n", gNY[fCompressedTexSubImageSupport]);
bsalomond08ea5f2015-02-20 06:58:13 -0800661 r.appendf("Oversized Stencil Support : %s\n", gNY[fOversizedStencilSupport]);
cdaltonfd4167d2015-04-21 11:45:56 -0700662 r.appendf("Texture Barrier Support : %s\n", gNY[fTextureBarrierSupport]);
bsalomon63b21962014-11-05 07:05:34 -0800663 r.appendf("Draw Instead of Clear [workaround] : %s\n", gNY[fUseDrawInsteadOfClear]);
664
665 r.appendf("Max Texture Size : %d\n", fMaxTextureSize);
666 r.appendf("Max Render Target Size : %d\n", fMaxRenderTargetSize);
667 r.appendf("Max Sample Count : %d\n", fMaxSampleCount);
668
cdalton8917d622015-05-06 13:40:21 -0700669 static const char* kBlendEquationSupportNames[] = {
670 "Basic",
671 "Advanced",
672 "Advanced Coherent",
673 };
674 GR_STATIC_ASSERT(0 == kBasic_BlendEquationSupport);
675 GR_STATIC_ASSERT(1 == kAdvanced_BlendEquationSupport);
676 GR_STATIC_ASSERT(2 == kAdvancedCoherent_BlendEquationSupport);
677 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kBlendEquationSupportNames) == kLast_BlendEquationSupport + 1);
678
679 r.appendf("Blend Equation Support : %s\n",
680 kBlendEquationSupportNames[fBlendEquationSupport]);
bsalomon63b21962014-11-05 07:05:34 -0800681 r.appendf("Map Buffer Support : %s\n",
682 map_flags_to_string(fMapBufferFlags).c_str());
commit-bot@chromium.org160b4782014-05-05 12:32:37 +0000683
commit-bot@chromium.org73880512013-10-14 15:33:45 +0000684 static const char* kConfigNames[] = {
685 "Unknown", // kUnknown_GrPixelConfig
686 "Alpha8", // kAlpha_8_GrPixelConfig,
687 "Index8", // kIndex_8_GrPixelConfig,
688 "RGB565", // kRGB_565_GrPixelConfig,
689 "RGBA444", // kRGBA_4444_GrPixelConfig,
690 "RGBA8888", // kRGBA_8888_GrPixelConfig,
691 "BGRA8888", // kBGRA_8888_GrPixelConfig,
jvanverthfa1e8a72014-12-22 08:31:49 -0800692 "SRGBA8888",// kSRGBA_8888_GrPixelConfig,
commit-bot@chromium.org6e7ddaa2014-05-30 13:55:58 +0000693 "ETC1", // kETC1_GrPixelConfig,
694 "LATC", // kLATC_GrPixelConfig,
krajcevski238b4562014-06-30 09:09:22 -0700695 "R11EAC", // kR11_EAC_GrPixelConfig,
krajcevski7ef21622014-07-16 15:21:13 -0700696 "ASTC12x12",// kASTC_12x12_GrPixelConfig,
jvanverth28f9c602014-12-05 13:06:35 -0800697 "RGBAFloat",// kRGBA_float_GrPixelConfig
698 "AlphaHalf",// kAlpha_half_GrPixelConfig
jvanverthfb5df432015-05-21 08:12:27 -0700699 "RGBAHalf", // kRGBA_half_GrPixelConfig
commit-bot@chromium.org73880512013-10-14 15:33:45 +0000700 };
krajcevski7ef21622014-07-16 15:21:13 -0700701 GR_STATIC_ASSERT(0 == kUnknown_GrPixelConfig);
702 GR_STATIC_ASSERT(1 == kAlpha_8_GrPixelConfig);
703 GR_STATIC_ASSERT(2 == kIndex_8_GrPixelConfig);
704 GR_STATIC_ASSERT(3 == kRGB_565_GrPixelConfig);
705 GR_STATIC_ASSERT(4 == kRGBA_4444_GrPixelConfig);
706 GR_STATIC_ASSERT(5 == kRGBA_8888_GrPixelConfig);
707 GR_STATIC_ASSERT(6 == kBGRA_8888_GrPixelConfig);
jvanverthfa1e8a72014-12-22 08:31:49 -0800708 GR_STATIC_ASSERT(7 == kSRGBA_8888_GrPixelConfig);
709 GR_STATIC_ASSERT(8 == kETC1_GrPixelConfig);
710 GR_STATIC_ASSERT(9 == kLATC_GrPixelConfig);
711 GR_STATIC_ASSERT(10 == kR11_EAC_GrPixelConfig);
712 GR_STATIC_ASSERT(11 == kASTC_12x12_GrPixelConfig);
713 GR_STATIC_ASSERT(12 == kRGBA_float_GrPixelConfig);
714 GR_STATIC_ASSERT(13 == kAlpha_half_GrPixelConfig);
jvanverthfb5df432015-05-21 08:12:27 -0700715 GR_STATIC_ASSERT(14 == kRGBA_half_GrPixelConfig);
commit-bot@chromium.org73880512013-10-14 15:33:45 +0000716 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kConfigNames) == kGrPixelConfigCnt);
717
commit-bot@chromium.org99017272013-11-08 18:45:27 +0000718 SkASSERT(!fConfigRenderSupport[kUnknown_GrPixelConfig][0]);
719 SkASSERT(!fConfigRenderSupport[kUnknown_GrPixelConfig][1]);
commit-bot@chromium.org6e7ddaa2014-05-30 13:55:58 +0000720
721 for (size_t i = 1; i < SK_ARRAY_COUNT(kConfigNames); ++i) {
722 r.appendf("%s is renderable: %s, with MSAA: %s\n",
723 kConfigNames[i],
724 gNY[fConfigRenderSupport[i][0]],
725 gNY[fConfigRenderSupport[i][1]]);
commit-bot@chromium.org73880512013-10-14 15:33:45 +0000726 }
commit-bot@chromium.org42dc8132014-05-27 19:26:59 +0000727
commit-bot@chromium.org6e7ddaa2014-05-30 13:55:58 +0000728 SkASSERT(!fConfigTextureSupport[kUnknown_GrPixelConfig]);
commit-bot@chromium.org42dc8132014-05-27 19:26:59 +0000729
commit-bot@chromium.org6e7ddaa2014-05-30 13:55:58 +0000730 for (size_t i = 1; i < SK_ARRAY_COUNT(kConfigNames); ++i) {
731 r.appendf("%s is uploadable to a texture: %s\n",
732 kConfigNames[i],
733 gNY[fConfigTextureSupport[i]]);
commit-bot@chromium.org42dc8132014-05-27 19:26:59 +0000734 }
735
commit-bot@chromium.org8b656c62013-11-21 15:23:15 +0000736 return r;
bsalomon@google.com18c9c192011-09-22 21:01:31 +0000737}
egdanielbc127a32014-09-19 12:07:43 -0700738
joshualitt2c93efe2014-11-06 12:57:13 -0800739///////////////////////////////////////////////////////////////////////////////////////////////////
740
egdaniel8dd688b2015-01-22 10:16:09 -0800741bool GrClipTarget::setupClip(GrPipelineBuilder* pipelineBuilder,
bsalomon6be6f7c2015-02-26 13:05:21 -0800742 GrPipelineBuilder::AutoRestoreFragmentProcessors* arfp,
egdaniel8dd688b2015-01-22 10:16:09 -0800743 GrPipelineBuilder::AutoRestoreStencil* ars,
joshualitt8059eb92014-12-29 15:10:07 -0800744 GrScissorState* scissorState,
745 const SkRect* devBounds) {
egdaniel8dd688b2015-01-22 10:16:09 -0800746 return fClipMaskManager.setupClipping(pipelineBuilder,
bsalomon6be6f7c2015-02-26 13:05:21 -0800747 arfp,
joshualitt2c93efe2014-11-06 12:57:13 -0800748 ars,
joshualitt9853cce2014-11-17 14:22:48 -0800749 scissorState,
joshualitt9853cce2014-11-17 14:22:48 -0800750 devBounds);
joshualitt2c93efe2014-11-06 12:57:13 -0800751}