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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 int s_currentResourceUsePixels = 0; | 59 int s_currentResourceUsePixels = 0; |
60 const float s_resourceAdjustedRatio = 0.5; | 60 const float s_resourceAdjustedRatio = 0.5; |
61 | 61 |
62 const bool s_allowContextEvictionOnCreate = true; | 62 const bool s_allowContextEvictionOnCreate = true; |
63 const int s_maxScaleAttempts = 3; | 63 const int s_maxScaleAttempts = 3; |
64 | 64 |
65 DEFINE_DEBUG_ONLY_GLOBAL(WTF::RefCountedLeakCounter, drawingBufferCounter, ("Dra
wingBuffer")); | 65 DEFINE_DEBUG_ONLY_GLOBAL(WTF::RefCountedLeakCounter, drawingBufferCounter, ("Dra
wingBuffer")); |
66 | 66 |
67 class ScopedTextureUnit0BindingRestorer { | 67 class ScopedTextureUnit0BindingRestorer { |
68 public: | 68 public: |
69 ScopedTextureUnit0BindingRestorer(blink::WebGraphicsContext3D* context, GLen
um activeTextureUnit, Platform3DObject textureUnitZeroId) | 69 ScopedTextureUnit0BindingRestorer(WebGraphicsContext3D* context, GLenum acti
veTextureUnit, Platform3DObject textureUnitZeroId) |
70 : m_context(context) | 70 : m_context(context) |
71 , m_oldActiveTextureUnit(activeTextureUnit) | 71 , m_oldActiveTextureUnit(activeTextureUnit) |
72 , m_oldTextureUnitZeroId(textureUnitZeroId) | 72 , m_oldTextureUnitZeroId(textureUnitZeroId) |
73 { | 73 { |
74 m_context->activeTexture(GL_TEXTURE0); | 74 m_context->activeTexture(GL_TEXTURE0); |
75 } | 75 } |
76 ~ScopedTextureUnit0BindingRestorer() | 76 ~ScopedTextureUnit0BindingRestorer() |
77 { | 77 { |
78 m_context->bindTexture(GL_TEXTURE_2D, m_oldTextureUnitZeroId); | 78 m_context->bindTexture(GL_TEXTURE_2D, m_oldTextureUnitZeroId); |
79 m_context->activeTexture(m_oldActiveTextureUnit); | 79 m_context->activeTexture(m_oldActiveTextureUnit); |
80 } | 80 } |
81 | 81 |
82 private: | 82 private: |
83 blink::WebGraphicsContext3D* m_context; | 83 WebGraphicsContext3D* m_context; |
84 GLenum m_oldActiveTextureUnit; | 84 GLenum m_oldActiveTextureUnit; |
85 Platform3DObject m_oldTextureUnitZeroId; | 85 Platform3DObject m_oldTextureUnitZeroId; |
86 }; | 86 }; |
87 | 87 |
88 } // namespace | 88 } // namespace |
89 | 89 |
90 PassRefPtr<DrawingBuffer> DrawingBuffer::create(PassOwnPtr<blink::WebGraphicsCon
text3D> context, const IntSize& size, PreserveDrawingBuffer preserve, blink::Web
GraphicsContext3D::Attributes requestedAttributes, PassRefPtr<ContextEvictionMan
ager> contextEvictionManager) | 90 PassRefPtr<DrawingBuffer> DrawingBuffer::create(PassOwnPtr<WebGraphicsContext3D>
context, const IntSize& size, PreserveDrawingBuffer preserve, WebGraphicsContex
t3D::Attributes requestedAttributes, PassRefPtr<ContextEvictionManager> contextE
victionManager) |
91 { | 91 { |
92 ASSERT(context); | 92 ASSERT(context); |
93 OwnPtr<Extensions3DUtil> extensionsUtil = Extensions3DUtil::create(context.g
et()); | 93 OwnPtr<Extensions3DUtil> extensionsUtil = Extensions3DUtil::create(context.g
et()); |
94 if (!extensionsUtil) { | 94 if (!extensionsUtil) { |
95 // This might be the first time we notice that the WebGraphicsContext3D
is lost. | 95 // This might be the first time we notice that the WebGraphicsContext3D
is lost. |
96 return nullptr; | 96 return nullptr; |
97 } | 97 } |
98 bool multisampleSupported = extensionsUtil->supportsExtension("GL_CHROMIUM_f
ramebuffer_multisample") | 98 bool multisampleSupported = extensionsUtil->supportsExtension("GL_CHROMIUM_f
ramebuffer_multisample") |
99 && extensionsUtil->supportsExtension("GL_OES_rgb8_rgba8"); | 99 && extensionsUtil->supportsExtension("GL_OES_rgb8_rgba8"); |
100 if (multisampleSupported) { | 100 if (multisampleSupported) { |
101 extensionsUtil->ensureExtensionEnabled("GL_CHROMIUM_framebuffer_multisam
ple"); | 101 extensionsUtil->ensureExtensionEnabled("GL_CHROMIUM_framebuffer_multisam
ple"); |
102 extensionsUtil->ensureExtensionEnabled("GL_OES_rgb8_rgba8"); | 102 extensionsUtil->ensureExtensionEnabled("GL_OES_rgb8_rgba8"); |
103 } | 103 } |
104 bool packedDepthStencilSupported = extensionsUtil->supportsExtension("GL_OES
_packed_depth_stencil"); | 104 bool packedDepthStencilSupported = extensionsUtil->supportsExtension("GL_OES
_packed_depth_stencil"); |
105 if (packedDepthStencilSupported) | 105 if (packedDepthStencilSupported) |
106 extensionsUtil->ensureExtensionEnabled("GL_OES_packed_depth_stencil"); | 106 extensionsUtil->ensureExtensionEnabled("GL_OES_packed_depth_stencil"); |
107 | 107 |
108 RefPtr<DrawingBuffer> drawingBuffer = adoptRef(new DrawingBuffer(context, ex
tensionsUtil.release(), multisampleSupported, packedDepthStencilSupported, prese
rve, requestedAttributes, contextEvictionManager)); | 108 RefPtr<DrawingBuffer> drawingBuffer = adoptRef(new DrawingBuffer(context, ex
tensionsUtil.release(), multisampleSupported, packedDepthStencilSupported, prese
rve, requestedAttributes, contextEvictionManager)); |
109 if (!drawingBuffer->initialize(size)) { | 109 if (!drawingBuffer->initialize(size)) { |
110 drawingBuffer->beginDestruction(); | 110 drawingBuffer->beginDestruction(); |
111 return PassRefPtr<DrawingBuffer>(); | 111 return PassRefPtr<DrawingBuffer>(); |
112 } | 112 } |
113 return drawingBuffer.release(); | 113 return drawingBuffer.release(); |
114 } | 114 } |
115 | 115 |
116 DrawingBuffer::DrawingBuffer(PassOwnPtr<blink::WebGraphicsContext3D> context, | 116 DrawingBuffer::DrawingBuffer(PassOwnPtr<WebGraphicsContext3D> context, |
117 PassOwnPtr<Extensions3DUtil> extensionsUtil, | 117 PassOwnPtr<Extensions3DUtil> extensionsUtil, |
118 bool multisampleExtensionSupported, | 118 bool multisampleExtensionSupported, |
119 bool packedDepthStencilExtensionSupported, | 119 bool packedDepthStencilExtensionSupported, |
120 PreserveDrawingBuffer preserve, | 120 PreserveDrawingBuffer preserve, |
121 blink::WebGraphicsContext3D::Attributes requestedAttributes, | 121 WebGraphicsContext3D::Attributes requestedAttributes, |
122 PassRefPtr<ContextEvictionManager> contextEvictionManager) | 122 PassRefPtr<ContextEvictionManager> contextEvictionManager) |
123 : m_preserveDrawingBuffer(preserve) | 123 : m_preserveDrawingBuffer(preserve) |
124 , m_scissorEnabled(false) | 124 , m_scissorEnabled(false) |
125 , m_texture2DBinding(0) | 125 , m_texture2DBinding(0) |
126 , m_framebufferBinding(0) | 126 , m_framebufferBinding(0) |
127 , m_activeTextureUnit(GL_TEXTURE0) | 127 , m_activeTextureUnit(GL_TEXTURE0) |
128 , m_context(context) | 128 , m_context(context) |
129 , m_extensionsUtil(extensionsUtil) | 129 , m_extensionsUtil(extensionsUtil) |
130 , m_size(-1, -1) | 130 , m_size(-1, -1) |
131 , m_requestedAttributes(requestedAttributes) | 131 , m_requestedAttributes(requestedAttributes) |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 bool DrawingBuffer::layerComposited() const | 178 bool DrawingBuffer::layerComposited() const |
179 { | 179 { |
180 return m_layerComposited; | 180 return m_layerComposited; |
181 } | 181 } |
182 | 182 |
183 void DrawingBuffer::markLayerComposited() | 183 void DrawingBuffer::markLayerComposited() |
184 { | 184 { |
185 m_layerComposited = true; | 185 m_layerComposited = true; |
186 } | 186 } |
187 | 187 |
188 blink::WebGraphicsContext3D* DrawingBuffer::context() | 188 WebGraphicsContext3D* DrawingBuffer::context() |
189 { | 189 { |
190 return m_context.get(); | 190 return m_context.get(); |
191 } | 191 } |
192 | 192 |
193 bool DrawingBuffer::prepareMailbox(blink::WebExternalTextureMailbox* outMailbox,
blink::WebExternalBitmap* bitmap) | 193 bool DrawingBuffer::prepareMailbox(WebExternalTextureMailbox* outMailbox, WebExt
ernalBitmap* bitmap) |
194 { | 194 { |
195 if (!m_contentsChanged) | 195 if (!m_contentsChanged) |
196 return false; | 196 return false; |
197 | 197 |
198 if (m_destructionInProgress) { | 198 if (m_destructionInProgress) { |
199 // It can be hit in the following sequence. | 199 // It can be hit in the following sequence. |
200 // 1. WebGL draws something. | 200 // 1. WebGL draws something. |
201 // 2. The compositor begins the frame. | 201 // 2. The compositor begins the frame. |
202 // 3. Javascript makes a context lost using WEBGL_lose_context extension
. | 202 // 3. Javascript makes a context lost using WEBGL_lose_context extension
. |
203 // 4. Here. | 203 // 4. Here. |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 markLayerComposited(); | 268 markLayerComposited(); |
269 | 269 |
270 // set m_parentDrawingBuffer to make sure 'this' stays alive as long as it h
as live mailboxes | 270 // set m_parentDrawingBuffer to make sure 'this' stays alive as long as it h
as live mailboxes |
271 ASSERT(!frontColorBufferMailbox->m_parentDrawingBuffer); | 271 ASSERT(!frontColorBufferMailbox->m_parentDrawingBuffer); |
272 frontColorBufferMailbox->m_parentDrawingBuffer = this; | 272 frontColorBufferMailbox->m_parentDrawingBuffer = this; |
273 *outMailbox = frontColorBufferMailbox->mailbox; | 273 *outMailbox = frontColorBufferMailbox->mailbox; |
274 m_frontColorBuffer = frontColorBufferMailbox->textureInfo; | 274 m_frontColorBuffer = frontColorBufferMailbox->textureInfo; |
275 return true; | 275 return true; |
276 } | 276 } |
277 | 277 |
278 void DrawingBuffer::mailboxReleased(const blink::WebExternalTextureMailbox& mail
box, bool lostResource) | 278 void DrawingBuffer::mailboxReleased(const WebExternalTextureMailbox& mailbox, bo
ol lostResource) |
279 { | 279 { |
280 if (m_destructionInProgress || m_context->isContextLost() || lostResource) { | 280 if (m_destructionInProgress || m_context->isContextLost() || lostResource) { |
281 mailboxReleasedWhileDestructionInProgress(mailbox); | 281 mailboxReleasedWhileDestructionInProgress(mailbox); |
282 return; | 282 return; |
283 } | 283 } |
284 | 284 |
285 for (size_t i = 0; i < m_textureMailboxes.size(); i++) { | 285 for (size_t i = 0; i < m_textureMailboxes.size(); i++) { |
286 RefPtr<MailboxInfo> mailboxInfo = m_textureMailboxes[i]; | 286 RefPtr<MailboxInfo> mailboxInfo = m_textureMailboxes[i]; |
287 if (nameEquals(mailboxInfo->mailbox, mailbox)) { | 287 if (nameEquals(mailboxInfo->mailbox, mailbox)) { |
288 mailboxInfo->mailbox.syncPoint = mailbox.syncPoint; | 288 mailboxInfo->mailbox.syncPoint = mailbox.syncPoint; |
289 ASSERT(mailboxInfo->m_parentDrawingBuffer.get() == this); | 289 ASSERT(mailboxInfo->m_parentDrawingBuffer.get() == this); |
290 mailboxInfo->m_parentDrawingBuffer.clear(); | 290 mailboxInfo->m_parentDrawingBuffer.clear(); |
291 m_recycledMailboxQueue.prepend(mailboxInfo->mailbox); | 291 m_recycledMailboxQueue.prepend(mailboxInfo->mailbox); |
292 return; | 292 return; |
293 } | 293 } |
294 } | 294 } |
295 ASSERT_NOT_REACHED(); | 295 ASSERT_NOT_REACHED(); |
296 } | 296 } |
297 | 297 |
298 void DrawingBuffer::mailboxReleasedWhileDestructionInProgress(const blink::WebEx
ternalTextureMailbox& mailbox) | 298 void DrawingBuffer::mailboxReleasedWhileDestructionInProgress(const WebExternalT
extureMailbox& mailbox) |
299 { | 299 { |
300 ASSERT(m_textureMailboxes.size()); | 300 ASSERT(m_textureMailboxes.size()); |
301 m_context->makeContextCurrent(); | 301 m_context->makeContextCurrent(); |
302 // Ensure not to call the destructor until deleteMailbox() is completed. | 302 // Ensure not to call the destructor until deleteMailbox() is completed. |
303 RefPtr<DrawingBuffer> self = this; | 303 RefPtr<DrawingBuffer> self = this; |
304 deleteMailbox(mailbox); | 304 deleteMailbox(mailbox); |
305 } | 305 } |
306 | 306 |
307 PassRefPtr<DrawingBuffer::MailboxInfo> DrawingBuffer::recycledMailbox() | 307 PassRefPtr<DrawingBuffer::MailboxInfo> DrawingBuffer::recycledMailbox() |
308 { | 308 { |
309 if (m_recycledMailboxQueue.isEmpty()) | 309 if (m_recycledMailboxQueue.isEmpty()) |
310 return PassRefPtr<MailboxInfo>(); | 310 return PassRefPtr<MailboxInfo>(); |
311 | 311 |
312 blink::WebExternalTextureMailbox mailbox; | 312 WebExternalTextureMailbox mailbox; |
313 while (!m_recycledMailboxQueue.isEmpty()) { | 313 while (!m_recycledMailboxQueue.isEmpty()) { |
314 mailbox = m_recycledMailboxQueue.takeLast(); | 314 mailbox = m_recycledMailboxQueue.takeLast(); |
315 // Never have more than one mailbox in the released state. | 315 // Never have more than one mailbox in the released state. |
316 if (!m_recycledMailboxQueue.isEmpty()) | 316 if (!m_recycledMailboxQueue.isEmpty()) |
317 deleteMailbox(mailbox); | 317 deleteMailbox(mailbox); |
318 } | 318 } |
319 | 319 |
320 RefPtr<MailboxInfo> mailboxInfo; | 320 RefPtr<MailboxInfo> mailboxInfo; |
321 for (size_t i = 0; i < m_textureMailboxes.size(); i++) { | 321 for (size_t i = 0; i < m_textureMailboxes.size(); i++) { |
322 if (nameEquals(m_textureMailboxes[i]->mailbox, mailbox)) { | 322 if (nameEquals(m_textureMailboxes[i]->mailbox, mailbox)) { |
(...skipping 20 matching lines...) Expand all Loading... |
343 PassRefPtr<DrawingBuffer::MailboxInfo> DrawingBuffer::createNewMailbox(const Tex
tureInfo& info) | 343 PassRefPtr<DrawingBuffer::MailboxInfo> DrawingBuffer::createNewMailbox(const Tex
tureInfo& info) |
344 { | 344 { |
345 RefPtr<MailboxInfo> returnMailbox = adoptRef(new MailboxInfo()); | 345 RefPtr<MailboxInfo> returnMailbox = adoptRef(new MailboxInfo()); |
346 m_context->genMailboxCHROMIUM(returnMailbox->mailbox.name); | 346 m_context->genMailboxCHROMIUM(returnMailbox->mailbox.name); |
347 returnMailbox->textureInfo = info; | 347 returnMailbox->textureInfo = info; |
348 returnMailbox->size = m_size; | 348 returnMailbox->size = m_size; |
349 m_textureMailboxes.append(returnMailbox); | 349 m_textureMailboxes.append(returnMailbox); |
350 return returnMailbox.release(); | 350 return returnMailbox.release(); |
351 } | 351 } |
352 | 352 |
353 void DrawingBuffer::deleteMailbox(const blink::WebExternalTextureMailbox& mailbo
x) | 353 void DrawingBuffer::deleteMailbox(const WebExternalTextureMailbox& mailbox) |
354 { | 354 { |
355 for (size_t i = 0; i < m_textureMailboxes.size(); i++) { | 355 for (size_t i = 0; i < m_textureMailboxes.size(); i++) { |
356 if (nameEquals(m_textureMailboxes[i]->mailbox, mailbox)) { | 356 if (nameEquals(m_textureMailboxes[i]->mailbox, mailbox)) { |
357 if (mailbox.syncPoint) | 357 if (mailbox.syncPoint) |
358 m_context->waitSyncPoint(mailbox.syncPoint); | 358 m_context->waitSyncPoint(mailbox.syncPoint); |
359 | 359 |
360 deleteChromiumImageForTexture(&m_textureMailboxes[i]->textureInfo); | 360 deleteChromiumImageForTexture(&m_textureMailboxes[i]->textureInfo); |
361 | 361 |
362 m_context->deleteTexture(m_textureMailboxes[i]->textureInfo.textureI
d); | 362 m_context->deleteTexture(m_textureMailboxes[i]->textureInfo.textureI
d); |
363 m_textureMailboxes.remove(i); | 363 m_textureMailboxes.remove(i); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 m_context->framebufferTexture2DMultisampleEXT(GL_FRAMEBUFFER, GL_COLOR_A
TTACHMENT0, GL_TEXTURE_2D, m_colorBuffer.textureId, 0, m_sampleCount); | 410 m_context->framebufferTexture2DMultisampleEXT(GL_FRAMEBUFFER, GL_COLOR_A
TTACHMENT0, GL_TEXTURE_2D, m_colorBuffer.textureId, 0, m_sampleCount); |
411 else | 411 else |
412 m_context->framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL
_TEXTURE_2D, m_colorBuffer.textureId, 0); | 412 m_context->framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL
_TEXTURE_2D, m_colorBuffer.textureId, 0); |
413 createSecondaryBuffers(); | 413 createSecondaryBuffers(); |
414 // We first try to initialize everything with the requested attributes. | 414 // We first try to initialize everything with the requested attributes. |
415 if (!reset(size)) | 415 if (!reset(size)) |
416 return false; | 416 return false; |
417 // If that succeeds, we then see what we actually got and update our actual
attributes to reflect that. | 417 // If that succeeds, we then see what we actually got and update our actual
attributes to reflect that. |
418 m_actualAttributes = m_requestedAttributes; | 418 m_actualAttributes = m_requestedAttributes; |
419 if (m_requestedAttributes.alpha) { | 419 if (m_requestedAttributes.alpha) { |
420 blink::WGC3Dint alphaBits = 0; | 420 WGC3Dint alphaBits = 0; |
421 m_context->getIntegerv(GL_ALPHA_BITS, &alphaBits); | 421 m_context->getIntegerv(GL_ALPHA_BITS, &alphaBits); |
422 m_actualAttributes.alpha = alphaBits > 0; | 422 m_actualAttributes.alpha = alphaBits > 0; |
423 } | 423 } |
424 if (m_requestedAttributes.depth) { | 424 if (m_requestedAttributes.depth) { |
425 blink::WGC3Dint depthBits = 0; | 425 WGC3Dint depthBits = 0; |
426 m_context->getIntegerv(GL_DEPTH_BITS, &depthBits); | 426 m_context->getIntegerv(GL_DEPTH_BITS, &depthBits); |
427 m_actualAttributes.depth = depthBits > 0; | 427 m_actualAttributes.depth = depthBits > 0; |
428 } | 428 } |
429 if (m_requestedAttributes.stencil) { | 429 if (m_requestedAttributes.stencil) { |
430 blink::WGC3Dint stencilBits = 0; | 430 WGC3Dint stencilBits = 0; |
431 m_context->getIntegerv(GL_STENCIL_BITS, &stencilBits); | 431 m_context->getIntegerv(GL_STENCIL_BITS, &stencilBits); |
432 m_actualAttributes.stencil = stencilBits > 0; | 432 m_actualAttributes.stencil = stencilBits > 0; |
433 } | 433 } |
434 m_actualAttributes.antialias = multisample(); | 434 m_actualAttributes.antialias = multisample(); |
435 return true; | 435 return true; |
436 } | 436 } |
437 | 437 |
438 bool DrawingBuffer::copyToPlatformTexture(blink::WebGraphicsContext3D* context,
Platform3DObject texture, GLenum internalFormat, GLenum destType, GLint level, b
ool premultiplyAlpha, bool flipY, bool fromFrontBuffer) | 438 bool DrawingBuffer::copyToPlatformTexture(WebGraphicsContext3D* context, Platfor
m3DObject texture, GLenum internalFormat, GLenum destType, GLint level, bool pre
multiplyAlpha, bool flipY, bool fromFrontBuffer) |
439 { | 439 { |
440 if (!m_context->makeContextCurrent()) | 440 if (!m_context->makeContextCurrent()) |
441 return false; | 441 return false; |
442 | 442 |
443 GLint textureId = m_colorBuffer.textureId; | 443 GLint textureId = m_colorBuffer.textureId; |
444 if (fromFrontBuffer && m_frontColorBuffer.textureId) | 444 if (fromFrontBuffer && m_frontColorBuffer.textureId) |
445 textureId = m_frontColorBuffer.textureId; | 445 textureId = m_frontColorBuffer.textureId; |
446 | 446 |
447 if (m_contentsChanged) { | 447 if (m_contentsChanged) { |
448 if (m_multisampleMode != None) { | 448 if (m_multisampleMode != None) { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 m_context->waitSyncPoint(context->insertSyncPoint()); | 493 m_context->waitSyncPoint(context->insertSyncPoint()); |
494 | 494 |
495 return true; | 495 return true; |
496 } | 496 } |
497 | 497 |
498 Platform3DObject DrawingBuffer::framebuffer() const | 498 Platform3DObject DrawingBuffer::framebuffer() const |
499 { | 499 { |
500 return m_fbo; | 500 return m_fbo; |
501 } | 501 } |
502 | 502 |
503 blink::WebLayer* DrawingBuffer::platformLayer() | 503 WebLayer* DrawingBuffer::platformLayer() |
504 { | 504 { |
505 if (!m_layer) { | 505 if (!m_layer) { |
506 m_layer = adoptPtr(blink::Platform::current()->compositorSupport()->crea
teExternalTextureLayer(this)); | 506 m_layer = adoptPtr(Platform::current()->compositorSupport()->createExter
nalTextureLayer(this)); |
507 | 507 |
508 m_layer->setOpaque(!m_actualAttributes.alpha); | 508 m_layer->setOpaque(!m_actualAttributes.alpha); |
509 m_layer->setBlendBackgroundColor(m_actualAttributes.alpha); | 509 m_layer->setBlendBackgroundColor(m_actualAttributes.alpha); |
510 m_layer->setPremultipliedAlpha(m_actualAttributes.premultipliedAlpha); | 510 m_layer->setPremultipliedAlpha(m_actualAttributes.premultipliedAlpha); |
511 GraphicsLayer::registerContentsLayer(m_layer->layer()); | 511 GraphicsLayer::registerContentsLayer(m_layer->layer()); |
512 } | 512 } |
513 | 513 |
514 return m_layer->layer(); | 514 return m_layer->layer(); |
515 } | 515 } |
516 | 516 |
517 void DrawingBuffer::paintCompositedResultsToCanvas(ImageBuffer* imageBuffer) | 517 void DrawingBuffer::paintCompositedResultsToCanvas(ImageBuffer* imageBuffer) |
518 { | 518 { |
519 if (!m_context->makeContextCurrent() || m_context->getGraphicsResetStatusARB
() != GL_NO_ERROR) | 519 if (!m_context->makeContextCurrent() || m_context->getGraphicsResetStatusARB
() != GL_NO_ERROR) |
520 return; | 520 return; |
521 | 521 |
522 if (!imageBuffer) | 522 if (!imageBuffer) |
523 return; | 523 return; |
524 Platform3DObject tex = imageBuffer->getBackingTexture(); | 524 Platform3DObject tex = imageBuffer->getBackingTexture(); |
525 if (tex) { | 525 if (tex) { |
526 RefPtr<MailboxInfo> bufferMailbox = adoptRef(new MailboxInfo()); | 526 RefPtr<MailboxInfo> bufferMailbox = adoptRef(new MailboxInfo()); |
527 m_context->genMailboxCHROMIUM(bufferMailbox->mailbox.name); | 527 m_context->genMailboxCHROMIUM(bufferMailbox->mailbox.name); |
528 m_context->produceTextureDirectCHROMIUM(m_frontColorBuffer.textureId, GL
_TEXTURE_2D, bufferMailbox->mailbox.name); | 528 m_context->produceTextureDirectCHROMIUM(m_frontColorBuffer.textureId, GL
_TEXTURE_2D, bufferMailbox->mailbox.name); |
529 m_context->flush(); | 529 m_context->flush(); |
530 | 530 |
531 bufferMailbox->mailbox.syncPoint = m_context->insertSyncPoint(); | 531 bufferMailbox->mailbox.syncPoint = m_context->insertSyncPoint(); |
532 OwnPtr<blink::WebGraphicsContext3DProvider> provider = | 532 OwnPtr<WebGraphicsContext3DProvider> provider = |
533 adoptPtr(blink::Platform::current()->createSharedOffscreenGraphicsCo
ntext3DProvider()); | 533 adoptPtr(Platform::current()->createSharedOffscreenGraphicsContext3D
Provider()); |
534 if (!provider) | 534 if (!provider) |
535 return; | 535 return; |
536 blink::WebGraphicsContext3D* context = provider->context3d(); | 536 WebGraphicsContext3D* context = provider->context3d(); |
537 if (!context || !context->makeContextCurrent()) | 537 if (!context || !context->makeContextCurrent()) |
538 return; | 538 return; |
539 | 539 |
540 context->waitSyncPoint(bufferMailbox->mailbox.syncPoint); | 540 context->waitSyncPoint(bufferMailbox->mailbox.syncPoint); |
541 Platform3DObject sourceTexture = context->createAndConsumeTextureCHROMIU
M(GL_TEXTURE_2D, bufferMailbox->mailbox.name); | 541 Platform3DObject sourceTexture = context->createAndConsumeTextureCHROMIU
M(GL_TEXTURE_2D, bufferMailbox->mailbox.name); |
542 context->copyTextureCHROMIUM(GL_TEXTURE_2D, sourceTexture, | 542 context->copyTextureCHROMIUM(GL_TEXTURE_2D, sourceTexture, |
543 tex, 0, GL_RGBA, GL_UNSIGNED_BYTE); | 543 tex, 0, GL_RGBA, GL_UNSIGNED_BYTE); |
544 context->deleteTexture(sourceTexture); | 544 context->deleteTexture(sourceTexture); |
545 context->flush(); | 545 context->flush(); |
546 m_context->waitSyncPoint(context->insertSyncPoint()); | 546 m_context->waitSyncPoint(context->insertSyncPoint()); |
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1049 void DrawingBuffer::deleteChromiumImageForTexture(TextureInfo* info) | 1049 void DrawingBuffer::deleteChromiumImageForTexture(TextureInfo* info) |
1050 { | 1050 { |
1051 if (info->imageId) { | 1051 if (info->imageId) { |
1052 m_context->releaseTexImage2DCHROMIUM(GL_TEXTURE_2D, info->imageId); | 1052 m_context->releaseTexImage2DCHROMIUM(GL_TEXTURE_2D, info->imageId); |
1053 m_context->destroyImageCHROMIUM(info->imageId); | 1053 m_context->destroyImageCHROMIUM(info->imageId); |
1054 info->imageId = 0; | 1054 info->imageId = 0; |
1055 } | 1055 } |
1056 } | 1056 } |
1057 | 1057 |
1058 } // namespace blink | 1058 } // namespace blink |
OLD | NEW |