| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "gpu/command_buffer/service/gles2_cmd_decoder.h" | 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
| 6 | 6 |
| 7 #include <stdio.h> | 7 #include <stdio.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <list> | 10 #include <list> |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 const CommandInfo g_command_info[] = { | 124 const CommandInfo g_command_info[] = { |
| 125 #define GLES2_CMD_OP(name) { \ | 125 #define GLES2_CMD_OP(name) { \ |
| 126 name::kArgFlags, \ | 126 name::kArgFlags, \ |
| 127 sizeof(name) / sizeof(CommandBufferEntry) - 1, }, /* NOLINT */ \ | 127 sizeof(name) / sizeof(CommandBufferEntry) - 1, }, /* NOLINT */ \ |
| 128 | 128 |
| 129 GLES2_COMMAND_LIST(GLES2_CMD_OP) | 129 GLES2_COMMAND_LIST(GLES2_CMD_OP) |
| 130 | 130 |
| 131 #undef GLES2_CMD_OP | 131 #undef GLES2_CMD_OP |
| 132 }; | 132 }; |
| 133 | 133 |
| 134 static bool IsAngle() { | |
| 135 #if defined(OS_WIN) | |
| 136 return gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2; | |
| 137 #else | |
| 138 return false; | |
| 139 #endif | |
| 140 } | |
| 141 | |
| 142 // Return true if a character belongs to the ASCII subset as defined in | 134 // Return true if a character belongs to the ASCII subset as defined in |
| 143 // GLSL ES 1.0 spec section 3.1. | 135 // GLSL ES 1.0 spec section 3.1. |
| 144 static bool CharacterIsValidForGLES(unsigned char c) { | 136 static bool CharacterIsValidForGLES(unsigned char c) { |
| 145 // Printing characters are valid except " $ ` @ \ ' DEL. | 137 // Printing characters are valid except " $ ` @ \ ' DEL. |
| 146 if (c >= 32 && c <= 126 && | 138 if (c >= 32 && c <= 126 && |
| 147 c != '"' && | 139 c != '"' && |
| 148 c != '$' && | 140 c != '$' && |
| 149 c != '`' && | 141 c != '`' && |
| 150 c != '@' && | 142 c != '@' && |
| 151 c != '\\' && | 143 c != '\\' && |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 501 } | 493 } |
| 502 | 494 |
| 503 GLES2Decoder::GLES2Decoder() | 495 GLES2Decoder::GLES2Decoder() |
| 504 : debug_(false), | 496 : debug_(false), |
| 505 log_commands_(false) { | 497 log_commands_(false) { |
| 506 } | 498 } |
| 507 | 499 |
| 508 GLES2Decoder::~GLES2Decoder() { | 500 GLES2Decoder::~GLES2Decoder() { |
| 509 } | 501 } |
| 510 | 502 |
| 503 bool GLES2Decoder::testing_force_is_angle_; |
| 504 |
| 505 void GLES2Decoder::set_testing_force_is_angle(bool force) { |
| 506 testing_force_is_angle_ = force; |
| 507 } |
| 508 |
| 509 bool GLES2Decoder::IsAngle() { |
| 510 #if defined(OS_WIN) |
| 511 return testing_force_is_angle_ || |
| 512 gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2; |
| 513 #else |
| 514 return testing_force_is_angle_; |
| 515 #endif |
| 516 } |
| 517 |
| 511 // This class implements GLES2Decoder so we don't have to expose all the GLES2 | 518 // This class implements GLES2Decoder so we don't have to expose all the GLES2 |
| 512 // cmd stuff to outside this class. | 519 // cmd stuff to outside this class. |
| 513 class GLES2DecoderImpl : public base::SupportsWeakPtr<GLES2DecoderImpl>, | 520 class GLES2DecoderImpl : public base::SupportsWeakPtr<GLES2DecoderImpl>, |
| 514 public GLES2Decoder { | 521 public GLES2Decoder { |
| 515 public: | 522 public: |
| 516 explicit GLES2DecoderImpl(ContextGroup* group); | 523 explicit GLES2DecoderImpl(ContextGroup* group); |
| 517 ~GLES2DecoderImpl(); | 524 ~GLES2DecoderImpl(); |
| 518 | 525 |
| 519 // Overridden from AsyncAPIInterface. | 526 // Overridden from AsyncAPIInterface. |
| 520 virtual Error DoCommand(unsigned int command, | 527 virtual Error DoCommand(unsigned int command, |
| (...skipping 1078 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1599 } | 1606 } |
| 1600 } | 1607 } |
| 1601 targetid = decoder_->offscreen_resolved_frame_buffer_->id(); | 1608 targetid = decoder_->offscreen_resolved_frame_buffer_->id(); |
| 1602 } else { | 1609 } else { |
| 1603 targetid = decoder_->offscreen_saved_frame_buffer_->id(); | 1610 targetid = decoder_->offscreen_saved_frame_buffer_->id(); |
| 1604 } | 1611 } |
| 1605 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, targetid); | 1612 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, targetid); |
| 1606 const int width = decoder_->offscreen_size_.width(); | 1613 const int width = decoder_->offscreen_size_.width(); |
| 1607 const int height = decoder_->offscreen_size_.height(); | 1614 const int height = decoder_->offscreen_size_.height(); |
| 1608 glDisable(GL_SCISSOR_TEST); | 1615 glDisable(GL_SCISSOR_TEST); |
| 1609 if (IsAngle()) { | 1616 if (GLES2Decoder::IsAngle()) { |
| 1610 glBlitFramebufferANGLE(0, 0, width, height, 0, 0, width, height, | 1617 glBlitFramebufferANGLE(0, 0, width, height, 0, 0, width, height, |
| 1611 GL_COLOR_BUFFER_BIT, GL_NEAREST); | 1618 GL_COLOR_BUFFER_BIT, GL_NEAREST); |
| 1612 } else { | 1619 } else { |
| 1613 glBlitFramebufferEXT(0, 0, width, height, 0, 0, width, height, | 1620 glBlitFramebufferEXT(0, 0, width, height, 0, 0, width, height, |
| 1614 GL_COLOR_BUFFER_BIT, GL_NEAREST); | 1621 GL_COLOR_BUFFER_BIT, GL_NEAREST); |
| 1615 } | 1622 } |
| 1616 glBindFramebufferEXT(GL_FRAMEBUFFER, targetid); | 1623 glBindFramebufferEXT(GL_FRAMEBUFFER, targetid); |
| 1617 } | 1624 } |
| 1618 | 1625 |
| 1619 ScopedResolvedFrameBufferBinder::~ScopedResolvedFrameBufferBinder() { | 1626 ScopedResolvedFrameBufferBinder::~ScopedResolvedFrameBufferBinder() { |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1739 bool RenderBuffer::AllocateStorage(const gfx::Size& size, GLenum format, | 1746 bool RenderBuffer::AllocateStorage(const gfx::Size& size, GLenum format, |
| 1740 GLsizei samples) { | 1747 GLsizei samples) { |
| 1741 ScopedGLErrorSuppressor suppressor(decoder_); | 1748 ScopedGLErrorSuppressor suppressor(decoder_); |
| 1742 ScopedRenderBufferBinder binder(decoder_, id_); | 1749 ScopedRenderBufferBinder binder(decoder_, id_); |
| 1743 if (samples <= 1) { | 1750 if (samples <= 1) { |
| 1744 glRenderbufferStorageEXT(GL_RENDERBUFFER, | 1751 glRenderbufferStorageEXT(GL_RENDERBUFFER, |
| 1745 format, | 1752 format, |
| 1746 size.width(), | 1753 size.width(), |
| 1747 size.height()); | 1754 size.height()); |
| 1748 } else { | 1755 } else { |
| 1749 if (IsAngle()) { | 1756 if (GLES2Decoder::IsAngle()) { |
| 1750 glRenderbufferStorageMultisampleANGLE(GL_RENDERBUFFER, | 1757 glRenderbufferStorageMultisampleANGLE(GL_RENDERBUFFER, |
| 1751 samples, | 1758 samples, |
| 1752 format, | 1759 format, |
| 1753 size.width(), | 1760 size.width(), |
| 1754 size.height()); | 1761 size.height()); |
| 1755 } else { | 1762 } else { |
| 1756 glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER, | 1763 glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER, |
| 1757 samples, | 1764 samples, |
| 1758 format, | 1765 format, |
| 1759 size.width(), | 1766 size.width(), |
| (...skipping 4792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6552 | 6559 |
| 6553 if (info->IsAttachedToFramebuffer()) { | 6560 if (info->IsAttachedToFramebuffer()) { |
| 6554 state_dirty_ = true; | 6561 state_dirty_ = true; |
| 6555 // TODO(gman): If textures tracked which framebuffers they were attached to | 6562 // TODO(gman): If textures tracked which framebuffers they were attached to |
| 6556 // we could just mark those framebuffers as not complete. | 6563 // we could just mark those framebuffers as not complete. |
| 6557 framebuffer_manager()->IncFramebufferStateChangeCount(); | 6564 framebuffer_manager()->IncFramebufferStateChangeCount(); |
| 6558 } | 6565 } |
| 6559 | 6566 |
| 6560 if (!teximage2d_faster_than_texsubimage2d_ && level_is_same && pixels) { | 6567 if (!teximage2d_faster_than_texsubimage2d_ && level_is_same && pixels) { |
| 6561 glTexSubImage2D(target, level, 0, 0, width, height, format, type, pixels); | 6568 glTexSubImage2D(target, level, 0, 0, width, height, format, type, pixels); |
| 6569 texture_manager()->SetLevelCleared(info, target, level); |
| 6562 tex_image_2d_failed_ = false; | 6570 tex_image_2d_failed_ = false; |
| 6563 return error::kNoError; | 6571 return error::kNoError; |
| 6564 } | 6572 } |
| 6565 | 6573 |
| 6566 CopyRealGLErrorsToWrapper(); | 6574 CopyRealGLErrorsToWrapper(); |
| 6567 WrappedTexImage2D( | 6575 WrappedTexImage2D( |
| 6568 target, level, internal_format, width, height, border, format, type, | 6576 target, level, internal_format, width, height, border, format, type, |
| 6569 pixels); | 6577 pixels); |
| 6570 GLenum error = PeekGLError(); | 6578 GLenum error = PeekGLError(); |
| 6571 if (error == GL_NO_ERROR) { | 6579 if (error == GL_NO_ERROR) { |
| (...skipping 1435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8007 } | 8015 } |
| 8008 } | 8016 } |
| 8009 | 8017 |
| 8010 // Include the auto-generated part of this file. We split this because it means | 8018 // Include the auto-generated part of this file. We split this because it means |
| 8011 // we can easily edit the non-auto generated parts right here in this file | 8019 // we can easily edit the non-auto generated parts right here in this file |
| 8012 // instead of having to edit some template or the code generator. | 8020 // instead of having to edit some template or the code generator. |
| 8013 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 8021 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 8014 | 8022 |
| 8015 } // namespace gles2 | 8023 } // namespace gles2 |
| 8016 } // namespace gpu | 8024 } // namespace gpu |
| OLD | NEW |