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 inline bool operator==(const blink::WebExternalTextureMailbox& a, const blink::W ebExternalTextureMailbox& b) | |
Ken Russell (switch to Gerrit)
2014/04/20 00:27:41
This really belongs in public/platform/WebExternal
| |
88 { | |
89 return !memcmp(a.name, b.name, sizeof(a.name)); | |
90 } | |
91 | |
92 } // namespace | |
93 | |
81 PassRefPtr<DrawingBuffer> DrawingBuffer::create(PassOwnPtr<blink::WebGraphicsCon text3D> context, const IntSize& size, PreserveDrawingBuffer preserve, PassRefPtr <ContextEvictionManager> contextEvictionManager) | 94 PassRefPtr<DrawingBuffer> DrawingBuffer::create(PassOwnPtr<blink::WebGraphicsCon text3D> context, const IntSize& size, PreserveDrawingBuffer preserve, PassRefPtr <ContextEvictionManager> contextEvictionManager) |
82 { | 95 { |
83 ASSERT(context); | 96 ASSERT(context); |
84 Extensions3DUtil extensionsUtil(context.get()); | 97 Extensions3DUtil extensionsUtil(context.get()); |
85 bool multisampleSupported = extensionsUtil.supportsExtension("GL_CHROMIUM_fr amebuffer_multisample") | 98 bool multisampleSupported = extensionsUtil.supportsExtension("GL_CHROMIUM_fr amebuffer_multisample") |
86 && extensionsUtil.supportsExtension("GL_OES_rgb8_rgba8"); | 99 && extensionsUtil.supportsExtension("GL_OES_rgb8_rgba8"); |
87 if (multisampleSupported) { | 100 if (multisampleSupported) { |
88 extensionsUtil.ensureExtensionEnabled("GL_CHROMIUM_framebuffer_multisamp le"); | 101 extensionsUtil.ensureExtensionEnabled("GL_CHROMIUM_framebuffer_multisamp le"); |
89 extensionsUtil.ensureExtensionEnabled("GL_OES_rgb8_rgba8"); | 102 extensionsUtil.ensureExtensionEnabled("GL_OES_rgb8_rgba8"); |
90 } | 103 } |
91 bool packedDepthStencilSupported = extensionsUtil.supportsExtension("GL_OES_ packed_depth_stencil"); | 104 bool packedDepthStencilSupported = extensionsUtil.supportsExtension("GL_OES_ packed_depth_stencil"); |
92 if (packedDepthStencilSupported) | 105 if (packedDepthStencilSupported) |
93 extensionsUtil.ensureExtensionEnabled("GL_OES_packed_depth_stencil"); | 106 extensionsUtil.ensureExtensionEnabled("GL_OES_packed_depth_stencil"); |
94 | 107 |
95 RefPtr<DrawingBuffer> drawingBuffer = adoptRef(new DrawingBuffer(context, mu ltisampleSupported, packedDepthStencilSupported, preserve, contextEvictionManage r)); | 108 RefPtr<DrawingBuffer> drawingBuffer = adoptRef(new DrawingBuffer(context, mu ltisampleSupported, packedDepthStencilSupported, preserve, contextEvictionManage r)); |
96 if (!drawingBuffer->initialize(size)) | 109 if (!drawingBuffer->initialize(size)) { |
110 drawingBuffer->beginDestruction(); | |
97 return PassRefPtr<DrawingBuffer>(); | 111 return PassRefPtr<DrawingBuffer>(); |
112 } | |
98 return drawingBuffer.release(); | 113 return drawingBuffer.release(); |
99 } | 114 } |
100 | 115 |
101 DrawingBuffer::DrawingBuffer(PassOwnPtr<blink::WebGraphicsContext3D> context, | 116 DrawingBuffer::DrawingBuffer(PassOwnPtr<blink::WebGraphicsContext3D> context, |
102 bool multisampleExtensionSupported, | 117 bool multisampleExtensionSupported, |
103 bool packedDepthStencilExtensionSupported, | 118 bool packedDepthStencilExtensionSupported, |
104 PreserveDrawingBuffer preserve, | 119 PreserveDrawingBuffer preserve, |
105 PassRefPtr<ContextEvictionManager> contextEvictionManager) | 120 PassRefPtr<ContextEvictionManager> contextEvictionManager) |
106 : m_preserveDrawingBuffer(preserve) | 121 : m_preserveDrawingBuffer(preserve) |
107 , m_scissorEnabled(false) | 122 , m_scissorEnabled(false) |
(...skipping 15 matching lines...) Expand all Loading... | |
123 , m_contentsChanged(true) | 138 , m_contentsChanged(true) |
124 , m_contentsChangeCommitted(false) | 139 , m_contentsChangeCommitted(false) |
125 , m_layerComposited(false) | 140 , m_layerComposited(false) |
126 , m_multisampleMode(None) | 141 , m_multisampleMode(None) |
127 , m_internalColorFormat(0) | 142 , m_internalColorFormat(0) |
128 , m_colorFormat(0) | 143 , m_colorFormat(0) |
129 , m_internalRenderbufferFormat(0) | 144 , m_internalRenderbufferFormat(0) |
130 , m_maxTextureSize(0) | 145 , m_maxTextureSize(0) |
131 , m_sampleCount(0) | 146 , m_sampleCount(0) |
132 , m_packAlignment(4) | 147 , m_packAlignment(4) |
148 , m_destructionInProgress(false) | |
133 , m_contextEvictionManager(contextEvictionManager) | 149 , m_contextEvictionManager(contextEvictionManager) |
134 { | 150 { |
135 // Used by browser tests to detect the use of a DrawingBuffer. | 151 // Used by browser tests to detect the use of a DrawingBuffer. |
136 TRACE_EVENT_INSTANT0("test_gpu", "DrawingBufferCreation"); | 152 TRACE_EVENT_INSTANT0("test_gpu", "DrawingBufferCreation"); |
153 #ifndef NDEBUG | |
154 drawingBufferCounter.increment(); | |
155 #endif | |
137 } | 156 } |
138 | 157 |
139 DrawingBuffer::~DrawingBuffer() | 158 DrawingBuffer::~DrawingBuffer() |
140 { | 159 { |
141 releaseResources(); | 160 ASSERT(m_destructionInProgress); |
161 ASSERT(m_textureMailboxes.isEmpty()); | |
162 m_layer.clear(); | |
163 m_context.clear(); | |
164 #ifndef NDEBUG | |
165 drawingBufferCounter.decrement(); | |
166 #endif | |
142 } | 167 } |
143 | 168 |
144 void DrawingBuffer::markContentsChanged() | 169 void DrawingBuffer::markContentsChanged() |
145 { | 170 { |
146 m_contentsChanged = true; | 171 m_contentsChanged = true; |
147 m_contentsChangeCommitted = false; | 172 m_contentsChangeCommitted = false; |
148 m_layerComposited = false; | 173 m_layerComposited = false; |
149 } | 174 } |
150 | 175 |
151 bool DrawingBuffer::layerComposited() const | 176 bool DrawingBuffer::layerComposited() const |
152 { | 177 { |
153 return m_layerComposited; | 178 return m_layerComposited; |
154 } | 179 } |
155 | 180 |
156 void DrawingBuffer::markLayerComposited() | 181 void DrawingBuffer::markLayerComposited() |
157 { | 182 { |
158 m_layerComposited = true; | 183 m_layerComposited = true; |
159 } | 184 } |
160 | 185 |
161 blink::WebGraphicsContext3D* DrawingBuffer::context() | 186 blink::WebGraphicsContext3D* DrawingBuffer::context() |
162 { | 187 { |
163 return m_context.get(); | 188 return m_context.get(); |
164 } | 189 } |
165 | 190 |
166 bool DrawingBuffer::prepareMailbox(blink::WebExternalTextureMailbox* outMailbox, blink::WebExternalBitmap* bitmap) | 191 bool DrawingBuffer::prepareMailbox(blink::WebExternalTextureMailbox* outMailbox, blink::WebExternalBitmap* bitmap) |
167 { | 192 { |
193 // prepareMailbox() is always called after layout. | |
194 ASSERT(!m_destructionInProgress); | |
195 | |
168 if (!m_contentsChanged) | 196 if (!m_contentsChanged) |
169 return false; | 197 return false; |
170 | 198 |
171 m_context->makeContextCurrent(); | 199 m_context->makeContextCurrent(); |
172 | 200 |
173 // Resolve the multisampled buffer into m_colorBuffer texture. | 201 // Resolve the multisampled buffer into m_colorBuffer texture. |
174 if (m_multisampleMode != None) | 202 if (m_multisampleMode != None) |
175 commit(); | 203 commit(); |
176 | 204 |
177 if (bitmap) { | 205 if (bitmap) { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
222 restoreFramebufferBinding(); | 250 restoreFramebufferBinding(); |
223 | 251 |
224 m_contentsChanged = false; | 252 m_contentsChanged = false; |
225 | 253 |
226 m_context->bindTexture(GL_TEXTURE_2D, frontColorBufferMailbox->textureId); | 254 m_context->bindTexture(GL_TEXTURE_2D, frontColorBufferMailbox->textureId); |
227 m_context->produceTextureCHROMIUM(GL_TEXTURE_2D, frontColorBufferMailbox->ma ilbox.name); | 255 m_context->produceTextureCHROMIUM(GL_TEXTURE_2D, frontColorBufferMailbox->ma ilbox.name); |
228 m_context->flush(); | 256 m_context->flush(); |
229 frontColorBufferMailbox->mailbox.syncPoint = m_context->insertSyncPoint(); | 257 frontColorBufferMailbox->mailbox.syncPoint = m_context->insertSyncPoint(); |
230 markLayerComposited(); | 258 markLayerComposited(); |
231 | 259 |
260 // set m_parentDrawingBuffer to make sure 'this' stays alive as long as it h as live mailboxes | |
261 ASSERT(!frontColorBufferMailbox->m_parentDrawingBuffer); | |
262 frontColorBufferMailbox->m_parentDrawingBuffer = this; | |
232 *outMailbox = frontColorBufferMailbox->mailbox; | 263 *outMailbox = frontColorBufferMailbox->mailbox; |
233 m_frontColorBuffer = frontColorBufferMailbox->textureId; | 264 m_frontColorBuffer = frontColorBufferMailbox->textureId; |
234 return true; | 265 return true; |
235 } | 266 } |
236 | 267 |
237 void DrawingBuffer::mailboxReleased(const blink::WebExternalTextureMailbox& mail box) | 268 void DrawingBuffer::mailboxReleased(const blink::WebExternalTextureMailbox& mail box) |
238 { | 269 { |
270 if (m_destructionInProgress) { | |
271 mailboxReleasedWhileDestructionInProgress(mailbox); | |
272 return; | |
273 } | |
274 | |
239 for (size_t i = 0; i < m_textureMailboxes.size(); i++) { | 275 for (size_t i = 0; i < m_textureMailboxes.size(); i++) { |
240 RefPtr<MailboxInfo> mailboxInfo = m_textureMailboxes[i]; | 276 RefPtr<MailboxInfo> mailboxInfo = m_textureMailboxes[i]; |
241 if (!memcmp(mailboxInfo->mailbox.name, mailbox.name, sizeof(mailbox.name ))) { | 277 if (mailboxInfo->mailbox == mailbox) { |
242 mailboxInfo->mailbox.syncPoint = mailbox.syncPoint; | 278 mailboxInfo->mailbox.syncPoint = mailbox.syncPoint; |
243 m_recycledMailboxes.prepend(mailboxInfo.release()); | 279 ASSERT(mailboxInfo->m_parentDrawingBuffer.get() == this); |
280 mailboxInfo->m_parentDrawingBuffer.clear(); | |
281 m_recycledMailboxQueue.prepend(mailboxInfo->mailbox); | |
244 return; | 282 return; |
245 } | 283 } |
246 } | 284 } |
247 ASSERT_NOT_REACHED(); | 285 ASSERT_NOT_REACHED(); |
248 } | 286 } |
249 | 287 |
288 void DrawingBuffer::mailboxReleasedWhileDestructionInProgress(const blink::WebEx ternalTextureMailbox& mailbox) | |
289 { | |
290 ASSERT(m_textureMailboxes.size()); | |
291 m_context->makeContextCurrent(); | |
292 // Ensure not to call the destructor until deleteMailbox() is completed. | |
293 RefPtr<DrawingBuffer> self = this; | |
294 deleteMailbox(mailbox); | |
295 } | |
296 | |
250 PassRefPtr<DrawingBuffer::MailboxInfo> DrawingBuffer::recycledMailbox() | 297 PassRefPtr<DrawingBuffer::MailboxInfo> DrawingBuffer::recycledMailbox() |
251 { | 298 { |
252 if (m_recycledMailboxes.isEmpty()) | 299 if (m_recycledMailboxQueue.isEmpty()) |
253 return PassRefPtr<MailboxInfo>(); | 300 return PassRefPtr<MailboxInfo>(); |
254 | 301 |
255 RefPtr<MailboxInfo> mailboxInfo = m_recycledMailboxes.last().release(); | 302 blink::WebExternalTextureMailbox mailbox = m_recycledMailboxQueue.takeLast() ; |
256 m_recycledMailboxes.removeLast(); | 303 RefPtr<MailboxInfo> mailboxInfo; |
304 for (size_t i = 0; i < m_textureMailboxes.size(); i++) { | |
305 if (m_textureMailboxes[i]->mailbox == mailbox) { | |
306 mailboxInfo = m_textureMailboxes[i]; | |
307 break; | |
308 } | |
309 } | |
310 ASSERT(mailboxInfo); | |
257 | 311 |
258 if (mailboxInfo->mailbox.syncPoint) { | 312 if (mailboxInfo->mailbox.syncPoint) { |
259 m_context->waitSyncPoint(mailboxInfo->mailbox.syncPoint); | 313 m_context->waitSyncPoint(mailboxInfo->mailbox.syncPoint); |
260 mailboxInfo->mailbox.syncPoint = 0; | 314 mailboxInfo->mailbox.syncPoint = 0; |
261 } | 315 } |
262 | 316 |
263 if (mailboxInfo->size != m_size) { | 317 if (mailboxInfo->size != m_size) { |
264 m_context->bindTexture(GL_TEXTURE_2D, mailboxInfo->textureId); | 318 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); | 319 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; | 320 mailboxInfo->size = m_size; |
267 } | 321 } |
268 | 322 |
269 return mailboxInfo.release(); | 323 return mailboxInfo.release(); |
270 } | 324 } |
271 | 325 |
272 PassRefPtr<DrawingBuffer::MailboxInfo> DrawingBuffer::createNewMailbox(unsigned textureId) | 326 PassRefPtr<DrawingBuffer::MailboxInfo> DrawingBuffer::createNewMailbox(unsigned textureId) |
273 { | 327 { |
274 RefPtr<MailboxInfo> returnMailbox = adoptRef(new MailboxInfo()); | 328 RefPtr<MailboxInfo> returnMailbox = adoptRef(new MailboxInfo()); |
275 m_context->genMailboxCHROMIUM(returnMailbox->mailbox.name); | 329 m_context->genMailboxCHROMIUM(returnMailbox->mailbox.name); |
276 returnMailbox->textureId = textureId; | 330 returnMailbox->textureId = textureId; |
277 returnMailbox->size = m_size; | 331 returnMailbox->size = m_size; |
278 m_textureMailboxes.append(returnMailbox); | 332 m_textureMailboxes.append(returnMailbox); |
279 return returnMailbox.release(); | 333 return returnMailbox.release(); |
280 } | 334 } |
281 | 335 |
336 void DrawingBuffer::deleteMailbox(const blink::WebExternalTextureMailbox& mailbo x) | |
337 { | |
338 for (size_t i = 0; i < m_textureMailboxes.size(); i++) { | |
339 if (m_textureMailboxes[i]->mailbox == mailbox) { | |
340 m_context->deleteTexture(m_textureMailboxes[i]->textureId); | |
341 m_textureMailboxes.remove(i); | |
342 return; | |
343 } | |
344 } | |
345 ASSERT_NOT_REACHED(); | |
346 } | |
347 | |
282 bool DrawingBuffer::initialize(const IntSize& size) | 348 bool DrawingBuffer::initialize(const IntSize& size) |
283 { | 349 { |
284 m_attributes = m_context->getContextAttributes(); | 350 m_attributes = m_context->getContextAttributes(); |
285 Extensions3DUtil extensionsUtil(m_context.get()); | 351 Extensions3DUtil extensionsUtil(m_context.get()); |
286 | 352 |
287 if (m_attributes.alpha) { | 353 if (m_attributes.alpha) { |
288 m_internalColorFormat = GL_RGBA; | 354 m_internalColorFormat = GL_RGBA; |
289 m_colorFormat = GL_RGBA; | 355 m_colorFormat = GL_RGBA; |
290 m_internalRenderbufferFormat = GL_RGBA8_OES; | 356 m_internalRenderbufferFormat = GL_RGBA8_OES; |
291 } else { | 357 } else { |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
466 } | 532 } |
467 | 533 |
468 void DrawingBuffer::clearPlatformLayer() | 534 void DrawingBuffer::clearPlatformLayer() |
469 { | 535 { |
470 if (m_layer) | 536 if (m_layer) |
471 m_layer->clearTexture(); | 537 m_layer->clearTexture(); |
472 | 538 |
473 m_context->flush(); | 539 m_context->flush(); |
474 } | 540 } |
475 | 541 |
476 void DrawingBuffer::releaseResources() | 542 void DrawingBuffer::beginDestruction() |
477 { | 543 { |
544 ASSERT(!m_destructionInProgress); | |
545 m_destructionInProgress = true; | |
546 | |
478 m_context->makeContextCurrent(); | 547 m_context->makeContextCurrent(); |
479 | 548 |
480 clearPlatformLayer(); | 549 clearPlatformLayer(); |
481 | 550 |
482 for (size_t i = 0; i < m_textureMailboxes.size(); i++) | 551 while (!m_recycledMailboxQueue.isEmpty()) |
483 m_context->deleteTexture(m_textureMailboxes[i]->textureId); | 552 deleteMailbox(m_recycledMailboxQueue.takeLast()); |
dshwang
2014/04/19 00:58:06
now m_recycledMailboxQueue just keeps mailbox name
| |
484 | 553 |
485 if (m_multisampleFBO) | 554 if (m_multisampleFBO) |
486 m_context->deleteFramebuffer(m_multisampleFBO); | 555 m_context->deleteFramebuffer(m_multisampleFBO); |
487 | 556 |
488 if (m_fbo) | 557 if (m_fbo) |
489 m_context->deleteFramebuffer(m_fbo); | 558 m_context->deleteFramebuffer(m_fbo); |
490 | 559 |
491 if (m_multisampleColorBuffer) | 560 if (m_multisampleColorBuffer) |
492 m_context->deleteRenderbuffer(m_multisampleColorBuffer); | 561 m_context->deleteRenderbuffer(m_multisampleColorBuffer); |
493 | 562 |
494 if (m_depthStencilBuffer) | 563 if (m_depthStencilBuffer) |
495 m_context->deleteRenderbuffer(m_depthStencilBuffer); | 564 m_context->deleteRenderbuffer(m_depthStencilBuffer); |
496 | 565 |
497 if (m_depthBuffer) | 566 if (m_depthBuffer) |
498 m_context->deleteRenderbuffer(m_depthBuffer); | 567 m_context->deleteRenderbuffer(m_depthBuffer); |
499 | 568 |
500 if (m_stencilBuffer) | 569 if (m_stencilBuffer) |
501 m_context->deleteRenderbuffer(m_stencilBuffer); | 570 m_context->deleteRenderbuffer(m_stencilBuffer); |
502 | 571 |
503 if (m_colorBuffer) | 572 if (m_colorBuffer) |
504 m_context->deleteTexture(m_colorBuffer); | 573 m_context->deleteTexture(m_colorBuffer); |
505 | 574 |
506 m_context.clear(); | |
507 | |
508 setSize(IntSize()); | 575 setSize(IntSize()); |
509 | 576 |
510 m_colorBuffer = 0; | 577 m_colorBuffer = 0; |
511 m_frontColorBuffer = 0; | 578 m_frontColorBuffer = 0; |
512 m_multisampleColorBuffer = 0; | 579 m_multisampleColorBuffer = 0; |
513 m_depthStencilBuffer = 0; | 580 m_depthStencilBuffer = 0; |
514 m_depthBuffer = 0; | 581 m_depthBuffer = 0; |
515 m_stencilBuffer = 0; | 582 m_stencilBuffer = 0; |
516 m_multisampleFBO = 0; | 583 m_multisampleFBO = 0; |
517 m_fbo = 0; | 584 m_fbo = 0; |
518 m_contextEvictionManager.clear(); | 585 m_contextEvictionManager.clear(); |
519 | 586 |
520 m_recycledMailboxes.clear(); | 587 if (m_layer) |
521 m_textureMailboxes.clear(); | |
522 | |
523 if (m_layer) { | |
524 GraphicsLayer::unregisterContentsLayer(m_layer->layer()); | 588 GraphicsLayer::unregisterContentsLayer(m_layer->layer()); |
525 m_layer.clear(); | |
526 } | |
527 } | 589 } |
528 | 590 |
529 unsigned DrawingBuffer::createColorTexture(const IntSize& size) | 591 unsigned DrawingBuffer::createColorTexture(const IntSize& size) |
530 { | 592 { |
531 unsigned offscreenColorTexture = m_context->createTexture(); | 593 unsigned offscreenColorTexture = m_context->createTexture(); |
532 if (!offscreenColorTexture) | 594 if (!offscreenColorTexture) |
533 return 0; | 595 return 0; |
534 | 596 |
535 m_context->bindTexture(GL_TEXTURE_2D, offscreenColorTexture); | 597 m_context->bindTexture(GL_TEXTURE_2D, offscreenColorTexture); |
536 m_context->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); | 598 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 } | 991 } |
930 } | 992 } |
931 | 993 |
932 void DrawingBuffer::texImage2DResourceSafe(GLenum target, GLint level, GLenum in ternalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, GLint unpackAlignment) | 994 void DrawingBuffer::texImage2DResourceSafe(GLenum target, GLint level, GLenum in ternalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, GLint unpackAlignment) |
933 { | 995 { |
934 ASSERT(unpackAlignment == 1 || unpackAlignment == 2 || unpackAlignment == 4 || unpackAlignment == 8); | 996 ASSERT(unpackAlignment == 1 || unpackAlignment == 2 || unpackAlignment == 4 || unpackAlignment == 8); |
935 m_context->texImage2D(target, level, internalformat, width, height, border, format, type, 0); | 997 m_context->texImage2D(target, level, internalformat, width, height, border, format, type, 0); |
936 } | 998 } |
937 | 999 |
938 } // namespace WebCore | 1000 } // namespace WebCore |
OLD | NEW |