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 OwnPtr<Extensions3DUtil> extensionsUtil = Extensions3DUtil::create(context.g
et()); | 92 OwnPtr<Extensions3DUtil> extensionsUtil = Extensions3DUtil::create(context.g
et()); |
85 if (!extensionsUtil) { | 93 if (!extensionsUtil) { |
86 // This might be the first time we notice that the WebGraphicsContext3D
is lost. | 94 // This might be the first time we notice that the WebGraphicsContext3D
is lost. |
87 return nullptr; | 95 return nullptr; |
88 } | 96 } |
89 bool multisampleSupported = extensionsUtil->supportsExtension("GL_CHROMIUM_f
ramebuffer_multisample") | 97 bool multisampleSupported = extensionsUtil->supportsExtension("GL_CHROMIUM_f
ramebuffer_multisample") |
90 && extensionsUtil->supportsExtension("GL_OES_rgb8_rgba8"); | 98 && extensionsUtil->supportsExtension("GL_OES_rgb8_rgba8"); |
91 if (multisampleSupported) { | 99 if (multisampleSupported) { |
92 extensionsUtil->ensureExtensionEnabled("GL_CHROMIUM_framebuffer_multisam
ple"); | 100 extensionsUtil->ensureExtensionEnabled("GL_CHROMIUM_framebuffer_multisam
ple"); |
93 extensionsUtil->ensureExtensionEnabled("GL_OES_rgb8_rgba8"); | 101 extensionsUtil->ensureExtensionEnabled("GL_OES_rgb8_rgba8"); |
94 } | 102 } |
95 bool packedDepthStencilSupported = extensionsUtil->supportsExtension("GL_OES
_packed_depth_stencil"); | 103 bool packedDepthStencilSupported = extensionsUtil->supportsExtension("GL_OES
_packed_depth_stencil"); |
96 if (packedDepthStencilSupported) | 104 if (packedDepthStencilSupported) |
97 extensionsUtil->ensureExtensionEnabled("GL_OES_packed_depth_stencil"); | 105 extensionsUtil->ensureExtensionEnabled("GL_OES_packed_depth_stencil"); |
98 | 106 |
99 RefPtr<DrawingBuffer> drawingBuffer = adoptRef(new DrawingBuffer(context, ex
tensionsUtil.release(), multisampleSupported, packedDepthStencilSupported, prese
rve, contextEvictionManager)); | 107 RefPtr<DrawingBuffer> drawingBuffer = adoptRef(new DrawingBuffer(context, ex
tensionsUtil.release(), multisampleSupported, packedDepthStencilSupported, prese
rve, contextEvictionManager)); |
100 if (!drawingBuffer->initialize(size)) | 108 if (!drawingBuffer->initialize(size)) { |
| 109 drawingBuffer->beginDestruction(); |
101 return PassRefPtr<DrawingBuffer>(); | 110 return PassRefPtr<DrawingBuffer>(); |
| 111 } |
102 return drawingBuffer.release(); | 112 return drawingBuffer.release(); |
103 } | 113 } |
104 | 114 |
105 DrawingBuffer::DrawingBuffer(PassOwnPtr<blink::WebGraphicsContext3D> context, | 115 DrawingBuffer::DrawingBuffer(PassOwnPtr<blink::WebGraphicsContext3D> context, |
106 PassOwnPtr<Extensions3DUtil> extensionsUtil, | 116 PassOwnPtr<Extensions3DUtil> extensionsUtil, |
107 bool multisampleExtensionSupported, | 117 bool multisampleExtensionSupported, |
108 bool packedDepthStencilExtensionSupported, | 118 bool packedDepthStencilExtensionSupported, |
109 PreserveDrawingBuffer preserve, | 119 PreserveDrawingBuffer preserve, |
110 PassRefPtr<ContextEvictionManager> contextEvictionManager) | 120 PassRefPtr<ContextEvictionManager> contextEvictionManager) |
111 : m_preserveDrawingBuffer(preserve) | 121 : m_preserveDrawingBuffer(preserve) |
(...skipping 17 matching lines...) Expand all Loading... |
129 , m_contentsChanged(true) | 139 , m_contentsChanged(true) |
130 , m_contentsChangeCommitted(false) | 140 , m_contentsChangeCommitted(false) |
131 , m_layerComposited(false) | 141 , m_layerComposited(false) |
132 , m_multisampleMode(None) | 142 , m_multisampleMode(None) |
133 , m_internalColorFormat(0) | 143 , m_internalColorFormat(0) |
134 , m_colorFormat(0) | 144 , m_colorFormat(0) |
135 , m_internalRenderbufferFormat(0) | 145 , m_internalRenderbufferFormat(0) |
136 , m_maxTextureSize(0) | 146 , m_maxTextureSize(0) |
137 , m_sampleCount(0) | 147 , m_sampleCount(0) |
138 , m_packAlignment(4) | 148 , m_packAlignment(4) |
| 149 , m_destructionInProgress(false) |
139 , m_contextEvictionManager(contextEvictionManager) | 150 , m_contextEvictionManager(contextEvictionManager) |
140 { | 151 { |
141 // Used by browser tests to detect the use of a DrawingBuffer. | 152 // Used by browser tests to detect the use of a DrawingBuffer. |
142 TRACE_EVENT_INSTANT0("test_gpu", "DrawingBufferCreation"); | 153 TRACE_EVENT_INSTANT0("test_gpu", "DrawingBufferCreation"); |
| 154 #ifndef NDEBUG |
| 155 drawingBufferCounter.increment(); |
| 156 #endif |
143 } | 157 } |
144 | 158 |
145 DrawingBuffer::~DrawingBuffer() | 159 DrawingBuffer::~DrawingBuffer() |
146 { | 160 { |
147 releaseResources(); | 161 ASSERT(m_destructionInProgress); |
| 162 ASSERT(m_textureMailboxes.isEmpty()); |
| 163 m_layer.clear(); |
| 164 m_context.clear(); |
| 165 #ifndef NDEBUG |
| 166 drawingBufferCounter.decrement(); |
| 167 #endif |
148 } | 168 } |
149 | 169 |
150 void DrawingBuffer::markContentsChanged() | 170 void DrawingBuffer::markContentsChanged() |
151 { | 171 { |
152 m_contentsChanged = true; | 172 m_contentsChanged = true; |
153 m_contentsChangeCommitted = false; | 173 m_contentsChangeCommitted = false; |
154 m_layerComposited = false; | 174 m_layerComposited = false; |
155 } | 175 } |
156 | 176 |
157 bool DrawingBuffer::layerComposited() const | 177 bool DrawingBuffer::layerComposited() const |
158 { | 178 { |
159 return m_layerComposited; | 179 return m_layerComposited; |
160 } | 180 } |
161 | 181 |
162 void DrawingBuffer::markLayerComposited() | 182 void DrawingBuffer::markLayerComposited() |
163 { | 183 { |
164 m_layerComposited = true; | 184 m_layerComposited = true; |
165 } | 185 } |
166 | 186 |
167 blink::WebGraphicsContext3D* DrawingBuffer::context() | 187 blink::WebGraphicsContext3D* DrawingBuffer::context() |
168 { | 188 { |
169 return m_context.get(); | 189 return m_context.get(); |
170 } | 190 } |
171 | 191 |
172 bool DrawingBuffer::prepareMailbox(blink::WebExternalTextureMailbox* outMailbox,
blink::WebExternalBitmap* bitmap) | 192 bool DrawingBuffer::prepareMailbox(blink::WebExternalTextureMailbox* outMailbox,
blink::WebExternalBitmap* bitmap) |
173 { | 193 { |
| 194 // prepareMailbox() is always called after layout. |
| 195 ASSERT(!m_destructionInProgress); |
| 196 |
174 if (!m_contentsChanged) | 197 if (!m_contentsChanged) |
175 return false; | 198 return false; |
176 | 199 |
177 m_context->makeContextCurrent(); | 200 m_context->makeContextCurrent(); |
178 | 201 |
179 // Resolve the multisampled buffer into m_colorBuffer texture. | 202 // Resolve the multisampled buffer into m_colorBuffer texture. |
180 if (m_multisampleMode != None) | 203 if (m_multisampleMode != None) |
181 commit(); | 204 commit(); |
182 | 205 |
183 if (bitmap) { | 206 if (bitmap) { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 restoreFramebufferBinding(); | 251 restoreFramebufferBinding(); |
229 | 252 |
230 m_contentsChanged = false; | 253 m_contentsChanged = false; |
231 | 254 |
232 m_context->bindTexture(GL_TEXTURE_2D, frontColorBufferMailbox->textureId); | 255 m_context->bindTexture(GL_TEXTURE_2D, frontColorBufferMailbox->textureId); |
233 m_context->produceTextureCHROMIUM(GL_TEXTURE_2D, frontColorBufferMailbox->ma
ilbox.name); | 256 m_context->produceTextureCHROMIUM(GL_TEXTURE_2D, frontColorBufferMailbox->ma
ilbox.name); |
234 m_context->flush(); | 257 m_context->flush(); |
235 frontColorBufferMailbox->mailbox.syncPoint = m_context->insertSyncPoint(); | 258 frontColorBufferMailbox->mailbox.syncPoint = m_context->insertSyncPoint(); |
236 markLayerComposited(); | 259 markLayerComposited(); |
237 | 260 |
| 261 // set m_parentDrawingBuffer to make sure 'this' stays alive as long as it h
as live mailboxes |
| 262 ASSERT(!frontColorBufferMailbox->m_parentDrawingBuffer); |
| 263 frontColorBufferMailbox->m_parentDrawingBuffer = this; |
238 *outMailbox = frontColorBufferMailbox->mailbox; | 264 *outMailbox = frontColorBufferMailbox->mailbox; |
239 m_frontColorBuffer = frontColorBufferMailbox->textureId; | 265 m_frontColorBuffer = frontColorBufferMailbox->textureId; |
240 return true; | 266 return true; |
241 } | 267 } |
242 | 268 |
243 void DrawingBuffer::mailboxReleased(const blink::WebExternalTextureMailbox& mail
box) | 269 void DrawingBuffer::mailboxReleased(const blink::WebExternalTextureMailbox& mail
box) |
244 { | 270 { |
| 271 if (m_destructionInProgress) { |
| 272 mailboxReleasedWhileDestructionInProgress(mailbox); |
| 273 return; |
| 274 } |
| 275 |
245 for (size_t i = 0; i < m_textureMailboxes.size(); i++) { | 276 for (size_t i = 0; i < m_textureMailboxes.size(); i++) { |
246 RefPtr<MailboxInfo> mailboxInfo = m_textureMailboxes[i]; | 277 RefPtr<MailboxInfo> mailboxInfo = m_textureMailboxes[i]; |
247 if (!memcmp(mailboxInfo->mailbox.name, mailbox.name, sizeof(mailbox.name
))) { | 278 if (nameEquals(mailboxInfo->mailbox, mailbox)) { |
248 mailboxInfo->mailbox.syncPoint = mailbox.syncPoint; | 279 mailboxInfo->mailbox.syncPoint = mailbox.syncPoint; |
249 m_recycledMailboxes.prepend(mailboxInfo.release()); | 280 ASSERT(mailboxInfo->m_parentDrawingBuffer.get() == this); |
| 281 mailboxInfo->m_parentDrawingBuffer.clear(); |
| 282 m_recycledMailboxQueue.prepend(mailboxInfo->mailbox); |
250 return; | 283 return; |
251 } | 284 } |
252 } | 285 } |
253 ASSERT_NOT_REACHED(); | 286 ASSERT_NOT_REACHED(); |
254 } | 287 } |
255 | 288 |
| 289 void DrawingBuffer::mailboxReleasedWhileDestructionInProgress(const blink::WebEx
ternalTextureMailbox& mailbox) |
| 290 { |
| 291 ASSERT(m_textureMailboxes.size()); |
| 292 m_context->makeContextCurrent(); |
| 293 // Ensure not to call the destructor until deleteMailbox() is completed. |
| 294 RefPtr<DrawingBuffer> self = this; |
| 295 deleteMailbox(mailbox); |
| 296 } |
| 297 |
256 PassRefPtr<DrawingBuffer::MailboxInfo> DrawingBuffer::recycledMailbox() | 298 PassRefPtr<DrawingBuffer::MailboxInfo> DrawingBuffer::recycledMailbox() |
257 { | 299 { |
258 if (m_recycledMailboxes.isEmpty()) | 300 if (m_recycledMailboxQueue.isEmpty()) |
259 return PassRefPtr<MailboxInfo>(); | 301 return PassRefPtr<MailboxInfo>(); |
260 | 302 |
261 RefPtr<MailboxInfo> mailboxInfo = m_recycledMailboxes.last().release(); | 303 blink::WebExternalTextureMailbox mailbox = m_recycledMailboxQueue.takeLast()
; |
262 m_recycledMailboxes.removeLast(); | 304 RefPtr<MailboxInfo> mailboxInfo; |
| 305 for (size_t i = 0; i < m_textureMailboxes.size(); i++) { |
| 306 if (nameEquals(m_textureMailboxes[i]->mailbox, mailbox)) { |
| 307 mailboxInfo = m_textureMailboxes[i]; |
| 308 break; |
| 309 } |
| 310 } |
| 311 ASSERT(mailboxInfo); |
263 | 312 |
264 if (mailboxInfo->mailbox.syncPoint) { | 313 if (mailboxInfo->mailbox.syncPoint) { |
265 m_context->waitSyncPoint(mailboxInfo->mailbox.syncPoint); | 314 m_context->waitSyncPoint(mailboxInfo->mailbox.syncPoint); |
266 mailboxInfo->mailbox.syncPoint = 0; | 315 mailboxInfo->mailbox.syncPoint = 0; |
267 } | 316 } |
268 | 317 |
269 if (mailboxInfo->size != m_size) { | 318 if (mailboxInfo->size != m_size) { |
270 m_context->bindTexture(GL_TEXTURE_2D, mailboxInfo->textureId); | 319 m_context->bindTexture(GL_TEXTURE_2D, mailboxInfo->textureId); |
271 texImage2DResourceSafe(GL_TEXTURE_2D, 0, m_internalColorFormat, m_size.w
idth(), m_size.height(), 0, m_colorFormat, GL_UNSIGNED_BYTE); | 320 texImage2DResourceSafe(GL_TEXTURE_2D, 0, m_internalColorFormat, m_size.w
idth(), m_size.height(), 0, m_colorFormat, GL_UNSIGNED_BYTE); |
272 mailboxInfo->size = m_size; | 321 mailboxInfo->size = m_size; |
273 } | 322 } |
274 | 323 |
275 return mailboxInfo.release(); | 324 return mailboxInfo.release(); |
276 } | 325 } |
277 | 326 |
278 PassRefPtr<DrawingBuffer::MailboxInfo> DrawingBuffer::createNewMailbox(unsigned
textureId) | 327 PassRefPtr<DrawingBuffer::MailboxInfo> DrawingBuffer::createNewMailbox(unsigned
textureId) |
279 { | 328 { |
280 RefPtr<MailboxInfo> returnMailbox = adoptRef(new MailboxInfo()); | 329 RefPtr<MailboxInfo> returnMailbox = adoptRef(new MailboxInfo()); |
281 m_context->genMailboxCHROMIUM(returnMailbox->mailbox.name); | 330 m_context->genMailboxCHROMIUM(returnMailbox->mailbox.name); |
282 returnMailbox->textureId = textureId; | 331 returnMailbox->textureId = textureId; |
283 returnMailbox->size = m_size; | 332 returnMailbox->size = m_size; |
284 m_textureMailboxes.append(returnMailbox); | 333 m_textureMailboxes.append(returnMailbox); |
285 return returnMailbox.release(); | 334 return returnMailbox.release(); |
286 } | 335 } |
287 | 336 |
| 337 void DrawingBuffer::deleteMailbox(const blink::WebExternalTextureMailbox& mailbo
x) |
| 338 { |
| 339 for (size_t i = 0; i < m_textureMailboxes.size(); i++) { |
| 340 if (nameEquals(m_textureMailboxes[i]->mailbox, mailbox)) { |
| 341 m_context->deleteTexture(m_textureMailboxes[i]->textureId); |
| 342 m_textureMailboxes.remove(i); |
| 343 return; |
| 344 } |
| 345 } |
| 346 ASSERT_NOT_REACHED(); |
| 347 } |
| 348 |
288 bool DrawingBuffer::initialize(const IntSize& size) | 349 bool DrawingBuffer::initialize(const IntSize& size) |
289 { | 350 { |
290 if (!m_context->makeContextCurrent()) { | 351 if (!m_context->makeContextCurrent()) { |
291 // Most likely the GPU process exited and the attempt to reconnect to it
failed. | 352 // Most likely the GPU process exited and the attempt to reconnect to it
failed. |
292 // Need to try to restore the context again later. | 353 // Need to try to restore the context again later. |
293 return false; | 354 return false; |
294 } | 355 } |
295 | 356 |
296 if (m_context->isContextLost()) { | 357 if (m_context->isContextLost()) { |
297 // Need to try to restore the context again later. | 358 // Need to try to restore the context again later. |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 } | 543 } |
483 | 544 |
484 void DrawingBuffer::clearPlatformLayer() | 545 void DrawingBuffer::clearPlatformLayer() |
485 { | 546 { |
486 if (m_layer) | 547 if (m_layer) |
487 m_layer->clearTexture(); | 548 m_layer->clearTexture(); |
488 | 549 |
489 m_context->flush(); | 550 m_context->flush(); |
490 } | 551 } |
491 | 552 |
492 void DrawingBuffer::releaseResources() | 553 void DrawingBuffer::beginDestruction() |
493 { | 554 { |
| 555 ASSERT(!m_destructionInProgress); |
| 556 m_destructionInProgress = true; |
| 557 |
494 m_context->makeContextCurrent(); | 558 m_context->makeContextCurrent(); |
495 | 559 |
496 clearPlatformLayer(); | 560 clearPlatformLayer(); |
497 | 561 |
498 for (size_t i = 0; i < m_textureMailboxes.size(); i++) | 562 while (!m_recycledMailboxQueue.isEmpty()) |
499 m_context->deleteTexture(m_textureMailboxes[i]->textureId); | 563 deleteMailbox(m_recycledMailboxQueue.takeLast()); |
500 | 564 |
501 if (m_multisampleFBO) | 565 if (m_multisampleFBO) |
502 m_context->deleteFramebuffer(m_multisampleFBO); | 566 m_context->deleteFramebuffer(m_multisampleFBO); |
503 | 567 |
504 if (m_fbo) | 568 if (m_fbo) |
505 m_context->deleteFramebuffer(m_fbo); | 569 m_context->deleteFramebuffer(m_fbo); |
506 | 570 |
507 if (m_multisampleColorBuffer) | 571 if (m_multisampleColorBuffer) |
508 m_context->deleteRenderbuffer(m_multisampleColorBuffer); | 572 m_context->deleteRenderbuffer(m_multisampleColorBuffer); |
509 | 573 |
510 if (m_depthStencilBuffer) | 574 if (m_depthStencilBuffer) |
511 m_context->deleteRenderbuffer(m_depthStencilBuffer); | 575 m_context->deleteRenderbuffer(m_depthStencilBuffer); |
512 | 576 |
513 if (m_depthBuffer) | 577 if (m_depthBuffer) |
514 m_context->deleteRenderbuffer(m_depthBuffer); | 578 m_context->deleteRenderbuffer(m_depthBuffer); |
515 | 579 |
516 if (m_stencilBuffer) | 580 if (m_stencilBuffer) |
517 m_context->deleteRenderbuffer(m_stencilBuffer); | 581 m_context->deleteRenderbuffer(m_stencilBuffer); |
518 | 582 |
519 if (m_colorBuffer) | 583 if (m_colorBuffer) |
520 m_context->deleteTexture(m_colorBuffer); | 584 m_context->deleteTexture(m_colorBuffer); |
521 | 585 |
522 m_context.clear(); | |
523 | |
524 setSize(IntSize()); | 586 setSize(IntSize()); |
525 | 587 |
526 m_colorBuffer = 0; | 588 m_colorBuffer = 0; |
527 m_frontColorBuffer = 0; | 589 m_frontColorBuffer = 0; |
528 m_multisampleColorBuffer = 0; | 590 m_multisampleColorBuffer = 0; |
529 m_depthStencilBuffer = 0; | 591 m_depthStencilBuffer = 0; |
530 m_depthBuffer = 0; | 592 m_depthBuffer = 0; |
531 m_stencilBuffer = 0; | 593 m_stencilBuffer = 0; |
532 m_multisampleFBO = 0; | 594 m_multisampleFBO = 0; |
533 m_fbo = 0; | 595 m_fbo = 0; |
534 m_contextEvictionManager.clear(); | 596 m_contextEvictionManager.clear(); |
535 | 597 |
536 m_recycledMailboxes.clear(); | 598 if (m_layer) |
537 m_textureMailboxes.clear(); | |
538 | |
539 if (m_layer) { | |
540 GraphicsLayer::unregisterContentsLayer(m_layer->layer()); | 599 GraphicsLayer::unregisterContentsLayer(m_layer->layer()); |
541 m_layer.clear(); | |
542 } | |
543 } | 600 } |
544 | 601 |
545 unsigned DrawingBuffer::createColorTexture(const IntSize& size) | 602 unsigned DrawingBuffer::createColorTexture(const IntSize& size) |
546 { | 603 { |
547 unsigned offscreenColorTexture = m_context->createTexture(); | 604 unsigned offscreenColorTexture = m_context->createTexture(); |
548 if (!offscreenColorTexture) | 605 if (!offscreenColorTexture) |
549 return 0; | 606 return 0; |
550 | 607 |
551 m_context->bindTexture(GL_TEXTURE_2D, offscreenColorTexture); | 608 m_context->bindTexture(GL_TEXTURE_2D, offscreenColorTexture); |
552 m_context->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); | 609 m_context->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
949 } | 1006 } |
950 } | 1007 } |
951 | 1008 |
952 void DrawingBuffer::texImage2DResourceSafe(GLenum target, GLint level, GLenum in
ternalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum
type, GLint unpackAlignment) | 1009 void DrawingBuffer::texImage2DResourceSafe(GLenum target, GLint level, GLenum in
ternalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum
type, GLint unpackAlignment) |
953 { | 1010 { |
954 ASSERT(unpackAlignment == 1 || unpackAlignment == 2 || unpackAlignment == 4
|| unpackAlignment == 8); | 1011 ASSERT(unpackAlignment == 1 || unpackAlignment == 2 || unpackAlignment == 4
|| unpackAlignment == 8); |
955 m_context->texImage2D(target, level, internalformat, width, height, border,
format, type, 0); | 1012 m_context->texImage2D(target, level, internalformat, width, height, border,
format, type, 0); |
956 } | 1013 } |
957 | 1014 |
958 } // namespace WebCore | 1015 } // namespace WebCore |
OLD | NEW |