| 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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 TRACE_EVENT_SCOPE_GLOBAL); | 161 TRACE_EVENT_SCOPE_GLOBAL); |
| 162 } | 162 } |
| 163 | 163 |
| 164 DrawingBuffer::~DrawingBuffer() { | 164 DrawingBuffer::~DrawingBuffer() { |
| 165 DCHECK(m_destructionInProgress); | 165 DCHECK(m_destructionInProgress); |
| 166 m_layer.reset(); | 166 m_layer.reset(); |
| 167 m_contextProvider.reset(); | 167 m_contextProvider.reset(); |
| 168 } | 168 } |
| 169 | 169 |
| 170 bool DrawingBuffer::markContentsChanged() { | 170 bool DrawingBuffer::markContentsChanged() { |
| 171 if (m_contentsChangeCommitted || !m_contentsChanged) { | 171 if (m_contentsChangeResolved || !m_contentsChanged) { |
| 172 m_contentsChangeCommitted = false; | 172 m_contentsChangeResolved = false; |
| 173 m_contentsChanged = true; | 173 m_contentsChanged = true; |
| 174 return true; | 174 return true; |
| 175 } | 175 } |
| 176 return false; | 176 return false; |
| 177 } | 177 } |
| 178 | 178 |
| 179 bool DrawingBuffer::bufferClearNeeded() const { | 179 bool DrawingBuffer::bufferClearNeeded() const { |
| 180 return m_bufferClearNeeded; | 180 return m_bufferClearNeeded; |
| 181 } | 181 } |
| 182 | 182 |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 // be trying to get a new context and may change modes. | 277 // be trying to get a new context and may change modes. |
| 278 if (m_gl->GetGraphicsResetStatusKHR() != GL_NO_ERROR) | 278 if (m_gl->GetGraphicsResetStatusKHR() != GL_NO_ERROR) |
| 279 return false; | 279 return false; |
| 280 | 280 |
| 281 TRACE_EVENT0("blink,rail", "DrawingBuffer::prepareMailbox"); | 281 TRACE_EVENT0("blink,rail", "DrawingBuffer::prepareMailbox"); |
| 282 | 282 |
| 283 if (m_newMailboxCallback) | 283 if (m_newMailboxCallback) |
| 284 (*m_newMailboxCallback)(); | 284 (*m_newMailboxCallback)(); |
| 285 | 285 |
| 286 // Resolve the multisampled buffer into m_backColorBuffer texture. | 286 // Resolve the multisampled buffer into m_backColorBuffer texture. |
| 287 if (m_antiAliasingMode != None) | 287 resolveIfNeeded(); |
| 288 resolveMultisampleFramebufferInternal(); | |
| 289 | 288 |
| 290 if (m_softwareRendering && !forceGpuResult) { | 289 if (m_softwareRendering && !forceGpuResult) { |
| 291 return finishPrepareTextureMailboxSoftware(outMailbox, outReleaseCallback); | 290 return finishPrepareTextureMailboxSoftware(outMailbox, outReleaseCallback); |
| 292 } else { | 291 } else { |
| 293 return finishPrepareTextureMailboxGpu(outMailbox, outReleaseCallback); | 292 return finishPrepareTextureMailboxGpu(outMailbox, outReleaseCallback); |
| 294 } | 293 } |
| 295 } | 294 } |
| 296 | 295 |
| 297 bool DrawingBuffer::finishPrepareTextureMailboxSoftware( | 296 bool DrawingBuffer::finishPrepareTextureMailboxSoftware( |
| 298 cc::TextureMailbox* outMailbox, | 297 cc::TextureMailbox* outMailbox, |
| (...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 688 GLenum destType, | 687 GLenum destType, |
| 689 GLint level, | 688 GLint level, |
| 690 bool premultiplyAlpha, | 689 bool premultiplyAlpha, |
| 691 bool flipY, | 690 bool flipY, |
| 692 const IntPoint& destTextureOffset, | 691 const IntPoint& destTextureOffset, |
| 693 const IntRect& sourceSubRectangle, | 692 const IntRect& sourceSubRectangle, |
| 694 SourceDrawingBuffer sourceBuffer) { | 693 SourceDrawingBuffer sourceBuffer) { |
| 695 ScopedStateRestorer scopedStateRestorer(this); | 694 ScopedStateRestorer scopedStateRestorer(this); |
| 696 | 695 |
| 697 if (m_contentsChanged) { | 696 if (m_contentsChanged) { |
| 698 if (m_antiAliasingMode != None) | 697 resolveIfNeeded(); |
| 699 resolveMultisampleFramebufferInternal(); | |
| 700 m_gl->Flush(); | 698 m_gl->Flush(); |
| 701 } | 699 } |
| 702 | 700 |
| 703 // Assume that the destination target is GL_TEXTURE_2D. | 701 // Assume that the destination target is GL_TEXTURE_2D. |
| 704 if (!Extensions3DUtil::canUseCopyTextureCHROMIUM( | 702 if (!Extensions3DUtil::canUseCopyTextureCHROMIUM( |
| 705 GL_TEXTURE_2D, internalFormat, destType, level)) | 703 GL_TEXTURE_2D, internalFormat, destType, level)) |
| 706 return false; | 704 return false; |
| 707 | 705 |
| 708 // Contexts may be in a different share group. We must transfer the texture | 706 // Contexts may be in a different share group. We must transfer the texture |
| 709 // through a mailbox first. | 707 // through a mailbox first. |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 964 m_gl->StencilMaskSeparate(GL_FRONT, 0xFFFFFFFF); | 962 m_gl->StencilMaskSeparate(GL_FRONT, 0xFFFFFFFF); |
| 965 } | 963 } |
| 966 | 964 |
| 967 clearFramebuffersInternal(clearMask); | 965 clearFramebuffersInternal(clearMask); |
| 968 return true; | 966 return true; |
| 969 } | 967 } |
| 970 | 968 |
| 971 void DrawingBuffer::resolveAndBindForReadAndDraw() { | 969 void DrawingBuffer::resolveAndBindForReadAndDraw() { |
| 972 { | 970 { |
| 973 ScopedStateRestorer scopedStateRestorer(this); | 971 ScopedStateRestorer scopedStateRestorer(this); |
| 974 resolveMultisampleFramebufferInternal(); | 972 resolveIfNeeded(); |
| 975 } | 973 } |
| 976 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_fbo); | 974 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_fbo); |
| 977 } | 975 } |
| 978 | 976 |
| 979 void DrawingBuffer::resolveMultisampleFramebufferInternal() { | 977 void DrawingBuffer::resolveMultisampleFramebufferInternal() { |
| 980 DCHECK(m_stateRestorer); | 978 DCHECK(m_stateRestorer); |
| 981 m_stateRestorer->setFramebufferBindingDirty(); | 979 m_stateRestorer->setFramebufferBindingDirty(); |
| 982 if (wantExplicitResolve() && !m_contentsChangeCommitted) { | 980 if (wantExplicitResolve() && !m_contentsChangeResolved) { |
| 983 m_stateRestorer->setClearStateDirty(); | 981 m_stateRestorer->setClearStateDirty(); |
| 984 m_gl->BindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, m_multisampleFBO); | 982 m_gl->BindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, m_multisampleFBO); |
| 985 m_gl->BindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, m_fbo); | 983 m_gl->BindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, m_fbo); |
| 986 m_gl->Disable(GL_SCISSOR_TEST); | 984 m_gl->Disable(GL_SCISSOR_TEST); |
| 987 | 985 |
| 988 int width = m_size.width(); | 986 int width = m_size.width(); |
| 989 int height = m_size.height(); | 987 int height = m_size.height(); |
| 990 // Use NEAREST, because there is no scale performed during the blit. | 988 // Use NEAREST, because there is no scale performed during the blit. |
| 991 GLuint filter = GL_NEAREST; | 989 GLuint filter = GL_NEAREST; |
| 992 | 990 |
| 993 m_gl->BlitFramebufferCHROMIUM(0, 0, width, height, 0, 0, width, height, | 991 m_gl->BlitFramebufferCHROMIUM(0, 0, width, height, 0, 0, width, height, |
| 994 GL_COLOR_BUFFER_BIT, filter); | 992 GL_COLOR_BUFFER_BIT, filter); |
| 995 | 993 |
| 996 // On old AMD GPUs on OS X, glColorMask doesn't work correctly for | 994 // On old AMD GPUs on OS X, glColorMask doesn't work correctly for |
| 997 // multisampled renderbuffers and the alpha channel can be overwritten. | 995 // multisampled renderbuffers and the alpha channel can be overwritten. |
| 998 // Clear the alpha channel of |m_fbo|. | 996 // Clear the alpha channel of |m_fbo|. |
| 999 if (defaultBufferRequiresAlphaChannelToBePreserved() && | 997 if (defaultBufferRequiresAlphaChannelToBePreserved() && |
| 1000 contextProvider() | 998 contextProvider() |
| 1001 ->getCapabilities() | 999 ->getCapabilities() |
| 1002 .disable_multisampling_color_mask_usage) { | 1000 .disable_multisampling_color_mask_usage) { |
| 1003 m_gl->ClearColor(0, 0, 0, 1); | 1001 m_gl->ClearColor(0, 0, 0, 1); |
| 1004 m_gl->ColorMask(false, false, false, true); | 1002 m_gl->ColorMask(false, false, false, true); |
| 1005 m_gl->Clear(GL_COLOR_BUFFER_BIT); | 1003 m_gl->Clear(GL_COLOR_BUFFER_BIT); |
| 1006 } | 1004 } |
| 1007 } | 1005 } |
| 1008 | 1006 |
| 1009 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_fbo); | 1007 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_fbo); |
| 1010 if (m_antiAliasingMode == ScreenSpaceAntialiasing) | 1008 if (m_antiAliasingMode == ScreenSpaceAntialiasing) |
| 1011 m_gl->ApplyScreenSpaceAntialiasingCHROMIUM(); | 1009 m_gl->ApplyScreenSpaceAntialiasingCHROMIUM(); |
| 1012 m_contentsChangeCommitted = true; | 1010 } |
| 1011 |
| 1012 void DrawingBuffer::resolveIfNeeded() { |
| 1013 if (m_antiAliasingMode != None) |
| 1014 resolveMultisampleFramebufferInternal(); |
| 1015 m_contentsChangeResolved = true; |
| 1013 } | 1016 } |
| 1014 | 1017 |
| 1015 void DrawingBuffer::restoreFramebufferBindings() { | 1018 void DrawingBuffer::restoreFramebufferBindings() { |
| 1016 m_client->DrawingBufferClientRestoreFramebufferBinding(); | 1019 m_client->DrawingBufferClientRestoreFramebufferBinding(); |
| 1017 } | 1020 } |
| 1018 | 1021 |
| 1019 void DrawingBuffer::restoreAllState() { | 1022 void DrawingBuffer::restoreAllState() { |
| 1020 m_client->DrawingBufferClientRestoreScissorTest(); | 1023 m_client->DrawingBufferClientRestoreScissorTest(); |
| 1021 m_client->DrawingBufferClientRestoreMaskAndClearValues(); | 1024 m_client->DrawingBufferClientRestoreMaskAndClearValues(); |
| 1022 m_client->DrawingBufferClientRestorePixelPackAlignment(); | 1025 m_client->DrawingBufferClientRestorePixelPackAlignment(); |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1292 if (m_pixelUnpackBufferBindingDirty) | 1295 if (m_pixelUnpackBufferBindingDirty) |
| 1293 client->DrawingBufferClientRestorePixelUnpackBufferBinding(); | 1296 client->DrawingBufferClientRestorePixelUnpackBufferBinding(); |
| 1294 } | 1297 } |
| 1295 | 1298 |
| 1296 bool DrawingBuffer::shouldUseChromiumImage() { | 1299 bool DrawingBuffer::shouldUseChromiumImage() { |
| 1297 return RuntimeEnabledFeatures::webGLImageChromiumEnabled() && | 1300 return RuntimeEnabledFeatures::webGLImageChromiumEnabled() && |
| 1298 m_chromiumImageUsage == AllowChromiumImage; | 1301 m_chromiumImageUsage == AllowChromiumImage; |
| 1299 } | 1302 } |
| 1300 | 1303 |
| 1301 } // namespace blink | 1304 } // namespace blink |
| OLD | NEW |