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

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

Issue 2241623002: blimp: Move compositing, input and render widget feature to client/core. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 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 BlimpCompositorManagerClient* client) {
30 gfx::Size device_size(real_size);
31 bool real_size_supported = true;
32 if (device_size.IsEmpty()) {
33 real_size_supported = false;
34 device_size = size;
35 }
36 return base::WrapUnique(new BlimpCompositorManagerAndroid(
37 device_size, real_size_supported, render_widget_feature, client));
38 }
39
40 BlimpCompositorManagerAndroid::BlimpCompositorManagerAndroid(
41 const gfx::Size& size,
42 bool real_size_supported,
43 RenderWidgetFeature* render_widget_feature,
44 BlimpCompositorManagerClient* client)
45 : BlimpCompositorManager(render_widget_feature, client),
46 portrait_width_(std::min(size.width(), size.height())),
47 landscape_width_(std::max(size.width(), size.height())),
48 real_size_supported_(real_size_supported) {}
49
50 BlimpCompositorManagerAndroid::~BlimpCompositorManagerAndroid() {}
51
52 void BlimpCompositorManagerAndroid::GenerateLayerTreeSettings(
53 cc::LayerTreeSettings* settings) {
54 BlimpCompositorManager::GenerateLayerTreeSettings(settings);
55
56 // Calculate the correct raster tile size to use. Assuming a square tile.
57 DCHECK_EQ(settings->default_tile_size.width(),
58 settings->default_tile_size.height());
59
60 int default_tile_size = settings->default_tile_size.width();
61 if (real_size_supported_) {
62 // Maximum HD dimensions should be 768x1280
63 // Maximum FHD dimensions should be 1200x1920
64 if (portrait_width_ > 768 || landscape_width_ > 1280)
65 default_tile_size = 384;
66 if (portrait_width_ > 1200 || landscape_width_ > 1920)
67 default_tile_size = 512;
68
69 // Adjust for some resolutions that barely straddle an extra
70 // tile when in portrait mode. This helps worst case scroll/raster
71 // by not needing a full extra tile for each row.
72 int right_tile_width = ((portrait_width_ - 1) % default_tile_size) + 1;
73 if (right_tile_width < kMinimumTileContentWidthPixels) {
74 // Figure out the new tile count without the small edge tile.
75 int full_tile_count = portrait_width_ / default_tile_size;
76 DCHECK_GT(full_tile_count, 0);
77
78 // Calculate the ideal new tile width with the new tile count.
79 default_tile_size = std::ceil(static_cast<float>(portrait_width_) /
80 static_cast<float>(full_tile_count));
81
82 // Round up to nearest 32 for GPU efficiency.
83 if (default_tile_size & 0x1F)
84 default_tile_size = (default_tile_size & ~0x1F) + 32;
85 }
86 } else {
87 // We don't know the exact resolution due to screen controls etc., so this
88 // just estimates the values above using tile counts.
89 int numTiles = (portrait_width_ * landscape_width_) / (256 * 256);
90 if (numTiles > 16)
91 default_tile_size = 384;
92 if (numTiles >= 40)
93 default_tile_size = 512;
94 }
95 settings->default_tile_size.SetSize(default_tile_size, default_tile_size);
96 }
97
98 } // namespace client
99 } // namespace blimp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698