OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/browser/android/composited_touch_handle_drawable.h" | 5 #include "content/browser/android/composited_touch_handle_drawable.h" |
6 | 6 |
7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/trace_event/trace_event.h" | 9 #include "base/trace_event/trace_event.h" |
10 #include "cc/layers/ui_resource_layer.h" | 10 #include "cc/layers/ui_resource_layer.h" |
| 11 #include "content/public/browser/android/compositor.h" |
11 #include "jni/HandleViewResources_jni.h" | 12 #include "jni/HandleViewResources_jni.h" |
12 #include "ui/gfx/android/java_bitmap.h" | 13 #include "ui/gfx/android/java_bitmap.h" |
13 | 14 |
14 namespace content { | 15 namespace content { |
15 | 16 |
16 namespace { | 17 namespace { |
17 | 18 |
18 static SkBitmap CreateSkBitmapFromJavaBitmap( | 19 static SkBitmap CreateSkBitmapFromJavaBitmap( |
19 base::android::ScopedJavaLocalRef<jobject> jbitmap) { | 20 base::android::ScopedJavaLocalRef<jobject> jbitmap) { |
20 return jbitmap.is_null() | 21 return jbitmap.is_null() |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 base::LazyInstance<HandleResources>::Leaky g_selection_resources; | 78 base::LazyInstance<HandleResources>::Leaky g_selection_resources; |
78 | 79 |
79 } // namespace | 80 } // namespace |
80 | 81 |
81 CompositedTouchHandleDrawable::CompositedTouchHandleDrawable( | 82 CompositedTouchHandleDrawable::CompositedTouchHandleDrawable( |
82 cc::Layer* root_layer, | 83 cc::Layer* root_layer, |
83 float dpi_scale, | 84 float dpi_scale, |
84 jobject context) | 85 jobject context) |
85 : dpi_scale_(dpi_scale), | 86 : dpi_scale_(dpi_scale), |
86 orientation_(ui::TouchHandleOrientation::UNDEFINED), | 87 orientation_(ui::TouchHandleOrientation::UNDEFINED), |
87 layer_(cc::UIResourceLayer::Create()) { | 88 layer_(cc::UIResourceLayer::Create(Compositor::LayerSettings())) { |
88 g_selection_resources.Get().LoadIfNecessary(context); | 89 g_selection_resources.Get().LoadIfNecessary(context); |
89 DCHECK(root_layer); | 90 DCHECK(root_layer); |
90 root_layer->AddChild(layer_.get()); | 91 root_layer->AddChild(layer_.get()); |
91 } | 92 } |
92 | 93 |
93 CompositedTouchHandleDrawable::~CompositedTouchHandleDrawable() { | 94 CompositedTouchHandleDrawable::~CompositedTouchHandleDrawable() { |
94 DetachLayer(); | 95 DetachLayer(); |
95 } | 96 } |
96 | 97 |
97 void CompositedTouchHandleDrawable::SetEnabled(bool enabled) { | 98 void CompositedTouchHandleDrawable::SetEnabled(bool enabled) { |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 void CompositedTouchHandleDrawable::UpdateLayerPosition() { | 158 void CompositedTouchHandleDrawable::UpdateLayerPosition() { |
158 layer_->SetPosition(focal_position_ - focal_offset_from_origin_); | 159 layer_->SetPosition(focal_position_ - focal_offset_from_origin_); |
159 } | 160 } |
160 | 161 |
161 // static | 162 // static |
162 bool CompositedTouchHandleDrawable::RegisterHandleViewResources(JNIEnv* env) { | 163 bool CompositedTouchHandleDrawable::RegisterHandleViewResources(JNIEnv* env) { |
163 return RegisterNativesImpl(env); | 164 return RegisterNativesImpl(env); |
164 } | 165 } |
165 | 166 |
166 } // namespace content | 167 } // namespace content |
OLD | NEW |