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

Side by Side Diff: content/common/gpu/client/gl_helper_readback_support.cc

Issue 639073003: Fix GLHelperReadbackSupport::SupportsFormat crash (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "content/common/gpu/client/gl_helper_readback_support.h" 5 #include "content/common/gpu/client/gl_helper_readback_support.h"
6 #include "base/logging.h" 6 #include "base/logging.h"
7 #include "gpu/GLES2/gl2extchromium.h" 7 #include "gpu/GLES2/gl2extchromium.h"
8 #include "third_party/skia/include/core/SkImageInfo.h" 8 #include "third_party/skia/include/core/SkImageInfo.h"
9 9
10 namespace content { 10 namespace content {
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 dst_framebuffer); 88 dst_framebuffer);
89 gl_->FramebufferTexture2D( 89 gl_->FramebufferTexture2D(
90 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, dst_texture, 0); 90 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, dst_texture, 0);
91 GLint format_tmp = 0, type_tmp = 0; 91 GLint format_tmp = 0, type_tmp = 0;
92 gl_->GetIntegerv(GL_IMPLEMENTATION_COLOR_READ_FORMAT, &format_tmp); 92 gl_->GetIntegerv(GL_IMPLEMENTATION_COLOR_READ_FORMAT, &format_tmp);
93 gl_->GetIntegerv(GL_IMPLEMENTATION_COLOR_READ_TYPE, &type_tmp); 93 gl_->GetIntegerv(GL_IMPLEMENTATION_COLOR_READ_TYPE, &type_tmp);
94 *format_out = format_tmp; 94 *format_out = format_tmp;
95 *type_out = type_tmp; 95 *type_out = type_tmp;
96 96
97 struct FormatCacheEntry entry = { format, type, *format_out, *type_out }; 97 struct FormatCacheEntry entry = { format, type, *format_out, *type_out };
98 format_cache_.push_back(entry); 98 format_cache_.push_back(entry);
no sievers 2014/10/08 21:27:13 Should we also not do this if format_out and type_
99 } 99 }
100 100
101 bool GLHelperReadbackSupport::SupportsFormat(GLenum format, GLenum type) { 101 bool GLHelperReadbackSupport::SupportsFormat(GLenum format, GLenum type) {
102 // GLES2.0 Specification says this pairing is always supported 102 // GLES2.0 Specification says this pairing is always supported
103 // with additional format from GL_IMPLEMENTATION_COLOR_READ_FORMAT/TYPE 103 // with additional format from GL_IMPLEMENTATION_COLOR_READ_FORMAT/TYPE
104 if (format == GL_RGBA && type == GL_UNSIGNED_BYTE) 104 if (format == GL_RGBA && type == GL_UNSIGNED_BYTE)
105 return true; 105 return true;
106 106
107 if (format == GL_BGRA_EXT && type == GL_UNSIGNED_BYTE) { 107 if (format == GL_BGRA_EXT && type == GL_UNSIGNED_BYTE) {
108 const GLubyte* tmp = gl_->GetString(GL_EXTENSIONS); 108 const GLubyte* tmp = gl_->GetString(GL_EXTENSIONS);
109 std::string extensions = 109 if (tmp) {
110 " " + std::string(reinterpret_cast<const char*>(tmp)) + " "; 110 std::string extensions =
111 if (extensions.find(" GL_EXT_read_format_bgra ") != std::string::npos) { 111 " " + std::string(reinterpret_cast<const char*>(tmp)) + " ";
112 return true; 112 if (extensions.find(" GL_EXT_read_format_bgra ") != std::string::npos) {
113 return true;
114 }
113 } 115 }
114 } 116 }
115 117
116 bool supports_format = false; 118 bool supports_format = false;
117 GLenum ext_format = 0, ext_type = 0; 119 GLenum ext_format = 0, ext_type = 0;
118 GetAdditionalFormat(format, type, &ext_format, &ext_type); 120 GetAdditionalFormat(format, type, &ext_format, &ext_type);
119 if ((ext_format == format) && (ext_type == type)) { 121 if ((ext_format == format) && (ext_type == type)) {
120 supports_format = true; 122 supports_format = true;
121 } 123 }
122 return supports_format; 124 return supports_format;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 return GLHelperReadbackSupport::NOT_SUPPORTED; 174 return GLHelperReadbackSupport::NOT_SUPPORTED;
173 default: 175 default:
174 NOTREACHED(); 176 NOTREACHED();
175 break; 177 break;
176 } 178 }
177 179
178 return GLHelperReadbackSupport::NOT_SUPPORTED; 180 return GLHelperReadbackSupport::NOT_SUPPORTED;
179 } 181 }
180 182
181 } // namespace content 183 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698