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

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

Issue 2689203002: Check for some extensions before calling potentially NULL GL entry points. (Closed)
Patch Set: Created 3 years, 10 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
OLDNEW
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2016 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_passthrough.h" 5 #include "gpu/command_buffer/service/gles2_cmd_decoder_passthrough.h"
6 6
7 #include "base/strings/string_split.h"
7 #include "gpu/command_buffer/service/feature_info.h" 8 #include "gpu/command_buffer/service/feature_info.h"
8 #include "gpu/command_buffer/service/gl_utils.h" 9 #include "gpu/command_buffer/service/gl_utils.h"
9 #include "ui/gl/gl_version_info.h" 10 #include "ui/gl/gl_version_info.h"
10 11
11 namespace gpu { 12 namespace gpu {
12 namespace gles2 { 13 namespace gles2 {
13 14
14 namespace { 15 namespace {
15 template <typename ClientType, typename ServiceType, typename DeleteFunction> 16 template <typename ClientType, typename ServiceType, typename DeleteFunction>
16 void DeleteServiceObjects(ClientServiceMap<ClientType, ServiceType>* id_map, 17 void DeleteServiceObjects(ClientServiceMap<ClientType, ServiceType>* id_map,
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 surface_ = surface; 165 surface_ = surface;
165 offscreen_ = offscreen; 166 offscreen_ = offscreen;
166 167
167 if (!group_->Initialize(this, attrib_helper.context_type, 168 if (!group_->Initialize(this, attrib_helper.context_type,
168 disallowed_features)) { 169 disallowed_features)) {
169 group_ = NULL; // Must not destroy ContextGroup if it is not initialized. 170 group_ = NULL; // Must not destroy ContextGroup if it is not initialized.
170 Destroy(true); 171 Destroy(true);
171 return false; 172 return false;
172 } 173 }
173 174
175 InitializeNativeCaps();
176
174 // Check for required extensions 177 // Check for required extensions
175 if (!feature_info_->feature_flags().angle_robust_client_memory || 178 if (!feature_info_->feature_flags().angle_robust_client_memory ||
176 !feature_info_->feature_flags().chromium_bind_generates_resource) { 179 !feature_info_->feature_flags().chromium_bind_generates_resource ||
180 !has_chromium_copy_texture_ || !has_chromium_copy_compressed_texture_) {
177 // TODO(geofflang): Verify that ANGLE_webgl_compatibility is enabled if this 181 // TODO(geofflang): Verify that ANGLE_webgl_compatibility is enabled if this
178 // is a WebGL context (depends on crbug.com/671217). 182 // is a WebGL context (depends on crbug.com/671217).
179 Destroy(true); 183 Destroy(true);
180 return false; 184 return false;
181 } 185 }
182 186
183 image_manager_.reset(new ImageManager()); 187 image_manager_.reset(new ImageManager());
184 188
185 bind_generates_resource_ = group_->bind_generates_resource(); 189 bind_generates_resource_ = group_->bind_generates_resource();
186 190
(...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after
840 glBindTexture(target, service_id); 844 glBindTexture(target, service_id);
841 } 845 }
842 } 846 }
843 847
844 // Reset the active texture unit if it was changed 848 // Reset the active texture unit if it was changed
845 if (cur_texture_unit != active_texture_unit_) { 849 if (cur_texture_unit != active_texture_unit_) {
846 glActiveTexture(static_cast<GLenum>(GL_TEXTURE0 + active_texture_unit_)); 850 glActiveTexture(static_cast<GLenum>(GL_TEXTURE0 + active_texture_unit_));
847 } 851 }
848 } 852 }
849 853
854 void GLES2DecoderPassthroughImpl::InitializeNativeCaps() {
855 has_es3_ = feature_info_->gl_version_info().IsAtLeastGLES(3, 0);
856
857 std::vector<std::string> extension_tokens =
858 base::SplitString(gl::GetGLExtensionsFromCurrentContext(), " ",
859 base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
860 std::unordered_set<std::string> extension_set(extension_tokens.begin(),
861 extension_tokens.end());
862
863 has_ext_discard_framebuffer_ =
864 extension_set.count("GL_EXT_discard_framebuffer") > 0;
865 has_angle_framebuffer_multisample_ =
866 extension_set.count("GL_ANGLE_framebuffer_multisample") > 0;
867 has_chromium_copy_texture_ =
868 extension_set.count("GL_CHROMIUM_copy_texture") > 0;
869 has_chromium_copy_compressed_texture_ =
870 extension_set.count("GL_CHROMIUM_copy_compressed_texture") > 0;
871 }
872
850 #define GLES2_CMD_OP(name) \ 873 #define GLES2_CMD_OP(name) \
851 { \ 874 { \
852 &GLES2DecoderPassthroughImpl::Handle##name, cmds::name::kArgFlags, \ 875 &GLES2DecoderPassthroughImpl::Handle##name, cmds::name::kArgFlags, \
853 cmds::name::cmd_flags, \ 876 cmds::name::cmd_flags, \
854 sizeof(cmds::name) / sizeof(CommandBufferEntry) - 1, \ 877 sizeof(cmds::name) / sizeof(CommandBufferEntry) - 1, \
855 }, /* NOLINT */ 878 }, /* NOLINT */
856 879
857 const GLES2DecoderPassthroughImpl::CommandInfo 880 const GLES2DecoderPassthroughImpl::CommandInfo
858 GLES2DecoderPassthroughImpl::command_info[] = { 881 GLES2DecoderPassthroughImpl::command_info[] = {
859 GLES2_COMMAND_LIST(GLES2_CMD_OP)}; 882 GLES2_COMMAND_LIST(GLES2_CMD_OP)};
860 883
861 #undef GLES2_CMD_OP 884 #undef GLES2_CMD_OP
862 885
863 } // namespace gles2 886 } // namespace gles2
864 } // namespace gpu 887 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698