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

Side by Side Diff: content/browser/android/in_process/synchronous_compositor_factory_impl.cc

Issue 1064033002: android: Merge WrapContext and WrapContextWithAttributes into a single function. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/browser/android/in_process/synchronous_compositor_factory_impl .h" 5 #include "content/browser/android/in_process/synchronous_compositor_factory_impl .h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/observer_list.h" 8 #include "base/observer_list.h"
9 #include "content/browser/android/in_process/synchronous_compositor_external_beg in_frame_source.h" 9 #include "content/browser/android/in_process/synchronous_compositor_external_beg in_frame_source.h"
10 #include "content/browser/android/in_process/synchronous_compositor_impl.h" 10 #include "content/browser/android/in_process/synchronous_compositor_impl.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 attributes.shareResources, 60 attributes.shareResources,
61 in_process_attribs, 61 in_process_attribs,
62 gpu_preference, 62 gpu_preference,
63 mem_limits, 63 mem_limits,
64 nullptr, 64 nullptr,
65 nullptr)); 65 nullptr));
66 return context.Pass(); 66 return context.Pass();
67 } 67 }
68 68
69 scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> WrapContext( 69 scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> WrapContext(
70 scoped_ptr<gpu::GLInProcessContext> context) {
71 if (!context.get())
72 return scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl>();
73
74 return scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl>(
75 WebGraphicsContext3DInProcessCommandBufferImpl::WrapContext(
76 context.Pass(), GetDefaultAttribs()));
77 }
78
79 scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl>
80 WrapContextWithAttributes(
81 scoped_ptr<gpu::GLInProcessContext> context, 70 scoped_ptr<gpu::GLInProcessContext> context,
82 const blink::WebGraphicsContext3D::Attributes& attributes) { 71 const blink::WebGraphicsContext3D::Attributes& attributes) {
83 if (!context.get()) 72 if (!context.get())
84 return scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl>(); 73 return scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl>();
85 74
86 return scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl>( 75 return scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl>(
87 WebGraphicsContext3DInProcessCommandBufferImpl::WrapContext( 76 WebGraphicsContext3DInProcessCommandBufferImpl::WrapContext(
88 context.Pass(), attributes)); 77 context.Pass(), attributes));
89 } 78 }
90 79
91 } // namespace 80 } // namespace
92 81
93 class SynchronousCompositorFactoryImpl::VideoContextProvider 82 class SynchronousCompositorFactoryImpl::VideoContextProvider
94 : public StreamTextureFactorySynchronousImpl::ContextProvider { 83 : public StreamTextureFactorySynchronousImpl::ContextProvider {
95 public: 84 public:
96 VideoContextProvider( 85 VideoContextProvider(
97 scoped_ptr<gpu::GLInProcessContext> gl_in_process_context) 86 scoped_ptr<gpu::GLInProcessContext> gl_in_process_context)
98 : gl_in_process_context_(gl_in_process_context.get()) { 87 : gl_in_process_context_(gl_in_process_context.get()) {
99
100 context_provider_ = webkit::gpu::ContextProviderInProcess::Create( 88 context_provider_ = webkit::gpu::ContextProviderInProcess::Create(
101 WrapContext(gl_in_process_context.Pass()), 89 WrapContext(gl_in_process_context.Pass(), GetDefaultAttribs()),
102 "Video-Offscreen-main-thread"); 90 "Video-Offscreen-main-thread");
103 context_provider_->BindToCurrentThread(); 91 context_provider_->BindToCurrentThread();
104 } 92 }
105 93
106 scoped_refptr<gfx::SurfaceTexture> GetSurfaceTexture( 94 scoped_refptr<gfx::SurfaceTexture> GetSurfaceTexture(
107 uint32 stream_id) override { 95 uint32 stream_id) override {
108 return gl_in_process_context_->GetSurfaceTexture(stream_id); 96 return gl_in_process_context_->GetSurfaceTexture(stream_id);
109 } 97 }
110 98
111 gpu::gles2::GLES2Interface* ContextGL() override { 99 gpu::gles2::GLES2Interface* ContextGL() override {
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 new SynchronousCompositorExternalBeginFrameSource(routing_id)); 166 new SynchronousCompositorExternalBeginFrameSource(routing_id));
179 } 167 }
180 168
181 scoped_refptr<ContextProviderWebContext> 169 scoped_refptr<ContextProviderWebContext>
182 SynchronousCompositorFactoryImpl::CreateOffscreenContextProvider( 170 SynchronousCompositorFactoryImpl::CreateOffscreenContextProvider(
183 const blink::WebGraphicsContext3D::Attributes& attributes, 171 const blink::WebGraphicsContext3D::Attributes& attributes,
184 const std::string& debug_name) { 172 const std::string& debug_name) {
185 scoped_ptr<gpu::GLInProcessContext> context = CreateContextHolder( 173 scoped_ptr<gpu::GLInProcessContext> context = CreateContextHolder(
186 attributes, nullptr, gpu::GLInProcessContextSharedMemoryLimits(), true); 174 attributes, nullptr, gpu::GLInProcessContextSharedMemoryLimits(), true);
187 return webkit::gpu::ContextProviderInProcess::Create( 175 return webkit::gpu::ContextProviderInProcess::Create(
188 WrapContext(context.Pass()), debug_name); 176 WrapContext(context.Pass(), GetDefaultAttribs()), debug_name);
boliu 2015/04/07 19:18:39 use |attributes|
tfarina 2015/04/07 20:04:04 Done. But note that before it was using GetDefault
boliu 2015/04/07 20:05:58 Yeah shouldn't hurt. Probably would have been a bu
189 } 177 }
190 178
191 scoped_refptr<cc::ContextProvider> 179 scoped_refptr<cc::ContextProvider>
192 SynchronousCompositorFactoryImpl::CreateContextProviderForCompositor() { 180 SynchronousCompositorFactoryImpl::CreateContextProviderForCompositor() {
193 DCHECK(service_.get()); 181 DCHECK(service_.get());
194 182
195 gpu::GLInProcessContextSharedMemoryLimits mem_limits; 183 gpu::GLInProcessContextSharedMemoryLimits mem_limits;
196 // This is half of what RenderWidget uses because synchronous compositor 184 // This is half of what RenderWidget uses because synchronous compositor
197 // pipeline is only one frame deep. 185 // pipeline is only one frame deep.
198 mem_limits.mapped_memory_reclaim_limit = 6 * 1024 * 1024; 186 mem_limits.mapped_memory_reclaim_limit = 6 * 1024 * 1024;
199 return webkit::gpu::ContextProviderInProcess::Create( 187 return webkit::gpu::ContextProviderInProcess::Create(
200 WrapContext( 188 WrapContext(
201 CreateContextHolder(GetDefaultAttribs(), nullptr, mem_limits, true)), 189 CreateContextHolder(GetDefaultAttribs(), nullptr, mem_limits, true),
190 GetDefaultAttribs()),
boliu 2015/04/07 19:18:39 Only call GetDefaultAttribs() once, save it in a l
tfarina 2015/04/07 20:04:04 Done.
202 "Child-Compositor"); 191 "Child-Compositor");
203 } 192 }
204 193
205 scoped_refptr<StreamTextureFactory> 194 scoped_refptr<StreamTextureFactory>
206 SynchronousCompositorFactoryImpl::CreateStreamTextureFactory(int frame_id) { 195 SynchronousCompositorFactoryImpl::CreateStreamTextureFactory(int frame_id) {
207 scoped_refptr<StreamTextureFactorySynchronousImpl> factory( 196 scoped_refptr<StreamTextureFactorySynchronousImpl> factory(
208 StreamTextureFactorySynchronousImpl::Create( 197 StreamTextureFactorySynchronousImpl::Create(
209 base::Bind( 198 base::Bind(
210 &SynchronousCompositorFactoryImpl::TryCreateStreamTextureFactory, 199 &SynchronousCompositorFactoryImpl::TryCreateStreamTextureFactory,
211 base::Unretained(this)), 200 base::Unretained(this)),
212 frame_id)); 201 frame_id));
213 return factory; 202 return factory;
214 } 203 }
215 204
216 WebGraphicsContext3DInProcessCommandBufferImpl* 205 WebGraphicsContext3DInProcessCommandBufferImpl*
217 SynchronousCompositorFactoryImpl::CreateOffscreenGraphicsContext3D( 206 SynchronousCompositorFactoryImpl::CreateOffscreenGraphicsContext3D(
218 const blink::WebGraphicsContext3D::Attributes& attributes) { 207 const blink::WebGraphicsContext3D::Attributes& attributes) {
219 return WrapContextWithAttributes( 208 return WrapContext(CreateContextHolder(
220 CreateContextHolder(attributes, nullptr, 209 attributes, nullptr,
221 gpu::GLInProcessContextSharedMemoryLimits(), 210 gpu::GLInProcessContextSharedMemoryLimits(), true),
222 true), 211 attributes).release();
223 attributes).release();
224 } 212 }
225 213
226 void SynchronousCompositorFactoryImpl::CompositorInitializedHardwareDraw() { 214 void SynchronousCompositorFactoryImpl::CompositorInitializedHardwareDraw() {
227 base::AutoLock lock(num_hardware_compositor_lock_); 215 base::AutoLock lock(num_hardware_compositor_lock_);
228 num_hardware_compositors_++; 216 num_hardware_compositors_++;
229 if (num_hardware_compositors_ == 1 && main_thread_proxy_.get()) { 217 if (num_hardware_compositors_ == 1 && main_thread_proxy_.get()) {
230 main_thread_proxy_->PostTask( 218 main_thread_proxy_->PostTask(
231 FROM_HERE, 219 FROM_HERE,
232 base::Bind( 220 base::Bind(
233 &SynchronousCompositorFactoryImpl::RestoreContextOnMainThread, 221 &SynchronousCompositorFactoryImpl::RestoreContextOnMainThread,
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 DCHECK(!service_.get()); 274 DCHECK(!service_.get());
287 service_ = service; 275 service_ = service;
288 } 276 }
289 277
290 void SynchronousCompositorFactoryImpl::SetRecordFullDocument( 278 void SynchronousCompositorFactoryImpl::SetRecordFullDocument(
291 bool record_full_document) { 279 bool record_full_document) {
292 record_full_layer_ = record_full_document; 280 record_full_layer_ = record_full_document;
293 } 281 }
294 282
295 } // namespace content 283 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698