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

Side by Side Diff: content/renderer/pepper/ppb_graphics_3d_impl.cc

Issue 2086363004: mac: Finish plumbing for Pepper3D Image Chromium. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@temp98_native_gmb
Patch Set: Rebase error. Created 4 years, 5 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) 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/renderer/pepper/ppb_graphics_3d_impl.h" 5 #include "content/renderer/pepper/ppb_graphics_3d_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "base/threading/thread_task_runner_handle.h" 12 #include "base/threading/thread_task_runner_handle.h"
13 #include "content/public/common/content_switches.h" 13 #include "content/public/common/content_switches.h"
14 #include "content/public/common/web_preferences.h" 14 #include "content/public/common/web_preferences.h"
15 #include "content/renderer/pepper/host_globals.h" 15 #include "content/renderer/pepper/host_globals.h"
16 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" 16 #include "content/renderer/pepper/pepper_plugin_instance_impl.h"
17 #include "content/renderer/pepper/plugin_instance_throttler_impl.h" 17 #include "content/renderer/pepper/plugin_instance_throttler_impl.h"
18 #include "content/renderer/pepper/plugin_module.h" 18 #include "content/renderer/pepper/plugin_module.h"
19 #include "content/renderer/render_thread_impl.h" 19 #include "content/renderer/render_thread_impl.h"
20 #include "content/renderer/render_view_impl.h" 20 #include "content/renderer/render_view_impl.h"
21 #include "gpu/GLES2/gl2extchromium.h"
21 #include "gpu/command_buffer/common/gles2_cmd_utils.h" 22 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
22 #include "gpu/ipc/client/command_buffer_proxy_impl.h" 23 #include "gpu/ipc/client/command_buffer_proxy_impl.h"
23 #include "gpu/ipc/client/gpu_channel_host.h" 24 #include "gpu/ipc/client/gpu_channel_host.h"
24 #include "ppapi/c/ppp_graphics_3d.h" 25 #include "ppapi/c/ppp_graphics_3d.h"
25 #include "ppapi/thunk/enter.h" 26 #include "ppapi/thunk/enter.h"
26 #include "third_party/WebKit/public/platform/WebString.h" 27 #include "third_party/WebKit/public/platform/WebString.h"
27 #include "third_party/WebKit/public/web/WebConsoleMessage.h" 28 #include "third_party/WebKit/public/web/WebConsoleMessage.h"
28 #include "third_party/WebKit/public/web/WebDocument.h" 29 #include "third_party/WebKit/public/web/WebDocument.h"
29 #include "third_party/WebKit/public/web/WebLocalFrame.h" 30 #include "third_party/WebKit/public/web/WebLocalFrame.h"
30 #include "third_party/WebKit/public/web/WebPluginContainer.h" 31 #include "third_party/WebKit/public/web/WebPluginContainer.h"
31 #include "third_party/khronos/GLES2/gl2.h" 32 #include "third_party/khronos/GLES2/gl2.h"
32 33
33 using ppapi::thunk::EnterResourceNoLock; 34 using ppapi::thunk::EnterResourceNoLock;
34 using ppapi::thunk::PPB_Graphics3D_API; 35 using ppapi::thunk::PPB_Graphics3D_API;
35 using blink::WebConsoleMessage; 36 using blink::WebConsoleMessage;
36 using blink::WebLocalFrame; 37 using blink::WebLocalFrame;
37 using blink::WebPluginContainer; 38 using blink::WebPluginContainer;
38 using blink::WebString; 39 using blink::WebString;
39 40
40 namespace content { 41 namespace content {
41 42
42 PPB_Graphics3D_Impl::PPB_Graphics3D_Impl(PP_Instance instance) 43 PPB_Graphics3D_Impl::PPB_Graphics3D_Impl(PP_Instance instance)
43 : PPB_Graphics3D_Shared(instance), 44 : PPB_Graphics3D_Shared(instance),
44 bound_to_instance_(false), 45 bound_to_instance_(false),
45 commit_pending_(false), 46 commit_pending_(false),
46 has_alpha_(false), 47 has_alpha_(false),
47 weak_ptr_factory_(this) {} 48 use_image_chromium_(false),
49 weak_ptr_factory_(this) {
50 #if defined(OS_MACOSX)
51 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
52 bool use_image_chromium =
53 !command_line->HasSwitch(switches::kDisablePepper3DImageChromium);
54 use_image_chromium_ = use_image_chromium;
55
56 // TODO(erikchen): Remove this line to enable the feature.
57 use_image_chromium_ = false;
58 #endif
59 }
48 60
49 PPB_Graphics3D_Impl::~PPB_Graphics3D_Impl() { 61 PPB_Graphics3D_Impl::~PPB_Graphics3D_Impl() {
50 // Unset the client before the command_buffer_ is destroyed, similar to how 62 // Unset the client before the command_buffer_ is destroyed, similar to how
51 // WeakPtrFactory invalidates before it. 63 // WeakPtrFactory invalidates before it.
52 if (command_buffer_) 64 if (command_buffer_)
53 command_buffer_->SetGpuControlClient(nullptr); 65 command_buffer_->SetGpuControlClient(nullptr);
54 } 66 }
55 67
56 // static 68 // static
57 PP_Resource PPB_Graphics3D_Impl::CreateRaw( 69 PP_Resource PPB_Graphics3D_Impl::CreateRaw(
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 } 163 }
152 164
153 gpu::CommandBuffer* PPB_Graphics3D_Impl::GetCommandBuffer() { 165 gpu::CommandBuffer* PPB_Graphics3D_Impl::GetCommandBuffer() {
154 return command_buffer_.get(); 166 return command_buffer_.get();
155 } 167 }
156 168
157 gpu::GpuControl* PPB_Graphics3D_Impl::GetGpuControl() { 169 gpu::GpuControl* PPB_Graphics3D_Impl::GetGpuControl() {
158 return command_buffer_.get(); 170 return command_buffer_.get();
159 } 171 }
160 172
161 int32_t PPB_Graphics3D_Impl::DoSwapBuffers(const gpu::SyncToken& sync_token) { 173 int32_t PPB_Graphics3D_Impl::DoSwapBuffers(const gpu::SyncToken& sync_token,
174 int32_t width,
175 int32_t height) {
162 DCHECK(command_buffer_); 176 DCHECK(command_buffer_);
163 if (taken_front_buffer_.IsZero()) { 177 if (taken_front_buffer_.IsZero()) {
164 DLOG(ERROR) << "TakeFrontBuffer should be called before DoSwapBuffers"; 178 DLOG(ERROR) << "TakeFrontBuffer should be called before DoSwapBuffers";
165 return PP_ERROR_FAILED; 179 return PP_ERROR_FAILED;
166 } 180 }
167 181
168 if (bound_to_instance_) { 182 if (bound_to_instance_) {
169 // If we are bound to the instance, we need to ask the compositor 183 // If we are bound to the instance, we need to ask the compositor
170 // to commit our backing texture so that the graphics appears on the page. 184 // to commit our backing texture so that the graphics appears on the page.
171 // When the backing texture will be committed we get notified via 185 // When the backing texture will be committed we get notified via
172 // ViewFlushedPaint(). 186 // ViewFlushedPaint().
173 // 187 //
174 // Don't need to check for NULL from GetPluginInstance since when we're 188 // Don't need to check for NULL from GetPluginInstance since when we're
175 // bound, we know our instance is valid. 189 // bound, we know our instance is valid.
176 cc::TextureMailbox texture_mailbox(taken_front_buffer_, sync_token, 190 if (width < 0 || height < 0) {
177 GL_TEXTURE_2D); 191 width = original_width_;
192 height = original_height_;
193 }
194 bool is_overlay_candidate = use_image_chromium_;
195 GLenum target =
196 is_overlay_candidate ? GL_TEXTURE_RECTANGLE_ARB : GL_TEXTURE_2D;
197 cc::TextureMailbox texture_mailbox(taken_front_buffer_, sync_token, target,
198 gfx::Size(width, height),
199 is_overlay_candidate, false);
178 taken_front_buffer_.SetZero(); 200 taken_front_buffer_.SetZero();
179 HostGlobals::Get() 201 HostGlobals::Get()
180 ->GetInstance(pp_instance()) 202 ->GetInstance(pp_instance())
181 ->CommitTextureMailbox(texture_mailbox); 203 ->CommitTextureMailbox(texture_mailbox);
182 commit_pending_ = true; 204 commit_pending_ = true;
183 } else { 205 } else {
184 // Wait for the command to complete on the GPU to allow for throttling. 206 // Wait for the command to complete on the GPU to allow for throttling.
185 command_buffer_->SignalSyncToken( 207 command_buffer_->SignalSyncToken(
186 sync_token, base::Bind(&PPB_Graphics3D_Impl::OnSwapBuffers, 208 sync_token, base::Bind(&PPB_Graphics3D_Impl::OnSwapBuffers,
187 weak_ptr_factory_.GetWeakPtr())); 209 weak_ptr_factory_.GetWeakPtr()));
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 default: 275 default:
254 attribs.push_back(attr[0]); 276 attribs.push_back(attr[0]);
255 attribs.push_back(attr[1]); 277 attribs.push_back(attr[1]);
256 break; 278 break;
257 } 279 }
258 } 280 }
259 attribs.push_back(PP_GRAPHICS3DATTRIB_NONE); 281 attribs.push_back(PP_GRAPHICS3DATTRIB_NONE);
260 } 282 }
261 if (!attrib_helper.Parse(attribs)) 283 if (!attrib_helper.Parse(attribs))
262 return false; 284 return false;
285 attrib_helper.should_use_native_gmb_for_backbuffer = use_image_chromium_;
263 286
264 gpu::CommandBufferProxyImpl* share_buffer = NULL; 287 gpu::CommandBufferProxyImpl* share_buffer = NULL;
265 if (share_context) { 288 if (share_context) {
266 PPB_Graphics3D_Impl* share_graphics = 289 PPB_Graphics3D_Impl* share_graphics =
267 static_cast<PPB_Graphics3D_Impl*>(share_context); 290 static_cast<PPB_Graphics3D_Impl*>(share_context);
268 share_buffer = share_graphics->GetCommandBufferProxy(); 291 share_buffer = share_graphics->GetCommandBufferProxy();
269 } 292 }
270 293
271 command_buffer_ = gpu::CommandBufferProxyImpl::Create( 294 command_buffer_ = gpu::CommandBufferProxyImpl::Create(
272 std::move(channel), gpu::kNullSurfaceHandle, share_buffer, 295 std::move(channel), gpu::kNullSurfaceHandle, share_buffer,
273 gpu::GPU_STREAM_DEFAULT, gpu::GpuStreamPriority::NORMAL, attrib_helper, 296 gpu::GPU_STREAM_DEFAULT, gpu::GpuStreamPriority::NORMAL, attrib_helper,
274 GURL::EmptyGURL(), base::ThreadTaskRunnerHandle::Get()); 297 GURL::EmptyGURL(), base::ThreadTaskRunnerHandle::Get());
298 original_width_ = attrib_helper.offscreen_framebuffer_size.width();
299 original_height_ = attrib_helper.offscreen_framebuffer_size.height();
275 if (!command_buffer_) 300 if (!command_buffer_)
276 return false; 301 return false;
277 302
278 command_buffer_->SetGpuControlClient(this); 303 command_buffer_->SetGpuControlClient(this);
279 304
280 if (shared_state_handle) 305 if (shared_state_handle)
281 *shared_state_handle = command_buffer_->GetSharedStateHandle(); 306 *shared_state_handle = command_buffer_->GetSharedStateHandle();
282 if (capabilities) 307 if (capabilities)
283 *capabilities = command_buffer_->GetCapabilities(); 308 *capabilities = command_buffer_->GetCapabilities();
284 if (command_buffer_id) 309 if (command_buffer_id)
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 if (!mailboxes_to_reuse_.empty()) { 390 if (!mailboxes_to_reuse_.empty()) {
366 gpu::Mailbox mailbox = mailboxes_to_reuse_.back(); 391 gpu::Mailbox mailbox = mailboxes_to_reuse_.back();
367 mailboxes_to_reuse_.pop_back(); 392 mailboxes_to_reuse_.pop_back();
368 return mailbox; 393 return mailbox;
369 } 394 }
370 395
371 return gpu::Mailbox::Generate(); 396 return gpu::Mailbox::Generate();
372 } 397 }
373 398
374 } // namespace content 399 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/pepper/ppb_graphics_3d_impl.h ('k') | gpu/ipc/common/gpu_param_traits_macros.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698