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

Unified Diff: content/browser/android/composited_touch_handle_drawable.cc

Issue 481683003: Support for Adaptive Handle Orientation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanup Created 5 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/android/composited_touch_handle_drawable.cc
diff --git a/content/browser/android/composited_touch_handle_drawable.cc b/content/browser/android/composited_touch_handle_drawable.cc
index 91a019eba89157780bd68ed5d82c979b050d0c88..eee7896d0fe6cc3eab0c3fe3c53777eb25724b46 100644
--- a/content/browser/android/composited_touch_handle_drawable.cc
+++ b/content/browser/android/composited_touch_handle_drawable.cc
@@ -102,23 +102,48 @@ void CompositedTouchHandleDrawable::SetEnabled(bool enabled) {
}
void CompositedTouchHandleDrawable::SetOrientation(
- ui::TouchHandleOrientation orientation) {
+ ui::TouchHandleOrientation orientation,
+ bool mirror_vertical,
+ bool mirror_horizontal) {
DCHECK(layer_->parent());
orientation_ = orientation;
const SkBitmap& bitmap = g_selection_resources.Get().GetBitmap(orientation);
+ const int bitmap_height = bitmap.height();
+ const int bitmap_width = bitmap.width();
+ int focal_offset_x = 0;
+ int focal_offset_y = mirror_vertical ? bitmap_height : 0;
+
layer_->SetBitmap(bitmap);
- layer_->SetBounds(gfx::Size(bitmap.width(), bitmap.height()));
+ layer_->SetBounds(gfx::Size(bitmap_width, bitmap_height));
+
+ // Invert about X and Y axis based on the mirror values
+ gfx::Transform transform;
+ float scale_x = mirror_horizontal ? -1.f : 1.f;
+ float scale_y = mirror_vertical ? -1.f : 1.f;
+
+ layer_->SetTransformOrigin(
+ gfx::Point3F(bitmap_width * 0.5f, bitmap_height * 0.5f, 0));
+ transform.Scale(scale_x, scale_y);
+ layer_->SetTransform(transform);
switch (orientation_) {
case ui::TouchHandleOrientation::LEFT:
- focal_offset_from_origin_ = gfx::Vector2dF(bitmap.width() * 0.75f, 0);
+ focal_offset_x =
+ mirror_horizontal ? bitmap_width * 0.25f : bitmap_width * 0.75f;
+ focal_offset_from_origin_ =
+ gfx::Vector2dF(focal_offset_x, focal_offset_y);
break;
case ui::TouchHandleOrientation::RIGHT:
- focal_offset_from_origin_ = gfx::Vector2dF(bitmap.width() * 0.25f, 0);
+ focal_offset_x =
+ mirror_horizontal ? bitmap_width * 0.75f : bitmap_width * 0.25f;
+ focal_offset_from_origin_ =
+ gfx::Vector2dF(focal_offset_x, focal_offset_y);
break;
case ui::TouchHandleOrientation::CENTER:
- focal_offset_from_origin_ = gfx::Vector2dF(bitmap.width() * 0.5f, 0);
+ focal_offset_x = bitmap_width * 0.5f;
+ focal_offset_from_origin_ =
+ gfx::Vector2dF(focal_offset_x, focal_offset_y);
break;
case ui::TouchHandleOrientation::UNDEFINED:
NOTREACHED() << "Invalid touch handle orientation.";

Powered by Google App Engine
This is Rietveld 408576698