Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(58)

Side by Side Diff: gpu/command_buffer/service/texture_manager.cc

Issue 638143003: Enabled EXT_sRGB WebGL extension support in the command buffer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added suggested comment Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « gpu/command_buffer/service/texture_manager.h ('k') | ui/gl/gl_bindings.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 // TODO: GLES 3 allows for internal format and format to differ. This logic
1646 // may need to change as a result.
1647 if (gfx::GetGLImplementation() == gfx::kGLImplementationDesktopGL) {
1648 if (format == GL_SRGB_EXT)
1649 return GL_RGB;
1650 if (format == GL_SRGB_ALPHA_EXT)
1651 return GL_RGBA;
1652 }
1653 return format;
1654 }
1655
1643 void TextureManager::DoTexImage2D( 1656 void TextureManager::DoTexImage2D(
1644 DecoderTextureState* texture_state, 1657 DecoderTextureState* texture_state,
1645 ErrorState* error_state, 1658 ErrorState* error_state,
1646 DecoderFramebufferState* framebuffer_state, 1659 DecoderFramebufferState* framebuffer_state,
1647 TextureRef* texture_ref, 1660 TextureRef* texture_ref,
1648 const DoTextImage2DArguments& args) { 1661 const DoTextImage2DArguments& args) {
1649 Texture* texture = texture_ref->texture(); 1662 Texture* texture = texture_ref->texture();
1650 GLsizei tex_width = 0; 1663 GLsizei tex_width = 0;
1651 GLsizei tex_height = 0; 1664 GLsizei tex_height = 0;
1652 GLenum tex_type = 0; 1665 GLenum tex_type = 0;
(...skipping 16 matching lines...) Expand all
1669 1682
1670 if (texture->IsAttachedToFramebuffer()) { 1683 if (texture->IsAttachedToFramebuffer()) {
1671 framebuffer_state->clear_state_dirty = true; 1684 framebuffer_state->clear_state_dirty = true;
1672 } 1685 }
1673 1686
1674 if (texture_state->texsubimage2d_faster_than_teximage2d && 1687 if (texture_state->texsubimage2d_faster_than_teximage2d &&
1675 level_is_same && args.pixels) { 1688 level_is_same && args.pixels) {
1676 { 1689 {
1677 ScopedTextureUploadTimer timer(texture_state); 1690 ScopedTextureUploadTimer timer(texture_state);
1678 glTexSubImage2D(args.target, args.level, 0, 0, args.width, args.height, 1691 glTexSubImage2D(args.target, args.level, 0, 0, args.width, args.height,
1679 args.format, args.type, args.pixels); 1692 AdjustTexFormat(args.format), args.type, args.pixels);
1680 } 1693 }
1681 SetLevelCleared(texture_ref, args.target, args.level, true); 1694 SetLevelCleared(texture_ref, args.target, args.level, true);
1682 texture_state->tex_image_2d_failed = false; 1695 texture_state->tex_image_2d_failed = false;
1683 return; 1696 return;
1684 } 1697 }
1685 1698
1686 ERRORSTATE_COPY_REAL_GL_ERRORS_TO_WRAPPER(error_state, "glTexImage2D"); 1699 ERRORSTATE_COPY_REAL_GL_ERRORS_TO_WRAPPER(error_state, "glTexImage2D");
1687 { 1700 {
1688 ScopedTextureUploadTimer timer(texture_state); 1701 ScopedTextureUploadTimer timer(texture_state);
1689 glTexImage2D( 1702 glTexImage2D(
1690 args.target, args.level, args.internal_format, args.width, args.height, 1703 args.target, args.level, args.internal_format, args.width, args.height,
1691 args.border, args.format, args.type, args.pixels); 1704 args.border, AdjustTexFormat(args.format), args.type, args.pixels);
1692 } 1705 }
1693 GLenum error = ERRORSTATE_PEEK_GL_ERROR(error_state, "glTexImage2D"); 1706 GLenum error = ERRORSTATE_PEEK_GL_ERROR(error_state, "glTexImage2D");
1694 if (error == GL_NO_ERROR) { 1707 if (error == GL_NO_ERROR) {
1695 SetLevelInfo( 1708 SetLevelInfo(
1696 texture_ref, 1709 texture_ref,
1697 args.target, args.level, args.internal_format, args.width, args.height, 1710 args.target, args.level, args.internal_format, args.width, args.height,
1698 1, args.border, args.format, args.type, args.pixels != NULL); 1711 1, args.border, args.format, args.type, args.pixels != NULL);
1699 texture_state->tex_image_2d_failed = false; 1712 texture_state->tex_image_2d_failed = false;
1700 } 1713 }
1701 } 1714 }
1702 1715
1703 ScopedTextureUploadTimer::ScopedTextureUploadTimer( 1716 ScopedTextureUploadTimer::ScopedTextureUploadTimer(
1704 DecoderTextureState* texture_state) 1717 DecoderTextureState* texture_state)
1705 : texture_state_(texture_state), 1718 : texture_state_(texture_state),
1706 begin_time_(base::TimeTicks::HighResNow()) { 1719 begin_time_(base::TimeTicks::HighResNow()) {
1707 } 1720 }
1708 1721
1709 ScopedTextureUploadTimer::~ScopedTextureUploadTimer() { 1722 ScopedTextureUploadTimer::~ScopedTextureUploadTimer() {
1710 texture_state_->texture_upload_count++; 1723 texture_state_->texture_upload_count++;
1711 texture_state_->total_texture_upload_time += 1724 texture_state_->total_texture_upload_time +=
1712 base::TimeTicks::HighResNow() - begin_time_; 1725 base::TimeTicks::HighResNow() - begin_time_;
1713 } 1726 }
1714 1727
1715 } // namespace gles2 1728 } // namespace gles2
1716 } // namespace gpu 1729 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/texture_manager.h ('k') | ui/gl/gl_bindings.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698