#include <limits>
#include <string>
-#if defined(OS_ANDROID)
-#include "base/android/sys_utils.h"
-#endif
-
#include "base/command_line.h"
#include "base/logging.h"
#include "base/strings/string_number_conversions.h"
#include "base/synchronization/lock.h"
+#include "base/sys_info.h"
#include "base/time/time.h"
#include "base/values.h"
#include "cc/base/latency_info_swap_promise.h"
#include "cc/base/latency_info_swap_promise_monitor.h"
+#include "cc/base/swap_promise.h"
#include "cc/base/switches.h"
#include "cc/debug/layer_tree_debug_state.h"
#include "cc/debug/micro_benchmark.h"
+#include "cc/input/layer_selection_bound.h"
#include "cc/layers/layer.h"
#include "cc/output/copy_output_request.h"
#include "cc/output/copy_output_result.h"
#include "content/renderer/render_thread_impl.h"
#include "gpu/command_buffer/client/gles2_interface.h"
#include "third_party/WebKit/public/platform/WebCompositeAndReadbackAsyncCallback.h"
+#include "third_party/WebKit/public/platform/WebSelectionBound.h"
#include "third_party/WebKit/public/platform/WebSize.h"
#include "third_party/WebKit/public/web/WebWidget.h"
#include "ui/gfx/frame_time.h"
#if defined(OS_ANDROID)
#include "content/renderer/android/synchronous_compositor_factory.h"
+#include "ui/gfx/android/device_display_info.h"
#endif
namespace base {
}
using blink::WebFloatPoint;
+using blink::WebSelectionBound;
using blink::WebSize;
using blink::WebRect;
}
}
+cc::LayerSelectionBound ConvertWebSelectionBound(
+ const WebSelectionBound& bound) {
+ DCHECK(bound.layerId);
+
+ cc::LayerSelectionBound result;
+ switch (bound.type) {
+ case blink::WebSelectionBound::Caret:
+ result.type = cc::SELECTION_BOUND_CENTER;
+ break;
+ case blink::WebSelectionBound::SelectionLeft:
+ result.type = cc::SELECTION_BOUND_LEFT;
+ break;
+ case blink::WebSelectionBound::SelectionRight:
+ result.type = cc::SELECTION_BOUND_RIGHT;
+ break;
+ }
+ result.layer_id = bound.layerId;
+ result.layer_rect = gfx::Rect(bound.edgeRectInLayer);
+ return result;
+}
+
+gfx::Size CalculateDefaultTileSize() {
+ int default_tile_size = 256;
+#if defined(OS_ANDROID)
+ // TODO(epenner): unify this for all platforms if it
+ // makes sense (http://crbug.com/159524)
+
+ gfx::DeviceDisplayInfo info;
+ bool real_size_supported = true;
+ int display_width = info.GetPhysicalDisplayWidth();
+ int display_height = info.GetPhysicalDisplayHeight();
+ if (display_width == 0 || display_height == 0) {
+ real_size_supported = false;
+ display_width = info.GetDisplayWidth();
+ display_height = info.GetDisplayHeight();
+ }
+
+ int portrait_width = std::min(display_width, display_height);
+ int landscape_width = std::max(display_width, display_height);
+
+ if (real_size_supported) {
+ // Maximum HD dimensions should be 768x1280
+ // Maximum FHD dimensions should be 1200x1920
+ if (portrait_width > 768 || landscape_width > 1280)
+ default_tile_size = 384;
+ if (portrait_width > 1200 || landscape_width > 1920)
+ default_tile_size = 512;
+
+ // Adjust for some resolutions that barely straddle an extra
+ // tile when in portrait mode. This helps worst case scroll/raster
+ // by not needing a full extra tile for each row.
+ if (default_tile_size == 256 && portrait_width == 768)
+ default_tile_size += 32;
+ if (default_tile_size == 384 && portrait_width == 1200)
+ default_tile_size += 32;
+ } else {
+ // We don't know the exact resolution due to screen controls etc.
+ // So this just estimates the values above using tile counts.
+ int numTiles = (display_width * display_height) / (256 * 256);
+ if (numTiles > 16)
+ default_tile_size = 384;
+ if (numTiles >= 40)
+ default_tile_size = 512;
+ }
+#endif
+ return gfx::Size(default_tile_size, default_tile_size);
+}
+
} // namespace
// static
settings.report_overscroll_only_for_scrollable_axes = true;
settings.accelerated_animation_enabled =
!cmd->HasSwitch(cc::switches::kDisableThreadedAnimation);
- settings.touch_hit_testing =
- !cmd->HasSwitch(cc::switches::kDisableCompositorTouchHitTesting);
- int default_tile_width = settings.default_tile_size.width();
+ settings.default_tile_size = CalculateDefaultTileSize();
if (cmd->HasSwitch(switches::kDefaultTileWidth)) {
- GetSwitchValueAsInt(*cmd, switches::kDefaultTileWidth, 1,
- std::numeric_limits<int>::max(), &default_tile_width);
+ int tile_width = 0;
+ GetSwitchValueAsInt(*cmd,
+ switches::kDefaultTileWidth,
+ 1,
+ std::numeric_limits<int>::max(),
+ &tile_width);
+ settings.default_tile_size.set_width(tile_width);
}
- int default_tile_height = settings.default_tile_size.height();
if (cmd->HasSwitch(switches::kDefaultTileHeight)) {
- GetSwitchValueAsInt(*cmd, switches::kDefaultTileHeight, 1,
- std::numeric_limits<int>::max(), &default_tile_height);
+ int tile_height = 0;
+ GetSwitchValueAsInt(*cmd,
+ switches::kDefaultTileHeight,
+ 1,
+ std::numeric_limits<int>::max(),
+ &tile_height);
+ settings.default_tile_size.set_height(tile_height);
}
- settings.default_tile_size = gfx::Size(default_tile_width,
- default_tile_height);
int max_untiled_layer_width = settings.max_untiled_layer_size.width();
if (cmd->HasSwitch(switches::kMaxUntiledLayerWidth)) {
// Memory policy on Android WebView does not depend on whether device is
// low end, so always use default policy.
bool is_low_end_device =
- base::android::SysUtils::IsLowEndDevice() &&
- !synchronous_compositor_factory;
+ base::SysInfo::IsLowEndDevice() && !synchronous_compositor_factory;
// RGBA_4444 textures are only enabled for low end devices
// and are disabled for Android WebView as it doesn't support the format.
settings.use_rgba_4444_textures = is_low_end_device;
return;
if (suppress)
- TRACE_EVENT_ASYNC_BEGIN0("gpu",
- "RenderWidgetCompositor::SetSuppressScheduleComposite", this);
+ TRACE_EVENT_ASYNC_BEGIN0(
+ "gpu", "RenderWidgetCompositor::SetSuppressScheduleComposite", this);
else
- TRACE_EVENT_ASYNC_END0("gpu",
- "RenderWidgetCompositor::SetSuppressScheduleComposite", this);
+ TRACE_EVENT_ASYNC_END0(
+ "gpu", "RenderWidgetCompositor::SetSuppressScheduleComposite", this);
suppress_schedule_composite_ = suppress;
}
return layer_tree_host_->id();
}
+int RenderWidgetCompositor::GetSourceFrameNumber() const {
+ return layer_tree_host_->source_frame_number();
+}
+
+void RenderWidgetCompositor::SetNeedsCommit() {
+ layer_tree_host_->SetNeedsCommit();
+}
+
void RenderWidgetCompositor::NotifyInputThrottledUntilCommit() {
layer_tree_host_->NotifyInputThrottledUntilCommit();
}
}
if (compositor_message_loop_proxy.get()) {
layer_tree_host_ = cc::LayerTreeHost::CreateThreaded(
- this, shared_bitmap_manager, settings, compositor_message_loop_proxy);
+ this,
+ shared_bitmap_manager,
+ settings,
+ base::MessageLoopProxy::current(),
+ compositor_message_loop_proxy);
} else {
layer_tree_host_ = cc::LayerTreeHost::CreateSingleThreaded(
- this, this, shared_bitmap_manager, settings);
+ this,
+ this,
+ shared_bitmap_manager,
+ settings,
+ base::MessageLoopProxy::current());
}
DCHECK(layer_tree_host_);
}
scoped_refptr<cc::Layer>());
}
+void RenderWidgetCompositor::registerSelection(
+ const blink::WebSelectionBound& start,
+ const blink::WebSelectionBound& end) {
+ layer_tree_host_->RegisterSelection(ConvertWebSelectionBound(start),
+ ConvertWebSelectionBound(end));
+}
+
+void RenderWidgetCompositor::clearSelection() {
+ cc::LayerSelectionBound empty_selection;
+ layer_tree_host_->RegisterSelection(empty_selection, empty_selection);
+}
+
void CompositeAndReadbackAsyncCallback(
blink::WebCompositeAndReadbackAsyncCallback* callback,
scoped_ptr<cc::CopyOutputResult> result) {