| 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 24 matching lines...) Expand all Loading... |
| 35 #include <algorithm> | 35 #include <algorithm> |
| 36 #include "platform/TraceEvent.h" | 36 #include "platform/TraceEvent.h" |
| 37 #include "platform/graphics/GraphicsLayer.h" | 37 #include "platform/graphics/GraphicsLayer.h" |
| 38 #include "platform/graphics/gpu/Extensions3DUtil.h" | 38 #include "platform/graphics/gpu/Extensions3DUtil.h" |
| 39 #include "public/platform/Platform.h" | 39 #include "public/platform/Platform.h" |
| 40 #include "public/platform/WebCompositorSupport.h" | 40 #include "public/platform/WebCompositorSupport.h" |
| 41 #include "public/platform/WebExternalBitmap.h" | 41 #include "public/platform/WebExternalBitmap.h" |
| 42 #include "public/platform/WebExternalTextureLayer.h" | 42 #include "public/platform/WebExternalTextureLayer.h" |
| 43 #include "public/platform/WebGraphicsContext3D.h" | 43 #include "public/platform/WebGraphicsContext3D.h" |
| 44 #include "public/platform/WebGraphicsContext3DProvider.h" | 44 #include "public/platform/WebGraphicsContext3DProvider.h" |
| 45 #ifndef NDEBUG |
| 46 #include "wtf/RefCountedLeakCounter.h" |
| 47 #endif |
| 45 | 48 |
| 46 using namespace std; | 49 using namespace std; |
| 47 | 50 |
| 48 namespace WebCore { | 51 namespace WebCore { |
| 49 | 52 |
| 53 namespace { |
| 50 // Global resource ceiling (expressed in terms of pixels) for DrawingBuffer crea
tion and resize. | 54 // Global resource ceiling (expressed in terms of pixels) for DrawingBuffer crea
tion and resize. |
| 51 // When this limit is set, DrawingBuffer::create() and DrawingBuffer::reset() ca
lls that would | 55 // When this limit is set, DrawingBuffer::create() and DrawingBuffer::reset() ca
lls that would |
| 52 // exceed the global cap will instead clear the buffer. | 56 // exceed the global cap will instead clear the buffer. |
| 53 static const int s_maximumResourceUsePixels = 16 * 1024 * 1024; | 57 const int s_maximumResourceUsePixels = 16 * 1024 * 1024; |
| 54 static int s_currentResourceUsePixels = 0; | 58 int s_currentResourceUsePixels = 0; |
| 55 static const float s_resourceAdjustedRatio = 0.5; | 59 const float s_resourceAdjustedRatio = 0.5; |
| 56 | 60 |
| 57 static const bool s_allowContextEvictionOnCreate = true; | 61 const bool s_allowContextEvictionOnCreate = true; |
| 58 static const int s_maxScaleAttempts = 3; | 62 const int s_maxScaleAttempts = 3; |
| 63 |
| 64 DEFINE_DEBUG_ONLY_GLOBAL(WTF::RefCountedLeakCounter, drawingBufferCounter, ("Dra
wingBuffer")); |
| 59 | 65 |
| 60 class ScopedTextureUnit0BindingRestorer { | 66 class ScopedTextureUnit0BindingRestorer { |
| 61 public: | 67 public: |
| 62 ScopedTextureUnit0BindingRestorer(blink::WebGraphicsContext3D* context, GLen
um activeTextureUnit, Platform3DObject textureUnitZeroId) | 68 ScopedTextureUnit0BindingRestorer(blink::WebGraphicsContext3D* context, GLen
um activeTextureUnit, Platform3DObject textureUnitZeroId) |
| 63 : m_context(context) | 69 : m_context(context) |
| 64 , m_oldActiveTextureUnit(activeTextureUnit) | 70 , m_oldActiveTextureUnit(activeTextureUnit) |
| 65 , m_oldTextureUnitZeroId(textureUnitZeroId) | 71 , m_oldTextureUnitZeroId(textureUnitZeroId) |
| 66 { | 72 { |
| 67 m_context->activeTexture(GL_TEXTURE0); | 73 m_context->activeTexture(GL_TEXTURE0); |
| 68 } | 74 } |
| 69 ~ScopedTextureUnit0BindingRestorer() | 75 ~ScopedTextureUnit0BindingRestorer() |
| 70 { | 76 { |
| 71 m_context->bindTexture(GL_TEXTURE_2D, m_oldTextureUnitZeroId); | 77 m_context->bindTexture(GL_TEXTURE_2D, m_oldTextureUnitZeroId); |
| 72 m_context->activeTexture(m_oldActiveTextureUnit); | 78 m_context->activeTexture(m_oldActiveTextureUnit); |
| 73 } | 79 } |
| 74 | 80 |
| 75 private: | 81 private: |
| 76 blink::WebGraphicsContext3D* m_context; | 82 blink::WebGraphicsContext3D* m_context; |
| 77 GLenum m_oldActiveTextureUnit; | 83 GLenum m_oldActiveTextureUnit; |
| 78 Platform3DObject m_oldTextureUnitZeroId; | 84 Platform3DObject m_oldTextureUnitZeroId; |
| 79 }; | 85 }; |
| 80 | 86 |
| 87 } // namespace |
| 88 |
| 81 PassRefPtr<DrawingBuffer> DrawingBuffer::create(PassOwnPtr<blink::WebGraphicsCon
text3D> context, const IntSize& size, PreserveDrawingBuffer preserve, PassRefPtr
<ContextEvictionManager> contextEvictionManager) | 89 PassRefPtr<DrawingBuffer> DrawingBuffer::create(PassOwnPtr<blink::WebGraphicsCon
text3D> context, const IntSize& size, PreserveDrawingBuffer preserve, PassRefPtr
<ContextEvictionManager> contextEvictionManager) |
| 82 { | 90 { |
| 83 ASSERT(context); | 91 ASSERT(context); |
| 84 Extensions3DUtil extensionsUtil(context.get()); | 92 Extensions3DUtil extensionsUtil(context.get()); |
| 85 bool multisampleSupported = extensionsUtil.supportsExtension("GL_CHROMIUM_fr
amebuffer_multisample") | 93 bool multisampleSupported = extensionsUtil.supportsExtension("GL_CHROMIUM_fr
amebuffer_multisample") |
| 86 && extensionsUtil.supportsExtension("GL_OES_rgb8_rgba8"); | 94 && extensionsUtil.supportsExtension("GL_OES_rgb8_rgba8"); |
| 87 if (multisampleSupported) { | 95 if (multisampleSupported) { |
| 88 extensionsUtil.ensureExtensionEnabled("GL_CHROMIUM_framebuffer_multisamp
le"); | 96 extensionsUtil.ensureExtensionEnabled("GL_CHROMIUM_framebuffer_multisamp
le"); |
| 89 extensionsUtil.ensureExtensionEnabled("GL_OES_rgb8_rgba8"); | 97 extensionsUtil.ensureExtensionEnabled("GL_OES_rgb8_rgba8"); |
| 90 } | 98 } |
| 91 bool packedDepthStencilSupported = extensionsUtil.supportsExtension("GL_OES_
packed_depth_stencil"); | 99 bool packedDepthStencilSupported = extensionsUtil.supportsExtension("GL_OES_
packed_depth_stencil"); |
| 92 if (packedDepthStencilSupported) | 100 if (packedDepthStencilSupported) |
| 93 extensionsUtil.ensureExtensionEnabled("GL_OES_packed_depth_stencil"); | 101 extensionsUtil.ensureExtensionEnabled("GL_OES_packed_depth_stencil"); |
| 94 | 102 |
| 95 RefPtr<DrawingBuffer> drawingBuffer = adoptRef(new DrawingBuffer(context, mu
ltisampleSupported, packedDepthStencilSupported, preserve, contextEvictionManage
r)); | 103 RefPtr<DrawingBuffer> drawingBuffer = adoptRef(new DrawingBuffer(context, mu
ltisampleSupported, packedDepthStencilSupported, preserve, contextEvictionManage
r)); |
| 96 if (!drawingBuffer->initialize(size)) | 104 if (!drawingBuffer->initialize(size)) { |
| 105 drawingBuffer->beginDestruction(); |
| 97 return PassRefPtr<DrawingBuffer>(); | 106 return PassRefPtr<DrawingBuffer>(); |
| 107 } |
| 98 return drawingBuffer.release(); | 108 return drawingBuffer.release(); |
| 99 } | 109 } |
| 100 | 110 |
| 101 DrawingBuffer::DrawingBuffer(PassOwnPtr<blink::WebGraphicsContext3D> context, | 111 DrawingBuffer::DrawingBuffer(PassOwnPtr<blink::WebGraphicsContext3D> context, |
| 102 bool multisampleExtensionSupported, | 112 bool multisampleExtensionSupported, |
| 103 bool packedDepthStencilExtensionSupported, | 113 bool packedDepthStencilExtensionSupported, |
| 104 PreserveDrawingBuffer preserve, | 114 PreserveDrawingBuffer preserve, |
| 105 PassRefPtr<ContextEvictionManager> contextEvictionManager) | 115 PassRefPtr<ContextEvictionManager> contextEvictionManager) |
| 106 : m_preserveDrawingBuffer(preserve) | 116 : m_preserveDrawingBuffer(preserve) |
| 107 , m_scissorEnabled(false) | 117 , m_scissorEnabled(false) |
| (...skipping 15 matching lines...) Expand all Loading... |
| 123 , m_contentsChanged(true) | 133 , m_contentsChanged(true) |
| 124 , m_contentsChangeCommitted(false) | 134 , m_contentsChangeCommitted(false) |
| 125 , m_layerComposited(false) | 135 , m_layerComposited(false) |
| 126 , m_multisampleMode(None) | 136 , m_multisampleMode(None) |
| 127 , m_internalColorFormat(0) | 137 , m_internalColorFormat(0) |
| 128 , m_colorFormat(0) | 138 , m_colorFormat(0) |
| 129 , m_internalRenderbufferFormat(0) | 139 , m_internalRenderbufferFormat(0) |
| 130 , m_maxTextureSize(0) | 140 , m_maxTextureSize(0) |
| 131 , m_sampleCount(0) | 141 , m_sampleCount(0) |
| 132 , m_packAlignment(4) | 142 , m_packAlignment(4) |
| 143 , m_destructionInProgress(false) |
| 133 , m_contextEvictionManager(contextEvictionManager) | 144 , m_contextEvictionManager(contextEvictionManager) |
| 134 { | 145 { |
| 135 // Used by browser tests to detect the use of a DrawingBuffer. | 146 // Used by browser tests to detect the use of a DrawingBuffer. |
| 136 TRACE_EVENT_INSTANT0("test_gpu", "DrawingBufferCreation"); | 147 TRACE_EVENT_INSTANT0("test_gpu", "DrawingBufferCreation"); |
| 148 #ifndef NDEBUG |
| 149 drawingBufferCounter.increment(); |
| 150 #endif |
| 137 } | 151 } |
| 138 | 152 |
| 139 DrawingBuffer::~DrawingBuffer() | 153 DrawingBuffer::~DrawingBuffer() |
| 140 { | 154 { |
| 141 releaseResources(); | 155 ASSERT(m_destructionInProgress); |
| 156 ASSERT(m_textureMailboxes.isEmpty()); |
| 157 m_layer.clear(); |
| 158 m_context.clear(); |
| 159 #ifndef NDEBUG |
| 160 drawingBufferCounter.decrement(); |
| 161 #endif |
| 142 } | 162 } |
| 143 | 163 |
| 144 void DrawingBuffer::markContentsChanged() | 164 void DrawingBuffer::markContentsChanged() |
| 145 { | 165 { |
| 146 m_contentsChanged = true; | 166 m_contentsChanged = true; |
| 147 m_contentsChangeCommitted = false; | 167 m_contentsChangeCommitted = false; |
| 148 m_layerComposited = false; | 168 m_layerComposited = false; |
| 149 } | 169 } |
| 150 | 170 |
| 151 bool DrawingBuffer::layerComposited() const | 171 bool DrawingBuffer::layerComposited() const |
| 152 { | 172 { |
| 153 return m_layerComposited; | 173 return m_layerComposited; |
| 154 } | 174 } |
| 155 | 175 |
| 156 void DrawingBuffer::markLayerComposited() | 176 void DrawingBuffer::markLayerComposited() |
| 157 { | 177 { |
| 158 m_layerComposited = true; | 178 m_layerComposited = true; |
| 159 } | 179 } |
| 160 | 180 |
| 161 blink::WebGraphicsContext3D* DrawingBuffer::context() | 181 blink::WebGraphicsContext3D* DrawingBuffer::context() |
| 162 { | 182 { |
| 163 return m_context.get(); | 183 return m_context.get(); |
| 164 } | 184 } |
| 165 | 185 |
| 166 bool DrawingBuffer::prepareMailbox(blink::WebExternalTextureMailbox* outMailbox,
blink::WebExternalBitmap* bitmap) | 186 bool DrawingBuffer::prepareMailbox(blink::WebExternalTextureMailbox* outMailbox,
blink::WebExternalBitmap* bitmap) |
| 167 { | 187 { |
| 188 // prepareMailbox() is always called after layout. |
| 189 ASSERT(!m_destructionInProgress); |
| 190 |
| 168 if (!m_contentsChanged) | 191 if (!m_contentsChanged) |
| 169 return false; | 192 return false; |
| 170 | 193 |
| 171 m_context->makeContextCurrent(); | 194 m_context->makeContextCurrent(); |
| 172 | 195 |
| 173 // Resolve the multisampled buffer into m_colorBuffer texture. | 196 // Resolve the multisampled buffer into m_colorBuffer texture. |
| 174 if (m_multisampleMode != None) | 197 if (m_multisampleMode != None) |
| 175 commit(); | 198 commit(); |
| 176 | 199 |
| 177 if (bitmap) { | 200 if (bitmap) { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 restoreFramebufferBinding(); | 245 restoreFramebufferBinding(); |
| 223 | 246 |
| 224 m_contentsChanged = false; | 247 m_contentsChanged = false; |
| 225 | 248 |
| 226 m_context->bindTexture(GL_TEXTURE_2D, frontColorBufferMailbox->textureId); | 249 m_context->bindTexture(GL_TEXTURE_2D, frontColorBufferMailbox->textureId); |
| 227 m_context->produceTextureCHROMIUM(GL_TEXTURE_2D, frontColorBufferMailbox->ma
ilbox.name); | 250 m_context->produceTextureCHROMIUM(GL_TEXTURE_2D, frontColorBufferMailbox->ma
ilbox.name); |
| 228 m_context->flush(); | 251 m_context->flush(); |
| 229 frontColorBufferMailbox->mailbox.syncPoint = m_context->insertSyncPoint(); | 252 frontColorBufferMailbox->mailbox.syncPoint = m_context->insertSyncPoint(); |
| 230 markLayerComposited(); | 253 markLayerComposited(); |
| 231 | 254 |
| 255 // set m_parentDrawingBuffer to make sure 'this' stays alive as long as it h
as live mailboxes |
| 256 ASSERT(!frontColorBufferMailbox->m_parentDrawingBuffer); |
| 257 frontColorBufferMailbox->m_parentDrawingBuffer = this; |
| 232 *outMailbox = frontColorBufferMailbox->mailbox; | 258 *outMailbox = frontColorBufferMailbox->mailbox; |
| 233 m_frontColorBuffer = frontColorBufferMailbox->textureId; | 259 m_frontColorBuffer = frontColorBufferMailbox->textureId; |
| 234 return true; | 260 return true; |
| 235 } | 261 } |
| 236 | 262 |
| 237 void DrawingBuffer::mailboxReleased(const blink::WebExternalTextureMailbox& mail
box) | 263 void DrawingBuffer::mailboxReleased(const blink::WebExternalTextureMailbox& mail
box) |
| 238 { | 264 { |
| 265 if (m_destructionInProgress) { |
| 266 mailboxReleasedWhileDestructionInProgress(mailbox); |
| 267 return; |
| 268 } |
| 269 |
| 239 for (size_t i = 0; i < m_textureMailboxes.size(); i++) { | 270 for (size_t i = 0; i < m_textureMailboxes.size(); i++) { |
| 240 RefPtr<MailboxInfo> mailboxInfo = m_textureMailboxes[i]; | 271 RefPtr<MailboxInfo> mailboxInfo = m_textureMailboxes[i]; |
| 241 if (!memcmp(mailboxInfo->mailbox.name, mailbox.name, sizeof(mailbox.name
))) { | 272 if (mailboxInfo->mailbox == mailbox) { |
| 242 mailboxInfo->mailbox.syncPoint = mailbox.syncPoint; | 273 mailboxInfo->mailbox.syncPoint = mailbox.syncPoint; |
| 243 m_recycledMailboxes.prepend(mailboxInfo.release()); | 274 ASSERT(mailboxInfo->m_parentDrawingBuffer.get() == this); |
| 275 mailboxInfo->m_parentDrawingBuffer.clear(); |
| 276 m_recycledMailboxQueue.prepend(mailboxInfo->mailbox); |
| 244 return; | 277 return; |
| 245 } | 278 } |
| 246 } | 279 } |
| 247 ASSERT_NOT_REACHED(); | 280 ASSERT_NOT_REACHED(); |
| 248 } | 281 } |
| 249 | 282 |
| 283 void DrawingBuffer::mailboxReleasedWhileDestructionInProgress(const blink::WebEx
ternalTextureMailbox& mailbox) |
| 284 { |
| 285 ASSERT(m_textureMailboxes.size()); |
| 286 m_context->makeContextCurrent(); |
| 287 // Ensure not to call the destructor until deleteMailbox() is completed. |
| 288 RefPtr<DrawingBuffer> self = this; |
| 289 deleteMailbox(mailbox); |
| 290 } |
| 291 |
| 250 PassRefPtr<DrawingBuffer::MailboxInfo> DrawingBuffer::recycledMailbox() | 292 PassRefPtr<DrawingBuffer::MailboxInfo> DrawingBuffer::recycledMailbox() |
| 251 { | 293 { |
| 252 if (m_recycledMailboxes.isEmpty()) | 294 if (m_recycledMailboxQueue.isEmpty()) |
| 253 return PassRefPtr<MailboxInfo>(); | 295 return PassRefPtr<MailboxInfo>(); |
| 254 | 296 |
| 255 RefPtr<MailboxInfo> mailboxInfo = m_recycledMailboxes.last().release(); | 297 blink::WebExternalTextureMailbox mailbox = m_recycledMailboxQueue.takeLast()
; |
| 256 m_recycledMailboxes.removeLast(); | 298 RefPtr<MailboxInfo> mailboxInfo; |
| 299 for (size_t i = 0; i < m_textureMailboxes.size(); i++) { |
| 300 if (m_textureMailboxes[i]->mailbox == mailbox) { |
| 301 mailboxInfo = m_textureMailboxes[i]; |
| 302 break; |
| 303 } |
| 304 } |
| 305 ASSERT(mailboxInfo); |
| 257 | 306 |
| 258 if (mailboxInfo->mailbox.syncPoint) { | 307 if (mailboxInfo->mailbox.syncPoint) { |
| 259 m_context->waitSyncPoint(mailboxInfo->mailbox.syncPoint); | 308 m_context->waitSyncPoint(mailboxInfo->mailbox.syncPoint); |
| 260 mailboxInfo->mailbox.syncPoint = 0; | 309 mailboxInfo->mailbox.syncPoint = 0; |
| 261 } | 310 } |
| 262 | 311 |
| 263 if (mailboxInfo->size != m_size) { | 312 if (mailboxInfo->size != m_size) { |
| 264 m_context->bindTexture(GL_TEXTURE_2D, mailboxInfo->textureId); | 313 m_context->bindTexture(GL_TEXTURE_2D, mailboxInfo->textureId); |
| 265 texImage2DResourceSafe(GL_TEXTURE_2D, 0, m_internalColorFormat, m_size.w
idth(), m_size.height(), 0, m_colorFormat, GL_UNSIGNED_BYTE); | 314 texImage2DResourceSafe(GL_TEXTURE_2D, 0, m_internalColorFormat, m_size.w
idth(), m_size.height(), 0, m_colorFormat, GL_UNSIGNED_BYTE); |
| 266 mailboxInfo->size = m_size; | 315 mailboxInfo->size = m_size; |
| 267 } | 316 } |
| 268 | 317 |
| 269 return mailboxInfo.release(); | 318 return mailboxInfo.release(); |
| 270 } | 319 } |
| 271 | 320 |
| 272 PassRefPtr<DrawingBuffer::MailboxInfo> DrawingBuffer::createNewMailbox(unsigned
textureId) | 321 PassRefPtr<DrawingBuffer::MailboxInfo> DrawingBuffer::createNewMailbox(unsigned
textureId) |
| 273 { | 322 { |
| 274 RefPtr<MailboxInfo> returnMailbox = adoptRef(new MailboxInfo()); | 323 RefPtr<MailboxInfo> returnMailbox = adoptRef(new MailboxInfo()); |
| 275 m_context->genMailboxCHROMIUM(returnMailbox->mailbox.name); | 324 m_context->genMailboxCHROMIUM(returnMailbox->mailbox.name); |
| 276 returnMailbox->textureId = textureId; | 325 returnMailbox->textureId = textureId; |
| 277 returnMailbox->size = m_size; | 326 returnMailbox->size = m_size; |
| 278 m_textureMailboxes.append(returnMailbox); | 327 m_textureMailboxes.append(returnMailbox); |
| 279 return returnMailbox.release(); | 328 return returnMailbox.release(); |
| 280 } | 329 } |
| 281 | 330 |
| 331 void DrawingBuffer::deleteMailbox(const blink::WebExternalTextureMailbox& mailbo
x) |
| 332 { |
| 333 for (size_t i = 0; i < m_textureMailboxes.size(); i++) { |
| 334 if (m_textureMailboxes[i]->mailbox == mailbox) { |
| 335 m_context->deleteTexture(m_textureMailboxes[i]->textureId); |
| 336 m_textureMailboxes.remove(i); |
| 337 return; |
| 338 } |
| 339 } |
| 340 ASSERT_NOT_REACHED(); |
| 341 } |
| 342 |
| 282 bool DrawingBuffer::initialize(const IntSize& size) | 343 bool DrawingBuffer::initialize(const IntSize& size) |
| 283 { | 344 { |
| 284 m_attributes = m_context->getContextAttributes(); | 345 m_attributes = m_context->getContextAttributes(); |
| 285 Extensions3DUtil extensionsUtil(m_context.get()); | 346 Extensions3DUtil extensionsUtil(m_context.get()); |
| 286 | 347 |
| 287 if (m_attributes.alpha) { | 348 if (m_attributes.alpha) { |
| 288 m_internalColorFormat = GL_RGBA; | 349 m_internalColorFormat = GL_RGBA; |
| 289 m_colorFormat = GL_RGBA; | 350 m_colorFormat = GL_RGBA; |
| 290 m_internalRenderbufferFormat = GL_RGBA8_OES; | 351 m_internalRenderbufferFormat = GL_RGBA8_OES; |
| 291 } else { | 352 } else { |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 } | 527 } |
| 467 | 528 |
| 468 void DrawingBuffer::clearPlatformLayer() | 529 void DrawingBuffer::clearPlatformLayer() |
| 469 { | 530 { |
| 470 if (m_layer) | 531 if (m_layer) |
| 471 m_layer->clearTexture(); | 532 m_layer->clearTexture(); |
| 472 | 533 |
| 473 m_context->flush(); | 534 m_context->flush(); |
| 474 } | 535 } |
| 475 | 536 |
| 476 void DrawingBuffer::releaseResources() | 537 void DrawingBuffer::beginDestruction() |
| 477 { | 538 { |
| 539 ASSERT(!m_destructionInProgress); |
| 540 m_destructionInProgress = true; |
| 541 |
| 478 m_context->makeContextCurrent(); | 542 m_context->makeContextCurrent(); |
| 479 | 543 |
| 480 clearPlatformLayer(); | 544 clearPlatformLayer(); |
| 481 | 545 |
| 482 for (size_t i = 0; i < m_textureMailboxes.size(); i++) | 546 while (!m_recycledMailboxQueue.isEmpty()) |
| 483 m_context->deleteTexture(m_textureMailboxes[i]->textureId); | 547 deleteMailbox(m_recycledMailboxQueue.takeLast()); |
| 484 | 548 |
| 485 if (m_multisampleFBO) | 549 if (m_multisampleFBO) |
| 486 m_context->deleteFramebuffer(m_multisampleFBO); | 550 m_context->deleteFramebuffer(m_multisampleFBO); |
| 487 | 551 |
| 488 if (m_fbo) | 552 if (m_fbo) |
| 489 m_context->deleteFramebuffer(m_fbo); | 553 m_context->deleteFramebuffer(m_fbo); |
| 490 | 554 |
| 491 if (m_multisampleColorBuffer) | 555 if (m_multisampleColorBuffer) |
| 492 m_context->deleteRenderbuffer(m_multisampleColorBuffer); | 556 m_context->deleteRenderbuffer(m_multisampleColorBuffer); |
| 493 | 557 |
| 494 if (m_depthStencilBuffer) | 558 if (m_depthStencilBuffer) |
| 495 m_context->deleteRenderbuffer(m_depthStencilBuffer); | 559 m_context->deleteRenderbuffer(m_depthStencilBuffer); |
| 496 | 560 |
| 497 if (m_depthBuffer) | 561 if (m_depthBuffer) |
| 498 m_context->deleteRenderbuffer(m_depthBuffer); | 562 m_context->deleteRenderbuffer(m_depthBuffer); |
| 499 | 563 |
| 500 if (m_stencilBuffer) | 564 if (m_stencilBuffer) |
| 501 m_context->deleteRenderbuffer(m_stencilBuffer); | 565 m_context->deleteRenderbuffer(m_stencilBuffer); |
| 502 | 566 |
| 503 if (m_colorBuffer) | 567 if (m_colorBuffer) |
| 504 m_context->deleteTexture(m_colorBuffer); | 568 m_context->deleteTexture(m_colorBuffer); |
| 505 | 569 |
| 506 m_context.clear(); | |
| 507 | |
| 508 setSize(IntSize()); | 570 setSize(IntSize()); |
| 509 | 571 |
| 510 m_colorBuffer = 0; | 572 m_colorBuffer = 0; |
| 511 m_frontColorBuffer = 0; | 573 m_frontColorBuffer = 0; |
| 512 m_multisampleColorBuffer = 0; | 574 m_multisampleColorBuffer = 0; |
| 513 m_depthStencilBuffer = 0; | 575 m_depthStencilBuffer = 0; |
| 514 m_depthBuffer = 0; | 576 m_depthBuffer = 0; |
| 515 m_stencilBuffer = 0; | 577 m_stencilBuffer = 0; |
| 516 m_multisampleFBO = 0; | 578 m_multisampleFBO = 0; |
| 517 m_fbo = 0; | 579 m_fbo = 0; |
| 518 m_contextEvictionManager.clear(); | 580 m_contextEvictionManager.clear(); |
| 519 | 581 |
| 520 m_recycledMailboxes.clear(); | 582 if (m_layer) |
| 521 m_textureMailboxes.clear(); | |
| 522 | |
| 523 if (m_layer) { | |
| 524 GraphicsLayer::unregisterContentsLayer(m_layer->layer()); | 583 GraphicsLayer::unregisterContentsLayer(m_layer->layer()); |
| 525 m_layer.clear(); | |
| 526 } | |
| 527 } | 584 } |
| 528 | 585 |
| 529 unsigned DrawingBuffer::createColorTexture(const IntSize& size) | 586 unsigned DrawingBuffer::createColorTexture(const IntSize& size) |
| 530 { | 587 { |
| 531 unsigned offscreenColorTexture = m_context->createTexture(); | 588 unsigned offscreenColorTexture = m_context->createTexture(); |
| 532 if (!offscreenColorTexture) | 589 if (!offscreenColorTexture) |
| 533 return 0; | 590 return 0; |
| 534 | 591 |
| 535 m_context->bindTexture(GL_TEXTURE_2D, offscreenColorTexture); | 592 m_context->bindTexture(GL_TEXTURE_2D, offscreenColorTexture); |
| 536 m_context->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); | 593 m_context->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
| (...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 929 } | 986 } |
| 930 } | 987 } |
| 931 | 988 |
| 932 void DrawingBuffer::texImage2DResourceSafe(GLenum target, GLint level, GLenum in
ternalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum
type, GLint unpackAlignment) | 989 void DrawingBuffer::texImage2DResourceSafe(GLenum target, GLint level, GLenum in
ternalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum
type, GLint unpackAlignment) |
| 933 { | 990 { |
| 934 ASSERT(unpackAlignment == 1 || unpackAlignment == 2 || unpackAlignment == 4
|| unpackAlignment == 8); | 991 ASSERT(unpackAlignment == 1 || unpackAlignment == 2 || unpackAlignment == 4
|| unpackAlignment == 8); |
| 935 m_context->texImage2D(target, level, internalformat, width, height, border,
format, type, 0); | 992 m_context->texImage2D(target, level, internalformat, width, height, border,
format, type, 0); |
| 936 } | 993 } |
| 937 | 994 |
| 938 } // namespace WebCore | 995 } // namespace WebCore |
| OLD | NEW |