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

Side by Side Diff: blimp/client/app/android/blimp_compositor_manager_android.cc

Issue 2274323002: Expose Blimp dependencies to the embedder (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@khushal_baseline_1
Patch Set: Fix linux build break Created 4 years, 3 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 2015 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/app/android/blimp_compositor_manager_android.h"
6
7 #include <algorithm>
8 #include <memory>
9
10 #include "base/command_line.h"
11 #include "base/memory/ptr_util.h"
12 #include "ui/gfx/geometry/size.h"
13
14 namespace {
15 // The minimum valid content width in a tile. This is used to make sure the
16 // width of the content on the rightmost tile isn't a tiny sliver.
17 const int kMinimumTileContentWidthPixels = 64;
18 }
19
20 namespace blimp {
21 namespace client {
22
23 // static
24 std::unique_ptr<BlimpCompositorManagerAndroid>
25 BlimpCompositorManagerAndroid::Create(
26 const gfx::Size& real_size,
27 const gfx::Size& size,
28 RenderWidgetFeature* render_widget_feature,
29 cc::SurfaceManager* surface_manager,
30 BlimpGpuMemoryBufferManager* gpu_memory_buffer_manager,
31 SurfaceIdAllocationCallback callback) {
32 gfx::Size device_size(real_size);
33 bool real_size_supported = true;
34 if (device_size.IsEmpty()) {
35 real_size_supported = false;
36 device_size = size;
37 }
38 return base::WrapUnique(new BlimpCompositorManagerAndroid(
39 device_size, real_size_supported, render_widget_feature, surface_manager,
40 gpu_memory_buffer_manager, callback));
41 }
42
43 BlimpCompositorManagerAndroid::BlimpCompositorManagerAndroid(
44 const gfx::Size& size,
45 bool real_size_supported,
46 RenderWidgetFeature* render_widget_feature,
47 cc::SurfaceManager* surface_manager,
48 BlimpGpuMemoryBufferManager* gpu_memory_buffer_manager,
49 SurfaceIdAllocationCallback callback)
50 : BlimpCompositorManager(render_widget_feature,
51 surface_manager,
52 gpu_memory_buffer_manager,
53 callback),
54 portrait_width_(std::min(size.width(), size.height())),
55 landscape_width_(std::max(size.width(), size.height())),
56 real_size_supported_(real_size_supported) {}
57
58 BlimpCompositorManagerAndroid::~BlimpCompositorManagerAndroid() {}
59
60 void BlimpCompositorManagerAndroid::GenerateLayerTreeSettings(
61 cc::LayerTreeSettings* settings) {
62 BlimpCompositorManager::GenerateLayerTreeSettings(settings);
63
64 // Calculate the correct raster tile size to use. Assuming a square tile.
65 DCHECK_EQ(settings->default_tile_size.width(),
66 settings->default_tile_size.height());
67
68 int default_tile_size = settings->default_tile_size.width();
69 if (real_size_supported_) {
70 // Maximum HD dimensions should be 768x1280
71 // Maximum FHD dimensions should be 1200x1920
72 if (portrait_width_ > 768 || landscape_width_ > 1280)
73 default_tile_size = 384;
74 if (portrait_width_ > 1200 || landscape_width_ > 1920)
75 default_tile_size = 512;
76
77 // Adjust for some resolutions that barely straddle an extra
78 // tile when in portrait mode. This helps worst case scroll/raster
79 // by not needing a full extra tile for each row.
80 int right_tile_width = ((portrait_width_ - 1) % default_tile_size) + 1;
81 if (right_tile_width < kMinimumTileContentWidthPixels) {
82 // Figure out the new tile count without the small edge tile.
83 int full_tile_count = portrait_width_ / default_tile_size;
84 DCHECK_GT(full_tile_count, 0);
85
86 // Calculate the ideal new tile width with the new tile count.
87 default_tile_size = std::ceil(static_cast<float>(portrait_width_) /
88 static_cast<float>(full_tile_count));
89
90 // Round up to nearest 32 for GPU efficiency.
91 if (default_tile_size & 0x1F)
92 default_tile_size = (default_tile_size & ~0x1F) + 32;
93 }
94 } else {
95 // We don't know the exact resolution due to screen controls etc., so this
96 // just estimates the values above using tile counts.
97 int numTiles = (portrait_width_ * landscape_width_) / (256 * 256);
98 if (numTiles > 16)
99 default_tile_size = 384;
100 if (numTiles >= 40)
101 default_tile_size = 512;
102 }
103 settings->default_tile_size.SetSize(default_tile_size, default_tile_size);
104 }
105
106 } // namespace client
107 } // namespace blimp
OLDNEW
« no previous file with comments | « blimp/client/app/android/blimp_compositor_manager_android.h ('k') | blimp/client/app/android/blimp_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698