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

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

Issue 9706042: Plumb client side synthesized GL messages to JS Console (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 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 | Annotate | Revision Log
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 "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" 5 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h"
6 6
7 #include "third_party/khronos/GLES2/gl2.h" 7 #include "third_party/khronos/GLES2/gl2.h"
8 #ifndef GL_GLEXT_PROTOTYPES 8 #ifndef GL_GLEXT_PROTOTYPES
9 #define GL_GLEXT_PROTOTYPES 1 9 #define GL_GLEXT_PROTOTYPES 1
10 #endif 10 #endif
(...skipping 26 matching lines...) Expand all
37 37
38 namespace { 38 namespace {
39 39
40 void ClearSharedContexts() { 40 void ClearSharedContexts() {
41 base::AutoLock lock(g_all_shared_contexts_lock.Get()); 41 base::AutoLock lock(g_all_shared_contexts_lock.Get());
42 g_all_shared_contexts.Pointer()->clear(); 42 g_all_shared_contexts.Pointer()->clear();
43 } 43 }
44 44
45 } // namespace anonymous 45 } // namespace anonymous
46 46
47 class WebGraphicsContext3DErrorMessageCallback
48 : public gpu::gles2::GLES2Implementation::ErrorMessageCallback {
49 public:
50 WebGraphicsContext3DErrorMessageCallback(
51 WebGraphicsContext3DCommandBufferImpl* context)
52 : context_(context) {
53 }
54
55 virtual void OnErrorMessage(const char* msg, int id) OVERRIDE;
56
57 private:
58 WebGraphicsContext3DCommandBufferImpl* context_;
59
60 DISALLOW_COPY_AND_ASSIGN(WebGraphicsContext3DErrorMessageCallback);
61 };
62
63 void WebGraphicsContext3DErrorMessageCallback::OnErrorMessage(
64 const char* msg, int id) {
65 context_->OnErrorMessage(msg, id);
66 }
47 67
48 WebGraphicsContext3DCommandBufferImpl::WebGraphicsContext3DCommandBufferImpl( 68 WebGraphicsContext3DCommandBufferImpl::WebGraphicsContext3DCommandBufferImpl(
49 int surface_id, 69 int surface_id,
50 const GURL& active_url, 70 const GURL& active_url,
51 GpuChannelHostFactory* factory, 71 GpuChannelHostFactory* factory,
52 const base::WeakPtr<WebGraphicsContext3DSwapBuffersClient>& swap_client) 72 const base::WeakPtr<WebGraphicsContext3DSwapBuffersClient>& swap_client)
53 : initialize_failed_(false), 73 : initialize_failed_(false),
54 factory_(factory), 74 factory_(factory),
55 context_(NULL), 75 context_(NULL),
56 gl_(NULL), 76 gl_(NULL),
57 host_(NULL), 77 host_(NULL),
58 surface_id_(surface_id), 78 surface_id_(surface_id),
59 active_url_(active_url), 79 active_url_(active_url),
60 swap_client_(swap_client), 80 swap_client_(swap_client),
61 memory_allocation_changed_callback_(0), 81 memory_allocation_changed_callback_(0),
62 context_lost_callback_(0), 82 context_lost_callback_(0),
63 context_lost_reason_(GL_NO_ERROR), 83 context_lost_reason_(GL_NO_ERROR),
64 error_message_callback_(0), 84 error_message_callback_(0),
65 swapbuffers_complete_callback_(0), 85 swapbuffers_complete_callback_(0),
66 gpu_preference_(gfx::PreferIntegratedGpu), 86 gpu_preference_(gfx::PreferIntegratedGpu),
67 cached_width_(0), 87 cached_width_(0),
68 cached_height_(0), 88 cached_height_(0),
69 bound_fbo_(0), 89 bound_fbo_(0),
70 weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { 90 weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
71 } 91 }
72 92
73 WebGraphicsContext3DCommandBufferImpl:: 93 WebGraphicsContext3DCommandBufferImpl::
74 ~WebGraphicsContext3DCommandBufferImpl() { 94 ~WebGraphicsContext3DCommandBufferImpl() {
95 if (gl_) {
96 gl_->SetErrorMessageCallback(NULL);
97 }
98
75 if (host_) { 99 if (host_) {
76 if (host_->WillGpuSwitchOccur(false, gpu_preference_)) { 100 if (host_->WillGpuSwitchOccur(false, gpu_preference_)) {
77 host_->ForciblyCloseChannel(); 101 host_->ForciblyCloseChannel();
78 ClearSharedContexts(); 102 ClearSharedContexts();
79 } 103 }
80 } 104 }
81 105
82 { 106 {
83 base::AutoLock lock(g_all_shared_contexts_lock.Get()); 107 base::AutoLock lock(g_all_shared_contexts_lock.Get());
84 g_all_shared_contexts.Pointer()->erase(this); 108 g_all_shared_contexts.Pointer()->erase(this);
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 gl_->EnableFeatureCHROMIUM("webgl_enable_glsl_webgl_validation"); 230 gl_->EnableFeatureCHROMIUM("webgl_enable_glsl_webgl_validation");
207 231
208 context_->SetContextLostCallback( 232 context_->SetContextLostCallback(
209 base::Bind(&WebGraphicsContext3DCommandBufferImpl::OnContextLost, 233 base::Bind(&WebGraphicsContext3DCommandBufferImpl::OnContextLost,
210 weak_ptr_factory_.GetWeakPtr())); 234 weak_ptr_factory_.GetWeakPtr()));
211 235
212 context_->GetCommandBufferProxy()->SetOnConsoleMessageCallback( 236 context_->GetCommandBufferProxy()->SetOnConsoleMessageCallback(
213 base::Bind(&WebGraphicsContext3DCommandBufferImpl::OnErrorMessage, 237 base::Bind(&WebGraphicsContext3DCommandBufferImpl::OnErrorMessage,
214 weak_ptr_factory_.GetWeakPtr())); 238 weak_ptr_factory_.GetWeakPtr()));
215 239
240 client_error_message_callback_.reset(
241 new WebGraphicsContext3DErrorMessageCallback(this));
242 gl_->SetErrorMessageCallback(client_error_message_callback_.get());
243
216 // TODO(gman): Remove this. 244 // TODO(gman): Remove this.
217 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 245 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
218 if (command_line.HasSwitch(switches::kDisableGLSLTranslator)) { 246 if (command_line.HasSwitch(switches::kDisableGLSLTranslator)) {
219 context_->DisableShaderTranslation(); 247 context_->DisableShaderTranslation();
220 } 248 }
221 249
222 // Set attributes_ from created offscreen context. 250 // Set attributes_ from created offscreen context.
223 { 251 {
224 GLint alpha_bits = 0; 252 GLint alpha_bits = 0;
225 getIntegerv(GL_ALPHA_BITS, &alpha_bits); 253 getIntegerv(GL_ALPHA_BITS, &alpha_bits);
(...skipping 996 matching lines...) Expand 10 before | Expand all | Expand 10 after
1222 } 1250 }
1223 1251
1224 void WebGraphicsContext3DCommandBufferImpl::OnErrorMessage( 1252 void WebGraphicsContext3DCommandBufferImpl::OnErrorMessage(
1225 const std::string& message, int id) { 1253 const std::string& message, int id) {
1226 if (error_message_callback_) { 1254 if (error_message_callback_) {
1227 WebKit::WebString str = WebKit::WebString::fromUTF8(message.c_str()); 1255 WebKit::WebString str = WebKit::WebString::fromUTF8(message.c_str());
1228 error_message_callback_->onErrorMessage(str, id); 1256 error_message_callback_->onErrorMessage(str, id);
1229 } 1257 }
1230 } 1258 }
1231 1259
OLDNEW
« no previous file with comments | « content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h ('k') | gpu/command_buffer/client/gles2_implementation.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698