OLD | NEW |
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 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 bool CompositorImpl::IsInitialized() { | 330 bool CompositorImpl::IsInitialized() { |
331 return g_initialized; | 331 return g_initialized; |
332 } | 332 } |
333 | 333 |
334 // static | 334 // static |
335 cc::SurfaceManager* CompositorImpl::GetSurfaceManager() { | 335 cc::SurfaceManager* CompositorImpl::GetSurfaceManager() { |
336 return g_surface_manager.Pointer(); | 336 return g_surface_manager.Pointer(); |
337 } | 337 } |
338 | 338 |
339 // static | 339 // static |
340 std::unique_ptr<cc::SurfaceIdAllocator> | 340 uint32_t CompositorImpl::AllocateSurfaceClientId() { |
341 CompositorImpl::CreateSurfaceIdAllocator() { | 341 uint32_t client_id = ++g_surface_client_id; |
342 std::unique_ptr<cc::SurfaceIdAllocator> allocator( | |
343 new cc::SurfaceIdAllocator(++g_surface_client_id)); | |
344 cc::SurfaceManager* manager = GetSurfaceManager(); | 342 cc::SurfaceManager* manager = GetSurfaceManager(); |
345 DCHECK(manager); | 343 DCHECK(manager); |
346 allocator->RegisterSurfaceClientId(manager); | 344 manager->RegisterSurfaceClientId(client_id); |
347 return allocator; | 345 return client_id; |
348 } | 346 } |
349 | 347 |
350 // static | 348 // static |
351 scoped_refptr<cc::VulkanInProcessContextProvider> | 349 scoped_refptr<cc::VulkanInProcessContextProvider> |
352 CompositorImpl::SharedVulkanContextProviderAndroid() { | 350 CompositorImpl::SharedVulkanContextProviderAndroid() { |
353 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 351 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
354 switches::kEnableVulkan)) { | 352 switches::kEnableVulkan)) { |
355 scoped_refptr<cc::VulkanInProcessContextProvider>* context_provider = | 353 scoped_refptr<cc::VulkanInProcessContextProvider>* context_provider = |
356 g_shared_vulkan_context_provider_android_.Pointer(); | 354 g_shared_vulkan_context_provider_android_.Pointer(); |
357 if (!*context_provider) | 355 if (!*context_provider) |
358 *context_provider = cc::VulkanInProcessContextProvider::Create(); | 356 *context_provider = cc::VulkanInProcessContextProvider::Create(); |
359 return *context_provider; | 357 return *context_provider; |
360 } | 358 } |
361 return nullptr; | 359 return nullptr; |
362 } | 360 } |
363 | 361 |
364 CompositorImpl::CompositorImpl(CompositorClient* client, | 362 CompositorImpl::CompositorImpl(CompositorClient* client, |
365 gfx::NativeWindow root_window) | 363 gfx::NativeWindow root_window) |
366 : root_layer_(cc::Layer::Create()), | 364 : root_layer_(cc::Layer::Create()), |
367 surface_id_allocator_(CreateSurfaceIdAllocator()), | 365 surface_id_allocator_( |
| 366 new cc::SurfaceIdAllocator(AllocateSurfaceClientId())), |
368 resource_manager_(root_window), | 367 resource_manager_(root_window), |
369 has_transparent_background_(false), | 368 has_transparent_background_(false), |
370 device_scale_factor_(1), | 369 device_scale_factor_(1), |
371 window_(NULL), | 370 window_(NULL), |
372 surface_handle_(gpu::kNullSurfaceHandle), | 371 surface_handle_(gpu::kNullSurfaceHandle), |
373 client_(client), | 372 client_(client), |
374 root_window_(root_window), | 373 root_window_(root_window), |
375 needs_animate_(false), | 374 needs_animate_(false), |
376 pending_swapbuffers_(0U), | 375 pending_swapbuffers_(0U), |
377 num_successive_context_creation_failures_(0), | 376 num_successive_context_creation_failures_(0), |
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
800 void CompositorImpl::SetNeedsAnimate() { | 799 void CompositorImpl::SetNeedsAnimate() { |
801 needs_animate_ = true; | 800 needs_animate_ = true; |
802 if (!host_->visible()) | 801 if (!host_->visible()) |
803 return; | 802 return; |
804 | 803 |
805 TRACE_EVENT0("compositor", "Compositor::SetNeedsAnimate"); | 804 TRACE_EVENT0("compositor", "Compositor::SetNeedsAnimate"); |
806 host_->SetNeedsAnimate(); | 805 host_->SetNeedsAnimate(); |
807 } | 806 } |
808 | 807 |
809 } // namespace content | 808 } // namespace content |
OLD | NEW |