Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "modules/webgl/WebGL2RenderingContextBase.h" | 5 #include "modules/webgl/WebGL2RenderingContextBase.h" |
| 6 | 6 |
| 7 #include "bindings/modules/v8/WebGLAny.h" | 7 #include "bindings/modules/v8/WebGLAny.h" |
| 8 #include "core/frame/ImageBitmap.h" | 8 #include "core/frame/ImageBitmap.h" |
| 9 #include "core/html/HTMLCanvasElement.h" | 9 #include "core/html/HTMLCanvasElement.h" |
| 10 #include "core/html/HTMLImageElement.h" | 10 #include "core/html/HTMLImageElement.h" |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 333 ScriptValue WebGL2RenderingContextBase::getInternalformatParameter(ScriptState* scriptState, GLenum target, GLenum internalformat, GLenum pname) | 333 ScriptValue WebGL2RenderingContextBase::getInternalformatParameter(ScriptState* scriptState, GLenum target, GLenum internalformat, GLenum pname) |
| 334 { | 334 { |
| 335 if (isContextLost()) | 335 if (isContextLost()) |
| 336 return ScriptValue::createNull(scriptState); | 336 return ScriptValue::createNull(scriptState); |
| 337 | 337 |
| 338 if (target != GL_RENDERBUFFER) { | 338 if (target != GL_RENDERBUFFER) { |
| 339 synthesizeGLError(GL_INVALID_ENUM, "getInternalformatParameter", "invali d target"); | 339 synthesizeGLError(GL_INVALID_ENUM, "getInternalformatParameter", "invali d target"); |
| 340 return ScriptValue::createNull(scriptState); | 340 return ScriptValue::createNull(scriptState); |
| 341 } | 341 } |
| 342 | 342 |
| 343 bool floatType = false; | |
| 344 | 343 |
| 345 switch (internalformat) { | 344 switch (internalformat) { |
| 346 // Renderbuffer doesn't support unsized internal formats, | 345 // Renderbuffer doesn't support unsized internal formats, |
| 347 // though GL_RGB and GL_RGBA are color-renderable. | 346 // though GL_RGB and GL_RGBA are color-renderable. |
| 348 case GL_RGB: | 347 case GL_RGB: |
| 349 case GL_RGBA: | 348 case GL_RGBA: |
| 350 // Multisampling is not supported for signed and unsigned integer internal f ormats. | 349 // Multisampling is not supported for signed and unsigned integer internal f ormats. |
| 351 case GL_R8UI: | 350 case GL_R8UI: |
| 352 case GL_R8I: | 351 case GL_R8I: |
| 353 case GL_R16UI: | 352 case GL_R16UI: |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 388 case GL_RG16F: | 387 case GL_RG16F: |
| 389 case GL_RGBA16F: | 388 case GL_RGBA16F: |
| 390 case GL_R32F: | 389 case GL_R32F: |
| 391 case GL_RG32F: | 390 case GL_RG32F: |
| 392 case GL_RGBA32F: | 391 case GL_RGBA32F: |
| 393 case GL_R11F_G11F_B10F: | 392 case GL_R11F_G11F_B10F: |
| 394 if (!extensionEnabled(EXTColorBufferFloatName)) { | 393 if (!extensionEnabled(EXTColorBufferFloatName)) { |
| 395 synthesizeGLError(GL_INVALID_ENUM, "getInternalformatParameter", "in valid internalformat when EXT_color_buffer_float is not enabled"); | 394 synthesizeGLError(GL_INVALID_ENUM, "getInternalformatParameter", "in valid internalformat when EXT_color_buffer_float is not enabled"); |
| 396 return ScriptValue::createNull(scriptState); | 395 return ScriptValue::createNull(scriptState); |
| 397 } | 396 } |
| 398 floatType = true; | |
| 399 break; | 397 break; |
| 400 default: | 398 default: |
| 401 synthesizeGLError(GL_INVALID_ENUM, "getInternalformatParameter", "invali d internalformat"); | 399 synthesizeGLError(GL_INVALID_ENUM, "getInternalformatParameter", "invali d internalformat"); |
| 402 return ScriptValue::createNull(scriptState); | 400 return ScriptValue::createNull(scriptState); |
| 403 } | 401 } |
| 404 | 402 |
| 405 switch (pname) { | 403 switch (pname) { |
| 406 case GL_SAMPLES: | 404 case GL_SAMPLES: |
| 407 { | 405 { |
| 408 std::unique_ptr<GLint[]> values; | 406 std::unique_ptr<GLint[]> values; |
| 409 GLint length = -1; | 407 GLint length = -1; |
| 410 if (!floatType) { | 408 contextGL()->GetInternalformativ(target, internalformat, GL_NUM_SAMP LE_COUNTS, 1, &length); |
| 411 contextGL()->GetInternalformativ(target, internalformat, GL_NUM_ SAMPLE_COUNTS, 1, &length); | 409 if (length <= 0) |
| 412 if (length <= 0) | 410 return WebGLAny(scriptState, DOMInt32Array::create(0)); |
| 413 return WebGLAny(scriptState, DOMInt32Array::create(0)); | |
| 414 | 411 |
| 415 values = wrapArrayUnique(new GLint[length]); | 412 values = wrapArrayUnique(new GLint[length]); |
| 416 for (GLint ii = 0; ii < length; ++ii) | 413 for (GLint ii = 0; ii < length; ++ii) |
| 417 values[ii] = 0; | 414 values[ii] = 0; |
| 418 contextGL()->GetInternalformativ(target, internalformat, GL_SAMP LES, length, values.get()); | 415 contextGL()->GetInternalformativ(target, internalformat, GL_SAMPLES, length, values.get()); |
| 419 } else { | |
| 420 length = 1; | |
| 421 values = wrapArrayUnique(new GLint[1]); | |
| 422 values[0] = 1; | |
| 423 } | |
| 424 return WebGLAny(scriptState, DOMInt32Array::create(values.get(), len gth)); | 416 return WebGLAny(scriptState, DOMInt32Array::create(values.get(), len gth)); |
| 425 } | 417 } |
| 426 default: | 418 default: |
| 427 synthesizeGLError(GL_INVALID_ENUM, "getInternalformatParameter", "invali d parameter name"); | 419 synthesizeGLError(GL_INVALID_ENUM, "getInternalformatParameter", "invali d parameter name"); |
| 428 return ScriptValue::createNull(scriptState); | 420 return ScriptValue::createNull(scriptState); |
| 429 } | 421 } |
| 430 } | 422 } |
| 431 | 423 |
| 432 bool WebGL2RenderingContextBase::checkAndTranslateAttachments(const char* functi onName, GLenum target, Vector<GLenum>& attachments) | 424 bool WebGL2RenderingContextBase::checkAndTranslateAttachments(const char* functi onName, GLenum target, Vector<GLenum>& attachments) |
| 433 { | 425 { |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 622 return; | 614 return; |
| 623 | 615 |
| 624 clearIfComposited(); | 616 clearIfComposited(); |
| 625 | 617 |
| 626 { | 618 { |
| 627 ScopedDrawingBufferBinder binder(drawingBuffer(), framebuffer); | 619 ScopedDrawingBufferBinder binder(drawingBuffer(), framebuffer); |
| 628 contextGL()->ReadPixels(x, y, width, height, format, type, reinterpret_c ast<void*>(offset)); | 620 contextGL()->ReadPixels(x, y, width, height, format, type, reinterpret_c ast<void*>(offset)); |
| 629 } | 621 } |
| 630 } | 622 } |
| 631 | 623 |
| 624 void WebGL2RenderingContextBase::renderbufferStorageHelper(GLenum target, GLsize i samples, GLenum internalformat, GLsizei width, GLsizei height, const char* fun ctionName) | |
| 625 { | |
| 626 if (!samples) { | |
| 627 contextGL()->RenderbufferStorage(target, internalformat, width, height); | |
| 628 } else { | |
| 629 GLint maxNumberOfSamples = 0; | |
| 630 contextGL()->GetInternalformativ(target, internalformat, GL_SAMPLES, 1, &maxNumberOfSamples); | |
| 631 if (samples > maxNumberOfSamples) { | |
| 632 synthesizeGLError(GL_INVALID_OPERATION, functionName, "samples out o f range"); | |
| 633 return; | |
| 634 } | |
| 635 LOG(ERROR) << "RenderbufferStorageMultisampleCHROMIUM: samples:" << samp les << ", format:" << internalformat; | |
|
Ken Russell (switch to Gerrit)
2016/08/03 00:58:50
Please remove debug logging.
| |
| 636 contextGL()->RenderbufferStorageMultisampleCHROMIUM(target, samples, int ernalformat, width, height); | |
| 637 } | |
| 638 } | |
| 639 | |
| 632 void WebGL2RenderingContextBase::renderbufferStorageImpl( | 640 void WebGL2RenderingContextBase::renderbufferStorageImpl( |
| 633 GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsize i height, | 641 GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsize i height, |
| 634 const char* functionName) | 642 const char* functionName) |
| 635 { | 643 { |
| 636 switch (internalformat) { | 644 switch (internalformat) { |
| 637 case GL_R8UI: | 645 case GL_R8UI: |
| 638 case GL_R8I: | 646 case GL_R8I: |
| 639 case GL_R16UI: | 647 case GL_R16UI: |
| 640 case GL_R16I: | 648 case GL_R16I: |
| 641 case GL_R32UI: | 649 case GL_R32UI: |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 666 case GL_SRGB8_ALPHA8: | 674 case GL_SRGB8_ALPHA8: |
| 667 case GL_RGB5_A1: | 675 case GL_RGB5_A1: |
| 668 case GL_RGBA4: | 676 case GL_RGBA4: |
| 669 case GL_RGB10_A2: | 677 case GL_RGB10_A2: |
| 670 case GL_DEPTH_COMPONENT16: | 678 case GL_DEPTH_COMPONENT16: |
| 671 case GL_DEPTH_COMPONENT24: | 679 case GL_DEPTH_COMPONENT24: |
| 672 case GL_DEPTH_COMPONENT32F: | 680 case GL_DEPTH_COMPONENT32F: |
| 673 case GL_DEPTH24_STENCIL8: | 681 case GL_DEPTH24_STENCIL8: |
| 674 case GL_DEPTH32F_STENCIL8: | 682 case GL_DEPTH32F_STENCIL8: |
| 675 case GL_STENCIL_INDEX8: | 683 case GL_STENCIL_INDEX8: |
| 676 if (!samples) { | 684 renderbufferStorageHelper(target, samples, internalformat, width, height , functionName); |
| 677 contextGL()->RenderbufferStorage(target, internalformat, width, heig ht); | |
| 678 } else { | |
| 679 GLint maxNumberOfSamples = 0; | |
| 680 contextGL()->GetInternalformativ(target, internalformat, GL_SAMPLES, 1, &maxNumberOfSamples); | |
| 681 if (samples > maxNumberOfSamples) { | |
| 682 synthesizeGLError(GL_INVALID_OPERATION, functionName, "samples o ut of range"); | |
| 683 return; | |
| 684 } | |
| 685 contextGL()->RenderbufferStorageMultisampleCHROMIUM( | |
| 686 target, samples, internalformat, width, height); | |
| 687 } | |
| 688 break; | 685 break; |
| 689 case GL_DEPTH_STENCIL: | 686 case GL_DEPTH_STENCIL: |
| 690 // To be WebGL 1 backward compatible. | 687 // To be WebGL 1 backward compatible. |
| 691 if (samples > 0) { | 688 if (samples > 0) { |
| 692 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid internalfo rmat"); | 689 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid internalfo rmat"); |
| 693 return; | 690 return; |
| 694 } | 691 } |
| 695 contextGL()->RenderbufferStorage(target, GL_DEPTH24_STENCIL8, width, hei ght); | 692 renderbufferStorageHelper(target, 0, GL_DEPTH24_STENCIL8, width, height, functionName); |
| 696 break; | 693 break; |
| 697 case GL_R16F: | 694 case GL_R16F: |
| 698 case GL_RG16F: | 695 case GL_RG16F: |
| 699 case GL_RGBA16F: | 696 case GL_RGBA16F: |
| 700 case GL_R32F: | 697 case GL_R32F: |
| 701 case GL_RG32F: | 698 case GL_RG32F: |
| 702 case GL_RGBA32F: | 699 case GL_RGBA32F: |
| 703 case GL_R11F_G11F_B10F: | 700 case GL_R11F_G11F_B10F: |
| 704 if (!extensionEnabled(EXTColorBufferFloatName)) { | 701 if (!extensionEnabled(EXTColorBufferFloatName)) { |
| 705 synthesizeGLError(GL_INVALID_ENUM, functionName, "EXT_color_buffer_f loat not enabled"); | 702 synthesizeGLError(GL_INVALID_ENUM, functionName, "EXT_color_buffer_f loat not enabled"); |
| 706 return; | 703 return; |
| 707 } | 704 } |
| 708 if (samples) { | 705 renderbufferStorageHelper(target, samples, internalformat, width, height , functionName); |
| 709 synthesizeGLError(GL_INVALID_VALUE, functionName, "multisampled floa t buffers not supported"); | |
| 710 return; | |
| 711 } | |
| 712 contextGL()->RenderbufferStorage(target, internalformat, width, height); | |
| 713 break; | 706 break; |
| 714 default: | 707 default: |
| 715 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid internalformat "); | 708 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid internalformat "); |
| 716 return; | 709 return; |
| 717 } | 710 } |
| 718 m_renderbufferBinding->setInternalFormat(internalformat); | 711 m_renderbufferBinding->setInternalFormat(internalformat); |
| 719 m_renderbufferBinding->setSize(width, height); | 712 m_renderbufferBinding->setSize(width, height); |
| 720 } | 713 } |
| 721 | 714 |
| 722 void WebGL2RenderingContextBase::renderbufferStorageMultisample(GLenum target, G Lsizei samples, GLenum internalformat, GLsizei width, GLsizei height) | 715 void WebGL2RenderingContextBase::renderbufferStorageMultisample(GLenum target, G Lsizei samples, GLenum internalformat, GLsizei width, GLsizei height) |
| (...skipping 2646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3369 params.skipPixels = m_unpackSkipPixels; | 3362 params.skipPixels = m_unpackSkipPixels; |
| 3370 params.skipRows = m_unpackSkipRows; | 3363 params.skipRows = m_unpackSkipRows; |
| 3371 if (dimension == Tex3D) { | 3364 if (dimension == Tex3D) { |
| 3372 params.imageHeight = m_unpackImageHeight; | 3365 params.imageHeight = m_unpackImageHeight; |
| 3373 params.skipImages = m_unpackSkipImages; | 3366 params.skipImages = m_unpackSkipImages; |
| 3374 } | 3367 } |
| 3375 return params; | 3368 return params; |
| 3376 } | 3369 } |
| 3377 | 3370 |
| 3378 } // namespace blink | 3371 } // namespace blink |
| OLD | NEW |