summaryrefslogtreecommitdiffstats
path: root/blimp/common
diff options
context:
space:
mode:
authordtrainor <dtrainor@chromium.org>2015-09-03 13:04:57 -0700
committerCommit bot <commit-bot@chromium.org>2015-09-03 20:05:44 +0000
commite9c78dddbb858895a13ed8b22c53a07d63a9ff1b (patch)
tree9d4251728f76d2a1d5c12931d22bf4147cf50638 /blimp/common
parent76479a04b3d7cd3a8249475adf205905d6bdcaba (diff)
downloadchromium_src-e9c78dddbb858895a13ed8b22c53a07d63a9ff1b.zip
chromium_src-e9c78dddbb858895a13ed8b22c53a07d63a9ff1b.tar.gz
chromium_src-e9c78dddbb858895a13ed8b22c53a07d63a9ff1b.tar.bz2
Initial commit of the blimp/ folder and target
- Sets up a basic Android compositor shell. - Eventually should support other platforms as well. Inspiration for most components: BlimpLibraryLoader: BrowserStartupController.java blimp_library_loader.[cc,h]: content/app/android/library_loader_hooks.[cc,h] content/app/content_main_runner.[h,cc] blimp_jni_registrar.[cc,h]: content/app/android/app_jni_registrar.[cc,h] BlimpView.java: CompositorView.java blimp_view.[cc,h]: compositor_view.[cc,h] blimp_compositor.[cc,h]/blimp_output_surface.[cc,h] compositor_impl_android.[cc,h] blimp_context_provider.[cc,h]: in_process_context_provider.[cc,h] aw_render_thread_context_provider.[cc,h] blimp_layer_tree_settings.[cc,h]: render_widget_compositor.[cc,h] BUG=526219 Review URL: https://codereview.chromium.org/1295243003 Cr-Commit-Position: refs/heads/master@{#347223}
Diffstat (limited to 'blimp/common')
-rw-r--r--blimp/common/BUILD.gn25
-rw-r--r--blimp/common/DEPS14
-rw-r--r--blimp/common/blimp_common_export.h29
-rw-r--r--blimp/common/compositor/blimp_layer_tree_settings.cc267
-rw-r--r--blimp/common/compositor/blimp_layer_tree_settings.h33
5 files changed, 368 insertions, 0 deletions
diff --git a/blimp/common/BUILD.gn b/blimp/common/BUILD.gn
new file mode 100644
index 0000000..7a71c284
--- /dev/null
+++ b/blimp/common/BUILD.gn
@@ -0,0 +1,25 @@
+# Copyright 2015 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+component("blimp_common") {
+ sources = [
+ # TODO(dtrainor): Remove this once the LayerTreeHost settings for Blimp
+ # are finalized or are pushed from the server component. See
+ # crbug.com/527655.
+ "../../content/public/common/content_switches.cc",
+ "blimp_common_export.h",
+ "compositor/blimp_layer_tree_settings.cc",
+ "compositor/blimp_layer_tree_settings.h",
+ ]
+
+ defines = [ "BLIMP_COMMON_IMPLEMENTATION=1" ]
+
+ deps = [
+ "//base",
+ "//cc",
+ "//skia",
+ "//ui/gfx/geometry",
+ "//ui/gl",
+ ]
+}
diff --git a/blimp/common/DEPS b/blimp/common/DEPS
new file mode 100644
index 0000000..2b54cf7
--- /dev/null
+++ b/blimp/common/DEPS
@@ -0,0 +1,14 @@
+include_rules = [
+ "+base",
+ "+cc",
+ "-cc/blink",
+ "-content",
+ "+third_party/skia",
+ "+ui/gfx",
+ "+ui/gl",
+
+ # TODO(dtrainor): Remove this once the LayerTreeHost settings for Blimp
+ # are finalized or are pushed from the server component. See
+ # crbug.com/527655.
+ "!content/public/common/content_switches.h",
+]
diff --git a/blimp/common/blimp_common_export.h b/blimp/common/blimp_common_export.h
new file mode 100644
index 0000000..6e031b8
--- /dev/null
+++ b/blimp/common/blimp_common_export.h
@@ -0,0 +1,29 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef BLIMP_COMMON_BLIMP_COMMON_EXPORT_H_
+#define BLIMP_COMMON_BLIMP_COMMON_EXPORT_H_
+
+#if defined(COMPONENT_BUILD)
+#if defined(WIN32)
+
+#if defined(BLIMP_COMMON_IMPLEMENTATION)
+#define BLIMP_COMMON_EXPORT __declspec(dllexport)
+#else
+#define BLIMP_COMMON_EXPORT __declspec(dllimport)
+#endif // defined(BLIMP_COMMON_IMPLEMENTATION)
+
+#else // defined(WIN32)
+#if defined(BLIMP_COMMON_IMPLEMENTATION)
+#define BLIMP_COMMON_EXPORT __attribute__((visibility("default")))
+#else
+#define BLIMP_COMMON_EXPORT
+#endif // defined(BLIMP_COMMON_IMPLEMENTATION)
+#endif
+
+#else // defined(COMPONENT_BUILD)
+#define BLIMP_COMMON_EXPORT
+#endif
+
+#endif // BLIMP_COMMON_BLIMP_COMMON_EXPORT_H_
diff --git a/blimp/common/compositor/blimp_layer_tree_settings.cc b/blimp/common/compositor/blimp_layer_tree_settings.cc
new file mode 100644
index 0000000..cef7317
--- /dev/null
+++ b/blimp/common/compositor/blimp_layer_tree_settings.cc
@@ -0,0 +1,267 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "blimp/common/compositor/blimp_layer_tree_settings.h"
+
+#include "base/command_line.h"
+#include "base/logging.h"
+#include "base/macros.h"
+#include "base/strings/string_number_conversions.h"
+#include "base/strings/string_split.h"
+#include "base/sys_info.h"
+#include "cc/base/switches.h"
+#include "cc/trees/layer_tree_settings.h"
+#include "content/public/common/content_switches.h"
+#include "third_party/skia/include/core/SkColor.h"
+#include "ui/gfx/buffer_types.h"
+#include "ui/gl/gl_switches.h"
+
+namespace {
+
+bool GetSwitchValueAsInt(const base::CommandLine& command_line,
+ const std::string& switch_string,
+ int min_value,
+ int max_value,
+ int* result) {
+ std::string string_value = command_line.GetSwitchValueASCII(switch_string);
+ int int_value;
+ if (base::StringToInt(string_value, &int_value) && int_value >= min_value &&
+ int_value <= max_value) {
+ *result = int_value;
+ return true;
+ } else {
+ return false;
+ }
+}
+
+void StringToUintVector(const std::string& str, std::vector<unsigned>* vector) {
+ DCHECK(vector->empty());
+ std::vector<std::string> pieces =
+ base::SplitString(str, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
+ DCHECK_EQ(pieces.size(), static_cast<size_t>(gfx::BufferFormat::LAST) + 1);
+ for (size_t i = 0; i < pieces.size(); ++i) {
+ unsigned number = 0;
+ bool succeed = base::StringToUint(pieces[i], &number);
+ DCHECK(succeed);
+ vector->push_back(number);
+ }
+}
+
+} // namespace
+
+namespace blimp {
+
+// TODO(dtrainor): This is temporary to get the compositor up and running.
+// Much of this will either have to be pulled from the server or refactored to
+// share the settings from render_widget_compositor.cc.
+void PopulateCommonLayerTreeSettings(cc::LayerTreeSettings* settings) {
+ const base::CommandLine& cmd = *base::CommandLine::ForCurrentProcess();
+ // For web contents, layer transforms should scale up the contents of layers
+ // to keep content always crisp when possible.
+ settings->layer_transforms_should_scale_layer_contents = true;
+
+ if (cmd.HasSwitch(switches::kDisableGpuVsync)) {
+ std::string display_vsync_string =
+ cmd.GetSwitchValueASCII(switches::kDisableGpuVsync);
+ if (display_vsync_string == "gpu") {
+ settings->renderer_settings.disable_display_vsync = true;
+ } else if (display_vsync_string == "beginframe") {
+ settings->wait_for_beginframe_interval = false;
+ } else {
+ settings->renderer_settings.disable_display_vsync = true;
+ settings->wait_for_beginframe_interval = false;
+ }
+ }
+ settings->main_frame_before_activation_enabled =
+ cmd.HasSwitch(cc::switches::kEnableMainFrameBeforeActivation) &&
+ !cmd.HasSwitch(cc::switches::kDisableMainFrameBeforeActivation);
+ settings->accelerated_animation_enabled =
+ !cmd.HasSwitch(cc::switches::kDisableThreadedAnimation);
+ settings->use_display_lists = cmd.HasSwitch(switches::kEnableSlimmingPaint);
+
+ settings->default_tile_size = gfx::Size(256, 256);
+ if (cmd.HasSwitch(switches::kDefaultTileWidth)) {
+ int tile_width = 0;
+ GetSwitchValueAsInt(cmd, switches::kDefaultTileWidth, 1,
+ std::numeric_limits<int>::max(), &tile_width);
+ settings->default_tile_size.set_width(tile_width);
+ }
+ if (cmd.HasSwitch(switches::kDefaultTileHeight)) {
+ int tile_height = 0;
+ GetSwitchValueAsInt(cmd, switches::kDefaultTileHeight, 1,
+ std::numeric_limits<int>::max(), &tile_height);
+ settings->default_tile_size.set_height(tile_height);
+ }
+
+ int max_untiled_layer_width = settings->max_untiled_layer_size.width();
+ if (cmd.HasSwitch(switches::kMaxUntiledLayerWidth)) {
+ GetSwitchValueAsInt(cmd, switches::kMaxUntiledLayerWidth, 1,
+ std::numeric_limits<int>::max(),
+ &max_untiled_layer_width);
+ }
+ int max_untiled_layer_height = settings->max_untiled_layer_size.height();
+ if (cmd.HasSwitch(switches::kMaxUntiledLayerHeight)) {
+ GetSwitchValueAsInt(cmd, switches::kMaxUntiledLayerHeight, 1,
+ std::numeric_limits<int>::max(),
+ &max_untiled_layer_height);
+ }
+
+ settings->max_untiled_layer_size =
+ gfx::Size(max_untiled_layer_width, max_untiled_layer_height);
+
+ settings->gpu_rasterization_msaa_sample_count = 0;
+ if (cmd.HasSwitch(switches::kGpuRasterizationMSAASampleCount)) {
+ GetSwitchValueAsInt(cmd, switches::kGpuRasterizationMSAASampleCount, 0,
+ std::numeric_limits<int>::max(),
+ &settings->gpu_rasterization_msaa_sample_count);
+ }
+
+ settings->gpu_rasterization_forced =
+ cmd.HasSwitch(switches::kForceGpuRasterization);
+ settings->gpu_rasterization_enabled =
+ cmd.HasSwitch(switches::kEnableGpuRasterization);
+
+ settings->can_use_lcd_text = false;
+ settings->use_distance_field_text =
+ cmd.HasSwitch(switches::kEnableDistanceFieldText);
+
+ settings->use_zero_copy = cmd.HasSwitch(switches::kEnableZeroCopy);
+ settings->enable_elastic_overscroll = false;
+
+ if (cmd.HasSwitch(switches::kContentImageTextureTarget)) {
+ settings->use_image_texture_targets.clear();
+ StringToUintVector(
+ cmd.GetSwitchValueASCII(switches::kContentImageTextureTarget),
+ &settings->use_image_texture_targets);
+ }
+
+ settings->gather_pixel_refs = false;
+ if (cmd.HasSwitch(switches::kNumRasterThreads)) {
+ int num_raster_threads = 0;
+ GetSwitchValueAsInt(cmd, switches::kNumRasterThreads, 0,
+ std::numeric_limits<int>::max(), &num_raster_threads);
+ settings->gather_pixel_refs = num_raster_threads > 1;
+ }
+
+ if (cmd.HasSwitch(cc::switches::kTopControlsShowThreshold)) {
+ std::string top_threshold_str =
+ cmd.GetSwitchValueASCII(cc::switches::kTopControlsShowThreshold);
+ double show_threshold;
+ if (base::StringToDouble(top_threshold_str, &show_threshold) &&
+ show_threshold >= 0.f && show_threshold <= 1.f)
+ settings->top_controls_show_threshold = show_threshold;
+ }
+
+ if (cmd.HasSwitch(cc::switches::kTopControlsHideThreshold)) {
+ std::string top_threshold_str =
+ cmd.GetSwitchValueASCII(cc::switches::kTopControlsHideThreshold);
+ double hide_threshold;
+ if (base::StringToDouble(top_threshold_str, &hide_threshold) &&
+ hide_threshold >= 0.f && hide_threshold <= 1.f)
+ settings->top_controls_hide_threshold = hide_threshold;
+ }
+
+ settings->verify_property_trees =
+ cmd.HasSwitch(cc::switches::kEnablePropertyTreeVerification);
+ settings->renderer_settings.allow_antialiasing &=
+ !cmd.HasSwitch(cc::switches::kDisableCompositedAntialiasing);
+ settings->single_thread_proxy_scheduler = false;
+
+ // These flags should be mirrored by UI versions in ui/compositor/.
+ settings->initial_debug_state.show_debug_borders =
+ cmd.HasSwitch(cc::switches::kShowCompositedLayerBorders);
+ settings->initial_debug_state.show_fps_counter =
+ cmd.HasSwitch(cc::switches::kShowFPSCounter);
+ settings->initial_debug_state.show_layer_animation_bounds_rects =
+ cmd.HasSwitch(cc::switches::kShowLayerAnimationBounds);
+ settings->initial_debug_state.show_paint_rects =
+ cmd.HasSwitch(switches::kShowPaintRects);
+ settings->initial_debug_state.show_property_changed_rects =
+ cmd.HasSwitch(cc::switches::kShowPropertyChangedRects);
+ settings->initial_debug_state.show_surface_damage_rects =
+ cmd.HasSwitch(cc::switches::kShowSurfaceDamageRects);
+ settings->initial_debug_state.show_screen_space_rects =
+ cmd.HasSwitch(cc::switches::kShowScreenSpaceRects);
+ settings->initial_debug_state.show_replica_screen_space_rects =
+ cmd.HasSwitch(cc::switches::kShowReplicaScreenSpaceRects);
+
+ settings->initial_debug_state.SetRecordRenderingStats(
+ cmd.HasSwitch(cc::switches::kEnableGpuBenchmarking));
+
+ if (cmd.HasSwitch(cc::switches::kSlowDownRasterScaleFactor)) {
+ const int kMinSlowDownScaleFactor = 0;
+ const int kMaxSlowDownScaleFactor = INT_MAX;
+ GetSwitchValueAsInt(
+ cmd, cc::switches::kSlowDownRasterScaleFactor, kMinSlowDownScaleFactor,
+ kMaxSlowDownScaleFactor,
+ &settings->initial_debug_state.slow_down_raster_scale_factor);
+ }
+
+ settings->invert_viewport_scroll_order =
+ cmd.HasSwitch(switches::kInvertViewportScrollOrder);
+
+ settings->strict_layer_property_change_checking =
+ cmd.HasSwitch(cc::switches::kStrictLayerPropertyChangeChecking);
+
+#if defined(OS_ANDROID)
+ if (base::SysInfo::IsLowEndDevice())
+ settings->gpu_rasterization_enabled = false;
+ settings->using_synchronous_renderer_compositor = false;
+ settings->record_full_layer = false;
+ settings->scrollbar_animator = cc::LayerTreeSettings::LINEAR_FADE;
+ settings->scrollbar_fade_delay_ms = 300;
+ settings->scrollbar_fade_resize_delay_ms = 2000;
+ settings->scrollbar_fade_duration_ms = 300;
+ settings->solid_color_scrollbar_color = SkColorSetARGB(128, 128, 128, 128);
+ settings->renderer_settings.highp_threshold_min = 2048;
+ settings->ignore_root_layer_flings = false;
+ bool use_low_memory_policy = base::SysInfo::IsLowEndDevice();
+ settings->renderer_settings.use_rgba_4444_textures = use_low_memory_policy;
+ if (use_low_memory_policy) {
+ // On low-end we want to be very carefull about killing other
+ // apps. So initially we use 50% more memory to avoid flickering
+ // or raster-on-demand.
+ settings->max_memory_for_prepaint_percentage = 67;
+ } else {
+ // On other devices we have increased memory excessively to avoid
+ // raster-on-demand already, so now we reserve 50% _only_ to avoid
+ // raster-on-demand, and use 50% of the memory otherwise.
+ settings->max_memory_for_prepaint_percentage = 50;
+ }
+ settings->renderer_settings.should_clear_root_render_pass = true;
+
+ // TODO(danakj): Only do this on low end devices.
+ settings->create_low_res_tiling = true;
+
+// TODO(dtrainor): Investigate whether or not we want to use an external
+// source here.
+// settings->use_external_begin_frame_source = true;
+
+#elif !defined(OS_MACOSX)
+ if (ui::IsOverlayScrollbarEnabled()) {
+ settings->scrollbar_animator = cc::LayerTreeSettings::THINNING;
+ settings->solid_color_scrollbar_color = SkColorSetARGB(128, 128, 128, 128);
+ } else {
+ settings->scrollbar_animator = cc::LayerTreeSettings::LINEAR_FADE;
+ settings->solid_color_scrollbar_color = SkColorSetARGB(128, 128, 128, 128);
+ }
+ settings->scrollbar_fade_delay_ms = 500;
+ settings->scrollbar_fade_resize_delay_ms = 500;
+ settings->scrollbar_fade_duration_ms = 300;
+
+ // When pinching in, only show the pinch-viewport overlay scrollbars if the
+ // page scale is at least some threshold away from the minimum. i.e. don't
+ // show the pinch scrollbars when at minimum scale.
+ settings->scrollbar_show_scale_threshold = 1.05f;
+#endif
+
+ if (cmd.HasSwitch(switches::kEnableLowResTiling))
+ settings->create_low_res_tiling = true;
+ if (cmd.HasSwitch(switches::kDisableLowResTiling))
+ settings->create_low_res_tiling = false;
+ if (cmd.HasSwitch(cc::switches::kEnableBeginFrameScheduling))
+ settings->use_external_begin_frame_source = true;
+}
+
+} // namespace blimp
diff --git a/blimp/common/compositor/blimp_layer_tree_settings.h b/blimp/common/compositor/blimp_layer_tree_settings.h
new file mode 100644
index 0000000..ddbabbc
--- /dev/null
+++ b/blimp/common/compositor/blimp_layer_tree_settings.h
@@ -0,0 +1,33 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef BLIMP_COMMON_COMPOSITOR_BLIMP_LAYER_TREE_SETTINGS_H_
+#define BLIMP_COMMON_COMPOSITOR_BLIMP_LAYER_TREE_SETTINGS_H_
+
+#include "blimp/common/blimp_common_export.h"
+
+namespace base {
+class CommandLine;
+}
+
+namespace cc {
+class LayerTreeSettings;
+}
+
+namespace gfx {
+class Size;
+}
+
+namespace blimp {
+
+// Populates shared server/client |settings| based on defaults & command line
+// flags. This might have to be tweaked into a message protocol if it turns out
+// the host compositor needs to actually drive some specific settings of the
+// client.
+BLIMP_COMMON_EXPORT void PopulateCommonLayerTreeSettings(
+ cc::LayerTreeSettings* settings);
+
+} // namespace blimp
+
+#endif // BLIMP_COMMON_COMPOSITOR_BLIMP_LAYER_TREE_SETTINGS_H_