OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "chrome/browser/android/compositor/scene_layer/toolbar_scene_layer.h" | 5 #include "chrome/browser/android/compositor/scene_layer/toolbar_scene_layer.h" |
6 | 6 |
7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
8 #include "base/android/jni_array.h" | 8 #include "base/android/jni_array.h" |
9 #include "cc/layers/solid_color_layer.h" | 9 #include "cc/layers/solid_color_layer.h" |
10 #include "chrome/browser/android/compositor/layer/toolbar_layer.h" | 10 #include "chrome/browser/android/compositor/layer/toolbar_layer.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 | 32 |
33 void ToolbarSceneLayer::UpdateToolbarLayer( | 33 void ToolbarSceneLayer::UpdateToolbarLayer( |
34 JNIEnv* env, | 34 JNIEnv* env, |
35 const JavaParamRef<jobject>& object, | 35 const JavaParamRef<jobject>& object, |
36 const JavaParamRef<jobject>& jresource_manager, | 36 const JavaParamRef<jobject>& jresource_manager, |
37 jint toolbar_resource_id, | 37 jint toolbar_resource_id, |
38 jint toolbar_background_color, | 38 jint toolbar_background_color, |
39 jint url_bar_resource_id, | 39 jint url_bar_resource_id, |
40 jfloat url_bar_alpha, | 40 jfloat url_bar_alpha, |
41 jfloat top_offset, | 41 jfloat top_offset, |
| 42 jfloat view_height, |
42 bool visible, | 43 bool visible, |
43 bool show_shadow) { | 44 bool show_shadow) { |
44 // If the toolbar layer has not been created yet, create it. | 45 // If the toolbar layer has not been created yet, create it. |
45 if (!toolbar_layer_) { | 46 if (!toolbar_layer_) { |
46 ui::ResourceManager* resource_manager = | 47 ui::ResourceManager* resource_manager = |
47 ui::ResourceManagerImpl::FromJavaObject(jresource_manager); | 48 ui::ResourceManagerImpl::FromJavaObject(jresource_manager); |
48 toolbar_layer_ = ToolbarLayer::Create(resource_manager); | 49 toolbar_layer_ = ToolbarLayer::Create(resource_manager); |
49 toolbar_layer_->layer()->SetHideLayerAndSubtree(true); | 50 toolbar_layer_->layer()->SetHideLayerAndSubtree(true); |
50 layer_->AddChild(toolbar_layer_->layer()); | 51 layer_->AddChild(toolbar_layer_->layer()); |
51 } | 52 } |
52 | 53 |
53 toolbar_layer_->layer()->SetHideLayerAndSubtree(!visible); | 54 toolbar_layer_->layer()->SetHideLayerAndSubtree(!visible); |
54 if (visible) { | 55 if (visible) { |
55 toolbar_layer_->layer()->SetPosition(gfx::PointF(0, top_offset)); | 56 toolbar_layer_->layer()->SetPosition(gfx::PointF(0, top_offset)); |
56 // If we're at rest, hide the shadow. The Android view should be drawing. | 57 // If we're at rest, hide the shadow. The Android view should be drawing. |
57 bool clip_shadow = top_offset >= 0.f && !show_shadow; | 58 bool clip_shadow = top_offset >= 0.f && !show_shadow; |
58 toolbar_layer_->PushResource(toolbar_resource_id, toolbar_background_color, | 59 toolbar_layer_->PushResource(toolbar_resource_id, toolbar_background_color, |
59 false, SK_ColorWHITE, url_bar_resource_id, | 60 false, SK_ColorWHITE, url_bar_resource_id, |
60 url_bar_alpha, false, clip_shadow); | 61 url_bar_alpha, view_height, false, |
| 62 clip_shadow); |
61 } | 63 } |
62 } | 64 } |
63 | 65 |
64 void ToolbarSceneLayer::UpdateProgressBar(JNIEnv* env, | 66 void ToolbarSceneLayer::UpdateProgressBar(JNIEnv* env, |
65 const JavaParamRef<jobject>& object, | 67 const JavaParamRef<jobject>& object, |
66 jint progress_bar_x, | 68 jint progress_bar_x, |
67 jint progress_bar_y, | 69 jint progress_bar_y, |
68 jint progress_bar_width, | 70 jint progress_bar_width, |
69 jint progress_bar_height, | 71 jint progress_bar_height, |
70 jint progress_bar_color, | 72 jint progress_bar_color, |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 ToolbarSceneLayer* toolbar_scene_layer = | 121 ToolbarSceneLayer* toolbar_scene_layer = |
120 new ToolbarSceneLayer(env, jobj); | 122 new ToolbarSceneLayer(env, jobj); |
121 return reinterpret_cast<intptr_t>(toolbar_scene_layer); | 123 return reinterpret_cast<intptr_t>(toolbar_scene_layer); |
122 } | 124 } |
123 | 125 |
124 bool RegisterToolbarSceneLayer(JNIEnv* env) { | 126 bool RegisterToolbarSceneLayer(JNIEnv* env) { |
125 return RegisterNativesImpl(env); | 127 return RegisterNativesImpl(env); |
126 } | 128 } |
127 | 129 |
128 } // namespace android | 130 } // namespace android |
OLD | NEW |