blob: e52e4f976bbc6a52754605c049b81b78e0117e17 [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"
bsalomona73239a2015-04-28 13:35:17 -070012#include "GrBufferAllocPool.h"
bsalomon@google.com26e18b52013-03-29 19:22:36 +000013#include "GrContext.h"
bsalomon@google.comc26d94f2013-03-25 18:19:00 +000014#include "GrDrawTargetCaps.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"
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +000018#include "GrRenderTarget.h"
bsalomon6bc1b5f2015-02-23 09:06:38 -080019#include "GrRenderTargetPriv.h"
bsalomonafbf2d62014-09-30 12:18:44 -070020#include "GrSurfacePriv.h"
bsalomon62c447d2014-08-08 08:08:50 -070021#include "GrTemplates.h"
bsalomon@google.com86afc2a2011-02-16 16:12:19 +000022#include "GrTexture.h"
bsalomon@google.com25fb21f2011-06-21 18:17:25 +000023#include "GrVertexBuffer.h"
reed@google.comac10a2d2010-12-22 21:39:39 +000024
sugoi@google.com5f74cf82012-12-17 21:16:45 +000025#include "SkStrokeRec.h"
sugoi@google.com12b4e272012-12-06 20:13:11 +000026
reed@google.comac10a2d2010-12-22 21:39:39 +000027////////////////////////////////////////////////////////////////////////////////
28
bsalomon@google.comd62e88e2013-02-01 14:19:27 +000029GrDrawTarget::DrawInfo& GrDrawTarget::DrawInfo::operator =(const DrawInfo& di) {
30 fPrimitiveType = di.fPrimitiveType;
31 fStartVertex = di.fStartVertex;
32 fStartIndex = di.fStartIndex;
33 fVertexCount = di.fVertexCount;
34 fIndexCount = di.fIndexCount;
35
36 fInstanceCount = di.fInstanceCount;
37 fVerticesPerInstance = di.fVerticesPerInstance;
38 fIndicesPerInstance = di.fIndicesPerInstance;
39
bsalomon49f085d2014-09-05 13:34:00 -070040 if (di.fDevBounds) {
tfarina@chromium.orgf6de4752013-08-17 00:02:59 +000041 SkASSERT(di.fDevBounds == &di.fDevBoundsStorage);
bsalomon@google.comd62e88e2013-02-01 14:19:27 +000042 fDevBoundsStorage = di.fDevBoundsStorage;
43 fDevBounds = &fDevBoundsStorage;
44 } else {
45 fDevBounds = NULL;
46 }
bsalomon@google.com26e18b52013-03-29 19:22:36 +000047
joshualitt7eb8c7b2014-11-18 14:24:27 -080048 this->setVertexBuffer(di.vertexBuffer());
49 this->setIndexBuffer(di.indexBuffer());
50
bsalomon@google.comd62e88e2013-02-01 14:19:27 +000051 return *this;
52}
53
bsalomon@google.comd62e88e2013-02-01 14:19:27 +000054////////////////////////////////////////////////////////////////////////////////
55
bsalomon@google.com25fb21f2011-06-21 18:17:25 +000056#define DEBUG_INVAL_BUFFER 0xdeadcafe
57#define DEBUG_INVAL_START_IDX -1
58
bsalomona73239a2015-04-28 13:35:17 -070059GrDrawTarget::GrDrawTarget(GrContext* context,
60 GrVertexBufferAllocPool* vpool,
61 GrIndexBufferAllocPool* ipool)
joshualitt44701df2015-02-23 14:44:57 -080062 : fContext(context)
bsalomona73239a2015-04-28 13:35:17 -070063 , fCaps(SkRef(context->getGpu()->caps()))
64 , fGpuTraceMarkerCount(0)
65 , fVertexPool(vpool)
66 , fIndexPool(ipool)
67 , fFlushing(false) {
bsalomon49f085d2014-09-05 13:34:00 -070068 SkASSERT(context);
bsalomon@google.com25fb21f2011-06-21 18:17:25 +000069}
70
71////////////////////////////////////////////////////////////////////////////////
72
bsalomon50785a32015-02-06 07:02:37 -080073bool GrDrawTarget::setupDstReadIfNecessary(const GrPipelineBuilder& pipelineBuilder,
egdaniele36914c2015-02-13 09:00:33 -080074 const GrProcOptInfo& colorPOI,
75 const GrProcOptInfo& coveragePOI,
joshualitt9853cce2014-11-17 14:22:48 -080076 GrDeviceCoordTexture* dstCopy,
77 const SkRect* drawBounds) {
egdaniele36914c2015-02-13 09:00:33 -080078 if (!pipelineBuilder.willXPNeedDstCopy(*this->caps(), colorPOI, coveragePOI)) {
bsalomon@google.com26e18b52013-03-29 19:22:36 +000079 return true;
80 }
commit-bot@chromium.orgfd03d4a2013-07-17 21:39:42 +000081 SkIRect copyRect;
bsalomon50785a32015-02-06 07:02:37 -080082 GrRenderTarget* rt = pipelineBuilder.getRenderTarget();
joshualitt44701df2015-02-23 14:44:57 -080083 pipelineBuilder.clip().getConservativeBounds(rt, &copyRect);
commit-bot@chromium.orgc4dc0ad2013-10-09 14:11:33 +000084
bsalomon49f085d2014-09-05 13:34:00 -070085 if (drawBounds) {
commit-bot@chromium.orgc4dc0ad2013-10-09 14:11:33 +000086 SkIRect drawIBounds;
87 drawBounds->roundOut(&drawIBounds);
commit-bot@chromium.orgbb5c4652013-04-01 12:49:31 +000088 if (!copyRect.intersect(drawIBounds)) {
commit-bot@chromium.org515dcd32013-08-28 14:17:03 +000089#ifdef SK_DEBUG
tfarina38406c82014-10-31 07:11:12 -070090 SkDebugf("Missed an early reject. Bailing on draw from setupDstReadIfNecessary.\n");
commit-bot@chromium.orgbb5c4652013-04-01 12:49:31 +000091#endif
92 return false;
93 }
94 } else {
commit-bot@chromium.org515dcd32013-08-28 14:17:03 +000095#ifdef SK_DEBUG
tfarina38406c82014-10-31 07:11:12 -070096 //SkDebugf("No dev bounds when dst copy is made.\n");
commit-bot@chromium.orgbb5c4652013-04-01 12:49:31 +000097#endif
98 }
skia.committer@gmail.com05a2ee02013-04-02 07:01:34 +000099
commit-bot@chromium.org63150af2013-04-11 22:00:22 +0000100 // MSAA consideration: When there is support for reading MSAA samples in the shader we could
101 // have per-sample dst values by making the copy multisampled.
bsalomonf2703d82014-10-28 14:33:06 -0700102 GrSurfaceDesc desc;
bsalomona73239a2015-04-28 13:35:17 -0700103 if (!this->getGpu()->initCopySurfaceDstDesc(rt, &desc)) {
104 desc.fOrigin = kDefault_GrSurfaceOrigin;
105 desc.fFlags = kRenderTarget_GrSurfaceFlag;
106 desc.fConfig = rt->config();
107 }
108
109
commit-bot@chromium.orgbb5c4652013-04-01 12:49:31 +0000110 desc.fWidth = copyRect.width();
111 desc.fHeight = copyRect.height();
bsalomon@google.com26e18b52013-03-29 19:22:36 +0000112
bsalomone3059732014-10-14 11:47:22 -0700113 SkAutoTUnref<GrTexture> copy(
114 fContext->refScratchTexture(desc, GrContext::kApprox_ScratchTexMatch));
bsalomon@google.com26e18b52013-03-29 19:22:36 +0000115
bsalomone3059732014-10-14 11:47:22 -0700116 if (!copy) {
tfarina38406c82014-10-31 07:11:12 -0700117 SkDebugf("Failed to create temporary copy of destination texture.\n");
bsalomon@google.com26e18b52013-03-29 19:22:36 +0000118 return false;
119 }
bsalomon@google.come4617bf2013-04-03 14:56:40 +0000120 SkIPoint dstPoint = {0, 0};
bsalomone3059732014-10-14 11:47:22 -0700121 if (this->copySurface(copy, rt, copyRect, dstPoint)) {
122 dstCopy->setTexture(copy);
commit-bot@chromium.orgc4dc0ad2013-10-09 14:11:33 +0000123 dstCopy->setOffset(copyRect.fLeft, copyRect.fTop);
bsalomon@google.come4617bf2013-04-03 14:56:40 +0000124 return true;
125 } else {
126 return false;
127 }
bsalomon@google.com26e18b52013-03-29 19:22:36 +0000128}
129
bsalomona73239a2015-04-28 13:35:17 -0700130void GrDrawTarget::reset() {
131 fVertexPool->reset();
132 fIndexPool->reset();
133
134 this->onReset();
135}
136
137void GrDrawTarget::flush() {
138 if (fFlushing) {
139 return;
140 }
141 fFlushing = true;
142
143 this->getGpu()->saveActiveTraceMarkers();
144
145 this->onFlush();
146
147 this->getGpu()->restoreActiveTraceMarkers();
148
149 fFlushing = false;
150 this->reset();
151}
152
joshualitt4d8da812015-01-28 12:53:54 -0800153void GrDrawTarget::drawBatch(GrPipelineBuilder* pipelineBuilder,
154 GrBatch* batch,
155 const SkRect* devBounds) {
156 SkASSERT(pipelineBuilder);
157 // TODO some kind of checkdraw, but not at this level
158
159 // Setup clip
160 GrScissorState scissorState;
bsalomon6be6f7c2015-02-26 13:05:21 -0800161 GrPipelineBuilder::AutoRestoreFragmentProcessors arfp;
joshualitt4d8da812015-01-28 12:53:54 -0800162 GrPipelineBuilder::AutoRestoreStencil ars;
bsalomon6be6f7c2015-02-26 13:05:21 -0800163 if (!this->setupClip(pipelineBuilder, &arfp, &ars, &scissorState, devBounds)) {
joshualitt4d8da812015-01-28 12:53:54 -0800164 return;
165 }
166
egdaniele36914c2015-02-13 09:00:33 -0800167 GrDrawTarget::PipelineInfo pipelineInfo(pipelineBuilder, &scissorState, batch, devBounds, this);
168 if (pipelineInfo.mustSkipDraw()) {
169 return;
170 }
171
172 this->onDrawBatch(batch, pipelineInfo);
joshualitt4d8da812015-01-28 12:53:54 -0800173}
174
joshualitt2c93efe2014-11-06 12:57:13 -0800175static const GrStencilSettings& winding_path_stencil_settings() {
176 GR_STATIC_CONST_SAME_STENCIL_STRUCT(gSettings,
177 kIncClamp_StencilOp,
178 kIncClamp_StencilOp,
179 kAlwaysIfInClip_StencilFunc,
180 0xFFFF, 0xFFFF, 0xFFFF);
181 return *GR_CONST_STENCIL_SETTINGS_PTR_FROM_STRUCT_PTR(&gSettings);
182}
183
184static const GrStencilSettings& even_odd_path_stencil_settings() {
185 GR_STATIC_CONST_SAME_STENCIL_STRUCT(gSettings,
186 kInvert_StencilOp,
187 kInvert_StencilOp,
188 kAlwaysIfInClip_StencilFunc,
189 0xFFFF, 0xFFFF, 0xFFFF);
190 return *GR_CONST_STENCIL_SETTINGS_PTR_FROM_STRUCT_PTR(&gSettings);
191}
192
193void GrDrawTarget::getPathStencilSettingsForFilltype(GrPathRendering::FillType fill,
egdaniel8dc7c3a2015-04-16 11:22:42 -0700194 const GrStencilAttachment* sb,
joshualitt2c93efe2014-11-06 12:57:13 -0800195 GrStencilSettings* outStencilSettings) {
196
197 switch (fill) {
198 default:
199 SkFAIL("Unexpected path fill.");
200 case GrPathRendering::kWinding_FillType:
201 *outStencilSettings = winding_path_stencil_settings();
202 break;
203 case GrPathRendering::kEvenOdd_FillType:
204 *outStencilSettings = even_odd_path_stencil_settings();
205 break;
206 }
joshualitt9853cce2014-11-17 14:22:48 -0800207 this->clipMaskManager()->adjustPathStencilParams(sb, outStencilSettings);
joshualitt2c93efe2014-11-06 12:57:13 -0800208}
209
egdaniel8dd688b2015-01-22 10:16:09 -0800210void GrDrawTarget::stencilPath(GrPipelineBuilder* pipelineBuilder,
joshualitt56995b52014-12-11 15:44:02 -0800211 const GrPathProcessor* pathProc,
joshualitt9853cce2014-11-17 14:22:48 -0800212 const GrPath* path,
213 GrPathRendering::FillType fill) {
bsalomon@google.com64aef2b2012-06-11 15:36:13 +0000214 // TODO: extract portions of checkDraw that are relevant to path stenciling.
bsalomon49f085d2014-09-05 13:34:00 -0700215 SkASSERT(path);
jvanverthe9c0fc62015-04-29 11:18:05 -0700216 SkASSERT(this->caps()->shaderCaps()->pathRenderingSupport());
egdaniel8dd688b2015-01-22 10:16:09 -0800217 SkASSERT(pipelineBuilder);
joshualitt2c93efe2014-11-06 12:57:13 -0800218
219 // Setup clip
bsalomon3e791242014-12-17 13:43:13 -0800220 GrScissorState scissorState;
bsalomon6be6f7c2015-02-26 13:05:21 -0800221 GrPipelineBuilder::AutoRestoreFragmentProcessors arfp;
egdaniel8dd688b2015-01-22 10:16:09 -0800222 GrPipelineBuilder::AutoRestoreStencil ars;
bsalomon6be6f7c2015-02-26 13:05:21 -0800223 if (!this->setupClip(pipelineBuilder, &arfp, &ars, &scissorState, NULL)) {
joshualitt2c93efe2014-11-06 12:57:13 -0800224 return;
225 }
226
227 // set stencil settings for path
228 GrStencilSettings stencilSettings;
bsalomon6bc1b5f2015-02-23 09:06:38 -0800229 GrRenderTarget* rt = pipelineBuilder->getRenderTarget();
egdaniel8dc7c3a2015-04-16 11:22:42 -0700230 GrStencilAttachment* sb = rt->renderTargetPriv().attachStencilAttachment();
bsalomon6bc1b5f2015-02-23 09:06:38 -0800231 this->getPathStencilSettingsForFilltype(fill, sb, &stencilSettings);
joshualitt2c93efe2014-11-06 12:57:13 -0800232
egdaniel8dd688b2015-01-22 10:16:09 -0800233 this->onStencilPath(*pipelineBuilder, pathProc, path, scissorState, stencilSettings);
bsalomon@google.com64aef2b2012-06-11 15:36:13 +0000234}
235
egdaniel8dd688b2015-01-22 10:16:09 -0800236void GrDrawTarget::drawPath(GrPipelineBuilder* pipelineBuilder,
joshualitt56995b52014-12-11 15:44:02 -0800237 const GrPathProcessor* pathProc,
joshualitt9853cce2014-11-17 14:22:48 -0800238 const GrPath* path,
239 GrPathRendering::FillType fill) {
commit-bot@chromium.orgc4dc0ad2013-10-09 14:11:33 +0000240 // TODO: extract portions of checkDraw that are relevant to path rendering.
bsalomon49f085d2014-09-05 13:34:00 -0700241 SkASSERT(path);
jvanverthe9c0fc62015-04-29 11:18:05 -0700242 SkASSERT(this->caps()->shaderCaps()->pathRenderingSupport());
egdaniel8dd688b2015-01-22 10:16:09 -0800243 SkASSERT(pipelineBuilder);
commit-bot@chromium.orgc4dc0ad2013-10-09 14:11:33 +0000244
joshualitt92e496f2014-10-31 13:56:50 -0700245 SkRect devBounds = path->getBounds();
joshualitt8059eb92014-12-29 15:10:07 -0800246 pathProc->viewMatrix().mapRect(&devBounds);
commit-bot@chromium.orgc4dc0ad2013-10-09 14:11:33 +0000247
joshualitt2c93efe2014-11-06 12:57:13 -0800248 // Setup clip
bsalomon3e791242014-12-17 13:43:13 -0800249 GrScissorState scissorState;
bsalomon6be6f7c2015-02-26 13:05:21 -0800250 GrPipelineBuilder::AutoRestoreFragmentProcessors arfp;
egdaniel8dd688b2015-01-22 10:16:09 -0800251 GrPipelineBuilder::AutoRestoreStencil ars;
bsalomon6be6f7c2015-02-26 13:05:21 -0800252 if (!this->setupClip(pipelineBuilder, &arfp, &ars, &scissorState, &devBounds)) {
joshualitt2c93efe2014-11-06 12:57:13 -0800253 return;
254 }
255
256 // set stencil settings for path
257 GrStencilSettings stencilSettings;
bsalomon6bc1b5f2015-02-23 09:06:38 -0800258 GrRenderTarget* rt = pipelineBuilder->getRenderTarget();
egdaniel8dc7c3a2015-04-16 11:22:42 -0700259 GrStencilAttachment* sb = rt->renderTargetPriv().attachStencilAttachment();
bsalomon6bc1b5f2015-02-23 09:06:38 -0800260 this->getPathStencilSettingsForFilltype(fill, sb, &stencilSettings);
joshualitt2c93efe2014-11-06 12:57:13 -0800261
egdaniele36914c2015-02-13 09:00:33 -0800262 GrDrawTarget::PipelineInfo pipelineInfo(pipelineBuilder, &scissorState, pathProc, &devBounds,
263 this);
264 if (pipelineInfo.mustSkipDraw()) {
265 return;
266 }
267
268 this->onDrawPath(pathProc, path, stencilSettings, pipelineInfo);
commit-bot@chromium.orgc4dc0ad2013-10-09 14:11:33 +0000269}
270
egdaniel8dd688b2015-01-22 10:16:09 -0800271void GrDrawTarget::drawPaths(GrPipelineBuilder* pipelineBuilder,
joshualitt56995b52014-12-11 15:44:02 -0800272 const GrPathProcessor* pathProc,
joshualitt9853cce2014-11-17 14:22:48 -0800273 const GrPathRange* pathRange,
cdalton55b24af2014-11-25 11:00:56 -0800274 const void* indices,
275 PathIndexType indexType,
276 const float transformValues[],
277 PathTransformType transformType,
joshualitt9853cce2014-11-17 14:22:48 -0800278 int count,
joshualitt92e496f2014-10-31 13:56:50 -0700279 GrPathRendering::FillType fill) {
jvanverthe9c0fc62015-04-29 11:18:05 -0700280 SkASSERT(this->caps()->shaderCaps()->pathRenderingSupport());
bsalomon49f085d2014-09-05 13:34:00 -0700281 SkASSERT(pathRange);
282 SkASSERT(indices);
cdalton55b24af2014-11-25 11:00:56 -0800283 SkASSERT(0 == reinterpret_cast<long>(indices) % GrPathRange::PathIndexSizeInBytes(indexType));
284 SkASSERT(transformValues);
egdaniel8dd688b2015-01-22 10:16:09 -0800285 SkASSERT(pipelineBuilder);
commit-bot@chromium.org9b62aa12014-03-25 11:59:40 +0000286
joshualitt2c93efe2014-11-06 12:57:13 -0800287 // Setup clip
bsalomon3e791242014-12-17 13:43:13 -0800288 GrScissorState scissorState;
bsalomon6be6f7c2015-02-26 13:05:21 -0800289 GrPipelineBuilder::AutoRestoreFragmentProcessors arfp;
egdaniel8dd688b2015-01-22 10:16:09 -0800290 GrPipelineBuilder::AutoRestoreStencil ars;
joshualitt2c93efe2014-11-06 12:57:13 -0800291
bsalomon6be6f7c2015-02-26 13:05:21 -0800292 if (!this->setupClip(pipelineBuilder, &arfp, &ars, &scissorState, NULL)) {
joshualitt2c93efe2014-11-06 12:57:13 -0800293 return;
294 }
295
296 // set stencil settings for path
297 GrStencilSettings stencilSettings;
bsalomon6bc1b5f2015-02-23 09:06:38 -0800298 GrRenderTarget* rt = pipelineBuilder->getRenderTarget();
egdaniel8dc7c3a2015-04-16 11:22:42 -0700299 GrStencilAttachment* sb = rt->renderTargetPriv().attachStencilAttachment();
bsalomon6bc1b5f2015-02-23 09:06:38 -0800300 this->getPathStencilSettingsForFilltype(fill, sb, &stencilSettings);
joshualitt2c93efe2014-11-06 12:57:13 -0800301
bsalomon50785a32015-02-06 07:02:37 -0800302 // Don't compute a bounding box for dst copy texture, we'll opt
cdaltonb85a0aa2014-07-21 15:32:44 -0700303 // instead for it to just copy the entire dst. Realistically this is a moot
304 // point, because any context that supports NV_path_rendering will also
305 // support NV_blend_equation_advanced.
egdaniele36914c2015-02-13 09:00:33 -0800306 GrDrawTarget::PipelineInfo pipelineInfo(pipelineBuilder, &scissorState, pathProc, NULL, this);
307 if (pipelineInfo.mustSkipDraw()) {
308 return;
309 }
310
311 this->onDrawPaths(pathProc, pathRange, indices, indexType, transformValues,
312 transformType, count, stencilSettings, pipelineInfo);
commit-bot@chromium.org9b62aa12014-03-25 11:59:40 +0000313}
314
joshualitt9853cce2014-11-17 14:22:48 -0800315void GrDrawTarget::clear(const SkIRect* rect,
316 GrColor color,
317 bool canIgnoreRect,
bsalomon63b21962014-11-05 07:05:34 -0800318 GrRenderTarget* renderTarget) {
319 if (fCaps->useDrawInsteadOfClear()) {
320 // This works around a driver bug with clear by drawing a rect instead.
321 // The driver will ignore a clear if it is the only thing rendered to a
322 // target before the target is read.
323 SkIRect rtRect = SkIRect::MakeWH(renderTarget->width(), renderTarget->height());
324 if (NULL == rect || canIgnoreRect || rect->contains(rtRect)) {
325 rect = &rtRect;
326 // We first issue a discard() since that may help tilers.
327 this->discard(renderTarget);
328 }
bsalomon63b21962014-11-05 07:05:34 -0800329
egdaniel8dd688b2015-01-22 10:16:09 -0800330 GrPipelineBuilder pipelineBuilder;
331 pipelineBuilder.setRenderTarget(renderTarget);
joshualitt9853cce2014-11-17 14:22:48 -0800332
egdaniel8dd688b2015-01-22 10:16:09 -0800333 this->drawSimpleRect(&pipelineBuilder, color, SkMatrix::I(), *rect);
bsalomon63b21962014-11-05 07:05:34 -0800334 } else {
335 this->onClear(rect, color, canIgnoreRect, renderTarget);
336 }
337}
338
egdaniel3eee3832014-06-18 13:09:11 -0700339typedef GrTraceMarkerSet::Iter TMIter;
340void GrDrawTarget::saveActiveTraceMarkers() {
341 if (this->caps()->gpuTracingSupport()) {
342 SkASSERT(0 == fStoredTraceMarkers.count());
343 fStoredTraceMarkers.addSet(fActiveTraceMarkers);
344 for (TMIter iter = fStoredTraceMarkers.begin(); iter != fStoredTraceMarkers.end(); ++iter) {
345 this->removeGpuTraceMarker(&(*iter));
346 }
347 }
348}
349
350void GrDrawTarget::restoreActiveTraceMarkers() {
351 if (this->caps()->gpuTracingSupport()) {
352 SkASSERT(0 == fActiveTraceMarkers.count());
353 for (TMIter iter = fStoredTraceMarkers.begin(); iter != fStoredTraceMarkers.end(); ++iter) {
354 this->addGpuTraceMarker(&(*iter));
355 }
356 for (TMIter iter = fActiveTraceMarkers.begin(); iter != fActiveTraceMarkers.end(); ++iter) {
357 this->fStoredTraceMarkers.remove(*iter);
358 }
359 }
360}
361
362void GrDrawTarget::addGpuTraceMarker(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 >= 0);
365 this->fActiveTraceMarkers.add(*marker);
commit-bot@chromium.org2a05de02014-03-25 15:17:32 +0000366 ++fGpuTraceMarkerCount;
commit-bot@chromium.orga3baf3b2014-02-21 18:45:30 +0000367 }
368}
369
egdaniel3eee3832014-06-18 13:09:11 -0700370void GrDrawTarget::removeGpuTraceMarker(const GrGpuTraceMarker* marker) {
commit-bot@chromium.orga3baf3b2014-02-21 18:45:30 +0000371 if (this->caps()->gpuTracingSupport()) {
commit-bot@chromium.org2a05de02014-03-25 15:17:32 +0000372 SkASSERT(fGpuTraceMarkerCount >= 1);
373 this->fActiveTraceMarkers.remove(*marker);
commit-bot@chromium.org2a05de02014-03-25 15:17:32 +0000374 --fGpuTraceMarkerCount;
commit-bot@chromium.orga3baf3b2014-02-21 18:45:30 +0000375 }
376}
377
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000378////////////////////////////////////////////////////////////////////////////////
bsalomon@google.com86afc2a2011-02-16 16:12:19 +0000379
bsalomon@google.com116ad842013-04-09 15:38:19 +0000380namespace {
381// returns true if the read/written rect intersects the src/dst and false if not.
382bool clip_srcrect_and_dstpoint(const GrSurface* dst,
383 const GrSurface* src,
bsalomon@google.come4617bf2013-04-03 14:56:40 +0000384 const SkIRect& srcRect,
bsalomon@google.com116ad842013-04-09 15:38:19 +0000385 const SkIPoint& dstPoint,
386 SkIRect* clippedSrcRect,
387 SkIPoint* clippedDstPoint) {
388 *clippedSrcRect = srcRect;
389 *clippedDstPoint = dstPoint;
skia.committer@gmail.coma9493a32013-04-04 07:01:12 +0000390
bsalomon@google.com116ad842013-04-09 15:38:19 +0000391 // clip the left edge to src and dst bounds, adjusting dstPoint if necessary
392 if (clippedSrcRect->fLeft < 0) {
393 clippedDstPoint->fX -= clippedSrcRect->fLeft;
394 clippedSrcRect->fLeft = 0;
bsalomon@google.come4617bf2013-04-03 14:56:40 +0000395 }
bsalomon@google.com116ad842013-04-09 15:38:19 +0000396 if (clippedDstPoint->fX < 0) {
397 clippedSrcRect->fLeft -= clippedDstPoint->fX;
398 clippedDstPoint->fX = 0;
bsalomon@google.come4617bf2013-04-03 14:56:40 +0000399 }
400
bsalomon@google.com116ad842013-04-09 15:38:19 +0000401 // clip the top edge to src and dst bounds, adjusting dstPoint if necessary
402 if (clippedSrcRect->fTop < 0) {
403 clippedDstPoint->fY -= clippedSrcRect->fTop;
404 clippedSrcRect->fTop = 0;
bsalomon@google.come4617bf2013-04-03 14:56:40 +0000405 }
bsalomon@google.com116ad842013-04-09 15:38:19 +0000406 if (clippedDstPoint->fY < 0) {
407 clippedSrcRect->fTop -= clippedDstPoint->fY;
408 clippedDstPoint->fY = 0;
bsalomon@google.come4617bf2013-04-03 14:56:40 +0000409 }
skia.committer@gmail.coma9493a32013-04-04 07:01:12 +0000410
bsalomon@google.come4617bf2013-04-03 14:56:40 +0000411 // clip the right edge to the src and dst bounds.
bsalomon@google.com116ad842013-04-09 15:38:19 +0000412 if (clippedSrcRect->fRight > src->width()) {
413 clippedSrcRect->fRight = src->width();
bsalomon@google.come4617bf2013-04-03 14:56:40 +0000414 }
bsalomon@google.com116ad842013-04-09 15:38:19 +0000415 if (clippedDstPoint->fX + clippedSrcRect->width() > dst->width()) {
416 clippedSrcRect->fRight = clippedSrcRect->fLeft + dst->width() - clippedDstPoint->fX;
bsalomon@google.come4617bf2013-04-03 14:56:40 +0000417 }
418
419 // clip the bottom edge to the src and dst bounds.
bsalomon@google.com116ad842013-04-09 15:38:19 +0000420 if (clippedSrcRect->fBottom > src->height()) {
421 clippedSrcRect->fBottom = src->height();
bsalomon@google.come4617bf2013-04-03 14:56:40 +0000422 }
bsalomon@google.com116ad842013-04-09 15:38:19 +0000423 if (clippedDstPoint->fY + clippedSrcRect->height() > dst->height()) {
424 clippedSrcRect->fBottom = clippedSrcRect->fTop + dst->height() - clippedDstPoint->fY;
bsalomon@google.come4617bf2013-04-03 14:56:40 +0000425 }
skia.committer@gmail.coma9493a32013-04-04 07:01:12 +0000426
bsalomon@google.come4617bf2013-04-03 14:56:40 +0000427 // The above clipping steps may have inverted the rect if it didn't intersect either the src or
428 // dst bounds.
bsalomon@google.com116ad842013-04-09 15:38:19 +0000429 return !clippedSrcRect->isEmpty();
430}
431}
432
433bool GrDrawTarget::copySurface(GrSurface* dst,
434 GrSurface* src,
435 const SkIRect& srcRect,
436 const SkIPoint& dstPoint) {
bsalomon49f085d2014-09-05 13:34:00 -0700437 SkASSERT(dst);
438 SkASSERT(src);
bsalomon@google.com116ad842013-04-09 15:38:19 +0000439
440 SkIRect clippedSrcRect;
441 SkIPoint clippedDstPoint;
442 // If the rect is outside the src or dst then we've already succeeded.
443 if (!clip_srcrect_and_dstpoint(dst,
444 src,
445 srcRect,
446 dstPoint,
447 &clippedSrcRect,
448 &clippedDstPoint)) {
bsalomon@google.come4617bf2013-04-03 14:56:40 +0000449 return true;
450 }
451
bsalomona73239a2015-04-28 13:35:17 -0700452 if (this->getGpu()->canCopySurface(dst, src, clippedSrcRect, clippedDstPoint)) {
453 this->onCopySurface(dst, src, clippedSrcRect, clippedDstPoint);
bsalomonf90a02b2014-11-26 12:28:00 -0800454 return true;
joshualitta7024152014-11-03 14:16:35 -0800455 }
456
457 GrRenderTarget* rt = dst->asRenderTarget();
458 GrTexture* tex = src->asTexture();
459
bsalomonf90a02b2014-11-26 12:28:00 -0800460 if ((dst == src) || !rt || !tex) {
461 return false;
462 }
463
egdaniel8dd688b2015-01-22 10:16:09 -0800464 GrPipelineBuilder pipelineBuilder;
465 pipelineBuilder.setRenderTarget(rt);
joshualitta7024152014-11-03 14:16:35 -0800466 SkMatrix matrix;
467 matrix.setTranslate(SkIntToScalar(clippedSrcRect.fLeft - clippedDstPoint.fX),
468 SkIntToScalar(clippedSrcRect.fTop - clippedDstPoint.fY));
469 matrix.postIDiv(tex->width(), tex->height());
egdaniel8dd688b2015-01-22 10:16:09 -0800470 pipelineBuilder.addColorTextureProcessor(tex, matrix);
joshualitta7024152014-11-03 14:16:35 -0800471 SkIRect dstRect = SkIRect::MakeXYWH(clippedDstPoint.fX,
472 clippedDstPoint.fY,
473 clippedSrcRect.width(),
474 clippedSrcRect.height());
egdaniel8dd688b2015-01-22 10:16:09 -0800475 this->drawSimpleRect(&pipelineBuilder, GrColor_WHITE, SkMatrix::I(), dstRect);
joshualitta7024152014-11-03 14:16:35 -0800476 return true;
bsalomon@google.come4617bf2013-04-03 14:56:40 +0000477}
478
joshualitt9853cce2014-11-17 14:22:48 -0800479bool GrDrawTarget::canCopySurface(const GrSurface* dst,
480 const GrSurface* src,
bsalomon@google.come4617bf2013-04-03 14:56:40 +0000481 const SkIRect& srcRect,
482 const SkIPoint& dstPoint) {
bsalomon49f085d2014-09-05 13:34:00 -0700483 SkASSERT(dst);
484 SkASSERT(src);
bsalomon@google.com116ad842013-04-09 15:38:19 +0000485
486 SkIRect clippedSrcRect;
487 SkIPoint clippedDstPoint;
488 // If the rect is outside the src or dst then we're guaranteed success
489 if (!clip_srcrect_and_dstpoint(dst,
490 src,
491 srcRect,
492 dstPoint,
493 &clippedSrcRect,
494 &clippedDstPoint)) {
495 return true;
496 }
bsalomonf90a02b2014-11-26 12:28:00 -0800497 return ((dst != src) && dst->asRenderTarget() && src->asTexture()) ||
bsalomona73239a2015-04-28 13:35:17 -0700498 this->getGpu()->canCopySurface(dst, src, clippedSrcRect, clippedDstPoint);
bsalomon@google.comeb851172013-04-15 13:51:00 +0000499}
500
egdaniele36914c2015-02-13 09:00:33 -0800501void GrDrawTarget::setupPipeline(const PipelineInfo& pipelineInfo,
502 GrPipeline* pipeline) {
503 SkNEW_PLACEMENT_ARGS(pipeline, GrPipeline, (*pipelineInfo.fPipelineBuilder,
504 pipelineInfo.fColorPOI,
505 pipelineInfo.fCoveragePOI,
506 *this->caps(),
507 *pipelineInfo.fScissor,
508 &pipelineInfo.fDstCopy));
509}
510///////////////////////////////////////////////////////////////////////////////
511
512GrDrawTarget::PipelineInfo::PipelineInfo(GrPipelineBuilder* pipelineBuilder,
513 GrScissorState* scissor,
514 const GrPrimitiveProcessor* primProc,
515 const SkRect* devBounds,
516 GrDrawTarget* target)
517 : fPipelineBuilder(pipelineBuilder)
518 , fScissor(scissor) {
519 fColorPOI = fPipelineBuilder->colorProcInfo(primProc);
520 fCoveragePOI = fPipelineBuilder->coverageProcInfo(primProc);
521 if (!target->setupDstReadIfNecessary(*fPipelineBuilder, fColorPOI, fCoveragePOI,
522 &fDstCopy, devBounds)) {
523 fPipelineBuilder = NULL;
524 }
525}
526
527GrDrawTarget::PipelineInfo::PipelineInfo(GrPipelineBuilder* pipelineBuilder,
528 GrScissorState* scissor,
529 const GrBatch* batch,
530 const SkRect* devBounds,
531 GrDrawTarget* target)
532 : fPipelineBuilder(pipelineBuilder)
533 , fScissor(scissor) {
534 fColorPOI = fPipelineBuilder->colorProcInfo(batch);
535 fCoveragePOI = fPipelineBuilder->coverageProcInfo(batch);
536 if (!target->setupDstReadIfNecessary(*fPipelineBuilder, fColorPOI, fCoveragePOI,
537 &fDstCopy, devBounds)) {
538 fPipelineBuilder = NULL;
539 }
540}
541
bsalomon@google.combcce8922013-03-25 15:38:39 +0000542///////////////////////////////////////////////////////////////////////////////
543
jvanverthe9c0fc62015-04-29 11:18:05 -0700544void GrShaderCaps::reset() {
545 fShaderDerivativeSupport = false;
546 fGeometryShaderSupport = false;
547 fPathRenderingSupport = false;
548 fDstReadInShaderSupport = false;
549 fDualSourceBlendingSupport = false;
550
551 fShaderPrecisionVaries = false;
552}
553
554GrShaderCaps& GrShaderCaps::operator=(const GrShaderCaps& other) {
555 fShaderDerivativeSupport = other.fShaderDerivativeSupport;
556 fGeometryShaderSupport = other.fGeometryShaderSupport;
557 fPathRenderingSupport = other.fPathRenderingSupport;
558 fDstReadInShaderSupport = other.fDstReadInShaderSupport;
559 fDualSourceBlendingSupport = other.fDualSourceBlendingSupport;
560
561 fShaderPrecisionVaries = other.fShaderPrecisionVaries;
562 for (int s = 0; s < kGrShaderTypeCount; ++s) {
563 for (int p = 0; p < kGrSLPrecisionCount; ++p) {
564 fFloatPrecisions[s][p] = other.fFloatPrecisions[s][p];
565 }
566 }
567 return *this;
568}
569
570static const char* shader_type_to_string(GrShaderType type) {
571 switch (type) {
572 case kVertex_GrShaderType:
573 return "vertex";
574 case kGeometry_GrShaderType:
575 return "geometry";
576 case kFragment_GrShaderType:
577 return "fragment";
578 }
579 return "";
580}
581
582static const char* precision_to_string(GrSLPrecision p) {
583 switch (p) {
584 case kLow_GrSLPrecision:
585 return "low";
586 case kMedium_GrSLPrecision:
587 return "medium";
588 case kHigh_GrSLPrecision:
589 return "high";
590 }
591 return "";
592}
593
594SkString GrShaderCaps::dump() const {
595 SkString r;
596 static const char* gNY[] = { "NO", "YES" };
597 r.appendf("Shader Derivative Support : %s\n", gNY[fShaderDerivativeSupport]);
598 r.appendf("Geometry Shader Support : %s\n", gNY[fGeometryShaderSupport]);
599 r.appendf("Path Rendering Support : %s\n", gNY[fPathRenderingSupport]);
600 r.appendf("Dst Read In Shader Support : %s\n", gNY[fDstReadInShaderSupport]);
601 r.appendf("Dual Source Blending Support : %s\n", gNY[fDualSourceBlendingSupport]);
602
603 r.appendf("Shader Float Precisions (varies: %s):\n", gNY[fShaderPrecisionVaries]);
604
605 for (int s = 0; s < kGrShaderTypeCount; ++s) {
606 GrShaderType shaderType = static_cast<GrShaderType>(s);
607 r.appendf("\t%s:\n", shader_type_to_string(shaderType));
608 for (int p = 0; p < kGrSLPrecisionCount; ++p) {
609 if (fFloatPrecisions[s][p].supported()) {
610 GrSLPrecision precision = static_cast<GrSLPrecision>(p);
611 r.appendf("\t\t%s: log_low: %d log_high: %d bits: %d\n",
612 precision_to_string(precision),
613 fFloatPrecisions[s][p].fLogRangeLow,
614 fFloatPrecisions[s][p].fLogRangeHigh,
615 fFloatPrecisions[s][p].fBits);
616 }
617 }
618 }
619
620 return r;
621}
622
623///////////////////////////////////////////////////////////////////////////////
624
bsalomon@google.comc26d94f2013-03-25 18:19:00 +0000625void GrDrawTargetCaps::reset() {
commit-bot@chromium.org47442312013-12-19 16:18:01 +0000626 fMipMapSupport = false;
bsalomon@google.combcce8922013-03-25 15:38:39 +0000627 fNPOTTextureTileSupport = false;
628 fTwoSidedStencilSupport = false;
629 fStencilWrapOpsSupport = false;
commit-bot@chromium.org28361fa2014-03-28 16:08:05 +0000630 fDiscardRenderTargetSupport = false;
commit-bot@chromium.orgb8356522013-07-18 22:26:39 +0000631 fReuseScratchTextures = true;
commit-bot@chromium.orga3baf3b2014-02-21 18:45:30 +0000632 fGpuTracingSupport = false;
krajcevski786978162014-07-30 11:25:44 -0700633 fCompressedTexSubImageSupport = false;
bsalomond08ea5f2015-02-20 06:58:13 -0800634 fOversizedStencilSupport = false;
cdaltonfd4167d2015-04-21 11:45:56 -0700635 fTextureBarrierSupport = false;
bsalomon@google.combcce8922013-03-25 15:38:39 +0000636
bsalomon63b21962014-11-05 07:05:34 -0800637 fUseDrawInsteadOfClear = false;
638
commit-bot@chromium.org160b4782014-05-05 12:32:37 +0000639 fMapBufferFlags = kNone_MapFlags;
640
bsalomon@google.combcce8922013-03-25 15:38:39 +0000641 fMaxRenderTargetSize = 0;
642 fMaxTextureSize = 0;
643 fMaxSampleCount = 0;
commit-bot@chromium.org73880512013-10-14 15:33:45 +0000644
645 memset(fConfigRenderSupport, 0, sizeof(fConfigRenderSupport));
commit-bot@chromium.org6e7ddaa2014-05-30 13:55:58 +0000646 memset(fConfigTextureSupport, 0, sizeof(fConfigTextureSupport));
bsalomon@google.combcce8922013-03-25 15:38:39 +0000647}
648
bsalomon@google.comc26d94f2013-03-25 18:19:00 +0000649GrDrawTargetCaps& GrDrawTargetCaps::operator=(const GrDrawTargetCaps& other) {
commit-bot@chromium.org47442312013-12-19 16:18:01 +0000650 fMipMapSupport = other.fMipMapSupport;
bsalomon@google.combcce8922013-03-25 15:38:39 +0000651 fNPOTTextureTileSupport = other.fNPOTTextureTileSupport;
652 fTwoSidedStencilSupport = other.fTwoSidedStencilSupport;
653 fStencilWrapOpsSupport = other.fStencilWrapOpsSupport;
commit-bot@chromium.org28361fa2014-03-28 16:08:05 +0000654 fDiscardRenderTargetSupport = other.fDiscardRenderTargetSupport;
commit-bot@chromium.orgb8356522013-07-18 22:26:39 +0000655 fReuseScratchTextures = other.fReuseScratchTextures;
commit-bot@chromium.orga3baf3b2014-02-21 18:45:30 +0000656 fGpuTracingSupport = other.fGpuTracingSupport;
krajcevski786978162014-07-30 11:25:44 -0700657 fCompressedTexSubImageSupport = other.fCompressedTexSubImageSupport;
bsalomond08ea5f2015-02-20 06:58:13 -0800658 fOversizedStencilSupport = other.fOversizedStencilSupport;
cdaltonfd4167d2015-04-21 11:45:56 -0700659 fTextureBarrierSupport = other.fTextureBarrierSupport;
bsalomon@google.combcce8922013-03-25 15:38:39 +0000660
bsalomon63b21962014-11-05 07:05:34 -0800661 fUseDrawInsteadOfClear = other.fUseDrawInsteadOfClear;
662
commit-bot@chromium.org160b4782014-05-05 12:32:37 +0000663 fMapBufferFlags = other.fMapBufferFlags;
664
bsalomon@google.combcce8922013-03-25 15:38:39 +0000665 fMaxRenderTargetSize = other.fMaxRenderTargetSize;
666 fMaxTextureSize = other.fMaxTextureSize;
667 fMaxSampleCount = other.fMaxSampleCount;
668
commit-bot@chromium.org73880512013-10-14 15:33:45 +0000669 memcpy(fConfigRenderSupport, other.fConfigRenderSupport, sizeof(fConfigRenderSupport));
commit-bot@chromium.org6e7ddaa2014-05-30 13:55:58 +0000670 memcpy(fConfigTextureSupport, other.fConfigTextureSupport, sizeof(fConfigTextureSupport));
commit-bot@chromium.org73880512013-10-14 15:33:45 +0000671
bsalomon@google.combcce8922013-03-25 15:38:39 +0000672 return *this;
673}
674
commit-bot@chromium.org160b4782014-05-05 12:32:37 +0000675static SkString map_flags_to_string(uint32_t flags) {
676 SkString str;
677 if (GrDrawTargetCaps::kNone_MapFlags == flags) {
678 str = "none";
679 } else {
680 SkASSERT(GrDrawTargetCaps::kCanMap_MapFlag & flags);
681 SkDEBUGCODE(flags &= ~GrDrawTargetCaps::kCanMap_MapFlag);
682 str = "can_map";
683
684 if (GrDrawTargetCaps::kSubset_MapFlag & flags) {
685 str.append(" partial");
686 } else {
687 str.append(" full");
688 }
689 SkDEBUGCODE(flags &= ~GrDrawTargetCaps::kSubset_MapFlag);
690 }
691 SkASSERT(0 == flags); // Make sure we handled all the flags.
692 return str;
693}
694
commit-bot@chromium.org8b656c62013-11-21 15:23:15 +0000695SkString GrDrawTargetCaps::dump() const {
696 SkString r;
bsalomon@google.com18c9c192011-09-22 21:01:31 +0000697 static const char* gNY[] = {"NO", "YES"};
bsalomon63b21962014-11-05 07:05:34 -0800698 r.appendf("MIP Map Support : %s\n", gNY[fMipMapSupport]);
699 r.appendf("NPOT Texture Tile Support : %s\n", gNY[fNPOTTextureTileSupport]);
700 r.appendf("Two Sided Stencil Support : %s\n", gNY[fTwoSidedStencilSupport]);
701 r.appendf("Stencil Wrap Ops Support : %s\n", gNY[fStencilWrapOpsSupport]);
bsalomon63b21962014-11-05 07:05:34 -0800702 r.appendf("Discard Render Target Support : %s\n", gNY[fDiscardRenderTargetSupport]);
703 r.appendf("Reuse Scratch Textures : %s\n", gNY[fReuseScratchTextures]);
704 r.appendf("Gpu Tracing Support : %s\n", gNY[fGpuTracingSupport]);
705 r.appendf("Compressed Update Support : %s\n", gNY[fCompressedTexSubImageSupport]);
bsalomond08ea5f2015-02-20 06:58:13 -0800706 r.appendf("Oversized Stencil Support : %s\n", gNY[fOversizedStencilSupport]);
cdaltonfd4167d2015-04-21 11:45:56 -0700707 r.appendf("Texture Barrier Support : %s\n", gNY[fTextureBarrierSupport]);
bsalomon63b21962014-11-05 07:05:34 -0800708 r.appendf("Draw Instead of Clear [workaround] : %s\n", gNY[fUseDrawInsteadOfClear]);
709
710 r.appendf("Max Texture Size : %d\n", fMaxTextureSize);
711 r.appendf("Max Render Target Size : %d\n", fMaxRenderTargetSize);
712 r.appendf("Max Sample Count : %d\n", fMaxSampleCount);
713
714 r.appendf("Map Buffer Support : %s\n",
715 map_flags_to_string(fMapBufferFlags).c_str());
commit-bot@chromium.org160b4782014-05-05 12:32:37 +0000716
commit-bot@chromium.org73880512013-10-14 15:33:45 +0000717 static const char* kConfigNames[] = {
718 "Unknown", // kUnknown_GrPixelConfig
719 "Alpha8", // kAlpha_8_GrPixelConfig,
720 "Index8", // kIndex_8_GrPixelConfig,
721 "RGB565", // kRGB_565_GrPixelConfig,
722 "RGBA444", // kRGBA_4444_GrPixelConfig,
723 "RGBA8888", // kRGBA_8888_GrPixelConfig,
724 "BGRA8888", // kBGRA_8888_GrPixelConfig,
jvanverthfa1e8a72014-12-22 08:31:49 -0800725 "SRGBA8888",// kSRGBA_8888_GrPixelConfig,
commit-bot@chromium.org6e7ddaa2014-05-30 13:55:58 +0000726 "ETC1", // kETC1_GrPixelConfig,
727 "LATC", // kLATC_GrPixelConfig,
krajcevski238b4562014-06-30 09:09:22 -0700728 "R11EAC", // kR11_EAC_GrPixelConfig,
krajcevski7ef21622014-07-16 15:21:13 -0700729 "ASTC12x12",// kASTC_12x12_GrPixelConfig,
jvanverth28f9c602014-12-05 13:06:35 -0800730 "RGBAFloat",// kRGBA_float_GrPixelConfig
731 "AlphaHalf",// kAlpha_half_GrPixelConfig
commit-bot@chromium.org73880512013-10-14 15:33:45 +0000732 };
krajcevski7ef21622014-07-16 15:21:13 -0700733 GR_STATIC_ASSERT(0 == kUnknown_GrPixelConfig);
734 GR_STATIC_ASSERT(1 == kAlpha_8_GrPixelConfig);
735 GR_STATIC_ASSERT(2 == kIndex_8_GrPixelConfig);
736 GR_STATIC_ASSERT(3 == kRGB_565_GrPixelConfig);
737 GR_STATIC_ASSERT(4 == kRGBA_4444_GrPixelConfig);
738 GR_STATIC_ASSERT(5 == kRGBA_8888_GrPixelConfig);
739 GR_STATIC_ASSERT(6 == kBGRA_8888_GrPixelConfig);
jvanverthfa1e8a72014-12-22 08:31:49 -0800740 GR_STATIC_ASSERT(7 == kSRGBA_8888_GrPixelConfig);
741 GR_STATIC_ASSERT(8 == kETC1_GrPixelConfig);
742 GR_STATIC_ASSERT(9 == kLATC_GrPixelConfig);
743 GR_STATIC_ASSERT(10 == kR11_EAC_GrPixelConfig);
744 GR_STATIC_ASSERT(11 == kASTC_12x12_GrPixelConfig);
745 GR_STATIC_ASSERT(12 == kRGBA_float_GrPixelConfig);
746 GR_STATIC_ASSERT(13 == kAlpha_half_GrPixelConfig);
commit-bot@chromium.org73880512013-10-14 15:33:45 +0000747 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kConfigNames) == kGrPixelConfigCnt);
748
commit-bot@chromium.org99017272013-11-08 18:45:27 +0000749 SkASSERT(!fConfigRenderSupport[kUnknown_GrPixelConfig][0]);
750 SkASSERT(!fConfigRenderSupport[kUnknown_GrPixelConfig][1]);
commit-bot@chromium.org6e7ddaa2014-05-30 13:55:58 +0000751
752 for (size_t i = 1; i < SK_ARRAY_COUNT(kConfigNames); ++i) {
753 r.appendf("%s is renderable: %s, with MSAA: %s\n",
754 kConfigNames[i],
755 gNY[fConfigRenderSupport[i][0]],
756 gNY[fConfigRenderSupport[i][1]]);
commit-bot@chromium.org73880512013-10-14 15:33:45 +0000757 }
commit-bot@chromium.org42dc8132014-05-27 19:26:59 +0000758
commit-bot@chromium.org6e7ddaa2014-05-30 13:55:58 +0000759 SkASSERT(!fConfigTextureSupport[kUnknown_GrPixelConfig]);
commit-bot@chromium.org42dc8132014-05-27 19:26:59 +0000760
commit-bot@chromium.org6e7ddaa2014-05-30 13:55:58 +0000761 for (size_t i = 1; i < SK_ARRAY_COUNT(kConfigNames); ++i) {
762 r.appendf("%s is uploadable to a texture: %s\n",
763 kConfigNames[i],
764 gNY[fConfigTextureSupport[i]]);
commit-bot@chromium.org42dc8132014-05-27 19:26:59 +0000765 }
766
commit-bot@chromium.org8b656c62013-11-21 15:23:15 +0000767 return r;
bsalomon@google.com18c9c192011-09-22 21:01:31 +0000768}
egdanielbc127a32014-09-19 12:07:43 -0700769
joshualitt2c93efe2014-11-06 12:57:13 -0800770///////////////////////////////////////////////////////////////////////////////////////////////////
771
egdaniel8dd688b2015-01-22 10:16:09 -0800772bool GrClipTarget::setupClip(GrPipelineBuilder* pipelineBuilder,
bsalomon6be6f7c2015-02-26 13:05:21 -0800773 GrPipelineBuilder::AutoRestoreFragmentProcessors* arfp,
egdaniel8dd688b2015-01-22 10:16:09 -0800774 GrPipelineBuilder::AutoRestoreStencil* ars,
joshualitt8059eb92014-12-29 15:10:07 -0800775 GrScissorState* scissorState,
776 const SkRect* devBounds) {
egdaniel8dd688b2015-01-22 10:16:09 -0800777 return fClipMaskManager.setupClipping(pipelineBuilder,
bsalomon6be6f7c2015-02-26 13:05:21 -0800778 arfp,
joshualitt2c93efe2014-11-06 12:57:13 -0800779 ars,
joshualitt9853cce2014-11-17 14:22:48 -0800780 scissorState,
joshualitt9853cce2014-11-17 14:22:48 -0800781 devBounds);
joshualitt2c93efe2014-11-06 12:57:13 -0800782}