Chromium Code Reviews| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 48 | 48 |
| 49 namespace blink { | 49 namespace blink { |
| 50 | 50 |
| 51 namespace { | 51 namespace { |
| 52 | 52 |
| 53 const float s_resourceAdjustedRatio = 0.5; | 53 const float s_resourceAdjustedRatio = 0.5; |
| 54 | 54 |
| 55 class ScopedTextureUnit0BindingRestorer { | 55 class ScopedTextureUnit0BindingRestorer { |
| 56 STACK_ALLOCATED(); | 56 STACK_ALLOCATED(); |
| 57 WTF_MAKE_NONCOPYABLE(ScopedTextureUnit0BindingRestorer); | 57 WTF_MAKE_NONCOPYABLE(ScopedTextureUnit0BindingRestorer); |
| 58 | |
| 58 public: | 59 public: |
| 59 ScopedTextureUnit0BindingRestorer(gpu::gles2::GLES2Interface* gl, GLenum act iveTextureUnit, GLuint textureUnitZeroId) | 60 ScopedTextureUnit0BindingRestorer(gpu::gles2::GLES2Interface* gl, GLenum act iveTextureUnit, GLuint textureUnitZeroId) |
| 60 : m_gl(gl) | 61 : m_gl(gl) |
| 61 , m_oldActiveTextureUnit(activeTextureUnit) | 62 , m_oldActiveTextureUnit(activeTextureUnit) |
| 62 , m_oldTextureUnitZeroId(textureUnitZeroId) | 63 , m_oldTextureUnitZeroId(textureUnitZeroId) |
| 63 { | 64 { |
| 64 m_gl->ActiveTexture(GL_TEXTURE0); | 65 m_gl->ActiveTexture(GL_TEXTURE0); |
| 65 } | 66 } |
| 66 ~ScopedTextureUnit0BindingRestorer() | 67 ~ScopedTextureUnit0BindingRestorer() |
| 67 { | 68 { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 103 extensionsUtil->ensureExtensionEnabled("GL_OES_rgb8_rgba8"); | 104 extensionsUtil->ensureExtensionEnabled("GL_OES_rgb8_rgba8"); |
| 104 if (extensionsUtil->supportsExtension("GL_CHROMIUM_framebuffer_multisamp le")) | 105 if (extensionsUtil->supportsExtension("GL_CHROMIUM_framebuffer_multisamp le")) |
| 105 extensionsUtil->ensureExtensionEnabled("GL_CHROMIUM_framebuffer_mult isample"); | 106 extensionsUtil->ensureExtensionEnabled("GL_CHROMIUM_framebuffer_mult isample"); |
| 106 else | 107 else |
| 107 extensionsUtil->ensureExtensionEnabled("GL_EXT_multisampled_render_t o_texture"); | 108 extensionsUtil->ensureExtensionEnabled("GL_EXT_multisampled_render_t o_texture"); |
| 108 } | 109 } |
| 109 bool discardFramebufferSupported = extensionsUtil->supportsExtension("GL_EXT _discard_framebuffer"); | 110 bool discardFramebufferSupported = extensionsUtil->supportsExtension("GL_EXT _discard_framebuffer"); |
| 110 if (discardFramebufferSupported) | 111 if (discardFramebufferSupported) |
| 111 extensionsUtil->ensureExtensionEnabled("GL_EXT_discard_framebuffer"); | 112 extensionsUtil->ensureExtensionEnabled("GL_EXT_discard_framebuffer"); |
| 112 | 113 |
| 113 RefPtr<DrawingBuffer> drawingBuffer = adoptRef(new DrawingBuffer(std::move(c ontextProvider), extensionsUtil.release(), discardFramebufferSupported, wantAlph aChannel, premultipliedAlpha, preserve)); | 114 RefPtr<DrawingBuffer> drawingBuffer = adoptRef(new DrawingBuffer(std::move(c ontextProvider), extensionsUtil.release(), discardFramebufferSupported, wantAlph aChannel, premultipliedAlpha, preserve, wantDepthBuffer, wantStencilBuffer)); |
| 114 if (!drawingBuffer->initialize(size, wantDepthBuffer, wantStencilBuffer, mul tisampleSupported)) { | 115 if (!drawingBuffer->initialize(size, multisampleSupported)) { |
| 115 drawingBuffer->beginDestruction(); | 116 drawingBuffer->beginDestruction(); |
| 116 return PassRefPtr<DrawingBuffer>(); | 117 return PassRefPtr<DrawingBuffer>(); |
| 117 } | 118 } |
| 118 return drawingBuffer.release(); | 119 return drawingBuffer.release(); |
| 119 } | 120 } |
| 120 | 121 |
| 121 void DrawingBuffer::forceNextDrawingBufferCreationToFail() | 122 void DrawingBuffer::forceNextDrawingBufferCreationToFail() |
| 122 { | 123 { |
| 123 shouldFailDrawingBufferCreationForTesting = true; | 124 shouldFailDrawingBufferCreationForTesting = true; |
| 124 } | 125 } |
| 125 | 126 |
| 126 DrawingBuffer::DrawingBuffer( | 127 DrawingBuffer::DrawingBuffer( |
| 127 PassOwnPtr<WebGraphicsContext3DProvider> contextProvider, | 128 PassOwnPtr<WebGraphicsContext3DProvider> contextProvider, |
| 128 PassOwnPtr<Extensions3DUtil> extensionsUtil, | 129 PassOwnPtr<Extensions3DUtil> extensionsUtil, |
| 129 bool discardFramebufferSupported, | 130 bool discardFramebufferSupported, |
| 130 bool wantAlphaChannel, | 131 bool wantAlphaChannel, |
| 131 bool premultipliedAlpha, | 132 bool premultipliedAlpha, |
| 132 PreserveDrawingBuffer preserve) | 133 PreserveDrawingBuffer preserve, |
| 134 bool wantDepth, | |
| 135 bool wantStencil) | |
| 133 : m_preserveDrawingBuffer(preserve) | 136 : m_preserveDrawingBuffer(preserve) |
| 134 , m_scissorEnabled(false) | |
| 135 , m_texture2DBinding(0) | |
| 136 , m_drawFramebufferBinding(0) | |
| 137 , m_readFramebufferBinding(0) | |
| 138 , m_renderbufferBinding(0) | |
| 139 , m_activeTextureUnit(GL_TEXTURE0) | |
| 140 , m_contextProvider(std::move(contextProvider)) | 137 , m_contextProvider(std::move(contextProvider)) |
| 141 , m_gl(m_contextProvider->contextGL()) | 138 , m_gl(m_contextProvider->contextGL()) |
| 142 , m_extensionsUtil(std::move(extensionsUtil)) | 139 , m_extensionsUtil(std::move(extensionsUtil)) |
| 143 , m_size(-1, -1) | |
| 144 , m_discardFramebufferSupported(discardFramebufferSupported) | 140 , m_discardFramebufferSupported(discardFramebufferSupported) |
| 145 , m_wantAlphaChannel(wantAlphaChannel) | 141 , m_wantAlphaChannel(wantAlphaChannel) |
| 146 , m_premultipliedAlpha(premultipliedAlpha) | 142 , m_premultipliedAlpha(premultipliedAlpha) |
| 147 , m_hasImplicitStencilBuffer(false) | 143 , m_wantDepth(wantDepth) |
| 148 , m_fbo(0) | 144 , m_wantStencil(wantStencil) |
| 149 , m_depthStencilBuffer(0) | |
| 150 , m_multisampleFBO(0) | |
| 151 , m_intermediateFBO(0) | |
| 152 , m_intermediateRenderbuffer(0) | |
| 153 , m_multisampleColorBuffer(0) | |
| 154 , m_contentsChanged(true) | |
| 155 , m_contentsChangeCommitted(false) | |
| 156 , m_bufferClearNeeded(false) | |
| 157 , m_antiAliasingMode(None) | |
| 158 , m_maxTextureSize(0) | |
| 159 , m_sampleCount(0) | |
| 160 , m_packAlignment(4) | |
| 161 , m_destructionInProgress(false) | |
| 162 , m_isHidden(false) | |
| 163 , m_filterQuality(kLow_SkFilterQuality) | |
| 164 { | 145 { |
| 165 memset(m_colorMask, 0, 4 * sizeof(GLboolean)); | 146 memset(m_colorMask, 0, 4 * sizeof(GLboolean)); |
| 166 memset(m_clearColor, 0, 4 * sizeof(GLfloat)); | 147 memset(m_clearColor, 0, 4 * sizeof(GLfloat)); |
| 167 // Used by browser tests to detect the use of a DrawingBuffer. | 148 // Used by browser tests to detect the use of a DrawingBuffer. |
| 168 TRACE_EVENT_INSTANT0("test_gpu", "DrawingBufferCreation", TRACE_EVENT_SCOPE_ GLOBAL); | 149 TRACE_EVENT_INSTANT0("test_gpu", "DrawingBufferCreation", TRACE_EVENT_SCOPE_ GLOBAL); |
| 169 } | 150 } |
| 170 | 151 |
| 171 DrawingBuffer::~DrawingBuffer() | 152 DrawingBuffer::~DrawingBuffer() |
| 172 { | 153 { |
| 173 ASSERT(m_destructionInProgress); | 154 ASSERT(m_destructionInProgress); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 217 | 198 |
| 218 void DrawingBuffer::setFilterQuality(SkFilterQuality filterQuality) | 199 void DrawingBuffer::setFilterQuality(SkFilterQuality filterQuality) |
| 219 { | 200 { |
| 220 if (m_filterQuality != filterQuality) { | 201 if (m_filterQuality != filterQuality) { |
| 221 m_filterQuality = filterQuality; | 202 m_filterQuality = filterQuality; |
| 222 if (m_layer) | 203 if (m_layer) |
| 223 m_layer->setNearestNeighbor(filterQuality == kNone_SkFilterQuality); | 204 m_layer->setNearestNeighbor(filterQuality == kNone_SkFilterQuality); |
| 224 } | 205 } |
| 225 } | 206 } |
| 226 | 207 |
| 227 bool DrawingBuffer::requiresRGBEmulation() | 208 bool DrawingBuffer::requiresAlphaMask() |
| 228 { | 209 { |
| 229 // When an explicit resolve is required, clients draw into a render buffer | 210 // When an explicit resolve is required, clients draw into a render buffer |
| 230 // which is never backed by an IOSurface. | 211 // which is never backed by an IOSurface. |
| 231 if (m_antiAliasingMode == MSAAExplicitResolve) | 212 if (m_antiAliasingMode == MSAAExplicitResolve) |
| 232 return false; | 213 return false; |
| 233 return !m_drawFramebufferBinding && !m_wantAlphaChannel && m_colorBuffer.ima geId && contextProvider()->getCapabilities().chromium_image_rgb_emulation; | 214 return !m_drawFramebufferBinding && !m_wantAlphaChannel && m_colorBuffer.ima geId && contextProvider()->getCapabilities().chromium_image_rgb_emulation; |
| 234 } | 215 } |
| 235 | 216 |
| 236 void DrawingBuffer::freeRecycledMailboxes() | 217 void DrawingBuffer::freeRecycledMailboxes() |
| 237 { | 218 { |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 251 // 4. Here. | 232 // 4. Here. |
| 252 return false; | 233 return false; |
| 253 } | 234 } |
| 254 ASSERT(!m_isHidden); | 235 ASSERT(!m_isHidden); |
| 255 if (!m_contentsChanged) | 236 if (!m_contentsChanged) |
| 256 return false; | 237 return false; |
| 257 | 238 |
| 258 if (m_newMailboxCallback) | 239 if (m_newMailboxCallback) |
| 259 (*m_newMailboxCallback)(); | 240 (*m_newMailboxCallback)(); |
| 260 | 241 |
| 261 // Resolve the multisampled buffer into m_colorBuffer texture. | 242 // Resolve the multisampled buffer into m_colorBuffertexture. |
|
Ken Russell (switch to Gerrit)
2016/05/04 21:13:11
Space was lost in comment.
erikchen
2016/05/04 21:17:53
Done.
| |
| 262 if (m_antiAliasingMode != None) | 243 if (m_antiAliasingMode != None) |
| 263 commit(); | 244 commit(); |
| 264 | 245 |
| 265 if (bitmap) { | 246 if (bitmap) { |
| 266 bitmap->setSize(size()); | 247 bitmap->setSize(size()); |
| 267 | 248 |
| 268 unsigned char* pixels = bitmap->pixels(); | 249 unsigned char* pixels = bitmap->pixels(); |
| 269 bool needPremultiply = m_wantAlphaChannel && !m_premultipliedAlpha; | 250 bool needPremultiply = m_wantAlphaChannel && !m_premultipliedAlpha; |
| 270 WebGLImageConversion::AlphaOp op = needPremultiply ? WebGLImageConversio n::AlphaDoPremultiply : WebGLImageConversion::AlphaDoNothing; | 251 WebGLImageConversion::AlphaOp op = needPremultiply ? WebGLImageConversio n::AlphaDoPremultiply : WebGLImageConversion::AlphaDoNothing; |
| 271 if (pixels) | 252 if (pixels) |
| 272 readBackFramebuffer(pixels, size().width(), size().height(), Readbac kSkia, op); | 253 readBackFramebuffer(pixels, size().width(), size().height(), Readbac kSkia, op); |
| 273 } | 254 } |
| 274 | 255 |
| 275 // We must restore the texture binding since creating new textures, | 256 // We must restore the texture binding since creating new textures, |
| 276 // consuming and producing mailboxes changes it. | 257 // consuming and producing mailboxes changes it. |
| 277 ScopedTextureUnit0BindingRestorer restorer(m_gl, m_activeTextureUnit, m_text ure2DBinding); | 258 ScopedTextureUnit0BindingRestorer restorer(m_gl, m_activeTextureUnit, m_text ure2DBinding); |
| 278 | 259 |
| 279 // First try to recycle an old buffer. | 260 // First try to recycle an old buffer. |
| 280 RefPtr<MailboxInfo> frontColorBufferMailbox = recycledMailbox(); | 261 RefPtr<MailboxInfo> frontColorBufferMailbox = recycledMailbox(); |
| 281 | 262 |
| 282 // No buffer available to recycle, create a new one. | 263 // No buffer available to recycle, create a new one. |
| 283 if (!frontColorBufferMailbox) | 264 if (!frontColorBufferMailbox) |
| 284 frontColorBufferMailbox = createNewMailbox(createTextureAndAllocateMemor y(m_size)); | 265 frontColorBufferMailbox = createNewMailbox(createTextureAndAllocateMemor y(m_size)); |
| 285 | 266 |
| 286 if (m_preserveDrawingBuffer == Discard) { | 267 if (m_preserveDrawingBuffer == Discard) { |
| 287 std::swap(frontColorBufferMailbox->textureInfo, m_colorBuffer); | 268 std::swap(frontColorBufferMailbox->textureInfo, m_colorBuffer); |
| 288 // It appears safe to overwrite the context's framebuffer binding in the Discard case since there will always be a | 269 attachColorBufferToReadFramebuffer(); |
| 289 // WebGLRenderingContext::clearIfComposited() call made before the next draw call which restores the framebuffer binding. | |
| 290 // If this stops being true at some point, we should track the current f ramebuffer binding in the DrawingBuffer and restore | |
| 291 // it after attaching the new back buffer here. | |
| 292 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_fbo); | |
| 293 attachColorBufferToCurrentFBO(); | |
| 294 | 270 |
| 295 if (m_discardFramebufferSupported) { | 271 if (m_discardFramebufferSupported) { |
| 296 // Explicitly discard framebuffer to save GPU memory bandwidth for t ile-based GPU arch. | 272 // Explicitly discard framebuffer to save GPU memory bandwidth for t ile-based GPU arch. |
| 297 const GLenum attachments[3] = { GL_COLOR_ATTACHMENT0, GL_DEPTH_ATTAC HMENT, GL_STENCIL_ATTACHMENT}; | 273 const GLenum attachments[3] = { GL_COLOR_ATTACHMENT0, GL_DEPTH_ATTAC HMENT, GL_STENCIL_ATTACHMENT }; |
| 298 m_gl->DiscardFramebufferEXT(GL_FRAMEBUFFER, 3, attachments); | 274 m_gl->DiscardFramebufferEXT(GL_FRAMEBUFFER, 3, attachments); |
| 299 } | 275 } |
| 300 } else { | 276 } else { |
| 301 m_gl->CopyTextureCHROMIUM(m_colorBuffer.textureId, frontColorBufferMailb ox->textureInfo.textureId, frontColorBufferMailbox->textureInfo.parameters.inter nalColorFormat, GL_UNSIGNED_BYTE, GL_FALSE, GL_FALSE, GL_FALSE); | 277 m_gl->CopyTextureCHROMIUM(m_colorBuffer.textureId, frontColorBufferMailb ox->textureInfo.textureId, frontColorBufferMailbox->textureInfo.parameters.inter nalColorFormat, GL_UNSIGNED_BYTE, GL_FALSE, GL_FALSE, GL_FALSE); |
| 302 } | 278 } |
| 303 | 279 |
| 304 restoreFramebufferBindings(); | 280 restoreFramebufferBindings(); |
| 305 m_contentsChanged = false; | 281 m_contentsChanged = false; |
| 306 | 282 |
| 307 m_gl->ProduceTextureDirectCHROMIUM(frontColorBufferMailbox->textureInfo.text ureId, frontColorBufferMailbox->textureInfo.parameters.target, frontColorBufferM ailbox->mailbox.name); | 283 m_gl->ProduceTextureDirectCHROMIUM(frontColorBufferMailbox->textureInfo.text ureId, frontColorBufferMailbox->textureInfo.parameters.target, frontColorBufferM ailbox->mailbox.name); |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 455 deleteChromiumImageForTexture(&m_textureMailboxes[i]->textureInfo); | 431 deleteChromiumImageForTexture(&m_textureMailboxes[i]->textureInfo); |
| 456 | 432 |
| 457 m_gl->DeleteTextures(1, &m_textureMailboxes[i]->textureInfo.textureI d); | 433 m_gl->DeleteTextures(1, &m_textureMailboxes[i]->textureInfo.textureI d); |
| 458 m_textureMailboxes.remove(i); | 434 m_textureMailboxes.remove(i); |
| 459 return; | 435 return; |
| 460 } | 436 } |
| 461 } | 437 } |
| 462 ASSERT_NOT_REACHED(); | 438 ASSERT_NOT_REACHED(); |
| 463 } | 439 } |
| 464 | 440 |
| 465 bool DrawingBuffer::initialize(const IntSize& size, bool wantDepthBuffer, bool w antStencilBuffer, bool useMultisampling) | 441 bool DrawingBuffer::initialize(const IntSize& size, bool useMultisampling) |
| 466 { | 442 { |
| 467 if (m_gl->GetGraphicsResetStatusKHR() != GL_NO_ERROR) { | 443 if (m_gl->GetGraphicsResetStatusKHR() != GL_NO_ERROR) { |
| 468 // Need to try to restore the context again later. | 444 // Need to try to restore the context again later. |
| 469 return false; | 445 return false; |
| 470 } | 446 } |
| 471 | 447 |
| 472 m_gl->GetIntegerv(GL_MAX_TEXTURE_SIZE, &m_maxTextureSize); | 448 m_gl->GetIntegerv(GL_MAX_TEXTURE_SIZE, &m_maxTextureSize); |
| 473 | 449 |
| 474 int maxSampleCount = 0; | 450 int maxSampleCount = 0; |
| 475 m_antiAliasingMode = None; | 451 m_antiAliasingMode = None; |
| 476 if (useMultisampling) { | 452 if (useMultisampling) { |
| 477 m_gl->GetIntegerv(GL_MAX_SAMPLES_ANGLE, &maxSampleCount); | 453 m_gl->GetIntegerv(GL_MAX_SAMPLES_ANGLE, &maxSampleCount); |
| 478 m_antiAliasingMode = MSAAExplicitResolve; | 454 m_antiAliasingMode = MSAAExplicitResolve; |
| 479 if (m_extensionsUtil->supportsExtension("GL_EXT_multisampled_render_to_t exture")) { | 455 if (m_extensionsUtil->supportsExtension("GL_EXT_multisampled_render_to_t exture")) { |
| 480 m_antiAliasingMode = MSAAImplicitResolve; | 456 m_antiAliasingMode = MSAAImplicitResolve; |
| 481 } else if (m_extensionsUtil->supportsExtension("GL_CHROMIUM_screen_space _antialiasing")) { | 457 } else if (m_extensionsUtil->supportsExtension("GL_CHROMIUM_screen_space _antialiasing")) { |
| 482 m_antiAliasingMode = ScreenSpaceAntialiasing; | 458 m_antiAliasingMode = ScreenSpaceAntialiasing; |
| 483 } | 459 } |
| 484 } | 460 } |
| 485 m_sampleCount = std::min(4, maxSampleCount); | 461 m_sampleCount = std::min(4, maxSampleCount); |
| 486 | 462 |
| 487 m_gl->GenFramebuffers(1, &m_fbo); | 463 m_gl->GenFramebuffers(1, &m_fbo); |
| 488 | |
| 489 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_fbo); | 464 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_fbo); |
| 490 createSecondaryBuffers(); | 465 if (wantExplicitResolve()) { |
| 491 if (!reset(size, wantDepthBuffer || wantStencilBuffer)) | 466 m_gl->GenFramebuffers(1, &m_multisampleFBO); |
| 467 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_multisampleFBO); | |
| 468 m_gl->GenRenderbuffers(1, &m_multisampleRenderbuffer); | |
| 469 } | |
| 470 if (!reset(size)) | |
| 492 return false; | 471 return false; |
| 493 | 472 |
| 494 if (m_depthStencilBuffer) { | 473 if (m_depthStencilBuffer) { |
| 495 DCHECK(wantDepthBuffer || wantStencilBuffer); | 474 DCHECK(wantDepthOrStencil()); |
| 496 m_hasImplicitStencilBuffer = !wantStencilBuffer; | 475 m_hasImplicitStencilBuffer = !m_wantStencil; |
| 497 } | 476 } |
| 498 | 477 |
| 499 if (m_gl->GetGraphicsResetStatusKHR() != GL_NO_ERROR) { | 478 if (m_gl->GetGraphicsResetStatusKHR() != GL_NO_ERROR) { |
| 500 // It's possible that the drawing buffer allocation provokes a context l oss, so check again just in case. http://crbug.com/512302 | 479 // It's possible that the drawing buffer allocation provokes a context l oss, so check again just in case. http://crbug.com/512302 |
| 501 return false; | 480 return false; |
| 502 } | 481 } |
| 503 | 482 |
| 504 return true; | 483 return true; |
| 505 } | 484 } |
| 506 | 485 |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 600 | 579 |
| 601 while (!m_recycledMailboxQueue.isEmpty()) | 580 while (!m_recycledMailboxQueue.isEmpty()) |
| 602 deleteMailbox(m_recycledMailboxQueue.takeLast()); | 581 deleteMailbox(m_recycledMailboxQueue.takeLast()); |
| 603 | 582 |
| 604 if (m_multisampleFBO) | 583 if (m_multisampleFBO) |
| 605 m_gl->DeleteFramebuffers(1, &m_multisampleFBO); | 584 m_gl->DeleteFramebuffers(1, &m_multisampleFBO); |
| 606 | 585 |
| 607 if (m_fbo) | 586 if (m_fbo) |
| 608 m_gl->DeleteFramebuffers(1, &m_fbo); | 587 m_gl->DeleteFramebuffers(1, &m_fbo); |
| 609 | 588 |
| 610 if (m_multisampleColorBuffer) | 589 if (m_multisampleRenderbuffer) |
| 611 m_gl->DeleteRenderbuffers(1, &m_multisampleColorBuffer); | 590 m_gl->DeleteRenderbuffers(1, &m_multisampleRenderbuffer); |
| 612 | 591 |
| 613 if (m_intermediateFBO) | 592 if (m_intermediateFBO) |
| 614 m_gl->DeleteFramebuffers(1, &m_intermediateFBO); | 593 m_gl->DeleteFramebuffers(1, &m_intermediateFBO); |
| 615 | 594 |
| 616 if (m_intermediateRenderbuffer) | 595 if (m_intermediateRenderbuffer) |
| 617 m_gl->DeleteRenderbuffers(1, &m_intermediateRenderbuffer); | 596 m_gl->DeleteRenderbuffers(1, &m_intermediateRenderbuffer); |
| 618 | 597 |
| 619 if (m_depthStencilBuffer) | 598 if (m_depthStencilBuffer) |
| 620 m_gl->DeleteRenderbuffers(1, &m_depthStencilBuffer); | 599 m_gl->DeleteRenderbuffers(1, &m_depthStencilBuffer); |
| 621 | 600 |
| 622 if (m_colorBuffer.textureId) { | 601 if (m_colorBuffer.textureId) { |
| 623 deleteChromiumImageForTexture(&m_colorBuffer); | 602 deleteChromiumImageForTexture(&m_colorBuffer); |
| 624 m_gl->DeleteTextures(1, &m_colorBuffer.textureId); | 603 m_gl->DeleteTextures(1, &m_colorBuffer.textureId); |
| 625 } | 604 } |
| 626 | 605 |
| 627 setSize(IntSize()); | 606 setSize(IntSize()); |
| 628 | 607 |
| 629 m_colorBuffer = TextureInfo(); | 608 m_colorBuffer = TextureInfo(); |
| 630 m_frontColorBuffer = FrontBufferInfo(); | 609 m_frontColorBuffer = FrontBufferInfo(); |
| 631 m_multisampleColorBuffer = 0; | 610 m_multisampleRenderbuffer = 0; |
| 632 m_depthStencilBuffer = 0; | 611 m_depthStencilBuffer = 0; |
| 633 m_multisampleFBO = 0; | 612 m_multisampleFBO = 0; |
| 634 m_fbo = 0; | 613 m_fbo = 0; |
| 635 | 614 |
| 636 if (m_layer) | 615 if (m_layer) |
| 637 GraphicsLayer::unregisterContentsLayer(m_layer->layer()); | 616 GraphicsLayer::unregisterContentsLayer(m_layer->layer()); |
| 638 } | 617 } |
| 639 | 618 |
| 640 GLuint DrawingBuffer::createColorTexture(const TextureParameters& parameters) | 619 GLuint DrawingBuffer::createColorTexture(const TextureParameters& parameters) |
| 641 { | 620 { |
| 642 GLuint offscreenColorTexture; | 621 GLuint offscreenColorTexture; |
| 643 m_gl->GenTextures(1, &offscreenColorTexture); | 622 m_gl->GenTextures(1, &offscreenColorTexture); |
| 644 m_gl->BindTexture(parameters.target, offscreenColorTexture); | 623 m_gl->BindTexture(parameters.target, offscreenColorTexture); |
| 645 m_gl->TexParameteri(parameters.target, GL_TEXTURE_MAG_FILTER, GL_LINEAR); | 624 m_gl->TexParameteri(parameters.target, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
| 646 m_gl->TexParameteri(parameters.target, GL_TEXTURE_MIN_FILTER, GL_LINEAR); | 625 m_gl->TexParameteri(parameters.target, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
| 647 m_gl->TexParameteri(parameters.target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); | 626 m_gl->TexParameteri(parameters.target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
| 648 m_gl->TexParameteri(parameters.target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); | 627 m_gl->TexParameteri(parameters.target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
| 649 return offscreenColorTexture; | 628 return offscreenColorTexture; |
| 650 } | 629 } |
| 651 | 630 |
| 652 void DrawingBuffer::createSecondaryBuffers() | 631 bool DrawingBuffer::resizeMultisampleFramebuffer(const IntSize& size) |
| 653 { | 632 { |
| 654 // create a multisample FBO | 633 DCHECK(wantExplicitResolve()); |
| 655 if (m_antiAliasingMode == MSAAExplicitResolve) { | 634 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_multisampleFBO); |
| 656 m_gl->GenFramebuffers(1, &m_multisampleFBO); | 635 m_gl->BindRenderbuffer(GL_RENDERBUFFER, m_multisampleRenderbuffer); |
| 657 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_multisampleFBO); | 636 m_gl->RenderbufferStorageMultisampleCHROMIUM(GL_RENDERBUFFER, m_sampleCount, m_colorBuffer.parameters.internalRenderbufferFormat, size.width(), size.height( )); |
| 658 m_gl->GenRenderbuffers(1, &m_multisampleColorBuffer); | |
| 659 } | |
| 660 } | |
| 661 | 637 |
| 662 bool DrawingBuffer::resizeFramebuffer(const IntSize& size, bool wantDepthOrStenc ilBuffer) | 638 if (m_gl->GetError() == GL_OUT_OF_MEMORY) |
| 663 { | |
| 664 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_fbo); | |
| 665 if (m_antiAliasingMode != MSAAExplicitResolve && wantDepthOrStencilBuffer) | |
| 666 resizeDepthStencil(size); | |
| 667 if (m_gl->CheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) | |
| 668 return false; | 639 return false; |
| 669 | 640 |
| 670 return true; | 641 m_gl->FramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDE RBUFFER, m_multisampleRenderbuffer); |
| 671 } | |
| 672 | 642 |
| 673 bool DrawingBuffer::resizeMultisampleFramebuffer(const IntSize& size, bool wantD epthOrStencilBuffer) | 643 if (m_intermediateFBO) { |
| 674 { | 644 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_intermediateFBO); |
| 675 if (m_antiAliasingMode == MSAAExplicitResolve) { | 645 m_gl->BindRenderbuffer(GL_RENDERBUFFER, m_intermediateRenderbuffer); |
| 676 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_multisampleFBO); | 646 m_gl->RenderbufferStorage(GL_RENDERBUFFER, m_colorBuffer.parameters.inte rnalRenderbufferFormat, size.width(), size.height()); |
| 677 | |
| 678 m_gl->BindRenderbuffer(GL_RENDERBUFFER, m_multisampleColorBuffer); | |
| 679 m_gl->RenderbufferStorageMultisampleCHROMIUM(GL_RENDERBUFFER, m_sampleCo unt, m_colorBuffer.parameters.internalRenderbufferFormat, size.width(), size.hei ght()); | |
| 680 | 647 |
| 681 if (m_gl->GetError() == GL_OUT_OF_MEMORY) | 648 if (m_gl->GetError() == GL_OUT_OF_MEMORY) |
| 682 return false; | 649 return false; |
| 683 | 650 |
| 684 m_gl->FramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_R ENDERBUFFER, m_multisampleColorBuffer); | 651 m_gl->FramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_R ENDERBUFFER, m_intermediateRenderbuffer); |
| 685 if (wantDepthOrStencilBuffer) | |
| 686 resizeDepthStencil(size); | |
| 687 if (m_gl->CheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPL ETE) | 652 if (m_gl->CheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPL ETE) |
| 688 return false; | 653 return false; |
| 689 | 654 |
| 690 if (m_intermediateFBO) { | 655 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_multisampleFBO); |
| 691 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_intermediateFBO); | |
| 692 m_gl->BindRenderbuffer(GL_RENDERBUFFER, m_intermediateRenderbuffer); | |
| 693 m_gl->RenderbufferStorage(GL_RENDERBUFFER, m_colorBuffer.parameters. internalRenderbufferFormat, size.width(), size.height()); | |
| 694 | |
| 695 if (m_gl->GetError() == GL_OUT_OF_MEMORY) | |
| 696 return false; | |
| 697 | |
| 698 m_gl->FramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, m_intermediateRenderbuffer); | |
| 699 if (m_gl->CheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_C OMPLETE) | |
| 700 return false; | |
| 701 | |
| 702 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_multisampleFBO); | |
| 703 } | |
| 704 } | 656 } |
| 705 | |
| 706 return true; | 657 return true; |
| 707 } | 658 } |
| 708 | 659 |
| 709 void DrawingBuffer::resizeDepthStencil(const IntSize& size) | 660 void DrawingBuffer::resizeDepthStencil(const IntSize& size) |
| 710 { | 661 { |
| 662 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_multisampleFBO ? m_multisampleFBO : m_fbo); | |
| 711 if (!m_depthStencilBuffer) | 663 if (!m_depthStencilBuffer) |
| 712 m_gl->GenRenderbuffers(1, &m_depthStencilBuffer); | 664 m_gl->GenRenderbuffers(1, &m_depthStencilBuffer); |
| 713 m_gl->BindRenderbuffer(GL_RENDERBUFFER, m_depthStencilBuffer); | 665 m_gl->BindRenderbuffer(GL_RENDERBUFFER, m_depthStencilBuffer); |
| 714 if (m_antiAliasingMode == MSAAImplicitResolve) | 666 if (m_antiAliasingMode == MSAAImplicitResolve) |
| 715 m_gl->RenderbufferStorageMultisampleEXT(GL_RENDERBUFFER, m_sampleCount, GL_DEPTH24_STENCIL8_OES, size.width(), size.height()); | 667 m_gl->RenderbufferStorageMultisampleEXT(GL_RENDERBUFFER, m_sampleCount, GL_DEPTH24_STENCIL8_OES, size.width(), size.height()); |
| 716 else if (m_antiAliasingMode == MSAAExplicitResolve) | 668 else if (m_antiAliasingMode == MSAAExplicitResolve) |
| 717 m_gl->RenderbufferStorageMultisampleCHROMIUM(GL_RENDERBUFFER, m_sampleCo unt, GL_DEPTH24_STENCIL8_OES, size.width(), size.height()); | 669 m_gl->RenderbufferStorageMultisampleCHROMIUM(GL_RENDERBUFFER, m_sampleCo unt, GL_DEPTH24_STENCIL8_OES, size.width(), size.height()); |
| 718 else | 670 else |
| 719 m_gl->RenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8_OES, size .width(), size.height()); | 671 m_gl->RenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8_OES, size .width(), size.height()); |
| 720 // For ES 2.0 contexts DEPTH_STENCIL is not available natively, so we emulat e it | 672 // For ES 2.0 contexts DEPTH_STENCIL is not available natively, so we emulat e it |
| 721 // at the command buffer level for WebGL contexts. | 673 // at the command buffer level for WebGL contexts. |
| 722 m_gl->FramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, G L_RENDERBUFFER, m_depthStencilBuffer); | 674 m_gl->FramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, G L_RENDERBUFFER, m_depthStencilBuffer); |
| 723 m_gl->BindRenderbuffer(GL_RENDERBUFFER, 0); | 675 m_gl->BindRenderbuffer(GL_RENDERBUFFER, 0); |
| 724 } | 676 } |
| 725 | 677 |
| 678 bool DrawingBuffer::resizeDefaultFramebuffer(const IntSize& size) | |
| 679 { | |
| 680 // Resize or create m_colorBuffer. | |
| 681 if (m_colorBuffer.textureId) { | |
| 682 resizeTextureMemory(&m_colorBuffer, size); | |
| 683 } else { | |
| 684 m_colorBuffer = createTextureAndAllocateMemory(size); | |
| 685 } | |
| 726 | 686 |
| 687 attachColorBufferToReadFramebuffer(); | |
| 688 | |
| 689 if (wantExplicitResolve()) { | |
| 690 if (!resizeMultisampleFramebuffer(size)) | |
| 691 return false; | |
| 692 } | |
| 693 | |
| 694 if (wantDepthOrStencil()) | |
| 695 resizeDepthStencil(size); | |
| 696 return m_gl->CheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLE TE; | |
| 697 } | |
| 727 | 698 |
| 728 void DrawingBuffer::clearFramebuffers(GLbitfield clearMask) | 699 void DrawingBuffer::clearFramebuffers(GLbitfield clearMask) |
| 729 { | 700 { |
| 730 // We will clear the multisample FBO, but we also need to clear the non-mult isampled buffer. | 701 // We will clear the multisample FBO, but we also need to clear the non-mult isampled buffer. |
| 731 if (m_multisampleFBO) { | 702 if (m_multisampleFBO) { |
| 732 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_fbo); | 703 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_fbo); |
| 733 m_gl->Clear(GL_COLOR_BUFFER_BIT); | 704 m_gl->Clear(GL_COLOR_BUFFER_BIT); |
| 734 } | 705 } |
| 735 | 706 |
| 736 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_multisampleFBO ? m_multisampleFBO : m_fbo); | 707 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_multisampleFBO ? m_multisampleFBO : m_fbo); |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 752 // Clamp if the desired size is greater than the maximum texture size for th e device. | 723 // Clamp if the desired size is greater than the maximum texture size for th e device. |
| 753 if (adjustedSize.height() > maxTextureSize) | 724 if (adjustedSize.height() > maxTextureSize) |
| 754 adjustedSize.setHeight(maxTextureSize); | 725 adjustedSize.setHeight(maxTextureSize); |
| 755 | 726 |
| 756 if (adjustedSize.width() > maxTextureSize) | 727 if (adjustedSize.width() > maxTextureSize) |
| 757 adjustedSize.setWidth(maxTextureSize); | 728 adjustedSize.setWidth(maxTextureSize); |
| 758 | 729 |
| 759 return adjustedSize; | 730 return adjustedSize; |
| 760 } | 731 } |
| 761 | 732 |
| 762 bool DrawingBuffer::reset(const IntSize& newSize, bool wantDepthOrStencilBuffer) | 733 bool DrawingBuffer::reset(const IntSize& newSize) |
| 763 { | 734 { |
| 764 ASSERT(!newSize.isEmpty()); | 735 ASSERT(!newSize.isEmpty()); |
| 765 IntSize adjustedSize = adjustSize(newSize, m_size, m_maxTextureSize); | 736 IntSize adjustedSize = adjustSize(newSize, m_size, m_maxTextureSize); |
| 766 if (adjustedSize.isEmpty()) | 737 if (adjustedSize.isEmpty()) |
| 767 return false; | 738 return false; |
| 768 | 739 |
| 769 if (adjustedSize != m_size) { | 740 if (adjustedSize != m_size) { |
| 770 do { | 741 do { |
| 771 if (m_colorBuffer.textureId) { | 742 if (!resizeDefaultFramebuffer(m_size)) { |
| 772 resizeTextureMemory(&m_colorBuffer, adjustedSize); | |
| 773 } else { | |
| 774 m_colorBuffer = createTextureAndAllocateMemory(adjustedSize); | |
| 775 } | |
| 776 | |
| 777 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_fbo); | |
| 778 attachColorBufferToCurrentFBO(); | |
| 779 | |
| 780 // resize multisample FBO | |
| 781 if (!resizeMultisampleFramebuffer(adjustedSize, wantDepthOrStencilBu ffer) | |
| 782 || !resizeFramebuffer(adjustedSize, wantDepthOrStencilBuffer)) { | |
| 783 adjustedSize.scale(s_resourceAdjustedRatio); | 743 adjustedSize.scale(s_resourceAdjustedRatio); |
| 784 continue; | 744 continue; |
| 785 } | 745 } |
| 786 break; | 746 break; |
| 787 } while (!adjustedSize.isEmpty()); | 747 } while (!adjustedSize.isEmpty()); |
| 788 | 748 |
| 789 setSize(adjustedSize); | 749 setSize(adjustedSize); |
| 790 | 750 |
| 791 if (adjustedSize.isEmpty()) | 751 if (adjustedSize.isEmpty()) |
| 792 return false; | 752 return false; |
| 793 } | 753 } |
| 794 | 754 |
| 795 m_gl->Disable(GL_SCISSOR_TEST); | 755 m_gl->Disable(GL_SCISSOR_TEST); |
| 796 m_gl->ClearColor(0, 0, 0, 0); | 756 m_gl->ClearColor(0, 0, 0, 0); |
| 797 m_gl->ColorMask(true, true, true, !requiresRGBEmulation()); | 757 m_gl->ColorMask(true, true, true, !requiresAlphaMask()); |
| 798 | 758 |
| 799 GLbitfield clearMask = GL_COLOR_BUFFER_BIT; | 759 GLbitfield clearMask = GL_COLOR_BUFFER_BIT; |
| 800 if (!!m_depthStencilBuffer) { | 760 if (!!m_depthStencilBuffer) { |
| 801 m_gl->ClearDepthf(1.0f); | 761 m_gl->ClearDepthf(1.0f); |
| 802 clearMask |= GL_DEPTH_BUFFER_BIT; | 762 clearMask |= GL_DEPTH_BUFFER_BIT; |
| 803 m_gl->DepthMask(true); | 763 m_gl->DepthMask(true); |
| 804 } | 764 } |
| 805 if (!!m_depthStencilBuffer) { | 765 if (!!m_depthStencilBuffer) { |
| 806 m_gl->ClearStencil(0); | 766 m_gl->ClearStencil(0); |
| 807 clearMask |= GL_STENCIL_BUFFER_BIT; | 767 clearMask |= GL_STENCIL_BUFFER_BIT; |
| 808 m_gl->StencilMaskSeparate(GL_FRONT, 0xFFFFFFFF); | 768 m_gl->StencilMaskSeparate(GL_FRONT, 0xFFFFFFFF); |
| 809 } | 769 } |
| 810 | 770 |
| 811 clearFramebuffers(clearMask); | 771 clearFramebuffers(clearMask); |
| 812 return true; | 772 return true; |
| 813 } | 773 } |
| 814 | 774 |
| 815 void DrawingBuffer::commit() | 775 void DrawingBuffer::commit() |
| 816 { | 776 { |
| 817 if (m_multisampleFBO && !m_contentsChangeCommitted) { | 777 if (wantExplicitResolve() && !m_contentsChangeCommitted) { |
| 818 m_gl->BindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, m_multisampleFBO); | 778 m_gl->BindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, m_multisampleFBO); |
| 819 m_gl->BindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, m_fbo); | 779 m_gl->BindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, m_fbo); |
| 820 | 780 |
| 821 if (m_scissorEnabled) | 781 if (m_scissorEnabled) |
| 822 m_gl->Disable(GL_SCISSOR_TEST); | 782 m_gl->Disable(GL_SCISSOR_TEST); |
| 823 | 783 |
| 824 int width = m_size.width(); | 784 int width = m_size.width(); |
| 825 int height = m_size.height(); | 785 int height = m_size.height(); |
| 826 // Use NEAREST, because there is no scale performed during the blit. | 786 // Use NEAREST, because there is no scale performed during the blit. |
| 827 GLuint filter = GL_NEAREST; | 787 GLuint filter = GL_NEAREST; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 890 } | 850 } |
| 891 } | 851 } |
| 892 | 852 |
| 893 bool DrawingBuffer::multisample() const | 853 bool DrawingBuffer::multisample() const |
| 894 { | 854 { |
| 895 return m_antiAliasingMode != None; | 855 return m_antiAliasingMode != None; |
| 896 } | 856 } |
| 897 | 857 |
| 898 void DrawingBuffer::bind(GLenum target) | 858 void DrawingBuffer::bind(GLenum target) |
| 899 { | 859 { |
| 900 if (target != GL_READ_FRAMEBUFFER) | 860 m_gl->BindFramebuffer(target, wantExplicitResolve() ? m_multisampleFBO : m_f bo); |
| 901 m_gl->BindFramebuffer(target, m_multisampleFBO ? m_multisampleFBO : m_fb o); | |
| 902 else | |
| 903 m_gl->BindFramebuffer(target, m_fbo); | |
| 904 } | 861 } |
| 905 | 862 |
| 906 void DrawingBuffer::setPackAlignment(GLint param) | 863 void DrawingBuffer::setPackAlignment(GLint param) |
| 907 { | 864 { |
| 908 m_packAlignment = param; | 865 m_packAlignment = param; |
| 909 } | 866 } |
| 910 | 867 |
| 911 bool DrawingBuffer::paintRenderingResultsToImageData(int& width, int& height, So urceDrawingBuffer sourceBuffer, WTF::ArrayBufferContents& contents) | 868 bool DrawingBuffer::paintRenderingResultsToImageData(int& width, int& height, So urceDrawingBuffer sourceBuffer, WTF::ArrayBufferContents& contents) |
| 912 { | 869 { |
| 913 ASSERT(!m_premultipliedAlpha); | 870 ASSERT(!m_premultipliedAlpha); |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1079 // If the desired texture target is different, there's no way to fall ba ck | 1036 // If the desired texture target is different, there's no way to fall ba ck |
| 1080 // to a non CHROMIUM_image texture. | 1037 // to a non CHROMIUM_image texture. |
| 1081 if (chromiumImageTextureParameters().target != defaultTextureParameters( ).target) | 1038 if (chromiumImageTextureParameters().target != defaultTextureParameters( ).target) |
| 1082 return; | 1039 return; |
| 1083 } | 1040 } |
| 1084 | 1041 |
| 1085 m_gl->BindTexture(info->parameters.target, info->textureId); | 1042 m_gl->BindTexture(info->parameters.target, info->textureId); |
| 1086 texImage2DResourceSafe(info->parameters.target, 0, info->parameters.creation InternalColorFormat, size.width(), size.height(), 0, info->parameters.colorForma t, GL_UNSIGNED_BYTE); | 1043 texImage2DResourceSafe(info->parameters.target, 0, info->parameters.creation InternalColorFormat, size.width(), size.height(), 0, info->parameters.colorForma t, GL_UNSIGNED_BYTE); |
| 1087 } | 1044 } |
| 1088 | 1045 |
| 1089 void DrawingBuffer::attachColorBufferToCurrentFBO() | 1046 void DrawingBuffer::attachColorBufferToReadFramebuffer() |
| 1090 { | 1047 { |
| 1048 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_fbo); | |
| 1049 | |
| 1091 GLenum target = m_colorBuffer.parameters.target; | 1050 GLenum target = m_colorBuffer.parameters.target; |
| 1051 GLenum id = m_colorBuffer.textureId; | |
| 1092 | 1052 |
| 1093 m_gl->BindTexture(target, m_colorBuffer.textureId); | 1053 m_gl->BindTexture(target, id); |
| 1094 | 1054 |
| 1095 if (m_antiAliasingMode == MSAAImplicitResolve) | 1055 if (m_antiAliasingMode == MSAAImplicitResolve) |
| 1096 m_gl->FramebufferTexture2DMultisampleEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACH MENT0, target, m_colorBuffer.textureId, 0, m_sampleCount); | 1056 m_gl->FramebufferTexture2DMultisampleEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACH MENT0, target, id, 0, m_sampleCount); |
| 1097 else | 1057 else |
| 1098 m_gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, target, m_colorBuffer.textureId, 0); | 1058 m_gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, target, id, 0); |
| 1099 | 1059 |
| 1060 restoreTextureBindings(); | |
| 1061 restoreFramebufferBindings(); | |
| 1062 } | |
| 1063 | |
| 1064 bool DrawingBuffer::wantExplicitResolve() | |
| 1065 { | |
| 1066 return m_antiAliasingMode == MSAAExplicitResolve; | |
| 1067 } | |
| 1068 | |
| 1069 bool DrawingBuffer::wantDepthOrStencil() | |
| 1070 { | |
| 1071 return m_wantDepth || m_wantStencil; | |
| 1072 } | |
| 1073 | |
| 1074 void DrawingBuffer::restoreTextureBindings() | |
| 1075 { | |
| 1076 // This class potentially modifies the bindings for GL_TEXTURE_2D and | |
| 1077 // GL_TEXTURE_RECTANGLE. Only GL_TEXTURE_2D needs to be restored since | |
| 1078 // the public interface for WebGL does not support GL_TEXTURE_RECTANGLE. | |
| 1100 m_gl->BindTexture(GL_TEXTURE_2D, m_texture2DBinding); | 1079 m_gl->BindTexture(GL_TEXTURE_2D, m_texture2DBinding); |
| 1101 } | 1080 } |
| 1102 | 1081 |
| 1103 } // namespace blink | 1082 } // namespace blink |
| OLD | NEW |