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

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

Issue 2166423002: ui::ContextFactory should not create SurfaceIdAllocators (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed Dana's nit 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/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
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 return ++g_surface_client_id;
342 std::unique_ptr<cc::SurfaceIdAllocator> allocator(
343 new cc::SurfaceIdAllocator(++g_surface_client_id));
344 cc::SurfaceManager* manager = GetSurfaceManager();
345 DCHECK(manager);
346 allocator->RegisterSurfaceClientId(manager);
347 return allocator;
348 } 342 }
349 343
350 // static 344 // static
351 scoped_refptr<cc::VulkanInProcessContextProvider> 345 scoped_refptr<cc::VulkanInProcessContextProvider>
352 CompositorImpl::SharedVulkanContextProviderAndroid() { 346 CompositorImpl::SharedVulkanContextProviderAndroid() {
353 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 347 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
354 switches::kEnableVulkan)) { 348 switches::kEnableVulkan)) {
355 scoped_refptr<cc::VulkanInProcessContextProvider>* context_provider = 349 scoped_refptr<cc::VulkanInProcessContextProvider>* context_provider =
356 g_shared_vulkan_context_provider_android_.Pointer(); 350 g_shared_vulkan_context_provider_android_.Pointer();
357 if (!*context_provider) 351 if (!*context_provider)
358 *context_provider = cc::VulkanInProcessContextProvider::Create(); 352 *context_provider = cc::VulkanInProcessContextProvider::Create();
359 return *context_provider; 353 return *context_provider;
360 } 354 }
361 return nullptr; 355 return nullptr;
362 } 356 }
363 357
364 CompositorImpl::CompositorImpl(CompositorClient* client, 358 CompositorImpl::CompositorImpl(CompositorClient* client,
365 gfx::NativeWindow root_window) 359 gfx::NativeWindow root_window)
366 : surface_id_allocator_(CreateSurfaceIdAllocator()), 360 : surface_id_allocator_(
361 new cc::SurfaceIdAllocator(AllocateSurfaceClientId())),
367 resource_manager_(root_window), 362 resource_manager_(root_window),
368 has_transparent_background_(false), 363 has_transparent_background_(false),
369 device_scale_factor_(1), 364 device_scale_factor_(1),
370 window_(NULL), 365 window_(NULL),
371 surface_handle_(gpu::kNullSurfaceHandle), 366 surface_handle_(gpu::kNullSurfaceHandle),
372 client_(client), 367 client_(client),
373 root_window_(root_window), 368 root_window_(root_window),
374 needs_animate_(false), 369 needs_animate_(false),
375 pending_swapbuffers_(0U), 370 pending_swapbuffers_(0U),
376 num_successive_context_creation_failures_(0), 371 num_successive_context_creation_failures_(0),
377 output_surface_request_pending_(false), 372 output_surface_request_pending_(false),
378 needs_begin_frames_(false), 373 needs_begin_frames_(false),
379 weak_factory_(this) { 374 weak_factory_(this) {
375 GetSurfaceManager()->RegisterSurfaceClientId(
376 surface_id_allocator_->client_id());
380 DCHECK(client); 377 DCHECK(client);
381 DCHECK(root_window); 378 DCHECK(root_window);
382 DCHECK(root_window->GetLayer() == nullptr); 379 DCHECK(root_window->GetLayer() == nullptr);
383 root_window->SetLayer(cc::Layer::Create()); 380 root_window->SetLayer(cc::Layer::Create());
384 root_window->AttachCompositor(this); 381 root_window->AttachCompositor(this);
385 CreateLayerTreeHost(); 382 CreateLayerTreeHost();
386 resource_manager_.Init(host_.get()); 383 resource_manager_.Init(host_.get());
387 } 384 }
388 385
389 CompositorImpl::~CompositorImpl() { 386 CompositorImpl::~CompositorImpl() {
390 root_window_->DetachCompositor(); 387 root_window_->DetachCompositor();
391 root_window_->SetLayer(nullptr); 388 root_window_->SetLayer(nullptr);
392 // Clean-up any surface references. 389 // Clean-up any surface references.
393 SetSurface(NULL); 390 SetSurface(NULL);
391 GetSurfaceManager()->InvalidateSurfaceClientId(
392 surface_id_allocator_->client_id());
394 } 393 }
395 394
396 ui::UIResourceProvider& CompositorImpl::GetUIResourceProvider() { 395 ui::UIResourceProvider& CompositorImpl::GetUIResourceProvider() {
397 return *this; 396 return *this;
398 } 397 }
399 398
400 ui::ResourceManager& CompositorImpl::GetResourceManager() { 399 ui::ResourceManager& CompositorImpl::GetResourceManager() {
401 return resource_manager_; 400 return resource_manager_;
402 } 401 }
403 402
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
802 void CompositorImpl::SetNeedsAnimate() { 801 void CompositorImpl::SetNeedsAnimate() {
803 needs_animate_ = true; 802 needs_animate_ = true;
804 if (!host_->visible()) 803 if (!host_->visible())
805 return; 804 return;
806 805
807 TRACE_EVENT0("compositor", "Compositor::SetNeedsAnimate"); 806 TRACE_EVENT0("compositor", "Compositor::SetNeedsAnimate");
808 host_->SetNeedsAnimate(); 807 host_->SetNeedsAnimate();
809 } 808 }
810 809
811 } // namespace content 810 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/compositor_impl_android.h ('k') | content/browser/renderer_host/delegated_frame_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698