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/blink/webgraphicscontext3d_impl.h" | 5 #include "gpu/blink/webgraphicscontext3d_impl.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "base/atomicops.h" | 9 #include "base/atomicops.h" |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/sys_info.h" | 13 #include "base/sys_info.h" |
14 #include "gpu/GLES2/gl2extchromium.h" | 14 #include "gpu/GLES2/gl2extchromium.h" |
15 #include "gpu/command_buffer/client/gles2_implementation.h" | 15 #include "gpu/command_buffer/client/gles2_implementation.h" |
16 #include "gpu/command_buffer/client/gles2_lib.h" | 16 #include "gpu/command_buffer/client/gles2_lib.h" |
17 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 17 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
18 #include "gpu/command_buffer/common/sync_token.h" | 18 #include "gpu/command_buffer/common/sync_token.h" |
19 #include "gpu/skia_bindings/gl_bindings_skia_cmd_buffer.h" | 19 #include "gpu/skia_bindings/gl_bindings_skia_cmd_buffer.h" |
20 | 20 |
21 #include "third_party/khronos/GLES2/gl2.h" | 21 #include "third_party/khronos/GLES2/gl2.h" |
22 #ifndef GL_GLEXT_PROTOTYPES | 22 #ifndef GL_GLEXT_PROTOTYPES |
23 #define GL_GLEXT_PROTOTYPES 1 | 23 #define GL_GLEXT_PROTOTYPES 1 |
24 #endif | 24 #endif |
25 #include "third_party/khronos/GLES2/gl2ext.h" | 25 #include "third_party/khronos/GLES2/gl2ext.h" |
26 | 26 |
27 namespace gpu_blink { | 27 namespace gpu_blink { |
28 | 28 |
29 class WebGraphicsContext3DErrorMessageCallback | |
30 : public ::gpu::gles2::GLES2ImplementationErrorMessageCallback { | |
31 public: | |
32 WebGraphicsContext3DErrorMessageCallback( | |
33 WebGraphicsContext3DImpl* context) | |
34 : graphics_context_(context) { | |
35 } | |
36 | |
37 void OnErrorMessage(const char* msg, int id) override; | |
38 | |
39 private: | |
40 WebGraphicsContext3DImpl* graphics_context_; | |
41 | |
42 DISALLOW_COPY_AND_ASSIGN(WebGraphicsContext3DErrorMessageCallback); | |
43 }; | |
44 | |
45 void WebGraphicsContext3DErrorMessageCallback::OnErrorMessage( | |
46 const char* msg, int id) { | |
47 graphics_context_->OnErrorMessage(msg, id); | |
48 } | |
49 | |
50 WebGraphicsContext3DImpl::WebGraphicsContext3DImpl() | 29 WebGraphicsContext3DImpl::WebGraphicsContext3DImpl() |
51 : initialized_(false), | 30 : initialized_(false), |
52 initialize_failed_(false), | 31 initialize_failed_(false), |
53 context_lost_callback_(0), | 32 context_lost_callback_(0), |
54 error_message_callback_(0), | 33 error_message_callback_(0), |
55 gl_(NULL) {} | 34 gl_(NULL) {} |
56 | 35 |
57 WebGraphicsContext3DImpl::~WebGraphicsContext3DImpl() { | 36 WebGraphicsContext3DImpl::~WebGraphicsContext3DImpl() { |
58 | 37 |
59 } | 38 } |
60 | 39 |
61 void WebGraphicsContext3DImpl::setErrorMessageCallback( | 40 void WebGraphicsContext3DImpl::setErrorMessageCallback( |
62 WebGraphicsContext3D::WebGraphicsErrorMessageCallback* cb) { | 41 WebGraphicsContext3D::WebGraphicsErrorMessageCallback* cb) { |
63 error_message_callback_ = cb; | 42 error_message_callback_ = cb; |
64 } | 43 } |
65 | 44 |
66 void WebGraphicsContext3DImpl::setContextLostCallback( | 45 void WebGraphicsContext3DImpl::setContextLostCallback( |
67 WebGraphicsContext3D::WebGraphicsContextLostCallback* cb) { | 46 WebGraphicsContext3D::WebGraphicsContextLostCallback* cb) { |
68 context_lost_callback_ = cb; | 47 context_lost_callback_ = cb; |
69 } | 48 } |
70 | 49 |
71 ::gpu::gles2::GLES2ImplementationErrorMessageCallback* | |
72 WebGraphicsContext3DImpl::getErrorMessageCallback() { | |
73 if (!client_error_message_callback_) { | |
74 client_error_message_callback_.reset( | |
75 new WebGraphicsContext3DErrorMessageCallback(this)); | |
76 } | |
77 return client_error_message_callback_.get(); | |
78 } | |
79 | |
80 void WebGraphicsContext3DImpl::OnErrorMessage( | |
81 const std::string& message, int id) { | |
82 if (error_message_callback_) { | |
83 blink::WebString str = blink::WebString::fromUTF8(message.c_str()); | |
84 error_message_callback_->onErrorMessage(str, id); | |
85 } | |
86 } | |
87 | |
88 } // namespace gpu_blink | 50 } // namespace gpu_blink |
OLD | NEW |