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 16 matching lines...) Expand all Loading... |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #include "config.h" | 31 #include "config.h" |
32 | 32 |
33 #include "platform/graphics/gpu/DrawingBuffer.h" | 33 #include "platform/graphics/gpu/DrawingBuffer.h" |
34 | 34 |
35 #include <algorithm> | 35 #include <algorithm> |
36 #include "platform/TraceEvent.h" | 36 #include "platform/TraceEvent.h" |
37 #include "platform/graphics/Extensions3D.h" | |
38 #include "platform/graphics/GraphicsLayer.h" | 37 #include "platform/graphics/GraphicsLayer.h" |
39 #include "public/platform/Platform.h" | 38 #include "public/platform/Platform.h" |
40 #include "public/platform/WebCompositorSupport.h" | 39 #include "public/platform/WebCompositorSupport.h" |
41 #include "public/platform/WebExternalBitmap.h" | 40 #include "public/platform/WebExternalBitmap.h" |
42 #include "public/platform/WebExternalTextureLayer.h" | 41 #include "public/platform/WebExternalTextureLayer.h" |
43 #include "public/platform/WebGraphicsContext3D.h" | 42 #include "public/platform/WebGraphicsContext3D.h" |
44 | 43 |
45 using namespace std; | 44 using namespace std; |
46 | 45 |
47 namespace WebCore { | 46 namespace WebCore { |
(...skipping 24 matching lines...) Expand all Loading... |
72 } | 71 } |
73 | 72 |
74 private: | 73 private: |
75 GraphicsContext3D* m_context; | 74 GraphicsContext3D* m_context; |
76 GLenum m_oldActiveTextureUnit; | 75 GLenum m_oldActiveTextureUnit; |
77 Platform3DObject m_oldTextureUnitZeroId; | 76 Platform3DObject m_oldTextureUnitZeroId; |
78 }; | 77 }; |
79 | 78 |
80 PassRefPtr<DrawingBuffer> DrawingBuffer::create(GraphicsContext3D* context, cons
t IntSize& size, PreserveDrawingBuffer preserve, PassRefPtr<ContextEvictionManag
er> contextEvictionManager) | 79 PassRefPtr<DrawingBuffer> DrawingBuffer::create(GraphicsContext3D* context, cons
t IntSize& size, PreserveDrawingBuffer preserve, PassRefPtr<ContextEvictionManag
er> contextEvictionManager) |
81 { | 80 { |
82 Extensions3D* extensions = context->extensions(); | 81 bool multisampleSupported = context->supportsExtension("GL_ANGLE_framebuffer
_blit") |
83 bool multisampleSupported = extensions->supports("GL_ANGLE_framebuffer_blit"
) | 82 && context->supportsExtension("GL_ANGLE_framebuffer_multisample") |
84 && extensions->supports("GL_ANGLE_framebuffer_multisample") | 83 && context->supportsExtension("GL_OES_rgb8_rgba8"); |
85 && extensions->supports("GL_OES_rgb8_rgba8"); | |
86 if (multisampleSupported) { | 84 if (multisampleSupported) { |
87 extensions->ensureEnabled("GL_ANGLE_framebuffer_blit"); | 85 context->ensureExtensionEnabled("GL_ANGLE_framebuffer_blit"); |
88 extensions->ensureEnabled("GL_ANGLE_framebuffer_multisample"); | 86 context->ensureExtensionEnabled("GL_ANGLE_framebuffer_multisample"); |
89 extensions->ensureEnabled("GL_OES_rgb8_rgba8"); | 87 context->ensureExtensionEnabled("GL_OES_rgb8_rgba8"); |
90 } | 88 } |
91 bool packedDepthStencilSupported = extensions->supports("GL_OES_packed_depth
_stencil"); | 89 bool packedDepthStencilSupported = context->supportsExtension("GL_OES_packed
_depth_stencil"); |
92 if (packedDepthStencilSupported) | 90 if (packedDepthStencilSupported) |
93 extensions->ensureEnabled("GL_OES_packed_depth_stencil"); | 91 context->ensureExtensionEnabled("GL_OES_packed_depth_stencil"); |
94 | 92 |
95 RefPtr<DrawingBuffer> drawingBuffer = adoptRef(new DrawingBuffer(context, si
ze, multisampleSupported, packedDepthStencilSupported, preserve, contextEviction
Manager)); | 93 RefPtr<DrawingBuffer> drawingBuffer = adoptRef(new DrawingBuffer(context, si
ze, multisampleSupported, packedDepthStencilSupported, preserve, contextEviction
Manager)); |
96 return drawingBuffer.release(); | 94 return drawingBuffer.release(); |
97 } | 95 } |
98 | 96 |
99 DrawingBuffer::DrawingBuffer(GraphicsContext3D* context, | 97 DrawingBuffer::DrawingBuffer(GraphicsContext3D* context, |
100 const IntSize& size, | 98 const IntSize& size, |
101 bool multisampleExtensionSupported, | 99 bool multisampleExtensionSupported, |
102 bool packedDepthStencilExtensionSupported, | 100 bool packedDepthStencilExtensionSupported, |
103 PreserveDrawingBuffer preserve, | 101 PreserveDrawingBuffer preserve, |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 if (m_preserveDrawingBuffer == Discard) { | 189 if (m_preserveDrawingBuffer == Discard) { |
192 m_colorBuffer = nextFrontColorBuffer->textureId; | 190 m_colorBuffer = nextFrontColorBuffer->textureId; |
193 swap(nextFrontColorBuffer, m_lastColorBuffer); | 191 swap(nextFrontColorBuffer, m_lastColorBuffer); |
194 // It appears safe to overwrite the context's framebuffer binding in the
Discard case since there will always be a | 192 // It appears safe to overwrite the context's framebuffer binding in the
Discard case since there will always be a |
195 // WebGLRenderingContext::clearIfComposited() call made before the next
draw call which restores the framebuffer binding. | 193 // WebGLRenderingContext::clearIfComposited() call made before the next
draw call which restores the framebuffer binding. |
196 // If this stops being true at some point, we should track the current f
ramebuffer binding in the DrawingBuffer and restore | 194 // If this stops being true at some point, we should track the current f
ramebuffer binding in the DrawingBuffer and restore |
197 // it after attaching the new back buffer here. | 195 // it after attaching the new back buffer here. |
198 m_context->bindFramebuffer(GL_FRAMEBUFFER, m_fbo); | 196 m_context->bindFramebuffer(GL_FRAMEBUFFER, m_fbo); |
199 m_context->framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL
_TEXTURE_2D, m_colorBuffer, 0); | 197 m_context->framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL
_TEXTURE_2D, m_colorBuffer, 0); |
200 } else { | 198 } else { |
201 Extensions3D* extensions = m_context->extensions(); | 199 m_context->webContext()->copyTextureCHROMIUM(GL_TEXTURE_2D, m_colorBuffe
r, nextFrontColorBuffer->textureId, 0, GL_RGBA, GL_UNSIGNED_BYTE); |
202 extensions->copyTextureCHROMIUM(GL_TEXTURE_2D, m_colorBuffer, nextFrontC
olorBuffer->textureId, 0, GL_RGBA, GL_UNSIGNED_BYTE); | |
203 } | 200 } |
204 | 201 |
205 if (multisample() && !m_framebufferBinding) | 202 if (multisample() && !m_framebufferBinding) |
206 bind(); | 203 bind(); |
207 else | 204 else |
208 restoreFramebufferBinding(); | 205 restoreFramebufferBinding(); |
209 | 206 |
210 m_contentsChanged = false; | 207 m_contentsChanged = false; |
211 | 208 |
212 context()->bindTexture(GL_TEXTURE_2D, nextFrontColorBuffer->textureId); | 209 context()->bindTexture(GL_TEXTURE_2D, nextFrontColorBuffer->textureId); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 } | 264 } |
268 | 265 |
269 void DrawingBuffer::initialize(const IntSize& size) | 266 void DrawingBuffer::initialize(const IntSize& size) |
270 { | 267 { |
271 ASSERT(m_context); | 268 ASSERT(m_context); |
272 m_attributes = m_context->getContextAttributes(); | 269 m_attributes = m_context->getContextAttributes(); |
273 | 270 |
274 if (m_attributes.alpha) { | 271 if (m_attributes.alpha) { |
275 m_internalColorFormat = GL_RGBA; | 272 m_internalColorFormat = GL_RGBA; |
276 m_colorFormat = GL_RGBA; | 273 m_colorFormat = GL_RGBA; |
277 m_internalRenderbufferFormat = Extensions3D::RGBA8_OES; | 274 m_internalRenderbufferFormat = GL_RGBA8_OES; |
278 } else { | 275 } else { |
279 m_internalColorFormat = GL_RGB; | 276 m_internalColorFormat = GL_RGB; |
280 m_colorFormat = GL_RGB; | 277 m_colorFormat = GL_RGB; |
281 m_internalRenderbufferFormat = Extensions3D::RGB8_OES; | 278 m_internalRenderbufferFormat = GL_RGB8_OES; |
282 } | 279 } |
283 | 280 |
284 m_context->getIntegerv(GL_MAX_TEXTURE_SIZE, &m_maxTextureSize); | 281 m_context->getIntegerv(GL_MAX_TEXTURE_SIZE, &m_maxTextureSize); |
285 | 282 |
286 int maxSampleCount = 0; | 283 int maxSampleCount = 0; |
287 if (multisample()) | 284 if (multisample()) |
288 m_context->getIntegerv(Extensions3D::MAX_SAMPLES, &maxSampleCount); | 285 m_context->getIntegerv(GL_MAX_SAMPLES_ANGLE, &maxSampleCount); |
289 m_sampleCount = std::min(4, maxSampleCount); | 286 m_sampleCount = std::min(4, maxSampleCount); |
290 | 287 |
291 m_fbo = m_context->createFramebuffer(); | 288 m_fbo = m_context->createFramebuffer(); |
292 | 289 |
293 m_context->bindFramebuffer(GL_FRAMEBUFFER, m_fbo); | 290 m_context->bindFramebuffer(GL_FRAMEBUFFER, m_fbo); |
294 m_colorBuffer = createColorTexture(); | 291 m_colorBuffer = createColorTexture(); |
295 m_context->framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEX
TURE_2D, m_colorBuffer, 0); | 292 m_context->framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEX
TURE_2D, m_colorBuffer, 0); |
296 createSecondaryBuffers(); | 293 createSecondaryBuffers(); |
297 reset(size); | 294 reset(size); |
298 m_lastColorBuffer = createNewMailbox(m_colorBuffer); | 295 m_lastColorBuffer = createNewMailbox(m_colorBuffer); |
(...skipping 15 matching lines...) Expand all Loading... |
314 bind(); | 311 bind(); |
315 else | 312 else |
316 restoreFramebufferBinding(); | 313 restoreFramebufferBinding(); |
317 } | 314 } |
318 m_context->flush(); | 315 m_context->flush(); |
319 } | 316 } |
320 Platform3DObject sourceTexture = colorBuffer(); | 317 Platform3DObject sourceTexture = colorBuffer(); |
321 | 318 |
322 if (!context.makeContextCurrent()) | 319 if (!context.makeContextCurrent()) |
323 return false; | 320 return false; |
324 Extensions3D* extensions = context.extensions(); | 321 if (!context.supportsExtension("GL_CHROMIUM_copy_texture") || !context.suppo
rtsExtension("GL_CHROMIUM_flipy") |
325 if (!extensions->supports("GL_CHROMIUM_copy_texture") || !extensions->suppor
ts("GL_CHROMIUM_flipy") | 322 || !context.canUseCopyTextureCHROMIUM(internalFormat, destType, level)) |
326 || !extensions->canUseCopyTextureCHROMIUM(internalFormat, destType, leve
l)) | |
327 return false; | 323 return false; |
328 | 324 |
329 bool unpackPremultiplyAlphaNeeded = false; | 325 bool unpackPremultiplyAlphaNeeded = false; |
330 bool unpackUnpremultiplyAlphaNeeded = false; | 326 bool unpackUnpremultiplyAlphaNeeded = false; |
331 if (m_attributes.alpha && m_attributes.premultipliedAlpha && !premultiplyAlp
ha) | 327 if (m_attributes.alpha && m_attributes.premultipliedAlpha && !premultiplyAlp
ha) |
332 unpackUnpremultiplyAlphaNeeded = true; | 328 unpackUnpremultiplyAlphaNeeded = true; |
333 else if (m_attributes.alpha && !m_attributes.premultipliedAlpha && premultip
lyAlpha) | 329 else if (m_attributes.alpha && !m_attributes.premultipliedAlpha && premultip
lyAlpha) |
334 unpackPremultiplyAlphaNeeded = true; | 330 unpackPremultiplyAlphaNeeded = true; |
335 | 331 |
336 context.pixelStorei(Extensions3D::UNPACK_UNPREMULTIPLY_ALPHA_CHROMIUM, unpac
kUnpremultiplyAlphaNeeded); | 332 context.pixelStorei(GC3D_UNPACK_UNPREMULTIPLY_ALPHA_CHROMIUM, unpackUnpremul
tiplyAlphaNeeded); |
337 context.pixelStorei(Extensions3D::UNPACK_PREMULTIPLY_ALPHA_CHROMIUM, unpackP
remultiplyAlphaNeeded); | 333 context.pixelStorei(GC3D_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM, unpackPremultipl
yAlphaNeeded); |
338 context.pixelStorei(Extensions3D::UNPACK_FLIP_Y_CHROMIUM, flipY); | 334 context.pixelStorei(GC3D_UNPACK_FLIP_Y_CHROMIUM, flipY); |
339 extensions->copyTextureCHROMIUM(GL_TEXTURE_2D, sourceTexture, texture, level
, internalFormat, destType); | 335 context.webContext()->copyTextureCHROMIUM(GL_TEXTURE_2D, sourceTexture, text
ure, level, internalFormat, destType); |
340 context.pixelStorei(Extensions3D::UNPACK_FLIP_Y_CHROMIUM, false); | 336 context.pixelStorei(GC3D_UNPACK_FLIP_Y_CHROMIUM, false); |
341 context.pixelStorei(Extensions3D::UNPACK_UNPREMULTIPLY_ALPHA_CHROMIUM, false
); | 337 context.pixelStorei(GC3D_UNPACK_UNPREMULTIPLY_ALPHA_CHROMIUM, false); |
342 context.pixelStorei(Extensions3D::UNPACK_PREMULTIPLY_ALPHA_CHROMIUM, false); | 338 context.pixelStorei(GC3D_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM, false); |
343 context.flush(); | 339 context.flush(); |
344 | 340 |
345 return true; | 341 return true; |
346 } | 342 } |
347 | 343 |
348 Platform3DObject DrawingBuffer::framebuffer() const | 344 Platform3DObject DrawingBuffer::framebuffer() const |
349 { | 345 { |
350 return m_fbo; | 346 return m_fbo; |
351 } | 347 } |
352 | 348 |
353 blink::WebLayer* DrawingBuffer::platformLayer() | 349 blink::WebLayer* DrawingBuffer::platformLayer() |
354 { | 350 { |
355 if (!m_context) | 351 if (!m_context) |
356 return 0; | 352 return 0; |
357 | 353 |
358 if (!m_layer) { | 354 if (!m_layer) { |
359 m_layer = adoptPtr(blink::Platform::current()->compositorSupport()->crea
teExternalTextureLayer(this)); | 355 m_layer = adoptPtr(blink::Platform::current()->compositorSupport()->crea
teExternalTextureLayer(this)); |
360 | 356 |
361 m_layer->setOpaque(!m_attributes.alpha); | 357 m_layer->setOpaque(!m_attributes.alpha); |
362 m_layer->setBlendBackgroundColor(m_attributes.alpha); | 358 m_layer->setBlendBackgroundColor(m_attributes.alpha); |
363 m_layer->setPremultipliedAlpha(m_attributes.premultipliedAlpha); | 359 m_layer->setPremultipliedAlpha(m_attributes.premultipliedAlpha); |
364 GraphicsLayer::registerContentsLayer(m_layer->layer()); | 360 GraphicsLayer::registerContentsLayer(m_layer->layer()); |
365 } | 361 } |
366 | 362 |
367 return m_layer->layer(); | 363 return m_layer->layer(); |
368 } | 364 } |
369 | 365 |
370 void DrawingBuffer::paintCompositedResultsToCanvas(ImageBuffer* imageBuffer) | 366 void DrawingBuffer::paintCompositedResultsToCanvas(ImageBuffer* imageBuffer) |
371 { | 367 { |
372 if (!m_context || !m_context->makeContextCurrent() || m_context->extensions(
)->getGraphicsResetStatusARB() != GL_NO_ERROR) | 368 if (!m_context || !m_context->makeContextCurrent() || m_context->webContext(
)->getGraphicsResetStatusARB() != GL_NO_ERROR) |
373 return; | 369 return; |
374 | 370 |
375 Extensions3D* extensions = m_context->extensions(); | |
376 | |
377 if (!imageBuffer) | 371 if (!imageBuffer) |
378 return; | 372 return; |
379 Platform3DObject tex = imageBuffer->getBackingTexture(); | 373 Platform3DObject tex = imageBuffer->getBackingTexture(); |
380 if (tex) { | 374 if (tex) { |
381 extensions->copyTextureCHROMIUM(GL_TEXTURE_2D, m_frontColorBuffer, | 375 m_context->webContext()->copyTextureCHROMIUM(GL_TEXTURE_2D, m_frontColor
Buffer, |
382 tex, 0, GL_RGBA, GL_UNSIGNED_BYTE); | 376 tex, 0, GL_RGBA, GL_UNSIGNED_BYTE); |
383 return; | 377 return; |
384 } | 378 } |
385 | 379 |
386 // Since the m_frontColorBuffer was produced and sent to the compositor, it
cannot be bound to an fbo. | 380 // Since the m_frontColorBuffer was produced and sent to the compositor, it
cannot be bound to an fbo. |
387 // We have to make a copy of it here and bind that copy instead. | 381 // We have to make a copy of it here and bind that copy instead. |
388 // FIXME: That's not true any more, provided we don't change texture | 382 // FIXME: That's not true any more, provided we don't change texture |
389 // parameters. | 383 // parameters. |
390 unsigned sourceTexture = createColorTexture(m_size); | 384 unsigned sourceTexture = createColorTexture(m_size); |
391 extensions->copyTextureCHROMIUM(GL_TEXTURE_2D, m_frontColorBuffer, sourceTex
ture, 0, GL_RGBA, GL_UNSIGNED_BYTE); | 385 m_context->webContext()->copyTextureCHROMIUM(GL_TEXTURE_2D, m_frontColorBuff
er, sourceTexture, 0, GL_RGBA, GL_UNSIGNED_BYTE); |
392 | 386 |
393 // Since we're using the same context as WebGL, we have to restore any state
we change (in this case, just the framebuffer binding). | 387 // Since we're using the same context as WebGL, we have to restore any state
we change (in this case, just the framebuffer binding). |
394 // FIXME: The WebGLRenderingContext tracks the current framebuffer binding,
it would be slightly more efficient to use this value | 388 // FIXME: The WebGLRenderingContext tracks the current framebuffer binding,
it would be slightly more efficient to use this value |
395 // rather than querying it off of the context. | 389 // rather than querying it off of the context. |
396 GLint previousFramebuffer = 0; | 390 GLint previousFramebuffer = 0; |
397 m_context->getIntegerv(GL_FRAMEBUFFER_BINDING, &previousFramebuffer); | 391 m_context->getIntegerv(GL_FRAMEBUFFER_BINDING, &previousFramebuffer); |
398 | 392 |
399 Platform3DObject framebuffer = m_context->createFramebuffer(); | 393 Platform3DObject framebuffer = m_context->createFramebuffer(); |
400 m_context->bindFramebuffer(GL_FRAMEBUFFER, framebuffer); | 394 m_context->bindFramebuffer(GL_FRAMEBUFFER, framebuffer); |
401 m_context->framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEX
TURE_2D, sourceTexture, 0); | 395 m_context->framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEX
TURE_2D, sourceTexture, 0); |
402 | 396 |
403 extensions->paintFramebufferToCanvas(framebuffer, size().width(), size().hei
ght(), !m_attributes.premultipliedAlpha, imageBuffer); | 397 m_context->paintFramebufferToCanvas(framebuffer, size().width(), size().heig
ht(), !m_attributes.premultipliedAlpha, imageBuffer); |
404 m_context->deleteFramebuffer(framebuffer); | 398 m_context->deleteFramebuffer(framebuffer); |
405 m_context->deleteTexture(sourceTexture); | 399 m_context->deleteTexture(sourceTexture); |
406 | 400 |
407 m_context->bindFramebuffer(GL_FRAMEBUFFER, previousFramebuffer); | 401 m_context->bindFramebuffer(GL_FRAMEBUFFER, previousFramebuffer); |
408 } | 402 } |
409 | 403 |
410 void DrawingBuffer::clearPlatformLayer() | 404 void DrawingBuffer::clearPlatformLayer() |
411 { | 405 { |
412 if (m_layer) | 406 if (m_layer) |
413 m_layer->clearTexture(); | 407 m_layer->clearTexture(); |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 | 514 |
521 return true; | 515 return true; |
522 } | 516 } |
523 | 517 |
524 bool DrawingBuffer::resizeMultisampleFramebuffer(const IntSize& size) | 518 bool DrawingBuffer::resizeMultisampleFramebuffer(const IntSize& size) |
525 { | 519 { |
526 if (multisample()) { | 520 if (multisample()) { |
527 m_context->bindFramebuffer(GL_FRAMEBUFFER, m_multisampleFBO); | 521 m_context->bindFramebuffer(GL_FRAMEBUFFER, m_multisampleFBO); |
528 | 522 |
529 m_context->bindRenderbuffer(GL_RENDERBUFFER, m_multisampleColorBuffer); | 523 m_context->bindRenderbuffer(GL_RENDERBUFFER, m_multisampleColorBuffer); |
530 m_context->extensions()->renderbufferStorageMultisample(GL_RENDERBUFFER,
m_sampleCount, m_internalRenderbufferFormat, size.width(), size.height()); | 524 m_context->webContext()->renderbufferStorageMultisampleCHROMIUM(GL_RENDE
RBUFFER, m_sampleCount, m_internalRenderbufferFormat, size.width(), size.height(
)); |
531 | 525 |
532 if (m_context->getError() == GL_OUT_OF_MEMORY) | 526 if (m_context->getError() == GL_OUT_OF_MEMORY) |
533 return false; | 527 return false; |
534 | 528 |
535 m_context->framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
GL_RENDERBUFFER, m_multisampleColorBuffer); | 529 m_context->framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
GL_RENDERBUFFER, m_multisampleColorBuffer); |
536 resizeDepthStencil(size); | 530 resizeDepthStencil(size); |
537 if (m_context->checkFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_
COMPLETE) | 531 if (m_context->checkFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_
COMPLETE) |
538 return false; | 532 return false; |
539 } | 533 } |
540 | 534 |
541 return true; | 535 return true; |
542 } | 536 } |
543 | 537 |
544 void DrawingBuffer::resizeDepthStencil(const IntSize& size) | 538 void DrawingBuffer::resizeDepthStencil(const IntSize& size) |
545 { | 539 { |
546 if (m_attributes.depth && m_attributes.stencil && m_packedDepthStencilExtens
ionSupported) { | 540 if (m_attributes.depth && m_attributes.stencil && m_packedDepthStencilExtens
ionSupported) { |
547 if (!m_depthStencilBuffer) | 541 if (!m_depthStencilBuffer) |
548 m_depthStencilBuffer = m_context->createRenderbuffer(); | 542 m_depthStencilBuffer = m_context->createRenderbuffer(); |
549 m_context->bindRenderbuffer(GL_RENDERBUFFER, m_depthStencilBuffer); | 543 m_context->bindRenderbuffer(GL_RENDERBUFFER, m_depthStencilBuffer); |
550 if (multisample()) | 544 if (multisample()) |
551 m_context->extensions()->renderbufferStorageMultisample(GL_RENDERBUF
FER, m_sampleCount, Extensions3D::DEPTH24_STENCIL8, size.width(), size.height())
; | 545 m_context->webContext()->renderbufferStorageMultisampleCHROMIUM(GL_R
ENDERBUFFER, m_sampleCount, GL_DEPTH24_STENCIL8_OES, size.width(), size.height()
); |
552 else | 546 else |
553 m_context->renderbufferStorage(GL_RENDERBUFFER, Extensions3D::DEPTH2
4_STENCIL8, size.width(), size.height()); | 547 m_context->renderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8_
OES, size.width(), size.height()); |
554 m_context->framebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT
, GL_RENDERBUFFER, m_depthStencilBuffer); | 548 m_context->framebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT
, GL_RENDERBUFFER, m_depthStencilBuffer); |
555 m_context->framebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
GL_RENDERBUFFER, m_depthStencilBuffer); | 549 m_context->framebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
GL_RENDERBUFFER, m_depthStencilBuffer); |
556 } else { | 550 } else { |
557 if (m_attributes.depth) { | 551 if (m_attributes.depth) { |
558 if (!m_depthBuffer) | 552 if (!m_depthBuffer) |
559 m_depthBuffer = m_context->createRenderbuffer(); | 553 m_depthBuffer = m_context->createRenderbuffer(); |
560 m_context->bindRenderbuffer(GL_RENDERBUFFER, m_depthBuffer); | 554 m_context->bindRenderbuffer(GL_RENDERBUFFER, m_depthBuffer); |
561 if (multisample()) | 555 if (multisample()) |
562 m_context->extensions()->renderbufferStorageMultisample(GL_RENDE
RBUFFER, m_sampleCount, GL_DEPTH_COMPONENT16, size.width(), size.height()); | 556 m_context->webContext()->renderbufferStorageMultisampleCHROMIUM(
GL_RENDERBUFFER, m_sampleCount, GL_DEPTH_COMPONENT16, size.width(), size.height(
)); |
563 else | 557 else |
564 m_context->renderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONE
NT16, size.width(), size.height()); | 558 m_context->renderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONE
NT16, size.width(), size.height()); |
565 m_context->framebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHME
NT, GL_RENDERBUFFER, m_depthBuffer); | 559 m_context->framebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHME
NT, GL_RENDERBUFFER, m_depthBuffer); |
566 } | 560 } |
567 if (m_attributes.stencil) { | 561 if (m_attributes.stencil) { |
568 if (!m_stencilBuffer) | 562 if (!m_stencilBuffer) |
569 m_stencilBuffer = m_context->createRenderbuffer(); | 563 m_stencilBuffer = m_context->createRenderbuffer(); |
570 m_context->bindRenderbuffer(GL_RENDERBUFFER, m_stencilBuffer); | 564 m_context->bindRenderbuffer(GL_RENDERBUFFER, m_stencilBuffer); |
571 if (multisample()) | 565 if (multisample()) |
572 m_context->extensions()->renderbufferStorageMultisample(GL_RENDE
RBUFFER, m_sampleCount, GL_STENCIL_INDEX8, size.width(), size.height()); | 566 m_context->webContext()->renderbufferStorageMultisampleCHROMIUM(
GL_RENDERBUFFER, m_sampleCount, GL_STENCIL_INDEX8, size.width(), size.height()); |
573 else | 567 else |
574 m_context->renderbufferStorage(GL_RENDERBUFFER, GL_STENCIL_INDEX
8, size.width(), size.height()); | 568 m_context->renderbufferStorage(GL_RENDERBUFFER, GL_STENCIL_INDEX
8, size.width(), size.height()); |
575 m_context->framebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACH
MENT, GL_RENDERBUFFER, m_stencilBuffer); | 569 m_context->framebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACH
MENT, GL_RENDERBUFFER, m_stencilBuffer); |
576 } | 570 } |
577 } | 571 } |
578 m_context->bindRenderbuffer(GL_RENDERBUFFER, 0); | 572 m_context->bindRenderbuffer(GL_RENDERBUFFER, 0); |
579 } | 573 } |
580 | 574 |
581 | 575 |
582 | 576 |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
712 return; | 706 return; |
713 | 707 |
714 if (width < 0) | 708 if (width < 0) |
715 width = m_size.width(); | 709 width = m_size.width(); |
716 if (height < 0) | 710 if (height < 0) |
717 height = m_size.height(); | 711 height = m_size.height(); |
718 | 712 |
719 m_context->makeContextCurrent(); | 713 m_context->makeContextCurrent(); |
720 | 714 |
721 if (m_multisampleFBO && !m_contentsChangeCommitted) { | 715 if (m_multisampleFBO && !m_contentsChangeCommitted) { |
722 m_context->bindFramebuffer(Extensions3D::READ_FRAMEBUFFER, m_multisample
FBO); | 716 m_context->bindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, m_multisampleFBO); |
723 m_context->bindFramebuffer(Extensions3D::DRAW_FRAMEBUFFER, m_fbo); | 717 m_context->bindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, m_fbo); |
724 | 718 |
725 if (m_scissorEnabled) | 719 if (m_scissorEnabled) |
726 m_context->disable(GL_SCISSOR_TEST); | 720 m_context->disable(GL_SCISSOR_TEST); |
727 | 721 |
728 // Use NEAREST, because there is no scale performed during the blit. | 722 // Use NEAREST, because there is no scale performed during the blit. |
729 m_context->extensions()->blitFramebuffer(x, y, width, height, x, y, widt
h, height, GL_COLOR_BUFFER_BIT, GL_NEAREST); | 723 m_context->webContext()->blitFramebufferCHROMIUM(x, y, width, height, x,
y, width, height, GL_COLOR_BUFFER_BIT, GL_NEAREST); |
730 | 724 |
731 if (m_scissorEnabled) | 725 if (m_scissorEnabled) |
732 m_context->enable(GL_SCISSOR_TEST); | 726 m_context->enable(GL_SCISSOR_TEST); |
733 } | 727 } |
734 | 728 |
735 m_context->bindFramebuffer(GL_FRAMEBUFFER, m_fbo); | 729 m_context->bindFramebuffer(GL_FRAMEBUFFER, m_fbo); |
736 m_contentsChangeCommitted = true; | 730 m_contentsChangeCommitted = true; |
737 } | 731 } |
738 | 732 |
739 void DrawingBuffer::restoreFramebufferBinding() | 733 void DrawingBuffer::restoreFramebufferBinding() |
(...skipping 11 matching lines...) Expand all Loading... |
751 | 745 |
752 void DrawingBuffer::bind() | 746 void DrawingBuffer::bind() |
753 { | 747 { |
754 if (!m_context) | 748 if (!m_context) |
755 return; | 749 return; |
756 | 750 |
757 m_context->bindFramebuffer(GL_FRAMEBUFFER, m_multisampleFBO ? m_multisampleF
BO : m_fbo); | 751 m_context->bindFramebuffer(GL_FRAMEBUFFER, m_multisampleFBO ? m_multisampleF
BO : m_fbo); |
758 } | 752 } |
759 | 753 |
760 } // namespace WebCore | 754 } // namespace WebCore |
OLD | NEW |