OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2010 Google Inc. | 2 * Copyright 2010 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 | 8 |
9 #include "GrGpu.h" | 9 #include "GrGpu.h" |
10 | 10 |
| 11 #include "GrBuffer.h" |
11 #include "GrCaps.h" | 12 #include "GrCaps.h" |
12 #include "GrContext.h" | 13 #include "GrContext.h" |
13 #include "GrGpuResourcePriv.h" | 14 #include "GrGpuResourcePriv.h" |
14 #include "GrIndexBuffer.h" | |
15 #include "GrMesh.h" | 15 #include "GrMesh.h" |
16 #include "GrPathRendering.h" | 16 #include "GrPathRendering.h" |
17 #include "GrPipeline.h" | 17 #include "GrPipeline.h" |
18 #include "GrResourceCache.h" | 18 #include "GrResourceCache.h" |
19 #include "GrResourceProvider.h" | 19 #include "GrResourceProvider.h" |
20 #include "GrRenderTargetPriv.h" | 20 #include "GrRenderTargetPriv.h" |
21 #include "GrStencilAttachment.h" | 21 #include "GrStencilAttachment.h" |
22 #include "GrSurfacePriv.h" | 22 #include "GrSurfacePriv.h" |
23 #include "GrTransferBuffer.h" | |
24 #include "GrVertexBuffer.h" | |
25 #include "SkTypes.h" | 23 #include "SkTypes.h" |
26 | 24 |
27 GrMesh& GrMesh::operator =(const GrMesh& di) { | 25 GrMesh& GrMesh::operator =(const GrMesh& di) { |
28 fPrimitiveType = di.fPrimitiveType; | 26 fPrimitiveType = di.fPrimitiveType; |
29 fStartVertex = di.fStartVertex; | 27 fStartVertex = di.fStartVertex; |
30 fStartIndex = di.fStartIndex; | 28 fStartIndex = di.fStartIndex; |
31 fVertexCount = di.fVertexCount; | 29 fVertexCount = di.fVertexCount; |
32 fIndexCount = di.fIndexCount; | 30 fIndexCount = di.fIndexCount; |
33 | 31 |
34 fInstanceCount = di.fInstanceCount; | 32 fInstanceCount = di.fInstanceCount; |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 if (!this->caps()->isConfigRenderable(desc.fConfig, desc.fSampleCnt > 0)) { | 229 if (!this->caps()->isConfigRenderable(desc.fConfig, desc.fSampleCnt > 0)) { |
232 return nullptr; | 230 return nullptr; |
233 } | 231 } |
234 int maxSize = this->caps()->maxTextureSize(); | 232 int maxSize = this->caps()->maxTextureSize(); |
235 if (desc.fWidth > maxSize || desc.fHeight > maxSize) { | 233 if (desc.fWidth > maxSize || desc.fHeight > maxSize) { |
236 return nullptr; | 234 return nullptr; |
237 } | 235 } |
238 return this->onWrapBackendTextureAsRenderTarget(desc, ownership); | 236 return this->onWrapBackendTextureAsRenderTarget(desc, ownership); |
239 } | 237 } |
240 | 238 |
241 GrVertexBuffer* GrGpu::createVertexBuffer(size_t size, bool dynamic) { | 239 GrBuffer* GrGpu::createBuffer(GrBufferType type, size_t size, GrAccessPattern ac
cessPattern) { |
242 this->handleDirtyContext(); | 240 this->handleDirtyContext(); |
243 GrVertexBuffer* vb = this->onCreateVertexBuffer(size, dynamic); | 241 GrBuffer* buffer = this->onCreateBuffer(type, size, accessPattern); |
244 if (!this->caps()->reuseScratchBuffers()) { | 242 if (!this->caps()->reuseScratchBuffers()) { |
245 vb->resourcePriv().removeScratchKey(); | 243 buffer->resourcePriv().removeScratchKey(); |
246 } | 244 } |
247 return vb; | 245 return buffer; |
248 } | |
249 | |
250 GrIndexBuffer* GrGpu::createIndexBuffer(size_t size, bool dynamic) { | |
251 this->handleDirtyContext(); | |
252 GrIndexBuffer* ib = this->onCreateIndexBuffer(size, dynamic); | |
253 if (!this->caps()->reuseScratchBuffers()) { | |
254 ib->resourcePriv().removeScratchKey(); | |
255 } | |
256 return ib; | |
257 } | |
258 | |
259 GrTransferBuffer* GrGpu::createTransferBuffer(size_t size, TransferType type) { | |
260 this->handleDirtyContext(); | |
261 GrTransferBuffer* tb = this->onCreateTransferBuffer(size, type); | |
262 return tb; | |
263 } | 246 } |
264 | 247 |
265 void GrGpu::clear(const SkIRect& rect, | 248 void GrGpu::clear(const SkIRect& rect, |
266 GrColor color, | 249 GrColor color, |
267 GrRenderTarget* renderTarget) { | 250 GrRenderTarget* renderTarget) { |
268 SkASSERT(renderTarget); | 251 SkASSERT(renderTarget); |
269 SkASSERT(SkIRect::MakeWH(renderTarget->width(), renderTarget->height()).cont
ains(rect)); | 252 SkASSERT(SkIRect::MakeWH(renderTarget->width(), renderTarget->height()).cont
ains(rect)); |
270 this->handleDirtyContext(); | 253 this->handleDirtyContext(); |
271 this->onClear(renderTarget, rect, color); | 254 this->onClear(renderTarget, rect, color); |
272 } | 255 } |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
409 mipLevel.fPixels = buffer; | 392 mipLevel.fPixels = buffer; |
410 mipLevel.fRowBytes = rowBytes; | 393 mipLevel.fRowBytes = rowBytes; |
411 SkSTArray<1, GrMipLevel> texels; | 394 SkSTArray<1, GrMipLevel> texels; |
412 texels.push_back(mipLevel); | 395 texels.push_back(mipLevel); |
413 | 396 |
414 return this->writePixels(surface, left, top, width, height, config, texels); | 397 return this->writePixels(surface, left, top, width, height, config, texels); |
415 } | 398 } |
416 | 399 |
417 bool GrGpu::transferPixels(GrSurface* surface, | 400 bool GrGpu::transferPixels(GrSurface* surface, |
418 int left, int top, int width, int height, | 401 int left, int top, int width, int height, |
419 GrPixelConfig config, GrTransferBuffer* buffer, | 402 GrPixelConfig config, GrBuffer* transferBuffer, |
420 size_t offset, size_t rowBytes) { | 403 size_t offset, size_t rowBytes) { |
421 SkASSERT(buffer); | 404 SkASSERT(transferBuffer); |
422 | 405 |
423 this->handleDirtyContext(); | 406 this->handleDirtyContext(); |
424 if (this->onTransferPixels(surface, left, top, width, height, config, | 407 if (this->onTransferPixels(surface, left, top, width, height, config, |
425 buffer, offset, rowBytes)) { | 408 transferBuffer, offset, rowBytes)) { |
426 fStats.incTransfersToTexture(); | 409 fStats.incTransfersToTexture(); |
427 return true; | 410 return true; |
428 } | 411 } |
429 return false; | 412 return false; |
430 } | 413 } |
431 | 414 |
432 void GrGpu::resolveRenderTarget(GrRenderTarget* target) { | 415 void GrGpu::resolveRenderTarget(GrRenderTarget* target) { |
433 SkASSERT(target); | 416 SkASSERT(target); |
434 this->handleDirtyContext(); | 417 this->handleDirtyContext(); |
435 this->onResolveRenderTarget(target); | 418 this->onResolveRenderTarget(target); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
499 if (primProc.numAttribs() > this->caps()->maxVertexAttributes()) { | 482 if (primProc.numAttribs() > this->caps()->maxVertexAttributes()) { |
500 fStats.incNumFailedDraws(); | 483 fStats.incNumFailedDraws(); |
501 return false; | 484 return false; |
502 } | 485 } |
503 this->handleDirtyContext(); | 486 this->handleDirtyContext(); |
504 | 487 |
505 this->onDraw(pipeline, primProc, meshes, meshCount); | 488 this->onDraw(pipeline, primProc, meshes, meshCount); |
506 return true; | 489 return true; |
507 } | 490 } |
508 | 491 |
OLD | NEW |