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

Side by Side Diff: blimp/client/support/compositor/compositor_dependencies_impl.cc

Issue 2274323002: Expose Blimp dependencies to the embedder (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@khushal_baseline_1
Patch Set: Addressed Khushal's initial comments Created 4 years, 4 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
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "blimp/client/support/compositor/compositor_dependencies_impl.h"
6
7 #include "blimp/client/support/compositor/blimp_context_provider.h"
8 #include "blimp/client/support/compositor/blimp_gpu_memory_buffer_manager.h"
9 #include "blimp/client/support/compositor/blimp_layer_tree_settings.h"
10 #include "cc/output/context_provider.h"
11 #include "cc/surfaces/surface_manager.h"
12 #include "cc/trees/layer_tree_settings.h"
13
14 #if defined(OS_ANDROID)
15 #include "ui/gfx/android/device_display_info.h"
16 #endif
17
18 namespace blimp {
19 namespace client {
20
21 CompositorDependenciesImpl::CompositorDependenciesImpl()
22 : gpu_memory_buffer_manager_(
23 base::MakeUnique<BlimpGpuMemoryBufferManager>()),
24 surface_manager_(base::MakeUnique<cc::SurfaceManager>()),
25 next_surface_id_(0) {}
26
27 CompositorDependenciesImpl::~CompositorDependenciesImpl() = default;
28
29 std::unique_ptr<cc::LayerTreeSettings>
30 CompositorDependenciesImpl::GetLayerTreeSettings() {
31 std::unique_ptr<cc::LayerTreeSettings> settings =
32 base::MakeUnique<cc::LayerTreeSettings>();
33 PopulateCommonLayerTreeSettings(settings.get());
34 settings->abort_commit_before_output_surface_creation = false;
35 settings->renderer_settings.buffer_to_texture_target_map =
36 BlimpGpuMemoryBufferManager::GetDefaultBufferToTextureTargetMap();
37 settings->use_output_surface_begin_frame_source = true;
38
39 int default_tile_size = 256;
40 #if defined(OS_ANDROID)
41 gfx::DeviceDisplayInfo info;
42 bool real_size_supported = true;
43 int display_width = info.GetPhysicalDisplayWidth();
44 int display_height = info.GetPhysicalDisplayHeight();
45 if (display_width == 0 || display_height == 0) {
46 real_size_supported = false;
47 display_width = info.GetDisplayWidth();
48 display_height = info.GetDisplayHeight();
49 }
50
51 int portrait_width = std::min(display_width, display_height);
52 int landscape_width = std::max(display_width, display_height);
53
54 if (real_size_supported) {
55 // Maximum HD dimensions should be 768x1280
56 // Maximum FHD dimensions should be 1200x1920
57 if (portrait_width > 768 || landscape_width > 1280)
58 default_tile_size = 384;
59 if (portrait_width > 1200 || landscape_width > 1920)
60 default_tile_size = 512;
61
62 // Adjust for some resolutions that barely straddle an extra
63 // tile when in portrait mode. This helps worst case scroll/raster
64 // by not needing a full extra tile for each row.
65 if (default_tile_size == 256 && portrait_width == 768)
66 default_tile_size += 32;
67 if (default_tile_size == 384 && portrait_width == 1200)
68 default_tile_size += 32;
69 } else {
70 // We don't know the exact resolution due to screen controls etc.
71 // So this just estimates the values above using tile counts.
72 int numTiles = (display_width * display_height) / (256 * 256);
73 if (numTiles > 16)
74 default_tile_size = 384;
75 if (numTiles >= 40)
76 default_tile_size = 512;
77 }
78 #endif
79 settings->default_tile_size.SetSize(default_tile_size, default_tile_size);
80
81 return settings;
82 }
83
84 gpu::GpuMemoryBufferManager*
85 CompositorDependenciesImpl::GetGpuMemoryBufferManager() {
86 return gpu_memory_buffer_manager_.get();
87 }
88
89 cc::SurfaceManager* CompositorDependenciesImpl::GetSurfaceManager() {
90 return surface_manager_.get();
91 }
92
93 uint32_t CompositorDependenciesImpl::AllocateSurfaceId() {
94 return ++next_surface_id_;
95 }
96
97 void CompositorDependenciesImpl::GetContextProvider(
98 const CompositorDependencies::ContextProviderCallback& callback) {
99 scoped_refptr<cc::ContextProvider> provider = BlimpContextProvider::Create(
100 gfx::kNullAcceleratedWidget, gpu_memory_buffer_manager_.get());
101 callback.Run(provider);
102 }
103
104 } // namespace client
105 } // namespace blimp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698