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/texture_manager.h" | 5 #include "gpu/command_buffer/service/texture_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bits.h" | 10 #include "base/bits.h" |
11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
12 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 12 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
13 #include "gpu/command_buffer/service/context_state.h" | 13 #include "gpu/command_buffer/service/context_state.h" |
14 #include "gpu/command_buffer/service/error_state.h" | 14 #include "gpu/command_buffer/service/error_state.h" |
15 #include "gpu/command_buffer/service/feature_info.h" | 15 #include "gpu/command_buffer/service/feature_info.h" |
16 #include "gpu/command_buffer/service/framebuffer_manager.h" | 16 #include "gpu/command_buffer/service/framebuffer_manager.h" |
17 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 17 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
18 #include "gpu/command_buffer/service/mailbox_manager.h" | 18 #include "gpu/command_buffer/service/mailbox_manager.h" |
19 #include "gpu/command_buffer/service/memory_tracking.h" | 19 #include "gpu/command_buffer/service/memory_tracking.h" |
20 #include "ui/gl/gl_implementation.h" | |
20 | 21 |
21 namespace gpu { | 22 namespace gpu { |
22 namespace gles2 { | 23 namespace gles2 { |
23 | 24 |
24 // This should contain everything to uniquely identify a Texture. | 25 // This should contain everything to uniquely identify a Texture. |
25 static const char TextureTag[] = "|Texture|"; | 26 static const char TextureTag[] = "|Texture|"; |
26 struct TextureSignature { | 27 struct TextureSignature { |
27 GLenum target_; | 28 GLenum target_; |
28 GLint level_; | 29 GLint level_; |
29 GLenum min_filter_; | 30 GLenum min_filter_; |
(...skipping 1603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1633 const DoTextImage2DArguments& args) { | 1634 const DoTextImage2DArguments& args) { |
1634 TextureRef* texture_ref; | 1635 TextureRef* texture_ref; |
1635 if (!ValidateTexImage2D(state, "glTexImage2D", args, &texture_ref)) { | 1636 if (!ValidateTexImage2D(state, "glTexImage2D", args, &texture_ref)) { |
1636 return; | 1637 return; |
1637 } | 1638 } |
1638 | 1639 |
1639 DoTexImage2D(texture_state, state->GetErrorState(), framebuffer_state, | 1640 DoTexImage2D(texture_state, state->GetErrorState(), framebuffer_state, |
1640 texture_ref, args); | 1641 texture_ref, args); |
1641 } | 1642 } |
1642 | 1643 |
1644 GLenum TextureManager::AdjustTexFormat(GLenum format) const { | |
1645 if (gfx::GetGLImplementation() == gfx::kGLImplementationDesktopGL) { | |
Ken Russell (switch to Gerrit)
2014/10/11 03:20:43
Is this going to have to change for the coming GLE
| |
1646 if (format == GL_SRGB_EXT) | |
1647 return GL_RGB; | |
1648 if (format == GL_SRGB_ALPHA_EXT) | |
1649 return GL_RGBA; | |
1650 } | |
1651 return format; | |
1652 } | |
1653 | |
1643 void TextureManager::DoTexImage2D( | 1654 void TextureManager::DoTexImage2D( |
1644 DecoderTextureState* texture_state, | 1655 DecoderTextureState* texture_state, |
1645 ErrorState* error_state, | 1656 ErrorState* error_state, |
1646 DecoderFramebufferState* framebuffer_state, | 1657 DecoderFramebufferState* framebuffer_state, |
1647 TextureRef* texture_ref, | 1658 TextureRef* texture_ref, |
1648 const DoTextImage2DArguments& args) { | 1659 const DoTextImage2DArguments& args) { |
1649 Texture* texture = texture_ref->texture(); | 1660 Texture* texture = texture_ref->texture(); |
1650 GLsizei tex_width = 0; | 1661 GLsizei tex_width = 0; |
1651 GLsizei tex_height = 0; | 1662 GLsizei tex_height = 0; |
1652 GLenum tex_type = 0; | 1663 GLenum tex_type = 0; |
(...skipping 16 matching lines...) Expand all Loading... | |
1669 | 1680 |
1670 if (texture->IsAttachedToFramebuffer()) { | 1681 if (texture->IsAttachedToFramebuffer()) { |
1671 framebuffer_state->clear_state_dirty = true; | 1682 framebuffer_state->clear_state_dirty = true; |
1672 } | 1683 } |
1673 | 1684 |
1674 if (texture_state->texsubimage2d_faster_than_teximage2d && | 1685 if (texture_state->texsubimage2d_faster_than_teximage2d && |
1675 level_is_same && args.pixels) { | 1686 level_is_same && args.pixels) { |
1676 { | 1687 { |
1677 ScopedTextureUploadTimer timer(texture_state); | 1688 ScopedTextureUploadTimer timer(texture_state); |
1678 glTexSubImage2D(args.target, args.level, 0, 0, args.width, args.height, | 1689 glTexSubImage2D(args.target, args.level, 0, 0, args.width, args.height, |
1679 args.format, args.type, args.pixels); | 1690 AdjustTexFormat(args.format), args.type, args.pixels); |
1680 } | 1691 } |
1681 SetLevelCleared(texture_ref, args.target, args.level, true); | 1692 SetLevelCleared(texture_ref, args.target, args.level, true); |
1682 texture_state->tex_image_2d_failed = false; | 1693 texture_state->tex_image_2d_failed = false; |
1683 return; | 1694 return; |
1684 } | 1695 } |
1685 | 1696 |
1686 ERRORSTATE_COPY_REAL_GL_ERRORS_TO_WRAPPER(error_state, "glTexImage2D"); | 1697 ERRORSTATE_COPY_REAL_GL_ERRORS_TO_WRAPPER(error_state, "glTexImage2D"); |
1687 { | 1698 { |
1688 ScopedTextureUploadTimer timer(texture_state); | 1699 ScopedTextureUploadTimer timer(texture_state); |
1689 glTexImage2D( | 1700 glTexImage2D( |
1690 args.target, args.level, args.internal_format, args.width, args.height, | 1701 args.target, args.level, args.internal_format, args.width, args.height, |
1691 args.border, args.format, args.type, args.pixels); | 1702 args.border, AdjustTexFormat(args.format), args.type, args.pixels); |
1692 } | 1703 } |
1693 GLenum error = ERRORSTATE_PEEK_GL_ERROR(error_state, "glTexImage2D"); | 1704 GLenum error = ERRORSTATE_PEEK_GL_ERROR(error_state, "glTexImage2D"); |
1694 if (error == GL_NO_ERROR) { | 1705 if (error == GL_NO_ERROR) { |
1695 SetLevelInfo( | 1706 SetLevelInfo( |
1696 texture_ref, | 1707 texture_ref, |
1697 args.target, args.level, args.internal_format, args.width, args.height, | 1708 args.target, args.level, args.internal_format, args.width, args.height, |
1698 1, args.border, args.format, args.type, args.pixels != NULL); | 1709 1, args.border, args.format, args.type, args.pixels != NULL); |
1699 texture_state->tex_image_2d_failed = false; | 1710 texture_state->tex_image_2d_failed = false; |
1700 } | 1711 } |
1701 } | 1712 } |
1702 | 1713 |
1703 ScopedTextureUploadTimer::ScopedTextureUploadTimer( | 1714 ScopedTextureUploadTimer::ScopedTextureUploadTimer( |
1704 DecoderTextureState* texture_state) | 1715 DecoderTextureState* texture_state) |
1705 : texture_state_(texture_state), | 1716 : texture_state_(texture_state), |
1706 begin_time_(base::TimeTicks::HighResNow()) { | 1717 begin_time_(base::TimeTicks::HighResNow()) { |
1707 } | 1718 } |
1708 | 1719 |
1709 ScopedTextureUploadTimer::~ScopedTextureUploadTimer() { | 1720 ScopedTextureUploadTimer::~ScopedTextureUploadTimer() { |
1710 texture_state_->texture_upload_count++; | 1721 texture_state_->texture_upload_count++; |
1711 texture_state_->total_texture_upload_time += | 1722 texture_state_->total_texture_upload_time += |
1712 base::TimeTicks::HighResNow() - begin_time_; | 1723 base::TimeTicks::HighResNow() - begin_time_; |
1713 } | 1724 } |
1714 | 1725 |
1715 } // namespace gles2 | 1726 } // namespace gles2 |
1716 } // namespace gpu | 1727 } // namespace gpu |
OLD | NEW |