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

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

Issue 225903006: PPAPI: Run clang_format.py on content/renderer/pepper (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge Created 6 years, 8 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/renderer/pepper/pepper_platform_context_3d.h" 5 #include "content/renderer/pepper/pepper_platform_context_3d.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "content/common/gpu/client/context_provider_command_buffer.h" 8 #include "content/common/gpu/client/context_provider_command_buffer.h"
9 #include "content/common/gpu/client/gpu_channel_host.h" 9 #include "content/common/gpu/client/gpu_channel_host.h"
10 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" 10 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h"
11 #include "content/renderer/render_thread_impl.h" 11 #include "content/renderer/render_thread_impl.h"
12 #include "gpu/command_buffer/client/gles2_cmd_helper.h" 12 #include "gpu/command_buffer/client/gles2_cmd_helper.h"
13 #include "gpu/command_buffer/client/gles2_implementation.h" 13 #include "gpu/command_buffer/client/gles2_implementation.h"
14 #include "ppapi/c/pp_graphics_3d.h" 14 #include "ppapi/c/pp_graphics_3d.h"
15 #include "ui/gl/gpu_preference.h" 15 #include "ui/gl/gpu_preference.h"
16 #include "url/gurl.h" 16 #include "url/gurl.h"
17 17
18 namespace content { 18 namespace content {
19 19
20 PlatformContext3D::PlatformContext3D() 20 PlatformContext3D::PlatformContext3D()
21 : has_alpha_(false), 21 : has_alpha_(false), command_buffer_(NULL), weak_ptr_factory_(this) {}
22 command_buffer_(NULL),
23 weak_ptr_factory_(this) {
24 }
25 22
26 PlatformContext3D::~PlatformContext3D() { 23 PlatformContext3D::~PlatformContext3D() {
27 if (command_buffer_) { 24 if (command_buffer_) {
28 DCHECK(channel_.get()); 25 DCHECK(channel_.get());
29 channel_->DestroyCommandBuffer(command_buffer_); 26 channel_->DestroyCommandBuffer(command_buffer_);
30 command_buffer_ = NULL; 27 command_buffer_ = NULL;
31 } 28 }
32 29
33 channel_ = NULL; 30 channel_ = NULL;
34 } 31 }
(...skipping 14 matching lines...) Expand all
49 CAUSE_FOR_GPU_LAUNCH_PEPPERPLATFORMCONTEXT3DIMPL_INITIALIZE); 46 CAUSE_FOR_GPU_LAUNCH_PEPPERPLATFORMCONTEXT3DIMPL_INITIALIZE);
50 if (!channel_.get()) 47 if (!channel_.get())
51 return false; 48 return false;
52 49
53 gfx::Size surface_size; 50 gfx::Size surface_size;
54 std::vector<int32> attribs; 51 std::vector<int32> attribs;
55 // TODO(alokp): Change GpuChannelHost::CreateOffscreenCommandBuffer() 52 // TODO(alokp): Change GpuChannelHost::CreateOffscreenCommandBuffer()
56 // interface to accept width and height in the attrib_list so that 53 // interface to accept width and height in the attrib_list so that
57 // we do not need to filter for width and height here. 54 // we do not need to filter for width and height here.
58 if (attrib_list) { 55 if (attrib_list) {
59 for (const int32_t* attr = attrib_list; 56 for (const int32_t* attr = attrib_list; attr[0] != PP_GRAPHICS3DATTRIB_NONE;
60 attr[0] != PP_GRAPHICS3DATTRIB_NONE;
61 attr += 2) { 57 attr += 2) {
62 switch (attr[0]) { 58 switch (attr[0]) {
63 case PP_GRAPHICS3DATTRIB_WIDTH: 59 case PP_GRAPHICS3DATTRIB_WIDTH:
64 surface_size.set_width(attr[1]); 60 surface_size.set_width(attr[1]);
65 break; 61 break;
66 case PP_GRAPHICS3DATTRIB_HEIGHT: 62 case PP_GRAPHICS3DATTRIB_HEIGHT:
67 surface_size.set_height(attr[1]); 63 surface_size.set_height(attr[1]);
68 break; 64 break;
69 case PP_GRAPHICS3DATTRIB_GPU_PREFERENCE: 65 case PP_GRAPHICS3DATTRIB_GPU_PREFERENCE:
70 gpu_preference = 66 gpu_preference =
71 (attr[1] == PP_GRAPHICS3DATTRIB_GPU_PREFERENCE_LOW_POWER) ? 67 (attr[1] == PP_GRAPHICS3DATTRIB_GPU_PREFERENCE_LOW_POWER)
72 gfx::PreferIntegratedGpu : gfx::PreferDiscreteGpu; 68 ? gfx::PreferIntegratedGpu
69 : gfx::PreferDiscreteGpu;
73 break; 70 break;
74 case PP_GRAPHICS3DATTRIB_ALPHA_SIZE: 71 case PP_GRAPHICS3DATTRIB_ALPHA_SIZE:
75 has_alpha_ = attr[1] > 0; 72 has_alpha_ = attr[1] > 0;
76 // fall-through 73 // fall-through
77 default: 74 default:
78 attribs.push_back(attr[0]); 75 attribs.push_back(attr[0]);
79 attribs.push_back(attr[1]); 76 attribs.push_back(attr[1]);
80 break; 77 break;
81 } 78 }
82 } 79 }
83 attribs.push_back(PP_GRAPHICS3DATTRIB_NONE); 80 attribs.push_back(PP_GRAPHICS3DATTRIB_NONE);
84 } 81 }
85 82
86 CommandBufferProxyImpl* share_buffer = NULL; 83 CommandBufferProxyImpl* share_buffer = NULL;
87 if (share_context) { 84 if (share_context) {
88 PlatformContext3D* share_impl = 85 PlatformContext3D* share_impl =
89 static_cast<PlatformContext3D*>(share_context); 86 static_cast<PlatformContext3D*>(share_context);
90 share_buffer = share_impl->command_buffer_; 87 share_buffer = share_impl->command_buffer_;
91 } 88 }
92 89
93 command_buffer_ = channel_->CreateOffscreenCommandBuffer( 90 command_buffer_ = channel_->CreateOffscreenCommandBuffer(
94 surface_size, 91 surface_size, share_buffer, attribs, GURL::EmptyGURL(), gpu_preference);
95 share_buffer,
96 attribs,
97 GURL::EmptyGURL(),
98 gpu_preference);
99 if (!command_buffer_) 92 if (!command_buffer_)
100 return false; 93 return false;
101 if (!command_buffer_->Initialize()) 94 if (!command_buffer_->Initialize())
102 return false; 95 return false;
103 gpu::Mailbox mailbox = gpu::Mailbox::Generate(); 96 gpu::Mailbox mailbox = gpu::Mailbox::Generate();
104 if (!command_buffer_->ProduceFrontBuffer(mailbox)) 97 if (!command_buffer_->ProduceFrontBuffer(mailbox))
105 return false; 98 return false;
106 mailbox_ = mailbox; 99 mailbox_ = mailbox;
107 sync_point_ = command_buffer_->InsertSyncPoint(); 100 sync_point_ = command_buffer_->InsertSyncPoint();
108 101
109 command_buffer_->SetChannelErrorCallback( 102 command_buffer_->SetChannelErrorCallback(base::Bind(
110 base::Bind(&PlatformContext3D::OnContextLost, 103 &PlatformContext3D::OnContextLost, weak_ptr_factory_.GetWeakPtr()));
111 weak_ptr_factory_.GetWeakPtr())); 104 command_buffer_->SetOnConsoleMessageCallback(base::Bind(
112 command_buffer_->SetOnConsoleMessageCallback( 105 &PlatformContext3D::OnConsoleMessage, weak_ptr_factory_.GetWeakPtr()));
113 base::Bind(&PlatformContext3D::OnConsoleMessage,
114 weak_ptr_factory_.GetWeakPtr()));
115 106
116 return true; 107 return true;
117 } 108 }
118 109
119 void PlatformContext3D::GetBackingMailbox(gpu::Mailbox* mailbox, 110 void PlatformContext3D::GetBackingMailbox(gpu::Mailbox* mailbox,
120 uint32* sync_point) { 111 uint32* sync_point) {
121 *mailbox = mailbox_; 112 *mailbox = mailbox_;
122 *sync_point = sync_point_; 113 *sync_point = sync_point_;
123 } 114 }
124 115
125 void PlatformContext3D::InsertSyncPointForBackingMailbox() { 116 void PlatformContext3D::InsertSyncPointForBackingMailbox() {
126 DCHECK(command_buffer_); 117 DCHECK(command_buffer_);
127 sync_point_ = command_buffer_->InsertSyncPoint(); 118 sync_point_ = command_buffer_->InsertSyncPoint();
128 } 119 }
129 120
130 bool PlatformContext3D::IsOpaque() { 121 bool PlatformContext3D::IsOpaque() {
131 DCHECK(command_buffer_); 122 DCHECK(command_buffer_);
132 return !has_alpha_; 123 return !has_alpha_;
133 } 124 }
134 125
135 gpu::CommandBuffer* PlatformContext3D::GetCommandBuffer() { 126 gpu::CommandBuffer* PlatformContext3D::GetCommandBuffer() {
136 return command_buffer_; 127 return command_buffer_;
137 } 128 }
138 129
139 gpu::GpuControl* PlatformContext3D::GetGpuControl() { 130 gpu::GpuControl* PlatformContext3D::GetGpuControl() { return command_buffer_; }
140 return command_buffer_;
141 }
142 131
143 int PlatformContext3D::GetCommandBufferRouteId() { 132 int PlatformContext3D::GetCommandBufferRouteId() {
144 DCHECK(command_buffer_); 133 DCHECK(command_buffer_);
145 return command_buffer_->GetRouteID(); 134 return command_buffer_->GetRouteID();
146 } 135 }
147 136
148 void PlatformContext3D::SetContextLostCallback(const base::Closure& task) { 137 void PlatformContext3D::SetContextLostCallback(const base::Closure& task) {
149 context_lost_callback_ = task; 138 context_lost_callback_ = task;
150 } 139 }
151 140
(...skipping 14 matching lines...) Expand all
166 } 155 }
167 156
168 void PlatformContext3D::OnConsoleMessage(const std::string& msg, int id) { 157 void PlatformContext3D::OnConsoleMessage(const std::string& msg, int id) {
169 DCHECK(command_buffer_); 158 DCHECK(command_buffer_);
170 159
171 if (!console_message_callback_.is_null()) 160 if (!console_message_callback_.is_null())
172 console_message_callback_.Run(msg, id); 161 console_message_callback_.Run(msg, id);
173 } 162 }
174 163
175 } // namespace content 164 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/pepper/pepper_platform_context_3d.h ('k') | content/renderer/pepper/pepper_platform_video_capture.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698