OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "webkit/common/gpu/context_provider_in_process.h" | 5 #include "webkit/common/gpu/context_provider_in_process.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
11 #include "base/strings/string_split.h" | 11 #include "base/strings/string_split.h" |
12 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
13 #include "cc/output/managed_memory_policy.h" | 13 #include "cc/output/managed_memory_policy.h" |
14 #include "gpu/command_buffer/client/gles2_implementation.h" | 14 #include "gpu/command_buffer/client/gles2_implementation.h" |
15 #include "webkit/common/gpu/grcontext_for_webgraphicscontext3d.h" | 15 #include "webkit/common/gpu/grcontext_for_webgraphicscontext3d.h" |
16 | 16 |
17 namespace webkit { | 17 namespace webkit { |
18 namespace gpu { | 18 namespace gpu { |
19 | 19 |
20 class ContextProviderInProcess::LostContextCallbackProxy | 20 class ContextProviderInProcess::LostContextCallbackProxy |
21 : public WebKit::WebGraphicsContext3D::WebGraphicsContextLostCallback { | 21 : public blink::WebGraphicsContext3D::WebGraphicsContextLostCallback { |
22 public: | 22 public: |
23 explicit LostContextCallbackProxy(ContextProviderInProcess* provider) | 23 explicit LostContextCallbackProxy(ContextProviderInProcess* provider) |
24 : provider_(provider) { | 24 : provider_(provider) { |
25 provider_->context3d_->setContextLostCallback(this); | 25 provider_->context3d_->setContextLostCallback(this); |
26 } | 26 } |
27 | 27 |
28 virtual ~LostContextCallbackProxy() { | 28 virtual ~LostContextCallbackProxy() { |
29 provider_->context3d_->setContextLostCallback(NULL); | 29 provider_->context3d_->setContextLostCallback(NULL); |
30 } | 30 } |
31 | 31 |
32 virtual void onContextLost() { | 32 virtual void onContextLost() { |
33 provider_->OnLostContext(); | 33 provider_->OnLostContext(); |
34 } | 34 } |
35 | 35 |
36 private: | 36 private: |
37 ContextProviderInProcess* provider_; | 37 ContextProviderInProcess* provider_; |
38 }; | 38 }; |
39 | 39 |
40 class ContextProviderInProcess::SwapBuffersCompleteCallbackProxy | 40 class ContextProviderInProcess::SwapBuffersCompleteCallbackProxy |
41 : public WebKit::WebGraphicsContext3D:: | 41 : public blink::WebGraphicsContext3D:: |
42 WebGraphicsSwapBuffersCompleteCallbackCHROMIUM { | 42 WebGraphicsSwapBuffersCompleteCallbackCHROMIUM { |
43 public: | 43 public: |
44 explicit SwapBuffersCompleteCallbackProxy(ContextProviderInProcess* provider) | 44 explicit SwapBuffersCompleteCallbackProxy(ContextProviderInProcess* provider) |
45 : provider_(provider) { | 45 : provider_(provider) { |
46 provider_->context3d_->setSwapBuffersCompleteCallbackCHROMIUM(this); | 46 provider_->context3d_->setSwapBuffersCompleteCallbackCHROMIUM(this); |
47 } | 47 } |
48 | 48 |
49 virtual ~SwapBuffersCompleteCallbackProxy() { | 49 virtual ~SwapBuffersCompleteCallbackProxy() { |
50 provider_->context3d_->setSwapBuffersCompleteCallbackCHROMIUM(NULL); | 50 provider_->context3d_->setSwapBuffersCompleteCallbackCHROMIUM(NULL); |
51 } | 51 } |
(...skipping 11 matching lines...) Expand all Loading... |
63 scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> context3d, | 63 scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> context3d, |
64 const std::string& debug_name) { | 64 const std::string& debug_name) { |
65 if (!context3d) | 65 if (!context3d) |
66 return NULL; | 66 return NULL; |
67 return new ContextProviderInProcess(context3d.Pass(), debug_name); | 67 return new ContextProviderInProcess(context3d.Pass(), debug_name); |
68 } | 68 } |
69 | 69 |
70 // static | 70 // static |
71 scoped_refptr<ContextProviderInProcess> | 71 scoped_refptr<ContextProviderInProcess> |
72 ContextProviderInProcess::CreateOffscreen() { | 72 ContextProviderInProcess::CreateOffscreen() { |
73 WebKit::WebGraphicsContext3D::Attributes attributes; | 73 blink::WebGraphicsContext3D::Attributes attributes; |
74 attributes.depth = false; | 74 attributes.depth = false; |
75 attributes.stencil = true; | 75 attributes.stencil = true; |
76 attributes.antialias = false; | 76 attributes.antialias = false; |
77 attributes.shareResources = true; | 77 attributes.shareResources = true; |
78 attributes.noAutomaticFlushes = true; | 78 attributes.noAutomaticFlushes = true; |
79 | 79 |
80 return Create( | 80 return Create( |
81 WebGraphicsContext3DInProcessCommandBufferImpl::CreateOffscreenContext( | 81 WebGraphicsContext3DInProcessCommandBufferImpl::CreateOffscreenContext( |
82 attributes), "Offscreen"); | 82 attributes), "Offscreen"); |
83 } | 83 } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 // provides the following capabilities: | 126 // provides the following capabilities: |
127 Capabilities caps; | 127 Capabilities caps; |
128 caps.discard_backbuffer = true; | 128 caps.discard_backbuffer = true; |
129 caps.map_image = true; | 129 caps.map_image = true; |
130 caps.map_sub = true; | 130 caps.map_sub = true; |
131 caps.set_visibility = true; | 131 caps.set_visibility = true; |
132 caps.shallow_flush = true; | 132 caps.shallow_flush = true; |
133 caps.texture_format_bgra8888 = true; | 133 caps.texture_format_bgra8888 = true; |
134 caps.texture_rectangle = true; | 134 caps.texture_rectangle = true; |
135 | 135 |
136 WebKit::WebString extensions = | 136 blink::WebString extensions = |
137 context3d_->getString(0x1F03 /* GL_EXTENSIONS */); | 137 context3d_->getString(0x1F03 /* GL_EXTENSIONS */); |
138 std::vector<std::string> extension_list; | 138 std::vector<std::string> extension_list; |
139 base::SplitString(extensions.utf8(), ' ', &extension_list); | 139 base::SplitString(extensions.utf8(), ' ', &extension_list); |
140 std::set<std::string> extension_set(extension_list.begin(), | 140 std::set<std::string> extension_set(extension_list.begin(), |
141 extension_list.end()); | 141 extension_list.end()); |
142 | 142 |
143 caps.post_sub_buffer = extension_set.count("GL_CHROMIUM_post_sub_buffer") > 0; | 143 caps.post_sub_buffer = extension_set.count("GL_CHROMIUM_post_sub_buffer") > 0; |
144 return caps; | 144 return caps; |
145 } | 145 } |
146 | 146 |
147 WebKit::WebGraphicsContext3D* ContextProviderInProcess::Context3d() { | 147 blink::WebGraphicsContext3D* ContextProviderInProcess::Context3d() { |
148 DCHECK(context3d_); | 148 DCHECK(context3d_); |
149 DCHECK(lost_context_callback_proxy_); // Is bound to thread. | 149 DCHECK(lost_context_callback_proxy_); // Is bound to thread. |
150 DCHECK(context_thread_checker_.CalledOnValidThread()); | 150 DCHECK(context_thread_checker_.CalledOnValidThread()); |
151 | 151 |
152 return context3d_.get(); | 152 return context3d_.get(); |
153 } | 153 } |
154 | 154 |
155 ::gpu::ContextSupport* ContextProviderInProcess::ContextSupport() { | 155 ::gpu::ContextSupport* ContextProviderInProcess::ContextSupport() { |
156 DCHECK(context3d_); | 156 DCHECK(context3d_); |
157 DCHECK(lost_context_callback_proxy_); // Is bound to thread. | 157 DCHECK(lost_context_callback_proxy_); // Is bound to thread. |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 swap_buffers_complete_callback_ = swap_buffers_complete_callback; | 231 swap_buffers_complete_callback_ = swap_buffers_complete_callback; |
232 } | 232 } |
233 | 233 |
234 void ContextProviderInProcess::SetMemoryPolicyChangedCallback( | 234 void ContextProviderInProcess::SetMemoryPolicyChangedCallback( |
235 const MemoryPolicyChangedCallback& memory_policy_changed_callback) { | 235 const MemoryPolicyChangedCallback& memory_policy_changed_callback) { |
236 // There's no memory manager for the in-process implementation. | 236 // There's no memory manager for the in-process implementation. |
237 } | 237 } |
238 | 238 |
239 } // namespace gpu | 239 } // namespace gpu |
240 } // namespace webkit | 240 } // namespace webkit |
OLD | NEW |