Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(390)

Side by Side Diff: src/gpu/gl/GrGLGpu.cpp

Issue 1316233002: Style Change: NULL->nullptr (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-08-27 (Thursday) 10:25:06 EDT Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/gl/GrGLGpu.h ('k') | src/gpu/gl/GrGLGpuProgramCache.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 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 "GrGLGpu.h" 9 #include "GrGLGpu.h"
10 #include "GrGLGLSL.h" 10 #include "GrGLGLSL.h"
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 GrGpu* GrGLGpu::Create(GrBackendContext backendContext, const GrContextOptions& options, 162 GrGpu* GrGLGpu::Create(GrBackendContext backendContext, const GrContextOptions& options,
163 GrContext* context) { 163 GrContext* context) {
164 SkAutoTUnref<const GrGLInterface> glInterface( 164 SkAutoTUnref<const GrGLInterface> glInterface(
165 reinterpret_cast<const GrGLInterface*>(backendContext)); 165 reinterpret_cast<const GrGLInterface*>(backendContext));
166 if (!glInterface) { 166 if (!glInterface) {
167 glInterface.reset(GrGLDefaultInterface()); 167 glInterface.reset(GrGLDefaultInterface());
168 } else { 168 } else {
169 glInterface->ref(); 169 glInterface->ref();
170 } 170 }
171 if (!glInterface) { 171 if (!glInterface) {
172 return NULL; 172 return nullptr;
173 } 173 }
174 GrGLContext* glContext = GrGLContext::Create(glInterface, options); 174 GrGLContext* glContext = GrGLContext::Create(glInterface, options);
175 if (glContext) { 175 if (glContext) {
176 return new GrGLGpu(glContext, context); 176 return new GrGLGpu(glContext, context);
177 } 177 }
178 return NULL; 178 return nullptr;
179 } 179 }
180 180
181 static bool gPrintStartupSpew; 181 static bool gPrintStartupSpew;
182 182
183 GrGLGpu::GrGLGpu(GrGLContext* ctx, GrContext* context) 183 GrGLGpu::GrGLGpu(GrGLContext* ctx, GrContext* context)
184 : GrGpu(context) 184 : GrGpu(context)
185 , fGLContext(ctx) { 185 , fGLContext(ctx) {
186 SkASSERT(ctx); 186 SkASSERT(ctx);
187 fCaps.reset(SkRef(ctx->caps())); 187 fCaps.reset(SkRef(ctx->caps()));
188 188
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 // to render upside down. 391 // to render upside down.
392 if (kDefault_GrSurfaceOrigin == origin) { 392 if (kDefault_GrSurfaceOrigin == origin) {
393 return renderTarget ? kBottomLeft_GrSurfaceOrigin : kTopLeft_GrSurfaceOr igin; 393 return renderTarget ? kBottomLeft_GrSurfaceOrigin : kTopLeft_GrSurfaceOr igin;
394 } else { 394 } else {
395 return origin; 395 return origin;
396 } 396 }
397 } 397 }
398 398
399 GrTexture* GrGLGpu::onWrapBackendTexture(const GrBackendTextureDesc& desc, 399 GrTexture* GrGLGpu::onWrapBackendTexture(const GrBackendTextureDesc& desc,
400 GrWrapOwnership ownership) { 400 GrWrapOwnership ownership) {
401 if (!this->configToGLFormats(desc.fConfig, false, NULL, NULL, NULL)) { 401 if (!this->configToGLFormats(desc.fConfig, false, nullptr, nullptr, nullptr) ) {
402 return NULL; 402 return nullptr;
403 } 403 }
404 404
405 if (0 == desc.fTextureHandle) { 405 if (0 == desc.fTextureHandle) {
406 return NULL; 406 return nullptr;
407 } 407 }
408 408
409 int maxSize = this->caps()->maxTextureSize(); 409 int maxSize = this->caps()->maxTextureSize();
410 if (desc.fWidth > maxSize || desc.fHeight > maxSize) { 410 if (desc.fWidth > maxSize || desc.fHeight > maxSize) {
411 return NULL; 411 return nullptr;
412 } 412 }
413 413
414 GrGLTexture::IDDesc idDesc; 414 GrGLTexture::IDDesc idDesc;
415 GrSurfaceDesc surfDesc; 415 GrSurfaceDesc surfDesc;
416 416
417 idDesc.fTextureID = static_cast<GrGLuint>(desc.fTextureHandle); 417 idDesc.fTextureID = static_cast<GrGLuint>(desc.fTextureHandle);
418 418
419 switch (ownership) { 419 switch (ownership) {
420 case kAdopt_GrWrapOwnership: 420 case kAdopt_GrWrapOwnership:
421 idDesc.fLifeCycle = GrGpuResource::kAdopted_LifeCycle; 421 idDesc.fLifeCycle = GrGpuResource::kAdopted_LifeCycle;
(...skipping 13 matching lines...) Expand all
435 // FIXME: this should be calling resolve_origin(), but Chrome code is curre ntly 435 // FIXME: this should be calling resolve_origin(), but Chrome code is curre ntly
436 // assuming the old behaviour, which is that backend textures are always 436 // assuming the old behaviour, which is that backend textures are always
437 // BottomLeft, even for non-RT's. Once Chrome is fixed, change this to: 437 // BottomLeft, even for non-RT's. Once Chrome is fixed, change this to:
438 // glTexDesc.fOrigin = resolve_origin(desc.fOrigin, renderTarget); 438 // glTexDesc.fOrigin = resolve_origin(desc.fOrigin, renderTarget);
439 if (kDefault_GrSurfaceOrigin == desc.fOrigin) { 439 if (kDefault_GrSurfaceOrigin == desc.fOrigin) {
440 surfDesc.fOrigin = kBottomLeft_GrSurfaceOrigin; 440 surfDesc.fOrigin = kBottomLeft_GrSurfaceOrigin;
441 } else { 441 } else {
442 surfDesc.fOrigin = desc.fOrigin; 442 surfDesc.fOrigin = desc.fOrigin;
443 } 443 }
444 444
445 GrGLTexture* texture = NULL; 445 GrGLTexture* texture = nullptr;
446 if (renderTarget) { 446 if (renderTarget) {
447 GrGLRenderTarget::IDDesc rtIDDesc; 447 GrGLRenderTarget::IDDesc rtIDDesc;
448 if (!this->createRenderTargetObjects(surfDesc, GrGpuResource::kUncached_ LifeCycle, 448 if (!this->createRenderTargetObjects(surfDesc, GrGpuResource::kUncached_ LifeCycle,
449 idDesc.fTextureID, &rtIDDesc)) { 449 idDesc.fTextureID, &rtIDDesc)) {
450 return NULL; 450 return nullptr;
451 } 451 }
452 texture = new GrGLTextureRenderTarget(this, surfDesc, idDesc, rtIDDesc); 452 texture = new GrGLTextureRenderTarget(this, surfDesc, idDesc, rtIDDesc);
453 } else { 453 } else {
454 texture = new GrGLTexture(this, surfDesc, idDesc); 454 texture = new GrGLTexture(this, surfDesc, idDesc);
455 } 455 }
456 if (NULL == texture) { 456 if (nullptr == texture) {
457 return NULL; 457 return nullptr;
458 } 458 }
459 459
460 return texture; 460 return texture;
461 } 461 }
462 462
463 GrRenderTarget* GrGLGpu::onWrapBackendRenderTarget(const GrBackendRenderTargetDe sc& wrapDesc, 463 GrRenderTarget* GrGLGpu::onWrapBackendRenderTarget(const GrBackendRenderTargetDe sc& wrapDesc,
464 GrWrapOwnership ownership) { 464 GrWrapOwnership ownership) {
465 GrGLRenderTarget::IDDesc idDesc; 465 GrGLRenderTarget::IDDesc idDesc;
466 idDesc.fRTFBOID = static_cast<GrGLuint>(wrapDesc.fRenderTargetHandle); 466 idDesc.fRTFBOID = static_cast<GrGLuint>(wrapDesc.fRenderTargetHandle);
467 idDesc.fMSColorRenderbufferID = 0; 467 idDesc.fMSColorRenderbufferID = 0;
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 ElevateDrawPreference(drawPreference, kGpuPrefersDraw_DrawPreference); 557 ElevateDrawPreference(drawPreference, kGpuPrefersDraw_DrawPreference);
558 } 558 }
559 559
560 return true; 560 return true;
561 } 561 }
562 562
563 bool GrGLGpu::onWritePixels(GrSurface* surface, 563 bool GrGLGpu::onWritePixels(GrSurface* surface,
564 int left, int top, int width, int height, 564 int left, int top, int width, int height,
565 GrPixelConfig config, const void* buffer, 565 GrPixelConfig config, const void* buffer,
566 size_t rowBytes) { 566 size_t rowBytes) {
567 if (NULL == buffer) { 567 if (nullptr == buffer) {
568 return false; 568 return false;
569 } 569 }
570 570
571 GrGLTexture* glTex = static_cast<GrGLTexture*>(surface->asTexture()); 571 GrGLTexture* glTex = static_cast<GrGLTexture*>(surface->asTexture());
572 if (!glTex) { 572 if (!glTex) {
573 return false; 573 return false;
574 } 574 }
575 575
576 // OpenGL doesn't do sRGB <-> linear conversions when reading and writing pi xels. 576 // OpenGL doesn't do sRGB <-> linear conversions when reading and writing pi xels.
577 if (GrPixelConfigIsSRGB(surface->config()) != GrPixelConfigIsSRGB(config)) { 577 if (GrPixelConfigIsSRGB(surface->config()) != GrPixelConfigIsSRGB(config)) {
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
806 SkASSERT(height <= desc.fHeight); 806 SkASSERT(height <= desc.fHeight);
807 } 807 }
808 #endif 808 #endif
809 809
810 // Make sure that the width and height that we pass to OpenGL 810 // Make sure that the width and height that we pass to OpenGL
811 // is a multiple of the block size. 811 // is a multiple of the block size.
812 size_t dataSize = GrCompressedFormatDataSize(desc.fConfig, width, height); 812 size_t dataSize = GrCompressedFormatDataSize(desc.fConfig, width, height);
813 813
814 // We only need the internal format for compressed 2D textures. 814 // We only need the internal format for compressed 2D textures.
815 GrGLenum internalFormat = 0; 815 GrGLenum internalFormat = 0;
816 if (!this->configToGLFormats(desc.fConfig, false, &internalFormat, NULL, NUL L)) { 816 if (!this->configToGLFormats(desc.fConfig, false, &internalFormat, nullptr, nullptr)) {
817 return false; 817 return false;
818 } 818 }
819 819
820 if (isNewTexture) { 820 if (isNewTexture) {
821 CLEAR_ERROR_BEFORE_ALLOC(this->glInterface()); 821 CLEAR_ERROR_BEFORE_ALLOC(this->glInterface());
822 GL_ALLOC_CALL(this->glInterface(), 822 GL_ALLOC_CALL(this->glInterface(),
823 CompressedTexImage2D(GR_GL_TEXTURE_2D, 823 CompressedTexImage2D(GR_GL_TEXTURE_2D,
824 0, // level 824 0, // level
825 internalFormat, 825 internalFormat,
826 width, height, 826 width, height,
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
919 // rendered from. 919 // rendered from.
920 if (desc.fSampleCnt > 0 && this->glCaps().usesMSAARenderBuffers()) { 920 if (desc.fSampleCnt > 0 && this->glCaps().usesMSAARenderBuffers()) {
921 GL_CALL(GenFramebuffers(1, &idDesc->fRTFBOID)); 921 GL_CALL(GenFramebuffers(1, &idDesc->fRTFBOID));
922 GL_CALL(GenRenderbuffers(1, &idDesc->fMSColorRenderbufferID)); 922 GL_CALL(GenRenderbuffers(1, &idDesc->fMSColorRenderbufferID));
923 if (!idDesc->fRTFBOID || 923 if (!idDesc->fRTFBOID ||
924 !idDesc->fMSColorRenderbufferID || 924 !idDesc->fMSColorRenderbufferID ||
925 !this->configToGLFormats(desc.fConfig, 925 !this->configToGLFormats(desc.fConfig,
926 // ES2 and ES3 require sized internal forma ts for rb storage. 926 // ES2 and ES3 require sized internal forma ts for rb storage.
927 kGLES_GrGLStandard == this->glStandard(), 927 kGLES_GrGLStandard == this->glStandard(),
928 &msColorFormat, 928 &msColorFormat,
929 NULL, 929 nullptr,
930 NULL)) { 930 nullptr)) {
931 goto FAILED; 931 goto FAILED;
932 } 932 }
933 } else { 933 } else {
934 idDesc->fRTFBOID = idDesc->fTexFBOID; 934 idDesc->fRTFBOID = idDesc->fTexFBOID;
935 } 935 }
936 936
937 // below here we may bind the FBO 937 // below here we may bind the FBO
938 fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID; 938 fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID;
939 if (idDesc->fRTFBOID != idDesc->fTexFBOID) { 939 if (idDesc->fRTFBOID != idDesc->fTexFBOID) {
940 SkASSERT(desc.fSampleCnt > 0); 940 SkASSERT(desc.fSampleCnt > 0);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
994 } 994 }
995 if (idDesc->fTexFBOID) { 995 if (idDesc->fTexFBOID) {
996 GL_CALL(DeleteFramebuffers(1, &idDesc->fTexFBOID)); 996 GL_CALL(DeleteFramebuffers(1, &idDesc->fTexFBOID));
997 } 997 }
998 return false; 998 return false;
999 } 999 }
1000 1000
1001 // good to set a break-point here to know when createTexture fails 1001 // good to set a break-point here to know when createTexture fails
1002 static GrTexture* return_null_texture() { 1002 static GrTexture* return_null_texture() {
1003 // SkDEBUGFAIL("null texture"); 1003 // SkDEBUGFAIL("null texture");
1004 return NULL; 1004 return nullptr;
1005 } 1005 }
1006 1006
1007 #if 0 && defined(SK_DEBUG) 1007 #if 0 && defined(SK_DEBUG)
1008 static size_t as_size_t(int x) { 1008 static size_t as_size_t(int x) {
1009 return x; 1009 return x;
1010 } 1010 }
1011 #endif 1011 #endif
1012 1012
1013 GrTexture* GrGLGpu::onCreateTexture(const GrSurfaceDesc& desc, 1013 GrTexture* GrGLGpu::onCreateTexture(const GrSurfaceDesc& desc,
1014 GrGpuResource::LifeCycle lifeCycle, 1014 GrGpuResource::LifeCycle lifeCycle,
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
1287 } 1287 }
1288 GL_CALL(DeleteRenderbuffers(1, &sbDesc.fRenderbufferID)); 1288 GL_CALL(DeleteRenderbuffers(1, &sbDesc.fRenderbufferID));
1289 return false; 1289 return false;
1290 } 1290 }
1291 1291
1292 bool GrGLGpu::attachStencilAttachmentToRenderTarget(GrStencilAttachment* sb, GrR enderTarget* rt) { 1292 bool GrGLGpu::attachStencilAttachmentToRenderTarget(GrStencilAttachment* sb, GrR enderTarget* rt) {
1293 GrGLRenderTarget* glrt = static_cast<GrGLRenderTarget*>(rt); 1293 GrGLRenderTarget* glrt = static_cast<GrGLRenderTarget*>(rt);
1294 1294
1295 GrGLuint fbo = glrt->renderFBOID(); 1295 GrGLuint fbo = glrt->renderFBOID();
1296 1296
1297 if (NULL == sb) { 1297 if (nullptr == sb) {
1298 if (rt->renderTargetPriv().getStencilAttachment()) { 1298 if (rt->renderTargetPriv().getStencilAttachment()) {
1299 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, 1299 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
1300 GR_GL_STENCIL_ATTACHMENT, 1300 GR_GL_STENCIL_ATTACHMENT,
1301 GR_GL_RENDERBUFFER, 0)); 1301 GR_GL_RENDERBUFFER, 0));
1302 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, 1302 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
1303 GR_GL_DEPTH_ATTACHMENT, 1303 GR_GL_DEPTH_ATTACHMENT,
1304 GR_GL_RENDERBUFFER, 0)); 1304 GR_GL_RENDERBUFFER, 0));
1305 #ifdef SK_DEBUG 1305 #ifdef SK_DEBUG
1306 GrGLenum status; 1306 GrGLenum status;
1307 GL_CALL_RET(status, CheckFramebufferStatus(GR_GL_FRAMEBUFFER)); 1307 GL_CALL_RET(status, CheckFramebufferStatus(GR_GL_FRAMEBUFFER));
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1365 return vertexBuffer; 1365 return vertexBuffer;
1366 } else { 1366 } else {
1367 GL_CALL(GenBuffers(1, &desc.fID)); 1367 GL_CALL(GenBuffers(1, &desc.fID));
1368 if (desc.fID) { 1368 if (desc.fID) {
1369 fHWGeometryState.setVertexBufferID(this, desc.fID); 1369 fHWGeometryState.setVertexBufferID(this, desc.fID);
1370 CLEAR_ERROR_BEFORE_ALLOC(this->glInterface()); 1370 CLEAR_ERROR_BEFORE_ALLOC(this->glInterface());
1371 // make sure driver can allocate memory for this buffer 1371 // make sure driver can allocate memory for this buffer
1372 GL_ALLOC_CALL(this->glInterface(), 1372 GL_ALLOC_CALL(this->glInterface(),
1373 BufferData(GR_GL_ARRAY_BUFFER, 1373 BufferData(GR_GL_ARRAY_BUFFER,
1374 (GrGLsizeiptr) desc.fSizeInBytes, 1374 (GrGLsizeiptr) desc.fSizeInBytes,
1375 NULL, // data ptr 1375 nullptr, // data ptr
1376 desc.fDynamic ? GR_GL_DYNAMIC_DRAW : GR_GL_ STATIC_DRAW)); 1376 desc.fDynamic ? GR_GL_DYNAMIC_DRAW : GR_GL_ STATIC_DRAW));
1377 if (CHECK_ALLOC_ERROR(this->glInterface()) != GR_GL_NO_ERROR) { 1377 if (CHECK_ALLOC_ERROR(this->glInterface()) != GR_GL_NO_ERROR) {
1378 GL_CALL(DeleteBuffers(1, &desc.fID)); 1378 GL_CALL(DeleteBuffers(1, &desc.fID));
1379 this->notifyVertexBufferDelete(desc.fID); 1379 this->notifyVertexBufferDelete(desc.fID);
1380 return NULL; 1380 return nullptr;
1381 } 1381 }
1382 GrGLVertexBuffer* vertexBuffer = new GrGLVertexBuffer(this, desc); 1382 GrGLVertexBuffer* vertexBuffer = new GrGLVertexBuffer(this, desc);
1383 return vertexBuffer; 1383 return vertexBuffer;
1384 } 1384 }
1385 return NULL; 1385 return nullptr;
1386 } 1386 }
1387 } 1387 }
1388 1388
1389 GrIndexBuffer* GrGLGpu::onCreateIndexBuffer(size_t size, bool dynamic) { 1389 GrIndexBuffer* GrGLGpu::onCreateIndexBuffer(size_t size, bool dynamic) {
1390 GrGLIndexBuffer::Desc desc; 1390 GrGLIndexBuffer::Desc desc;
1391 desc.fDynamic = dynamic; 1391 desc.fDynamic = dynamic;
1392 desc.fSizeInBytes = size; 1392 desc.fSizeInBytes = size;
1393 1393
1394 if (this->glCaps().useNonVBOVertexAndIndexDynamicData() && desc.fDynamic) { 1394 if (this->glCaps().useNonVBOVertexAndIndexDynamicData() && desc.fDynamic) {
1395 desc.fID = 0; 1395 desc.fID = 0;
1396 GrIndexBuffer* indexBuffer = new GrGLIndexBuffer(this, desc); 1396 GrIndexBuffer* indexBuffer = new GrGLIndexBuffer(this, desc);
1397 return indexBuffer; 1397 return indexBuffer;
1398 } else { 1398 } else {
1399 GL_CALL(GenBuffers(1, &desc.fID)); 1399 GL_CALL(GenBuffers(1, &desc.fID));
1400 if (desc.fID) { 1400 if (desc.fID) {
1401 fHWGeometryState.setIndexBufferIDOnDefaultVertexArray(this, desc.fID ); 1401 fHWGeometryState.setIndexBufferIDOnDefaultVertexArray(this, desc.fID );
1402 CLEAR_ERROR_BEFORE_ALLOC(this->glInterface()); 1402 CLEAR_ERROR_BEFORE_ALLOC(this->glInterface());
1403 // make sure driver can allocate memory for this buffer 1403 // make sure driver can allocate memory for this buffer
1404 GL_ALLOC_CALL(this->glInterface(), 1404 GL_ALLOC_CALL(this->glInterface(),
1405 BufferData(GR_GL_ELEMENT_ARRAY_BUFFER, 1405 BufferData(GR_GL_ELEMENT_ARRAY_BUFFER,
1406 (GrGLsizeiptr) desc.fSizeInBytes, 1406 (GrGLsizeiptr) desc.fSizeInBytes,
1407 NULL, // data ptr 1407 nullptr, // data ptr
1408 desc.fDynamic ? GR_GL_DYNAMIC_DRAW : GR_GL_ STATIC_DRAW)); 1408 desc.fDynamic ? GR_GL_DYNAMIC_DRAW : GR_GL_ STATIC_DRAW));
1409 if (CHECK_ALLOC_ERROR(this->glInterface()) != GR_GL_NO_ERROR) { 1409 if (CHECK_ALLOC_ERROR(this->glInterface()) != GR_GL_NO_ERROR) {
1410 GL_CALL(DeleteBuffers(1, &desc.fID)); 1410 GL_CALL(DeleteBuffers(1, &desc.fID));
1411 this->notifyIndexBufferDelete(desc.fID); 1411 this->notifyIndexBufferDelete(desc.fID);
1412 return NULL; 1412 return nullptr;
1413 } 1413 }
1414 GrIndexBuffer* indexBuffer = new GrGLIndexBuffer(this, desc); 1414 GrIndexBuffer* indexBuffer = new GrGLIndexBuffer(this, desc);
1415 return indexBuffer; 1415 return indexBuffer;
1416 } 1416 }
1417 return NULL; 1417 return nullptr;
1418 } 1418 }
1419 } 1419 }
1420 1420
1421 void GrGLGpu::flushScissor(const GrScissorState& scissorState, 1421 void GrGLGpu::flushScissor(const GrScissorState& scissorState,
1422 const GrGLIRect& rtViewport, 1422 const GrGLIRect& rtViewport,
1423 GrSurfaceOrigin rtOrigin) { 1423 GrSurfaceOrigin rtOrigin) {
1424 if (scissorState.enabled()) { 1424 if (scissorState.enabled()) {
1425 GrGLIRect scissor; 1425 GrGLIRect scissor;
1426 scissor.setRelativeTo(rtViewport, 1426 scissor.setRelativeTo(rtViewport,
1427 scissorState.rect().fLeft, 1427 scissorState.rect().fLeft,
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1482 static_cast<GrGLTexture*>(textureAccesses[i]->getTextu re())); 1482 static_cast<GrGLTexture*>(textureAccesses[i]->getTextu re()));
1483 } 1483 }
1484 1484
1485 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(pipeline.getRenderTa rget()); 1485 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(pipeline.getRenderTa rget());
1486 this->flushStencil(pipeline.getStencil()); 1486 this->flushStencil(pipeline.getStencil());
1487 this->flushScissor(pipeline.getScissorState(), glRT->getViewport(), glRT->or igin()); 1487 this->flushScissor(pipeline.getScissorState(), glRT->getViewport(), glRT->or igin());
1488 this->flushHWAAState(glRT, pipeline.isHWAntialiasState()); 1488 this->flushHWAAState(glRT, pipeline.isHWAntialiasState());
1489 1489
1490 // This must come after textures are flushed because a texture may need 1490 // This must come after textures are flushed because a texture may need
1491 // to be msaa-resolved (which will modify bound FBO state). 1491 // to be msaa-resolved (which will modify bound FBO state).
1492 this->flushRenderTarget(glRT, NULL); 1492 this->flushRenderTarget(glRT, nullptr);
1493 1493
1494 return true; 1494 return true;
1495 } 1495 }
1496 1496
1497 void GrGLGpu::setupGeometry(const GrPrimitiveProcessor& primProc, 1497 void GrGLGpu::setupGeometry(const GrPrimitiveProcessor& primProc,
1498 const GrNonInstancedVertices& vertices, 1498 const GrNonInstancedVertices& vertices,
1499 size_t* indexOffsetInBytes) { 1499 size_t* indexOffsetInBytes) {
1500 GrGLVertexBuffer* vbuf; 1500 GrGLVertexBuffer* vbuf;
1501 vbuf = (GrGLVertexBuffer*) vertices.vertexBuffer(); 1501 vbuf = (GrGLVertexBuffer*) vertices.vertexBuffer();
1502 1502
1503 SkASSERT(vbuf); 1503 SkASSERT(vbuf);
1504 SkASSERT(!vbuf->isMapped()); 1504 SkASSERT(!vbuf->isMapped());
1505 1505
1506 GrGLIndexBuffer* ibuf = NULL; 1506 GrGLIndexBuffer* ibuf = nullptr;
1507 if (vertices.isIndexed()) { 1507 if (vertices.isIndexed()) {
1508 SkASSERT(indexOffsetInBytes); 1508 SkASSERT(indexOffsetInBytes);
1509 1509
1510 *indexOffsetInBytes = 0; 1510 *indexOffsetInBytes = 0;
1511 ibuf = (GrGLIndexBuffer*)vertices.indexBuffer(); 1511 ibuf = (GrGLIndexBuffer*)vertices.indexBuffer();
1512 1512
1513 SkASSERT(ibuf); 1513 SkASSERT(ibuf);
1514 SkASSERT(!ibuf->isMapped()); 1514 SkASSERT(!ibuf->isMapped());
1515 *indexOffsetInBytes += ibuf->baseOffset(); 1515 *indexOffsetInBytes += ibuf->baseOffset();
1516 } 1516 }
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
1631 GL_CALL(DiscardFramebuffer(GR_GL_FRAMEBUFFER, SK_ARRAY_COUNT(att achments), 1631 GL_CALL(DiscardFramebuffer(GR_GL_FRAMEBUFFER, SK_ARRAY_COUNT(att achments),
1632 attachments)); 1632 attachments));
1633 } 1633 }
1634 break; 1634 break;
1635 } 1635 }
1636 } 1636 }
1637 renderTarget->flagAsResolved(); 1637 renderTarget->flagAsResolved();
1638 } 1638 }
1639 1639
1640 void GrGLGpu::clearStencil(GrRenderTarget* target) { 1640 void GrGLGpu::clearStencil(GrRenderTarget* target) {
1641 if (NULL == target) { 1641 if (nullptr == target) {
1642 return; 1642 return;
1643 } 1643 }
1644 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(target); 1644 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(target);
1645 this->flushRenderTarget(glRT, &SkIRect::EmptyIRect()); 1645 this->flushRenderTarget(glRT, &SkIRect::EmptyIRect());
1646 1646
1647 this->disableScissor(); 1647 this->disableScissor();
1648 1648
1649 GL_CALL(StencilMask(0xffffffff)); 1649 GL_CALL(StencilMask(0xffffffff));
1650 GL_CALL(ClearStencil(0)); 1650 GL_CALL(ClearStencil(0));
1651 GL_CALL(Clear(GR_GL_STENCIL_BUFFER_BIT)); 1651 GL_CALL(Clear(GR_GL_STENCIL_BUFFER_BIT));
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
1792 } 1792 }
1793 1793
1794 // OpenGL doesn't do sRGB <-> linear conversions when reading and writing pi xels. 1794 // OpenGL doesn't do sRGB <-> linear conversions when reading and writing pi xels.
1795 if (GrPixelConfigIsSRGB(surface->config()) != GrPixelConfigIsSRGB(config)) { 1795 if (GrPixelConfigIsSRGB(surface->config()) != GrPixelConfigIsSRGB(config)) {
1796 return false; 1796 return false;
1797 } 1797 }
1798 1798
1799 GrGLenum format = 0; 1799 GrGLenum format = 0;
1800 GrGLenum type = 0; 1800 GrGLenum type = 0;
1801 bool flipY = kBottomLeft_GrSurfaceOrigin == surface->origin(); 1801 bool flipY = kBottomLeft_GrSurfaceOrigin == surface->origin();
1802 if (!this->configToGLFormats(config, false, NULL, &format, &type)) { 1802 if (!this->configToGLFormats(config, false, nullptr, &format, &type)) {
1803 return false; 1803 return false;
1804 } 1804 }
1805 1805
1806 // glReadPixels does not allow GL_SRGB_ALPHA. Instead use GL_RGBA. This will not trigger a 1806 // glReadPixels does not allow GL_SRGB_ALPHA. Instead use GL_RGBA. This will not trigger a
1807 // conversion when the src is srgb. 1807 // conversion when the src is srgb.
1808 if (GR_GL_SRGB_ALPHA == format) { 1808 if (GR_GL_SRGB_ALPHA == format) {
1809 format = GR_GL_RGBA; 1809 format = GR_GL_RGBA;
1810 } 1810 }
1811 1811
1812 // resolve the render target if necessary 1812 // resolve the render target if necessary
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
1940 bool enableSRGBWrite = GrPixelConfigIsSRGB(target->config()); 1940 bool enableSRGBWrite = GrPixelConfigIsSRGB(target->config());
1941 if (enableSRGBWrite && kYes_TriState != fHWSRGBFramebuffer) { 1941 if (enableSRGBWrite && kYes_TriState != fHWSRGBFramebuffer) {
1942 GL_CALL(Enable(GR_GL_FRAMEBUFFER_SRGB)); 1942 GL_CALL(Enable(GR_GL_FRAMEBUFFER_SRGB));
1943 fHWSRGBFramebuffer = kYes_TriState; 1943 fHWSRGBFramebuffer = kYes_TriState;
1944 } else if (!enableSRGBWrite && kNo_TriState != fHWSRGBFramebuffer) { 1944 } else if (!enableSRGBWrite && kNo_TriState != fHWSRGBFramebuffer) {
1945 GL_CALL(Disable(GR_GL_FRAMEBUFFER_SRGB)); 1945 GL_CALL(Disable(GR_GL_FRAMEBUFFER_SRGB));
1946 fHWSRGBFramebuffer = kNo_TriState; 1946 fHWSRGBFramebuffer = kNo_TriState;
1947 } 1947 }
1948 } 1948 }
1949 } 1949 }
1950 if (NULL == bound || !bound->isEmpty()) { 1950 if (nullptr == bound || !bound->isEmpty()) {
1951 target->flagAsNeedingResolve(bound); 1951 target->flagAsNeedingResolve(bound);
1952 } 1952 }
1953 1953
1954 GrTexture *texture = target->asTexture(); 1954 GrTexture *texture = target->asTexture();
1955 if (texture) { 1955 if (texture) {
1956 texture->texturePriv().dirtyMipMaps(true); 1956 texture->texturePriv().dirtyMipMaps(true);
1957 } 1957 }
1958 } 1958 }
1959 1959
1960 GrGLenum gPrimitiveType2GLMode[] = { 1960 GrGLenum gPrimitiveType2GLMode[] = {
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
2402 fHWDrawFace = face; 2402 fHWDrawFace = face;
2403 } 2403 }
2404 } 2404 }
2405 2405
2406 bool GrGLGpu::configToGLFormats(GrPixelConfig config, 2406 bool GrGLGpu::configToGLFormats(GrPixelConfig config,
2407 bool getSizedInternalFormat, 2407 bool getSizedInternalFormat,
2408 GrGLenum* internalFormat, 2408 GrGLenum* internalFormat,
2409 GrGLenum* externalFormat, 2409 GrGLenum* externalFormat,
2410 GrGLenum* externalType) const { 2410 GrGLenum* externalType) const {
2411 GrGLenum dontCare; 2411 GrGLenum dontCare;
2412 if (NULL == internalFormat) { 2412 if (nullptr == internalFormat) {
2413 internalFormat = &dontCare; 2413 internalFormat = &dontCare;
2414 } 2414 }
2415 if (NULL == externalFormat) { 2415 if (nullptr == externalFormat) {
2416 externalFormat = &dontCare; 2416 externalFormat = &dontCare;
2417 } 2417 }
2418 if (NULL == externalType) { 2418 if (nullptr == externalType) {
2419 externalType = &dontCare; 2419 externalType = &dontCare;
2420 } 2420 }
2421 2421
2422 if(!this->glCaps().isConfigTexturable(config)) { 2422 if(!this->glCaps().isConfigTexturable(config)) {
2423 return false; 2423 return false;
2424 } 2424 }
2425 2425
2426 switch (config) { 2426 switch (config) {
2427 case kRGBA_8888_GrPixelConfig: 2427 case kRGBA_8888_GrPixelConfig:
2428 *internalFormat = GR_GL_RGBA; 2428 *internalFormat = GR_GL_RGBA;
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
2663 } 2663 }
2664 } 2664 }
2665 2665
2666 } 2666 }
2667 2667
2668 // If a temporary FBO was created, its non-zero ID is returned. The viewport tha t the copy rect is 2668 // If a temporary FBO was created, its non-zero ID is returned. The viewport tha t the copy rect is
2669 // relative to is output. 2669 // relative to is output.
2670 GrGLuint GrGLGpu::bindSurfaceAsFBO(GrSurface* surface, GrGLenum fboTarget, GrGLI Rect* viewport, 2670 GrGLuint GrGLGpu::bindSurfaceAsFBO(GrSurface* surface, GrGLenum fboTarget, GrGLI Rect* viewport,
2671 TempFBOTarget tempFBOTarget) { 2671 TempFBOTarget tempFBOTarget) {
2672 GrGLRenderTarget* rt = static_cast<GrGLRenderTarget*>(surface->asRenderTarge t()); 2672 GrGLRenderTarget* rt = static_cast<GrGLRenderTarget*>(surface->asRenderTarge t());
2673 if (NULL == rt) { 2673 if (nullptr == rt) {
2674 SkASSERT(surface->asTexture()); 2674 SkASSERT(surface->asTexture());
2675 GrGLuint texID = static_cast<GrGLTexture*>(surface->asTexture())->textur eID(); 2675 GrGLuint texID = static_cast<GrGLTexture*>(surface->asTexture())->textur eID();
2676 GrGLuint* tempFBOID; 2676 GrGLuint* tempFBOID;
2677 tempFBOID = kSrc_TempFBOTarget == tempFBOTarget ? &fTempSrcFBOID : &fTem pDstFBOID; 2677 tempFBOID = kSrc_TempFBOTarget == tempFBOTarget ? &fTempSrcFBOID : &fTem pDstFBOID;
2678 2678
2679 if (0 == *tempFBOID) { 2679 if (0 == *tempFBOID) {
2680 GR_GL_CALL(this->glInterface(), GenFramebuffers(1, tempFBOID)); 2680 GR_GL_CALL(this->glInterface(), GenFramebuffers(1, tempFBOID));
2681 } 2681 }
2682 2682
2683 fStats.incRenderTargetBinds(); 2683 fStats.incRenderTargetBinds();
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
2729 kBGRA_8888_GrPixelConfig == src->config()) { 2729 kBGRA_8888_GrPixelConfig == src->config()) {
2730 // glCopyTexSubImage2D doesn't work with this config. If the bgra can be used with fbo blit 2730 // glCopyTexSubImage2D doesn't work with this config. If the bgra can be used with fbo blit
2731 // then we set up for that, otherwise fail. 2731 // then we set up for that, otherwise fail.
2732 if (this->caps()->isConfigRenderable(kBGRA_8888_GrPixelConfig, false)) { 2732 if (this->caps()->isConfigRenderable(kBGRA_8888_GrPixelConfig, false)) {
2733 desc->fOrigin = kDefault_GrSurfaceOrigin; 2733 desc->fOrigin = kDefault_GrSurfaceOrigin;
2734 desc->fFlags = kRenderTarget_GrSurfaceFlag; 2734 desc->fFlags = kRenderTarget_GrSurfaceFlag;
2735 desc->fConfig = kBGRA_8888_GrPixelConfig; 2735 desc->fConfig = kBGRA_8888_GrPixelConfig;
2736 return true; 2736 return true;
2737 } 2737 }
2738 return false; 2738 return false;
2739 } else if (NULL == src->asRenderTarget()) { 2739 } else if (nullptr == src->asRenderTarget()) {
2740 // CopyTexSubImage2D or fbo blit would require creating a temp fbo for t he src. 2740 // CopyTexSubImage2D or fbo blit would require creating a temp fbo for t he src.
2741 return false; 2741 return false;
2742 } 2742 }
2743 2743
2744 const GrGLRenderTarget* srcRT = static_cast<const GrGLRenderTarget*>(src->as RenderTarget()); 2744 const GrGLRenderTarget* srcRT = static_cast<const GrGLRenderTarget*>(src->as RenderTarget());
2745 if (srcRT && srcRT->renderFBOID() != srcRT->textureFBOID()) { 2745 if (srcRT && srcRT->renderFBOID() != srcRT->textureFBOID()) {
2746 // It's illegal to call CopyTexSubImage2D on a MSAA renderbuffer. Set up for FBO blit or 2746 // It's illegal to call CopyTexSubImage2D on a MSAA renderbuffer. Set up for FBO blit or
2747 // fail. 2747 // fail.
2748 if (this->caps()->isConfigRenderable(src->config(), false)) { 2748 if (this->caps()->isConfigRenderable(src->config(), false)) {
2749 desc->fOrigin = kDefault_GrSurfaceOrigin; 2749 desc->fOrigin = kDefault_GrSurfaceOrigin;
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
3140 GL_CALL(DeleteTextures(1, &texID)); 3140 GL_CALL(DeleteTextures(1, &texID));
3141 } 3141 }
3142 3142
3143 /////////////////////////////////////////////////////////////////////////////// 3143 ///////////////////////////////////////////////////////////////////////////////
3144 GrGLAttribArrayState* GrGLGpu::HWGeometryState::bindArrayAndBuffersToDraw( 3144 GrGLAttribArrayState* GrGLGpu::HWGeometryState::bindArrayAndBuffersToDraw(
3145 GrGLGpu* gpu, 3145 GrGLGpu* gpu,
3146 const GrGLVertexBuffer* vbuffer, 3146 const GrGLVertexBuffer* vbuffer,
3147 const GrGLIndexBuffer* ibuffer) { 3147 const GrGLIndexBuffer* ibuffer) {
3148 SkASSERT(vbuffer); 3148 SkASSERT(vbuffer);
3149 GrGLuint vbufferID = vbuffer->bufferID(); 3149 GrGLuint vbufferID = vbuffer->bufferID();
3150 GrGLuint* ibufferIDPtr = NULL; 3150 GrGLuint* ibufferIDPtr = nullptr;
3151 GrGLuint ibufferID; 3151 GrGLuint ibufferID;
3152 if (ibuffer) { 3152 if (ibuffer) {
3153 ibufferID = ibuffer->bufferID(); 3153 ibufferID = ibuffer->bufferID();
3154 ibufferIDPtr = &ibufferID; 3154 ibufferIDPtr = &ibufferID;
3155 } 3155 }
3156 return this->internalBind(gpu, vbufferID, ibufferIDPtr); 3156 return this->internalBind(gpu, vbufferID, ibufferIDPtr);
3157 } 3157 }
3158 3158
3159 GrGLAttribArrayState* GrGLGpu::HWGeometryState::bindArrayAndBufferToDraw(GrGLGpu * gpu, 3159 GrGLAttribArrayState* GrGLGpu::HWGeometryState::bindArrayAndBufferToDraw(GrGLGpu * gpu,
3160 GrGLuin t vbufferID) { 3160 GrGLuin t vbufferID) {
3161 return this->internalBind(gpu, vbufferID, NULL); 3161 return this->internalBind(gpu, vbufferID, nullptr);
3162 } 3162 }
3163 3163
3164 GrGLAttribArrayState* GrGLGpu::HWGeometryState::bindArrayAndBuffersToDraw(GrGLGp u* gpu, 3164 GrGLAttribArrayState* GrGLGpu::HWGeometryState::bindArrayAndBuffersToDraw(GrGLGp u* gpu,
3165 GrGLui nt vbufferID, 3165 GrGLui nt vbufferID,
3166 GrGLui nt ibufferID) { 3166 GrGLui nt ibufferID) {
3167 return this->internalBind(gpu, vbufferID, &ibufferID); 3167 return this->internalBind(gpu, vbufferID, &ibufferID);
3168 } 3168 }
3169 3169
3170 GrGLAttribArrayState* GrGLGpu::HWGeometryState::internalBind(GrGLGpu* gpu, 3170 GrGLAttribArrayState* GrGLGpu::HWGeometryState::internalBind(GrGLGpu* gpu,
3171 GrGLuint vbufferID, 3171 GrGLuint vbufferID,
(...skipping 19 matching lines...) Expand all
3191 this->setVertexArrayID(gpu, 0); 3191 this->setVertexArrayID(gpu, 0);
3192 } 3192 }
3193 int attrCount = gpu->glCaps().maxVertexAttributes(); 3193 int attrCount = gpu->glCaps().maxVertexAttributes();
3194 if (fDefaultVertexArrayAttribState.count() != attrCount) { 3194 if (fDefaultVertexArrayAttribState.count() != attrCount) {
3195 fDefaultVertexArrayAttribState.resize(attrCount); 3195 fDefaultVertexArrayAttribState.resize(attrCount);
3196 } 3196 }
3197 attribState = &fDefaultVertexArrayAttribState; 3197 attribState = &fDefaultVertexArrayAttribState;
3198 } 3198 }
3199 return attribState; 3199 return attribState;
3200 } 3200 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLGpu.h ('k') | src/gpu/gl/GrGLGpuProgramCache.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698