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

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: Initial patchset Created 5 years, 9 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..9ce0c08cd82588e37837fe2837a7da8fb46a3184 100644
--- a/content/browser/android/composited_touch_handle_drawable.cc
+++ b/content/browser/android/composited_touch_handle_drawable.cc
@@ -10,6 +10,7 @@
#include "cc/layers/ui_resource_layer.h"
#include "jni/HandleViewResources_jni.h"
#include "ui/gfx/android/java_bitmap.h"
+#include "ui/gfx/skbitmap_operations.h"
namespace content {
@@ -44,10 +45,19 @@ class HandleResources {
Java_HandleViewResources_getRightHandleBitmap(env, context));
center_bitmap_ = CreateSkBitmapFromJavaBitmap(
Java_HandleViewResources_getCenterHandleBitmap(env, context));
+ left_inverted_bitmap_ = SkBitmapOperations::Rotate(
+ right_bitmap_, SkBitmapOperations::ROTATION_180_CW);
+ right_inverted_bitmap_ = SkBitmapOperations::Rotate(
+ left_bitmap_, SkBitmapOperations::ROTATION_180_CW);
+ center_inverted_bitmap_ = SkBitmapOperations::Rotate(
+ center_bitmap_, SkBitmapOperations::ROTATION_180_CW);
left_bitmap_.setImmutable();
right_bitmap_.setImmutable();
center_bitmap_.setImmutable();
+ left_inverted_bitmap_.setImmutable();
+ right_inverted_bitmap_.setImmutable();
+ center_inverted_bitmap_.setImmutable();
}
const SkBitmap& GetBitmap(ui::TouchHandleOrientation orientation) {
@@ -59,6 +69,20 @@ class HandleResources {
return right_bitmap_;
case ui::TouchHandleOrientation::CENTER:
return center_bitmap_;
+ case ui::TouchHandleOrientation::LEFT_INVERTED:
+ return left_inverted_bitmap_;
+ case ui::TouchHandleOrientation::RIGHT_INVERTED:
+ return right_inverted_bitmap_;
+ case ui::TouchHandleOrientation::LEFT_FLIPPED:
+ return right_bitmap_;
+ case ui::TouchHandleOrientation::RIGHT_FLIPPED:
+ return left_bitmap_;
+ case ui::TouchHandleOrientation::LEFT_FLIPPED_INVERTED:
+ return right_inverted_bitmap_;
+ case ui::TouchHandleOrientation::RIGHT_FLIPPED_INVERTED:
+ return left_inverted_bitmap_;
+ case ui::TouchHandleOrientation::CENTER_INVERTED:
+ return center_inverted_bitmap_;
case ui::TouchHandleOrientation::UNDEFINED:
NOTREACHED() << "Invalid touch handle orientation.";
};
@@ -69,6 +93,9 @@ class HandleResources {
SkBitmap left_bitmap_;
SkBitmap right_bitmap_;
SkBitmap center_bitmap_;
+ SkBitmap left_inverted_bitmap_;
+ SkBitmap right_inverted_bitmap_;
+ SkBitmap center_inverted_bitmap_;
bool loaded_;
DISALLOW_COPY_AND_ASSIGN(HandleResources);
@@ -120,6 +147,32 @@ void CompositedTouchHandleDrawable::SetOrientation(
case ui::TouchHandleOrientation::CENTER:
focal_offset_from_origin_ = gfx::Vector2dF(bitmap.width() * 0.5f, 0);
break;
+ case ui::TouchHandleOrientation::LEFT_INVERTED:
+ focal_offset_from_origin_ =
+ gfx::Vector2dF(bitmap.width() * 0.75f, bitmap.height());
+ break;
+ case ui::TouchHandleOrientation::RIGHT_INVERTED:
+ focal_offset_from_origin_ =
+ gfx::Vector2dF(bitmap.width() * 0.25f, bitmap.height());
+ break;
+ case ui::TouchHandleOrientation::LEFT_FLIPPED:
+ focal_offset_from_origin_ = gfx::Vector2dF(bitmap.width() * 0.25f, 0);
+ break;
+ case ui::TouchHandleOrientation::RIGHT_FLIPPED:
+ focal_offset_from_origin_ = gfx::Vector2dF(bitmap.width() * 0.75f, 0);
+ break;
+ case ui::TouchHandleOrientation::LEFT_FLIPPED_INVERTED:
+ focal_offset_from_origin_ =
+ gfx::Vector2dF(bitmap.width() * 0.25f, bitmap.height());
+ break;
+ case ui::TouchHandleOrientation::RIGHT_FLIPPED_INVERTED:
+ focal_offset_from_origin_ =
+ gfx::Vector2dF(bitmap.width() * 0.75f, bitmap.height());
+ break;
+ case ui::TouchHandleOrientation::CENTER_INVERTED:
+ focal_offset_from_origin_ =
+ gfx::Vector2dF(bitmap.width() * 0.5f, bitmap.height());
+ break;
case ui::TouchHandleOrientation::UNDEFINED:
NOTREACHED() << "Invalid touch handle orientation.";
break;

Powered by Google App Engine
This is Rietveld 408576698