blob: 8548e54a17121588eaddef0d57a0abe1796ed1e7 [file] [log] [blame]
reed@google.comac10a2d2010-12-22 21:39:39 +00001/*
epoger@google.comec3ed6a2011-07-28 14:26:00 +00002 * Copyright 2010 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
reed@google.comac10a2d2010-12-22 21:39:39 +00006 */
7
epoger@google.comec3ed6a2011-07-28 14:26:00 +00008
reed@google.comac10a2d2010-12-22 21:39:39 +00009#include "GrGpu.h"
bsalomon@google.com558a75b2011-08-08 17:01:14 +000010
bsalomoneb1cb5c2015-05-22 08:01:09 -070011#include "GrCaps.h"
bsalomon@google.com558a75b2011-08-08 17:01:14 +000012#include "GrContext.h"
bsalomon3582d3e2015-02-13 14:20:05 -080013#include "GrGpuResourcePriv.h"
reed@google.comac10a2d2010-12-22 21:39:39 +000014#include "GrIndexBuffer.h"
kkinnunencabe20c2015-06-01 01:37:26 -070015#include "GrPathRendering.h"
bsalomoncb02b382015-08-12 11:14:50 -070016#include "GrPipeline.h"
bsalomon0ea80f42015-02-11 10:49:59 -080017#include "GrResourceCache.h"
egdanielec00d942015-09-14 12:56:10 -070018#include "GrResourceProvider.h"
bsalomon6bc1b5f2015-02-23 09:06:38 -080019#include "GrRenderTargetPriv.h"
egdaniel8dc7c3a2015-04-16 11:22:42 -070020#include "GrStencilAttachment.h"
egdaniel6d901da2015-07-30 12:02:15 -070021#include "GrSurfacePriv.h"
jvanverth73063dc2015-12-03 09:15:47 -080022#include "GrTransferBuffer.h"
bsalomon@google.com81c3f8d2011-08-03 15:18:33 +000023#include "GrVertexBuffer.h"
bsalomoncb8979d2015-05-05 09:51:38 -070024#include "GrVertices.h"
25
26GrVertices& GrVertices::operator =(const GrVertices& di) {
27 fPrimitiveType = di.fPrimitiveType;
28 fStartVertex = di.fStartVertex;
29 fStartIndex = di.fStartIndex;
30 fVertexCount = di.fVertexCount;
31 fIndexCount = di.fIndexCount;
32
33 fInstanceCount = di.fInstanceCount;
34 fVerticesPerInstance = di.fVerticesPerInstance;
35 fIndicesPerInstance = di.fIndicesPerInstance;
bsalomone64eb572015-05-07 11:35:55 -070036 fMaxInstancesPerDraw = di.fMaxInstancesPerDraw;
bsalomoncb8979d2015-05-05 09:51:38 -070037
38 fVertexBuffer.reset(di.vertexBuffer());
39 fIndexBuffer.reset(di.indexBuffer());
40
41 return *this;
42}
bsalomon@google.com1c13c962011-02-14 16:51:21 +000043
bsalomon@google.comd302f142011-03-03 13:54:13 +000044////////////////////////////////////////////////////////////////////////////////
reed@google.comac10a2d2010-12-22 21:39:39 +000045
bsalomon@google.com6e4e6502013-02-25 20:12:45 +000046GrGpu::GrGpu(GrContext* context)
joshualitt3322fa42014-11-07 08:48:51 -080047 : fResetTimestamp(kExpiredTimestamp+1)
bsalomon@google.com0a208a12013-06-28 18:57:35 +000048 , fResetBits(kAll_GrBackendState)
joshualitt3322fa42014-11-07 08:48:51 -080049 , fContext(context) {
reed@google.comac10a2d2010-12-22 21:39:39 +000050}
51
bsalomoned0bcad2015-05-04 10:36:42 -070052GrGpu::~GrGpu() {}
bsalomon1d89ddc2014-08-19 14:20:58 -070053
robertphillipse3371302014-09-17 06:01:06 -070054void GrGpu::contextAbandoned() {}
reed@google.comac10a2d2010-12-22 21:39:39 +000055
bsalomon@google.comd302f142011-03-03 13:54:13 +000056////////////////////////////////////////////////////////////////////////////////
reed@google.comac10a2d2010-12-22 21:39:39 +000057
bsalomon045802d2015-10-20 07:58:01 -070058bool GrGpu::makeCopyForTextureParams(int width, int height, const GrTextureParams& textureParams,
bsalomon89fe56b2015-10-29 10:49:28 -070059 GrTextureProducer::CopyParams* copyParams) const {
bsalomon045802d2015-10-20 07:58:01 -070060 const GrCaps& caps = *this->caps();
61 if (textureParams.isTiled() && !caps.npotTextureTileSupport() &&
62 (!SkIsPow2(width) || !SkIsPow2(height))) {
bsalomon100b8f82015-10-28 08:37:44 -070063 copyParams->fWidth = GrNextPow2(width);
64 copyParams->fHeight = GrNextPow2(height);
bsalomon045802d2015-10-20 07:58:01 -070065 switch (textureParams.filterMode()) {
66 case GrTextureParams::kNone_FilterMode:
67 copyParams->fFilter = GrTextureParams::kNone_FilterMode;
68 break;
69 case GrTextureParams::kBilerp_FilterMode:
70 case GrTextureParams::kMipMap_FilterMode:
71 // We are only ever scaling up so no reason to ever indicate kMipMap.
72 copyParams->fFilter = GrTextureParams::kBilerp_FilterMode;
73 break;
74 }
bsalomon100b8f82015-10-28 08:37:44 -070075 return true;
bsalomon045802d2015-10-20 07:58:01 -070076 }
bsalomon100b8f82015-10-28 08:37:44 -070077 return false;
bsalomon045802d2015-10-20 07:58:01 -070078}
79
egdanielcf614fd2015-04-22 13:58:58 -070080static GrSurfaceOrigin resolve_origin(GrSurfaceOrigin origin, bool renderTarget) {
egdanielb0e1be22015-04-22 13:27:39 -070081 // By default, GrRenderTargets are GL's normal orientation so that they
82 // can be drawn to by the outside world without the client having
83 // to render upside down.
84 if (kDefault_GrSurfaceOrigin == origin) {
85 return renderTarget ? kBottomLeft_GrSurfaceOrigin : kTopLeft_GrSurfaceOrigin;
86 } else {
87 return origin;
88 }
89}
90
bsalomon5ec26ae2016-02-25 08:33:02 -080091GrTexture* GrGpu::createTexture(const GrSurfaceDesc& origDesc, SkBudgeted budgeted,
bsalomon@google.coma7f84e12011-03-10 14:13:19 +000092 const void* srcData, size_t rowBytes) {
egdanielb0e1be22015-04-22 13:27:39 -070093 GrSurfaceDesc desc = origDesc;
94
krajcevski9c0e6292014-06-02 07:38:14 -070095 if (!this->caps()->isConfigTexturable(desc.fConfig)) {
halcanary96fcdcc2015-08-27 07:41:13 -070096 return nullptr;
robertphillips@google.comd3eb3362012-10-31 13:56:35 +000097 }
krajcevski9c0e6292014-06-02 07:38:14 -070098
bsalomondb558dd2015-01-23 13:19:00 -080099 bool isRT = SkToBool(desc.fFlags & kRenderTarget_GrSurfaceFlag);
100 if (isRT && !this->caps()->isConfigRenderable(desc.fConfig, desc.fSampleCnt > 0)) {
halcanary96fcdcc2015-08-27 07:41:13 -0700101 return nullptr;
commit-bot@chromium.org6b7938f2013-10-15 14:18:16 +0000102 }
robertphillips@google.comd3eb3362012-10-31 13:56:35 +0000103
robertphillips6e83ac72015-08-13 05:19:14 -0700104 // We currently do not support multisampled textures
egdaniel8c9b6f12015-05-12 13:36:30 -0700105 if (!isRT && desc.fSampleCnt > 0) {
halcanary96fcdcc2015-08-27 07:41:13 -0700106 return nullptr;
egdaniel8c9b6f12015-05-12 13:36:30 -0700107 }
108
halcanary96fcdcc2015-08-27 07:41:13 -0700109 GrTexture *tex = nullptr;
egdanielb0e1be22015-04-22 13:27:39 -0700110
111 if (isRT) {
112 int maxRTSize = this->caps()->maxRenderTargetSize();
113 if (desc.fWidth > maxRTSize || desc.fHeight > maxRTSize) {
halcanary96fcdcc2015-08-27 07:41:13 -0700114 return nullptr;
egdanielb0e1be22015-04-22 13:27:39 -0700115 }
116 } else {
117 int maxSize = this->caps()->maxTextureSize();
118 if (desc.fWidth > maxSize || desc.fHeight > maxSize) {
halcanary96fcdcc2015-08-27 07:41:13 -0700119 return nullptr;
egdanielb0e1be22015-04-22 13:27:39 -0700120 }
121 }
122
bsalomon5ec26ae2016-02-25 08:33:02 -0800123 GrGpuResource::LifeCycle lifeCycle = SkBudgeted::kYes == budgeted ?
124 GrGpuResource::kCached_LifeCycle :
125 GrGpuResource::kUncached_LifeCycle;
egdanielb0e1be22015-04-22 13:27:39 -0700126
127 desc.fSampleCnt = SkTMin(desc.fSampleCnt, this->caps()->maxSampleCount());
128 // Attempt to catch un- or wrongly initialized sample counts;
129 SkASSERT(desc.fSampleCnt >= 0 && desc.fSampleCnt <= 64);
130
131 desc.fOrigin = resolve_origin(desc.fOrigin, isRT);
132
krajcevski9c0e6292014-06-02 07:38:14 -0700133 if (GrPixelConfigIsCompressed(desc.fConfig)) {
134 // We shouldn't be rendering into this
egdanielb0e1be22015-04-22 13:27:39 -0700135 SkASSERT(!isRT);
136 SkASSERT(0 == desc.fSampleCnt);
krajcevski9c0e6292014-06-02 07:38:14 -0700137
138 if (!this->caps()->npotTextureTileSupport() &&
tfarinaf9dae782014-06-06 06:35:28 -0700139 (!SkIsPow2(desc.fWidth) || !SkIsPow2(desc.fHeight))) {
halcanary96fcdcc2015-08-27 07:41:13 -0700140 return nullptr;
bsalomon@google.com81c3f8d2011-08-03 15:18:33 +0000141 }
tfarinaf9dae782014-06-06 06:35:28 -0700142
krajcevski9c0e6292014-06-02 07:38:14 -0700143 this->handleDirtyContext();
egdanielb0e1be22015-04-22 13:27:39 -0700144 tex = this->onCreateCompressedTexture(desc, lifeCycle, srcData);
krajcevski9c0e6292014-06-02 07:38:14 -0700145 } else {
146 this->handleDirtyContext();
egdanielb0e1be22015-04-22 13:27:39 -0700147 tex = this->onCreateTexture(desc, lifeCycle, srcData, rowBytes);
bsalomon@google.com81c3f8d2011-08-03 15:18:33 +0000148 }
bsalomondb558dd2015-01-23 13:19:00 -0800149 if (!this->caps()->reuseScratchTextures() && !isRT) {
bsalomon3582d3e2015-02-13 14:20:05 -0800150 tex->resourcePriv().removeScratchKey();
bsalomondb558dd2015-01-23 13:19:00 -0800151 }
bsalomonb12ea412015-02-02 21:19:50 -0800152 if (tex) {
153 fStats.incTextureCreates();
154 if (srcData) {
155 fStats.incTextureUploads();
156 }
157 }
bsalomon@google.com81c3f8d2011-08-03 15:18:33 +0000158 return tex;
159}
160
bsalomon6dc6f5f2015-06-18 09:12:16 -0700161GrTexture* GrGpu::wrapBackendTexture(const GrBackendTextureDesc& desc, GrWrapOwnership ownership) {
bsalomon@google.come269f212011-11-07 13:29:52 +0000162 this->handleDirtyContext();
bsalomon5b30c6f2015-12-17 14:17:34 -0800163 if (!this->caps()->isConfigTexturable(desc.fConfig)) {
164 return nullptr;
165 }
166 if ((desc.fFlags & kRenderTarget_GrBackendTextureFlag) &&
167 !this->caps()->isConfigRenderable(desc.fConfig, desc.fSampleCnt > 0)) {
168 return nullptr;
169 }
ericrkf7b8b8a2016-02-24 14:49:51 -0800170 int maxSize = this->caps()->maxTextureSize();
171 if (desc.fWidth > maxSize || desc.fHeight > maxSize) {
172 return nullptr;
173 }
bsalomon6dc6f5f2015-06-18 09:12:16 -0700174 GrTexture* tex = this->onWrapBackendTexture(desc, ownership);
halcanary96fcdcc2015-08-27 07:41:13 -0700175 if (nullptr == tex) {
176 return nullptr;
bsalomon@google.coma14dd6d2012-01-03 21:08:12 +0000177 }
bsalomon@google.come269f212011-11-07 13:29:52 +0000178 // TODO: defer this and attach dynamically
179 GrRenderTarget* tgt = tex->asRenderTarget();
egdanielec00d942015-09-14 12:56:10 -0700180 if (tgt && !fContext->resourceProvider()->attachStencilAttachment(tgt)) {
bsalomon@google.come269f212011-11-07 13:29:52 +0000181 tex->unref();
halcanary96fcdcc2015-08-27 07:41:13 -0700182 return nullptr;
bsalomon@google.come269f212011-11-07 13:29:52 +0000183 } else {
184 return tex;
185 }
186}
187
bsalomon6dc6f5f2015-06-18 09:12:16 -0700188GrRenderTarget* GrGpu::wrapBackendRenderTarget(const GrBackendRenderTargetDesc& desc,
189 GrWrapOwnership ownership) {
bsalomon5b30c6f2015-12-17 14:17:34 -0800190 if (!this->caps()->isConfigRenderable(desc.fConfig, desc.fSampleCnt > 0)) {
191 return nullptr;
192 }
bsalomon@google.come269f212011-11-07 13:29:52 +0000193 this->handleDirtyContext();
bsalomon6dc6f5f2015-06-18 09:12:16 -0700194 return this->onWrapBackendRenderTarget(desc, ownership);
bsalomon@google.come269f212011-11-07 13:29:52 +0000195}
196
ericrkf7b8b8a2016-02-24 14:49:51 -0800197GrRenderTarget* GrGpu::wrapBackendTextureAsRenderTarget(const GrBackendTextureDesc& desc,
198 GrWrapOwnership ownership) {
199 this->handleDirtyContext();
200 if (!(desc.fFlags & kRenderTarget_GrBackendTextureFlag)) {
201 return nullptr;
202 }
203 if (!this->caps()->isConfigRenderable(desc.fConfig, desc.fSampleCnt > 0)) {
204 return nullptr;
205 }
206 int maxSize = this->caps()->maxTextureSize();
207 if (desc.fWidth > maxSize || desc.fHeight > maxSize) {
208 return nullptr;
209 }
210 return this->onWrapBackendTextureAsRenderTarget(desc, ownership);
211}
212
robertphillips@google.comadacc702013-10-14 21:53:24 +0000213GrVertexBuffer* GrGpu::createVertexBuffer(size_t size, bool dynamic) {
bsalomon@google.coma7f84e12011-03-10 14:13:19 +0000214 this->handleDirtyContext();
robertphillips1b8e1b52015-06-24 06:54:10 -0700215 GrVertexBuffer* vb = this->onCreateVertexBuffer(size, dynamic);
216 if (!this->caps()->reuseScratchBuffers()) {
217 vb->resourcePriv().removeScratchKey();
218 }
219 return vb;
bsalomon@google.coma7f84e12011-03-10 14:13:19 +0000220}
221
robertphillips@google.comadacc702013-10-14 21:53:24 +0000222GrIndexBuffer* GrGpu::createIndexBuffer(size_t size, bool dynamic) {
bsalomon@google.coma7f84e12011-03-10 14:13:19 +0000223 this->handleDirtyContext();
robertphillips1b8e1b52015-06-24 06:54:10 -0700224 GrIndexBuffer* ib = this->onCreateIndexBuffer(size, dynamic);
225 if (!this->caps()->reuseScratchBuffers()) {
226 ib->resourcePriv().removeScratchKey();
227 }
228 return ib;
bsalomon@google.coma7f84e12011-03-10 14:13:19 +0000229}
230
jvanverth73063dc2015-12-03 09:15:47 -0800231GrTransferBuffer* GrGpu::createTransferBuffer(size_t size, TransferType type) {
232 this->handleDirtyContext();
233 GrTransferBuffer* tb = this->onCreateTransferBuffer(size, type);
234 return tb;
235}
236
egdaniel51c8d402015-08-06 10:54:13 -0700237void GrGpu::clear(const SkIRect& rect,
joshualitt3322fa42014-11-07 08:48:51 -0800238 GrColor color,
joshualitt3322fa42014-11-07 08:48:51 -0800239 GrRenderTarget* renderTarget) {
bsalomon89c62982014-11-03 12:08:42 -0800240 SkASSERT(renderTarget);
egdaniel51c8d402015-08-06 10:54:13 -0700241 SkASSERT(SkIRect::MakeWH(renderTarget->width(), renderTarget->height()).contains(rect));
bsalomon@google.coma7f84e12011-03-10 14:13:19 +0000242 this->handleDirtyContext();
egdaniel51c8d402015-08-06 10:54:13 -0700243 this->onClear(renderTarget, rect, color);
bsalomon@google.coma7f84e12011-03-10 14:13:19 +0000244}
245
joshualitt6db519c2014-10-29 08:48:18 -0700246void GrGpu::clearStencilClip(const SkIRect& rect,
247 bool insideClip,
248 GrRenderTarget* renderTarget) {
joshualittd53a8272014-11-10 16:03:14 -0800249 SkASSERT(renderTarget);
joshualitt6db519c2014-10-29 08:48:18 -0700250 this->handleDirtyContext();
251 this->onClearStencilClip(renderTarget, rect, insideClip);
252}
253
joshualitt1cbdcde2015-08-21 11:53:29 -0700254bool GrGpu::copySurface(GrSurface* dst,
255 GrSurface* src,
256 const SkIRect& srcRect,
257 const SkIPoint& dstPoint) {
258 SkASSERT(dst && src);
259 this->handleDirtyContext();
260 return this->onCopySurface(dst, src, srcRect, dstPoint);
261}
262
bsalomonf0674512015-07-28 13:26:15 -0700263bool GrGpu::getReadPixelsInfo(GrSurface* srcSurface, int width, int height, size_t rowBytes,
264 GrPixelConfig readConfig, DrawPreference* drawPreference,
265 ReadPixelTempDrawInfo* tempDrawInfo) {
266 SkASSERT(drawPreference);
267 SkASSERT(tempDrawInfo);
268 SkASSERT(kGpuPrefersDraw_DrawPreference != *drawPreference);
269
egdaniel6d901da2015-07-30 12:02:15 -0700270 // We currently do not support reading into a compressed buffer
271 if (GrPixelConfigIsCompressed(readConfig)) {
272 return false;
273 }
274
bsalomonf0674512015-07-28 13:26:15 -0700275 if (!this->onGetReadPixelsInfo(srcSurface, width, height, rowBytes, readConfig, drawPreference,
276 tempDrawInfo)) {
277 return false;
278 }
279
280 // Check to see if we're going to request that the caller draw when drawing is not possible.
281 if (!srcSurface->asTexture() ||
282 !this->caps()->isConfigRenderable(tempDrawInfo->fTempSurfaceDesc.fConfig, false)) {
283 // If we don't have a fallback to a straight read then fail.
284 if (kRequireDraw_DrawPreference == *drawPreference) {
285 return false;
286 }
287 *drawPreference = kNoDraw_DrawPreference;
288 }
289
290 return true;
291}
cblumeed828002016-02-16 13:00:01 -0800292bool GrGpu::getWritePixelsInfo(GrSurface* dstSurface, int width, int height,
bsalomonf0674512015-07-28 13:26:15 -0700293 GrPixelConfig srcConfig, DrawPreference* drawPreference,
294 WritePixelTempDrawInfo* tempDrawInfo) {
295 SkASSERT(drawPreference);
296 SkASSERT(tempDrawInfo);
297 SkASSERT(kGpuPrefersDraw_DrawPreference != *drawPreference);
298
jvanverth2dc29942015-09-01 07:16:46 -0700299 if (GrPixelConfigIsCompressed(dstSurface->desc().fConfig) &&
300 dstSurface->desc().fConfig != srcConfig) {
301 return false;
302 }
303
bsalomonbabafcc2016-02-16 11:36:47 -0800304 if (SkToBool(dstSurface->asRenderTarget())) {
305 if (this->caps()->useDrawInsteadOfAllRenderTargetWrites()) {
306 ElevateDrawPreference(drawPreference, kRequireDraw_DrawPreference);
307 } else if (this->caps()->useDrawInsteadOfPartialRenderTargetWrite() &&
308 (width < dstSurface->width() || height < dstSurface->height())) {
309 ElevateDrawPreference(drawPreference, kRequireDraw_DrawPreference);
310 }
bsalomonf0674512015-07-28 13:26:15 -0700311 }
312
cblumeed828002016-02-16 13:00:01 -0800313 if (!this->onGetWritePixelsInfo(dstSurface, width, height, srcConfig, drawPreference,
bsalomonf0674512015-07-28 13:26:15 -0700314 tempDrawInfo)) {
315 return false;
316 }
317
318 // Check to see if we're going to request that the caller draw when drawing is not possible.
319 if (!dstSurface->asRenderTarget() ||
320 !this->caps()->isConfigTexturable(tempDrawInfo->fTempSurfaceDesc.fConfig)) {
321 // If we don't have a fallback to a straight upload then fail.
322 if (kRequireDraw_DrawPreference == *drawPreference ||
323 !this->caps()->isConfigTexturable(srcConfig)) {
324 return false;
325 }
326 *drawPreference = kNoDraw_DrawPreference;
327 }
328 return true;
329}
330
bsalomon6cb3cbe2015-07-30 07:34:27 -0700331bool GrGpu::readPixels(GrSurface* surface,
bsalomon@google.com669fdc42011-04-05 17:08:27 +0000332 int left, int top, int width, int height,
bsalomon@google.comc6980972011-11-02 19:57:21 +0000333 GrPixelConfig config, void* buffer,
senorblanco@chromium.org3cb406b2013-02-05 19:50:46 +0000334 size_t rowBytes) {
bsalomon@google.coma7f84e12011-03-10 14:13:19 +0000335 this->handleDirtyContext();
egdaniel6d901da2015-07-30 12:02:15 -0700336
337 // We cannot read pixels into a compressed buffer
338 if (GrPixelConfigIsCompressed(config)) {
339 return false;
340 }
341
342 size_t bpp = GrBytesPerPixel(config);
343 if (!GrSurfacePriv::AdjustReadPixelParams(surface->width(), surface->height(), bpp,
344 &left, &top, &width, &height,
345 &buffer,
346 &rowBytes)) {
347 return false;
348 }
349
350 return this->onReadPixels(surface,
351 left, top, width, height,
352 config, buffer,
353 rowBytes);
bsalomon@google.coma7f84e12011-03-10 14:13:19 +0000354}
355
bsalomon6cb3cbe2015-07-30 07:34:27 -0700356bool GrGpu::writePixels(GrSurface* surface,
357 int left, int top, int width, int height,
358 GrPixelConfig config, const void* buffer,
359 size_t rowBytes) {
jvanverth17aa0472016-01-05 10:41:27 -0800360 if (!buffer || !surface) {
jvanverth2dc29942015-09-01 07:16:46 -0700361 return false;
362 }
363
bsalomon@google.com6f379512011-11-16 20:36:03 +0000364 this->handleDirtyContext();
bsalomon6cb3cbe2015-07-30 07:34:27 -0700365 if (this->onWritePixels(surface, left, top, width, height, config, buffer, rowBytes)) {
bsalomonb12ea412015-02-02 21:19:50 -0800366 fStats.incTextureUploads();
367 return true;
368 }
369 return false;
bsalomon@google.com6f379512011-11-16 20:36:03 +0000370}
371
jvanverth17aa0472016-01-05 10:41:27 -0800372bool GrGpu::transferPixels(GrSurface* surface,
373 int left, int top, int width, int height,
374 GrPixelConfig config, GrTransferBuffer* buffer,
375 size_t offset, size_t rowBytes) {
376 SkASSERT(buffer);
377
378 this->handleDirtyContext();
cblume61214052016-01-26 09:10:48 -0800379 if (this->onTransferPixels(surface, left, top, width, height, config,
jvanverth17aa0472016-01-05 10:41:27 -0800380 buffer, offset, rowBytes)) {
381 fStats.incTransfersToTexture();
382 return true;
383 }
384 return false;
385}
386
bsalomon@google.com75f9f252012-01-31 13:35:56 +0000387void GrGpu::resolveRenderTarget(GrRenderTarget* target) {
tfarina@chromium.orgf6de4752013-08-17 00:02:59 +0000388 SkASSERT(target);
bsalomon@google.com75f9f252012-01-31 13:35:56 +0000389 this->handleDirtyContext();
390 this->onResolveRenderTarget(target);
391}
392
bsalomon@google.coma7f84e12011-03-10 14:13:19 +0000393////////////////////////////////////////////////////////////////////////////////
394
bsalomoncb8979d2015-05-05 09:51:38 -0700395void GrGpu::draw(const DrawArgs& args, const GrVertices& vertices) {
bsalomon@google.coma7f84e12011-03-10 14:13:19 +0000396 this->handleDirtyContext();
bsalomoncb02b382015-08-12 11:14:50 -0700397 if (GrXferBarrierType barrierType = args.fPipeline->xferBarrierType(*this->caps())) {
398 this->xferBarrier(args.fPipeline->getRenderTarget(), barrierType);
399 }
400
bsalomone64eb572015-05-07 11:35:55 -0700401 GrVertices::Iterator iter;
402 const GrNonInstancedVertices* verts = iter.init(vertices);
403 do {
404 this->onDraw(args, *verts);
joshualitt336cda32015-09-09 08:29:47 -0700405 fStats.incNumDraws();
bsalomone64eb572015-05-07 11:35:55 -0700406 } while ((verts = iter.next()));
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000407}
ethannicholas22793252016-01-30 09:59:10 -0800408