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/android/context_utils.h" | 7 #include "base/android/context_utils.h" |
8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/trace_event/trace_event.h" | 11 #include "base/trace_event/trace_event.h" |
12 #include "cc/layers/layer_settings.h" | |
13 #include "cc/layers/ui_resource_layer.h" | 12 #include "cc/layers/ui_resource_layer.h" |
14 #include "content/public/browser/android/compositor.h" | 13 #include "content/public/browser/android/compositor.h" |
15 #include "jni/HandleViewResources_jni.h" | 14 #include "jni/HandleViewResources_jni.h" |
16 #include "ui/gfx/android/java_bitmap.h" | 15 #include "ui/gfx/android/java_bitmap.h" |
17 | 16 |
18 namespace content { | 17 namespace content { |
19 | 18 |
20 namespace { | 19 namespace { |
21 | 20 |
22 static SkBitmap CreateSkBitmapFromJavaBitmap( | 21 static SkBitmap CreateSkBitmapFromJavaBitmap( |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 base::LazyInstance<HandleResources>::Leaky g_selection_resources; | 89 base::LazyInstance<HandleResources>::Leaky g_selection_resources; |
91 | 90 |
92 } // namespace | 91 } // namespace |
93 | 92 |
94 CompositedTouchHandleDrawable::CompositedTouchHandleDrawable( | 93 CompositedTouchHandleDrawable::CompositedTouchHandleDrawable( |
95 cc::Layer* root_layer, | 94 cc::Layer* root_layer, |
96 float dpi_scale, | 95 float dpi_scale, |
97 jobject context) | 96 jobject context) |
98 : dpi_scale_(dpi_scale), | 97 : dpi_scale_(dpi_scale), |
99 orientation_(ui::TouchHandleOrientation::UNDEFINED), | 98 orientation_(ui::TouchHandleOrientation::UNDEFINED), |
100 layer_(cc::UIResourceLayer::Create(cc::LayerSettings())) { | 99 layer_(cc::UIResourceLayer::Create()) { |
101 g_selection_resources.Get().LoadIfNecessary(context); | 100 g_selection_resources.Get().LoadIfNecessary(context); |
102 drawable_horizontal_padding_ratio_ = | 101 drawable_horizontal_padding_ratio_ = |
103 g_selection_resources.Get().GetDrawableHorizontalPaddingRatio(); | 102 g_selection_resources.Get().GetDrawableHorizontalPaddingRatio(); |
104 DCHECK(root_layer); | 103 DCHECK(root_layer); |
105 root_layer->AddChild(layer_.get()); | 104 root_layer->AddChild(layer_.get()); |
106 } | 105 } |
107 | 106 |
108 CompositedTouchHandleDrawable::~CompositedTouchHandleDrawable() { | 107 CompositedTouchHandleDrawable::~CompositedTouchHandleDrawable() { |
109 DetachLayer(); | 108 DetachLayer(); |
110 } | 109 } |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 void CompositedTouchHandleDrawable::UpdateLayerPosition() { | 178 void CompositedTouchHandleDrawable::UpdateLayerPosition() { |
180 layer_->SetPosition(origin_position_); | 179 layer_->SetPosition(origin_position_); |
181 } | 180 } |
182 | 181 |
183 // static | 182 // static |
184 bool CompositedTouchHandleDrawable::RegisterHandleViewResources(JNIEnv* env) { | 183 bool CompositedTouchHandleDrawable::RegisterHandleViewResources(JNIEnv* env) { |
185 return RegisterNativesImpl(env); | 184 return RegisterNativesImpl(env); |
186 } | 185 } |
187 | 186 |
188 } // namespace content | 187 } // namespace content |
OLD | NEW |