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

Side by Side Diff: content/browser/renderer_host/compositor_impl_android.cc

Issue 2731833002: content: Add public context creation API. (Closed)
Patch Set: piman's comments Created 3 years, 9 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 | content/public/browser/android/compositor.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/browser/renderer_host/compositor_impl_android.h" 5 #include "content/browser/renderer_host/compositor_impl_android.h"
6 6
7 #include <android/bitmap.h> 7 #include <android/bitmap.h>
8 #include <android/native_window_jni.h> 8 #include <android/native_window_jni.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 #include <unordered_set> 10 #include <unordered_set>
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 // -1. 177 // -1.
178 attributes.alpha_size = 0; 178 attributes.alpha_size = 0;
179 attributes.red_size = 5; 179 attributes.red_size = 5;
180 attributes.green_size = 6; 180 attributes.green_size = 6;
181 attributes.blue_size = 5; 181 attributes.blue_size = 5;
182 } 182 }
183 183
184 return attributes; 184 return attributes;
185 } 185 }
186 186
187 void CreateContextProviderAfterGpuChannelEstablished(
188 gpu::SurfaceHandle handle,
189 gpu::gles2::ContextCreationAttribHelper attributes,
190 gpu::SharedMemoryLimits shared_memory_limits,
191 Compositor::ContextProviderCallback callback,
192 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host) {
193 if (!gpu_channel_host)
194 callback.Run(nullptr);
195
196 constexpr bool automatic_flushes = false;
197 constexpr bool support_locking = false;
198 scoped_refptr<ui::ContextProviderCommandBuffer> context_provider =
199 new ui::ContextProviderCommandBuffer(
200 std::move(gpu_channel_host), gpu::GPU_STREAM_DEFAULT,
201 gpu::GpuStreamPriority::NORMAL, handle,
202 GURL(std::string("chrome://gpu/Compositor::CreateContextProvider")),
203 automatic_flushes, support_locking, shared_memory_limits, attributes,
204 nullptr /* shared_context */,
205 ui::command_buffer_metrics::CONTEXT_TYPE_UNKNOWN);
206 callback.Run(std::move(context_provider));
207 }
208
187 class AndroidOutputSurface : public cc::OutputSurface { 209 class AndroidOutputSurface : public cc::OutputSurface {
188 public: 210 public:
189 AndroidOutputSurface( 211 AndroidOutputSurface(
190 scoped_refptr<ui::ContextProviderCommandBuffer> context_provider, 212 scoped_refptr<ui::ContextProviderCommandBuffer> context_provider,
191 base::Closure swap_buffers_callback) 213 base::Closure swap_buffers_callback)
192 : cc::OutputSurface(std::move(context_provider)), 214 : cc::OutputSurface(std::move(context_provider)),
193 swap_buffers_callback_(std::move(swap_buffers_callback)), 215 swap_buffers_callback_(std::move(swap_buffers_callback)),
194 overlay_candidate_validator_( 216 overlay_candidate_validator_(
195 new display_compositor:: 217 new display_compositor::
196 CompositorOverlayCandidateValidatorAndroid()), 218 CompositorOverlayCandidateValidatorAndroid()),
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 return client ? new CompositorImpl(client, root_window) : NULL; 370 return client ? new CompositorImpl(client, root_window) : NULL;
349 } 371 }
350 372
351 // static 373 // static
352 void Compositor::Initialize() { 374 void Compositor::Initialize() {
353 DCHECK(!CompositorImpl::IsInitialized()); 375 DCHECK(!CompositorImpl::IsInitialized());
354 g_initialized = true; 376 g_initialized = true;
355 } 377 }
356 378
357 // static 379 // static
380 void Compositor::CreateContextProvider(
381 gpu::SurfaceHandle handle,
382 gpu::gles2::ContextCreationAttribHelper attributes,
383 gpu::SharedMemoryLimits shared_memory_limits,
384 ContextProviderCallback callback) {
385 BrowserGpuChannelHostFactory::instance()->EstablishGpuChannel(
386 base::Bind(&CreateContextProviderAfterGpuChannelEstablished, handle,
387 attributes, shared_memory_limits, callback));
388 }
389
390 // static
358 cc::SurfaceManager* CompositorImpl::GetSurfaceManager() { 391 cc::SurfaceManager* CompositorImpl::GetSurfaceManager() {
359 return &g_compositor_dependencies.Get().surface_manager; 392 return &g_compositor_dependencies.Get().surface_manager;
360 } 393 }
361 394
362 // static 395 // static
363 cc::FrameSinkId CompositorImpl::AllocateFrameSinkId() { 396 cc::FrameSinkId CompositorImpl::AllocateFrameSinkId() {
364 return g_compositor_dependencies.Get() 397 return g_compositor_dependencies.Get()
365 .frame_sink_id_allocator.NextFrameSinkId(); 398 .frame_sink_id_allocator.NextFrameSinkId();
366 } 399 }
367 400
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
821 } 854 }
822 GetSurfaceManager()->UnregisterFrameSinkHierarchy(frame_sink_id_, 855 GetSurfaceManager()->UnregisterFrameSinkHierarchy(frame_sink_id_,
823 frame_sink_id); 856 frame_sink_id);
824 } 857 }
825 858
826 bool CompositorImpl::HavePendingReadbacks() { 859 bool CompositorImpl::HavePendingReadbacks() {
827 return !readback_layer_tree_->children().empty(); 860 return !readback_layer_tree_->children().empty();
828 } 861 }
829 862
830 } // namespace content 863 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/public/browser/android/compositor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698