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

Side by Side Diff: blimp/client/compositor/blimp_compositor_android.cc

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

Powered by Google App Engine
This is Rietveld 408576698