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