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