| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2010, Google Inc. All rights reserved. | 2 * Copyright (c) 2010, Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 // it after attaching the new back buffer here. | 292 // it after attaching the new back buffer here. |
| 293 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_fbo); | 293 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_fbo); |
| 294 attachColorBufferToCurrentFBO(); | 294 attachColorBufferToCurrentFBO(); |
| 295 | 295 |
| 296 if (m_discardFramebufferSupported) { | 296 if (m_discardFramebufferSupported) { |
| 297 // Explicitly discard framebuffer to save GPU memory bandwidth for t
ile-based GPU arch. | 297 // Explicitly discard framebuffer to save GPU memory bandwidth for t
ile-based GPU arch. |
| 298 const WGC3Denum attachments[3] = { GL_COLOR_ATTACHMENT0, GL_DEPTH_AT
TACHMENT, GL_STENCIL_ATTACHMENT}; | 298 const WGC3Denum attachments[3] = { GL_COLOR_ATTACHMENT0, GL_DEPTH_AT
TACHMENT, GL_STENCIL_ATTACHMENT}; |
| 299 m_gl->DiscardFramebufferEXT(GL_FRAMEBUFFER, 3, attachments); | 299 m_gl->DiscardFramebufferEXT(GL_FRAMEBUFFER, 3, attachments); |
| 300 } | 300 } |
| 301 } else { | 301 } else { |
| 302 m_context->copyTextureCHROMIUM(m_colorBuffer.textureId, frontColorBuffer
Mailbox->textureInfo.textureId, frontColorBufferMailbox->textureInfo.parameters.
internalColorFormat, GL_UNSIGNED_BYTE, GL_FALSE, GL_FALSE, GL_FALSE); | 302 m_gl->CopyTextureCHROMIUM(m_colorBuffer.textureId, frontColorBufferMailb
ox->textureInfo.textureId, frontColorBufferMailbox->textureInfo.parameters.inter
nalColorFormat, GL_UNSIGNED_BYTE, GL_FALSE, GL_FALSE, GL_FALSE); |
| 303 } | 303 } |
| 304 | 304 |
| 305 restoreFramebufferBindings(); | 305 restoreFramebufferBindings(); |
| 306 m_contentsChanged = false; | 306 m_contentsChanged = false; |
| 307 | 307 |
| 308 m_context->produceTextureDirectCHROMIUM(frontColorBufferMailbox->textureInfo
.textureId, frontColorBufferMailbox->textureInfo.parameters.target, frontColorBu
fferMailbox->mailbox.name); | 308 m_gl->ProduceTextureDirectCHROMIUM(frontColorBufferMailbox->textureInfo.text
ureId, frontColorBufferMailbox->textureInfo.parameters.target, frontColorBufferM
ailbox->mailbox.name); |
| 309 const GLuint64 fenceSync = m_gl->InsertFenceSyncCHROMIUM(); | 309 const GLuint64 fenceSync = m_gl->InsertFenceSyncCHROMIUM(); |
| 310 m_context->flush(); | 310 m_gl->Flush(); |
| 311 frontColorBufferMailbox->mailbox.validSyncToken = m_context->genSyncTokenCHR
OMIUM(fenceSync, frontColorBufferMailbox->mailbox.syncToken); | 311 frontColorBufferMailbox->mailbox.validSyncToken = m_context->genSyncTokenCHR
OMIUM(fenceSync, frontColorBufferMailbox->mailbox.syncToken); |
| 312 frontColorBufferMailbox->mailbox.allowOverlay = frontColorBufferMailbox->tex
tureInfo.imageId != 0; | 312 frontColorBufferMailbox->mailbox.allowOverlay = frontColorBufferMailbox->tex
tureInfo.imageId != 0; |
| 313 frontColorBufferMailbox->mailbox.textureTarget = frontColorBufferMailbox->te
xtureInfo.parameters.target; | 313 frontColorBufferMailbox->mailbox.textureTarget = frontColorBufferMailbox->te
xtureInfo.parameters.target; |
| 314 frontColorBufferMailbox->mailbox.textureSize = WebSize(m_size.width(), m_siz
e.height()); | 314 frontColorBufferMailbox->mailbox.textureSize = WebSize(m_size.width(), m_siz
e.height()); |
| 315 setBufferClearNeeded(true); | 315 setBufferClearNeeded(true); |
| 316 | 316 |
| 317 // set m_parentDrawingBuffer to make sure 'this' stays alive as long as it h
as live mailboxes | 317 // set m_parentDrawingBuffer to make sure 'this' stays alive as long as it h
as live mailboxes |
| 318 ASSERT(!frontColorBufferMailbox->m_parentDrawingBuffer); | 318 ASSERT(!frontColorBufferMailbox->m_parentDrawingBuffer); |
| 319 frontColorBufferMailbox->m_parentDrawingBuffer = this; | 319 frontColorBufferMailbox->m_parentDrawingBuffer = this; |
| 320 *outMailbox = frontColorBufferMailbox->mailbox; | 320 *outMailbox = frontColorBufferMailbox->mailbox; |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 resizeTextureMemory(&mailboxInfo->textureInfo, m_size); | 415 resizeTextureMemory(&mailboxInfo->textureInfo, m_size); |
| 416 mailboxInfo->size = m_size; | 416 mailboxInfo->size = m_size; |
| 417 } | 417 } |
| 418 | 418 |
| 419 return mailboxInfo.release(); | 419 return mailboxInfo.release(); |
| 420 } | 420 } |
| 421 | 421 |
| 422 PassRefPtr<DrawingBuffer::MailboxInfo> DrawingBuffer::createNewMailbox(const Tex
tureInfo& info) | 422 PassRefPtr<DrawingBuffer::MailboxInfo> DrawingBuffer::createNewMailbox(const Tex
tureInfo& info) |
| 423 { | 423 { |
| 424 RefPtr<MailboxInfo> returnMailbox = adoptRef(new MailboxInfo()); | 424 RefPtr<MailboxInfo> returnMailbox = adoptRef(new MailboxInfo()); |
| 425 m_context->genMailboxCHROMIUM(returnMailbox->mailbox.name); | 425 m_gl->GenMailboxCHROMIUM(returnMailbox->mailbox.name); |
| 426 returnMailbox->textureInfo = info; | 426 returnMailbox->textureInfo = info; |
| 427 returnMailbox->size = m_size; | 427 returnMailbox->size = m_size; |
| 428 m_textureMailboxes.append(returnMailbox); | 428 m_textureMailboxes.append(returnMailbox); |
| 429 return returnMailbox.release(); | 429 return returnMailbox.release(); |
| 430 } | 430 } |
| 431 | 431 |
| 432 void DrawingBuffer::deleteMailbox(const WebExternalTextureMailbox& mailbox) | 432 void DrawingBuffer::deleteMailbox(const WebExternalTextureMailbox& mailbox) |
| 433 { | 433 { |
| 434 for (size_t i = 0; i < m_textureMailboxes.size(); i++) { | 434 for (size_t i = 0; i < m_textureMailboxes.size(); i++) { |
| 435 if (nameEquals(m_textureMailboxes[i]->mailbox, mailbox)) { | 435 if (nameEquals(m_textureMailboxes[i]->mailbox, mailbox)) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 446 ASSERT_NOT_REACHED(); | 446 ASSERT_NOT_REACHED(); |
| 447 } | 447 } |
| 448 | 448 |
| 449 bool DrawingBuffer::initialize(const IntSize& size) | 449 bool DrawingBuffer::initialize(const IntSize& size) |
| 450 { | 450 { |
| 451 if (m_gl->GetGraphicsResetStatusKHR() != GL_NO_ERROR) { | 451 if (m_gl->GetGraphicsResetStatusKHR() != GL_NO_ERROR) { |
| 452 // Need to try to restore the context again later. | 452 // Need to try to restore the context again later. |
| 453 return false; | 453 return false; |
| 454 } | 454 } |
| 455 | 455 |
| 456 m_context->getIntegerv(GL_MAX_TEXTURE_SIZE, &m_maxTextureSize); | 456 m_gl->GetIntegerv(GL_MAX_TEXTURE_SIZE, &m_maxTextureSize); |
| 457 | 457 |
| 458 int maxSampleCount = 0; | 458 int maxSampleCount = 0; |
| 459 m_antiAliasingMode = None; | 459 m_antiAliasingMode = None; |
| 460 if (m_requestedAttributes.antialias && m_multisampleExtensionSupported) { | 460 if (m_requestedAttributes.antialias && m_multisampleExtensionSupported) { |
| 461 m_context->getIntegerv(GL_MAX_SAMPLES_ANGLE, &maxSampleCount); | 461 m_gl->GetIntegerv(GL_MAX_SAMPLES_ANGLE, &maxSampleCount); |
| 462 m_antiAliasingMode = MSAAExplicitResolve; | 462 m_antiAliasingMode = MSAAExplicitResolve; |
| 463 if (m_extensionsUtil->supportsExtension("GL_EXT_multisampled_render_to_t
exture")) { | 463 if (m_extensionsUtil->supportsExtension("GL_EXT_multisampled_render_to_t
exture")) { |
| 464 m_antiAliasingMode = MSAAImplicitResolve; | 464 m_antiAliasingMode = MSAAImplicitResolve; |
| 465 } else if (m_extensionsUtil->supportsExtension("GL_CHROMIUM_screen_space
_antialiasing")) { | 465 } else if (m_extensionsUtil->supportsExtension("GL_CHROMIUM_screen_space
_antialiasing")) { |
| 466 m_antiAliasingMode = ScreenSpaceAntialiasing; | 466 m_antiAliasingMode = ScreenSpaceAntialiasing; |
| 467 } | 467 } |
| 468 } | 468 } |
| 469 m_sampleCount = std::min(4, maxSampleCount); | 469 m_sampleCount = std::min(4, maxSampleCount); |
| 470 | 470 |
| 471 m_fbo = m_context->createFramebuffer(); | 471 m_fbo = m_context->createFramebuffer(); |
| 472 | 472 |
| 473 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_fbo); | 473 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_fbo); |
| 474 createSecondaryBuffers(); | 474 createSecondaryBuffers(); |
| 475 // We first try to initialize everything with the requested attributes. | 475 // We first try to initialize everything with the requested attributes. |
| 476 if (!reset(size)) | 476 if (!reset(size)) |
| 477 return false; | 477 return false; |
| 478 // If that succeeds, we then see what we actually got and update our actual
attributes to reflect that. | 478 // If that succeeds, we then see what we actually got and update our actual
attributes to reflect that. |
| 479 m_actualAttributes = m_requestedAttributes; | 479 m_actualAttributes = m_requestedAttributes; |
| 480 if (m_requestedAttributes.alpha) { | 480 if (m_requestedAttributes.alpha) { |
| 481 WGC3Dint alphaBits = 0; | 481 WGC3Dint alphaBits = 0; |
| 482 m_context->getIntegerv(GL_ALPHA_BITS, &alphaBits); | 482 m_gl->GetIntegerv(GL_ALPHA_BITS, &alphaBits); |
| 483 m_actualAttributes.alpha = alphaBits > 0; | 483 m_actualAttributes.alpha = alphaBits > 0; |
| 484 } | 484 } |
| 485 if (m_requestedAttributes.depth) { | 485 if (m_requestedAttributes.depth) { |
| 486 WGC3Dint depthBits = 0; | 486 WGC3Dint depthBits = 0; |
| 487 m_context->getIntegerv(GL_DEPTH_BITS, &depthBits); | 487 m_gl->GetIntegerv(GL_DEPTH_BITS, &depthBits); |
| 488 m_actualAttributes.depth = depthBits > 0; | 488 m_actualAttributes.depth = depthBits > 0; |
| 489 } | 489 } |
| 490 if (m_requestedAttributes.stencil) { | 490 if (m_requestedAttributes.stencil) { |
| 491 WGC3Dint stencilBits = 0; | 491 WGC3Dint stencilBits = 0; |
| 492 m_context->getIntegerv(GL_STENCIL_BITS, &stencilBits); | 492 m_gl->GetIntegerv(GL_STENCIL_BITS, &stencilBits); |
| 493 m_actualAttributes.stencil = stencilBits > 0; | 493 m_actualAttributes.stencil = stencilBits > 0; |
| 494 } | 494 } |
| 495 m_actualAttributes.antialias = multisample(); | 495 m_actualAttributes.antialias = multisample(); |
| 496 | 496 |
| 497 if (m_gl->GetGraphicsResetStatusKHR() != GL_NO_ERROR) { | 497 if (m_gl->GetGraphicsResetStatusKHR() != GL_NO_ERROR) { |
| 498 // It's possible that the drawing buffer allocation provokes a context l
oss, so check again just in case. http://crbug.com/512302 | 498 // It's possible that the drawing buffer allocation provokes a context l
oss, so check again just in case. http://crbug.com/512302 |
| 499 return false; | 499 return false; |
| 500 } | 500 } |
| 501 | 501 |
| 502 return true; | 502 return true; |
| 503 } | 503 } |
| 504 | 504 |
| 505 bool DrawingBuffer::copyToPlatformTexture(WebGraphicsContext3D* context, gpu::gl
es2::GLES2Interface* gl, Platform3DObject texture, GLenum internalFormat, | 505 bool DrawingBuffer::copyToPlatformTexture(WebGraphicsContext3D* context, gpu::gl
es2::GLES2Interface* gl, Platform3DObject texture, GLenum internalFormat, |
| 506 GLenum destType, GLint level, bool premultiplyAlpha, bool flipY, SourceDrawi
ngBuffer sourceBuffer) | 506 GLenum destType, GLint level, bool premultiplyAlpha, bool flipY, SourceDrawi
ngBuffer sourceBuffer) |
| 507 { | 507 { |
| 508 if (m_contentsChanged) { | 508 if (m_contentsChanged) { |
| 509 if (m_antiAliasingMode != None) { | 509 if (m_antiAliasingMode != None) { |
| 510 commit(); | 510 commit(); |
| 511 restoreFramebufferBindings(); | 511 restoreFramebufferBindings(); |
| 512 } | 512 } |
| 513 m_context->flush(); | 513 m_gl->Flush(); |
| 514 } | 514 } |
| 515 | 515 |
| 516 // Assume that the destination target is GL_TEXTURE_2D. | 516 // Assume that the destination target is GL_TEXTURE_2D. |
| 517 if (!Extensions3DUtil::canUseCopyTextureCHROMIUM(GL_TEXTURE_2D, internalForm
at, destType, level)) | 517 if (!Extensions3DUtil::canUseCopyTextureCHROMIUM(GL_TEXTURE_2D, internalForm
at, destType, level)) |
| 518 return false; | 518 return false; |
| 519 | 519 |
| 520 // Contexts may be in a different share group. We must transfer the texture
through a mailbox first | 520 // Contexts may be in a different share group. We must transfer the texture
through a mailbox first |
| 521 WebExternalTextureMailbox mailbox; | 521 WebExternalTextureMailbox mailbox; |
| 522 GLint textureId = 0; | 522 GLint textureId = 0; |
| 523 GLenum target = 0; | 523 GLenum target = 0; |
| 524 if (sourceBuffer == FrontBuffer && m_frontColorBuffer.texInfo.textureId) { | 524 if (sourceBuffer == FrontBuffer && m_frontColorBuffer.texInfo.textureId) { |
| 525 textureId = m_frontColorBuffer.texInfo.textureId; | 525 textureId = m_frontColorBuffer.texInfo.textureId; |
| 526 mailbox = m_frontColorBuffer.mailbox; | 526 mailbox = m_frontColorBuffer.mailbox; |
| 527 target = m_frontColorBuffer.texInfo.parameters.target; | 527 target = m_frontColorBuffer.texInfo.parameters.target; |
| 528 } else { | 528 } else { |
| 529 textureId = m_colorBuffer.textureId; | 529 textureId = m_colorBuffer.textureId; |
| 530 target = m_colorBuffer.parameters.target; | 530 target = m_colorBuffer.parameters.target; |
| 531 m_context->genMailboxCHROMIUM(mailbox.name); | 531 m_gl->GenMailboxCHROMIUM(mailbox.name); |
| 532 m_context->produceTextureDirectCHROMIUM(textureId, target, mailbox.name)
; | 532 m_gl->ProduceTextureDirectCHROMIUM(textureId, target, mailbox.name); |
| 533 const GLuint64 fenceSync = m_gl->InsertFenceSyncCHROMIUM(); | 533 const GLuint64 fenceSync = m_gl->InsertFenceSyncCHROMIUM(); |
| 534 m_context->flush(); | 534 m_gl->Flush(); |
| 535 mailbox.validSyncToken = m_context->genSyncTokenCHROMIUM(fenceSync, mail
box.syncToken); | 535 mailbox.validSyncToken = m_context->genSyncTokenCHROMIUM(fenceSync, mail
box.syncToken); |
| 536 } | 536 } |
| 537 | 537 |
| 538 if (mailbox.validSyncToken) | 538 if (mailbox.validSyncToken) |
| 539 gl->WaitSyncTokenCHROMIUM(mailbox.syncToken); | 539 gl->WaitSyncTokenCHROMIUM(mailbox.syncToken); |
| 540 Platform3DObject sourceTexture = context->createAndConsumeTextureCHROMIUM(ta
rget, mailbox.name); | 540 Platform3DObject sourceTexture = gl->CreateAndConsumeTextureCHROMIUM(target,
mailbox.name); |
| 541 | 541 |
| 542 GLboolean unpackPremultiplyAlphaNeeded = GL_FALSE; | 542 GLboolean unpackPremultiplyAlphaNeeded = GL_FALSE; |
| 543 GLboolean unpackUnpremultiplyAlphaNeeded = GL_FALSE; | 543 GLboolean unpackUnpremultiplyAlphaNeeded = GL_FALSE; |
| 544 if (m_actualAttributes.alpha && m_actualAttributes.premultipliedAlpha && !pr
emultiplyAlpha) | 544 if (m_actualAttributes.alpha && m_actualAttributes.premultipliedAlpha && !pr
emultiplyAlpha) |
| 545 unpackUnpremultiplyAlphaNeeded = GL_TRUE; | 545 unpackUnpremultiplyAlphaNeeded = GL_TRUE; |
| 546 else if (m_actualAttributes.alpha && !m_actualAttributes.premultipliedAlpha
&& premultiplyAlpha) | 546 else if (m_actualAttributes.alpha && !m_actualAttributes.premultipliedAlpha
&& premultiplyAlpha) |
| 547 unpackPremultiplyAlphaNeeded = GL_TRUE; | 547 unpackPremultiplyAlphaNeeded = GL_TRUE; |
| 548 | 548 |
| 549 context->copyTextureCHROMIUM(sourceTexture, texture, internalFormat, destTyp
e, flipY, unpackPremultiplyAlphaNeeded, unpackUnpremultiplyAlphaNeeded); | 549 gl->CopyTextureCHROMIUM(sourceTexture, texture, internalFormat, destType, fl
ipY, unpackPremultiplyAlphaNeeded, unpackUnpremultiplyAlphaNeeded); |
| 550 | 550 |
| 551 context->deleteTexture(sourceTexture); | 551 context->deleteTexture(sourceTexture); |
| 552 | 552 |
| 553 const GLuint64 fenceSync = gl->InsertFenceSyncCHROMIUM(); | 553 const GLuint64 fenceSync = gl->InsertFenceSyncCHROMIUM(); |
| 554 | 554 |
| 555 context->flush(); | 555 gl->Flush(); |
| 556 GLbyte syncToken[24]; | 556 GLbyte syncToken[24]; |
| 557 if (context->genSyncTokenCHROMIUM(fenceSync, syncToken)) | 557 if (context->genSyncTokenCHROMIUM(fenceSync, syncToken)) |
| 558 m_gl->WaitSyncTokenCHROMIUM(syncToken); | 558 m_gl->WaitSyncTokenCHROMIUM(syncToken); |
| 559 | 559 |
| 560 return true; | 560 return true; |
| 561 } | 561 } |
| 562 | 562 |
| 563 Platform3DObject DrawingBuffer::framebuffer() const | 563 Platform3DObject DrawingBuffer::framebuffer() const |
| 564 { | 564 { |
| 565 return m_fbo; | 565 return m_fbo; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 578 } | 578 } |
| 579 | 579 |
| 580 return m_layer->layer(); | 580 return m_layer->layer(); |
| 581 } | 581 } |
| 582 | 582 |
| 583 void DrawingBuffer::clearPlatformLayer() | 583 void DrawingBuffer::clearPlatformLayer() |
| 584 { | 584 { |
| 585 if (m_layer) | 585 if (m_layer) |
| 586 m_layer->clearTexture(); | 586 m_layer->clearTexture(); |
| 587 | 587 |
| 588 m_context->flush(); | 588 m_gl->Flush(); |
| 589 } | 589 } |
| 590 | 590 |
| 591 void DrawingBuffer::beginDestruction() | 591 void DrawingBuffer::beginDestruction() |
| 592 { | 592 { |
| 593 ASSERT(!m_destructionInProgress); | 593 ASSERT(!m_destructionInProgress); |
| 594 m_destructionInProgress = true; | 594 m_destructionInProgress = true; |
| 595 | 595 |
| 596 clearPlatformLayer(); | 596 clearPlatformLayer(); |
| 597 | 597 |
| 598 while (!m_recycledMailboxQueue.isEmpty()) | 598 while (!m_recycledMailboxQueue.isEmpty()) |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 690 return; | 690 return; |
| 691 | 691 |
| 692 if (!m_depthStencilBuffer) | 692 if (!m_depthStencilBuffer) |
| 693 m_depthStencilBuffer = m_context->createRenderbuffer(); | 693 m_depthStencilBuffer = m_context->createRenderbuffer(); |
| 694 m_gl->BindRenderbuffer(GL_RENDERBUFFER, m_depthStencilBuffer); | 694 m_gl->BindRenderbuffer(GL_RENDERBUFFER, m_depthStencilBuffer); |
| 695 if (m_antiAliasingMode == MSAAImplicitResolve) | 695 if (m_antiAliasingMode == MSAAImplicitResolve) |
| 696 m_context->renderbufferStorageMultisampleEXT(GL_RENDERBUFFER, m_sampleCo
unt, GL_DEPTH24_STENCIL8_OES, size.width(), size.height()); | 696 m_context->renderbufferStorageMultisampleEXT(GL_RENDERBUFFER, m_sampleCo
unt, GL_DEPTH24_STENCIL8_OES, size.width(), size.height()); |
| 697 else if (m_antiAliasingMode == MSAAExplicitResolve) | 697 else if (m_antiAliasingMode == MSAAExplicitResolve) |
| 698 m_gl->RenderbufferStorageMultisampleCHROMIUM(GL_RENDERBUFFER, m_sampleCo
unt, GL_DEPTH24_STENCIL8_OES, size.width(), size.height()); | 698 m_gl->RenderbufferStorageMultisampleCHROMIUM(GL_RENDERBUFFER, m_sampleCo
unt, GL_DEPTH24_STENCIL8_OES, size.width(), size.height()); |
| 699 else | 699 else |
| 700 m_context->renderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8_OES,
size.width(), size.height()); | 700 m_gl->RenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8_OES, size
.width(), size.height()); |
| 701 m_gl->FramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, G
L_RENDERBUFFER, m_depthStencilBuffer); | 701 m_gl->FramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, G
L_RENDERBUFFER, m_depthStencilBuffer); |
| 702 m_gl->BindRenderbuffer(GL_RENDERBUFFER, 0); | 702 m_gl->BindRenderbuffer(GL_RENDERBUFFER, 0); |
| 703 } | 703 } |
| 704 | 704 |
| 705 | 705 |
| 706 | 706 |
| 707 void DrawingBuffer::clearFramebuffers(GLbitfield clearMask) | 707 void DrawingBuffer::clearFramebuffers(GLbitfield clearMask) |
| 708 { | 708 { |
| 709 // We will clear the multisample FBO, but we also need to clear the non-mult
isampled buffer. | 709 // We will clear the multisample FBO, but we also need to clear the non-mult
isampled buffer. |
| 710 if (m_multisampleFBO) { | 710 if (m_multisampleFBO) { |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 781 | 781 |
| 782 GLbitfield clearMask = GL_COLOR_BUFFER_BIT; | 782 GLbitfield clearMask = GL_COLOR_BUFFER_BIT; |
| 783 if (m_actualAttributes.depth) { | 783 if (m_actualAttributes.depth) { |
| 784 m_gl->ClearDepthf(1.0f); | 784 m_gl->ClearDepthf(1.0f); |
| 785 clearMask |= GL_DEPTH_BUFFER_BIT; | 785 clearMask |= GL_DEPTH_BUFFER_BIT; |
| 786 m_gl->DepthMask(true); | 786 m_gl->DepthMask(true); |
| 787 } | 787 } |
| 788 if (m_actualAttributes.stencil) { | 788 if (m_actualAttributes.stencil) { |
| 789 m_gl->ClearStencil(0); | 789 m_gl->ClearStencil(0); |
| 790 clearMask |= GL_STENCIL_BUFFER_BIT; | 790 clearMask |= GL_STENCIL_BUFFER_BIT; |
| 791 m_context->stencilMaskSeparate(GL_FRONT, 0xFFFFFFFF); | 791 m_gl->StencilMaskSeparate(GL_FRONT, 0xFFFFFFFF); |
| 792 } | 792 } |
| 793 | 793 |
| 794 clearFramebuffers(clearMask); | 794 clearFramebuffers(clearMask); |
| 795 return true; | 795 return true; |
| 796 } | 796 } |
| 797 | 797 |
| 798 void DrawingBuffer::commit() | 798 void DrawingBuffer::commit() |
| 799 { | 799 { |
| 800 if (m_multisampleFBO && !m_contentsChangeCommitted) { | 800 if (m_multisampleFBO && !m_contentsChangeCommitted) { |
| 801 m_gl->BindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, m_multisampleFBO); | 801 m_gl->BindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, m_multisampleFBO); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 895 | 895 |
| 896 restoreFramebufferBindings(); | 896 restoreFramebufferBindings(); |
| 897 | 897 |
| 898 pixels.transfer(contents); | 898 pixels.transfer(contents); |
| 899 return true; | 899 return true; |
| 900 } | 900 } |
| 901 | 901 |
| 902 void DrawingBuffer::readBackFramebuffer(unsigned char* pixels, int width, int he
ight, ReadbackOrder readbackOrder, WebGLImageConversion::AlphaOp op) | 902 void DrawingBuffer::readBackFramebuffer(unsigned char* pixels, int width, int he
ight, ReadbackOrder readbackOrder, WebGLImageConversion::AlphaOp op) |
| 903 { | 903 { |
| 904 if (m_packAlignment > 4) | 904 if (m_packAlignment > 4) |
| 905 m_context->pixelStorei(GL_PACK_ALIGNMENT, 1); | 905 m_gl->PixelStorei(GL_PACK_ALIGNMENT, 1); |
| 906 m_context->readPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, pixels
); | 906 m_gl->ReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, pixels); |
| 907 if (m_packAlignment > 4) | 907 if (m_packAlignment > 4) |
| 908 m_context->pixelStorei(GL_PACK_ALIGNMENT, m_packAlignment); | 908 m_gl->PixelStorei(GL_PACK_ALIGNMENT, m_packAlignment); |
| 909 | 909 |
| 910 size_t bufferSize = 4 * width * height; | 910 size_t bufferSize = 4 * width * height; |
| 911 | 911 |
| 912 if (readbackOrder == ReadbackSkia) { | 912 if (readbackOrder == ReadbackSkia) { |
| 913 #if (SK_R32_SHIFT == 16) && !SK_B32_SHIFT | 913 #if (SK_R32_SHIFT == 16) && !SK_B32_SHIFT |
| 914 // Swizzle red and blue channels to match SkBitmap's byte ordering. | 914 // Swizzle red and blue channels to match SkBitmap's byte ordering. |
| 915 // TODO(kbr): expose GL_BGRA as extension. | 915 // TODO(kbr): expose GL_BGRA as extension. |
| 916 for (size_t i = 0; i < bufferSize; i += 4) { | 916 for (size_t i = 0; i < bufferSize; i += 4) { |
| 917 std::swap(pixels[i], pixels[i + 2]); | 917 std::swap(pixels[i], pixels[i + 2]); |
| 918 } | 918 } |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1036 | 1036 |
| 1037 if (m_antiAliasingMode == MSAAImplicitResolve) | 1037 if (m_antiAliasingMode == MSAAImplicitResolve) |
| 1038 m_context->framebufferTexture2DMultisampleEXT(GL_FRAMEBUFFER, GL_COLOR_A
TTACHMENT0, target, m_colorBuffer.textureId, 0, m_sampleCount); | 1038 m_context->framebufferTexture2DMultisampleEXT(GL_FRAMEBUFFER, GL_COLOR_A
TTACHMENT0, target, m_colorBuffer.textureId, 0, m_sampleCount); |
| 1039 else | 1039 else |
| 1040 m_gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, target,
m_colorBuffer.textureId, 0); | 1040 m_gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, target,
m_colorBuffer.textureId, 0); |
| 1041 | 1041 |
| 1042 m_gl->BindTexture(GL_TEXTURE_2D, m_texture2DBinding); | 1042 m_gl->BindTexture(GL_TEXTURE_2D, m_texture2DBinding); |
| 1043 } | 1043 } |
| 1044 | 1044 |
| 1045 } // namespace blink | 1045 } // namespace blink |
| OLD | NEW |