| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/contextual_search_scene_
layer.h" | 5 #include "chrome/browser/android/compositor/scene_layer/contextual_search_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/contextual_search_layer.h" | 10 #include "chrome/browser/android/compositor/layer/contextual_search_layer.h" |
| 11 #include "content/public/browser/android/compositor.h" | 11 #include "content/public/browser/android/compositor.h" |
| 12 #include "content/public/browser/android/content_view_core.h" | 12 #include "content/public/browser/web_contents.h" |
| 13 #include "jni/ContextualSearchSceneLayer_jni.h" | 13 #include "jni/ContextualSearchSceneLayer_jni.h" |
| 14 #include "ui/android/resources/resource_manager_impl.h" | 14 #include "ui/android/resources/resource_manager_impl.h" |
| 15 #include "ui/android/view_android.h" |
| 15 #include "ui/gfx/android/java_bitmap.h" | 16 #include "ui/gfx/android/java_bitmap.h" |
| 16 | 17 |
| 17 namespace chrome { | 18 namespace chrome { |
| 18 namespace android { | 19 namespace android { |
| 19 | 20 |
| 20 ContextualSearchSceneLayer::ContextualSearchSceneLayer(JNIEnv* env, | 21 ContextualSearchSceneLayer::ContextualSearchSceneLayer(JNIEnv* env, |
| 21 jobject jobj) | 22 jobject jobj) |
| 22 : SceneLayer(env, jobj), | 23 : SceneLayer(env, jobj), |
| 23 base_page_brightness_(1.0f), | 24 base_page_brightness_(1.0f), |
| 24 content_container_(cc::Layer::Create()) { | 25 content_container_(cc::Layer::Create()) { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 jint arrow_up_resource_id, | 59 jint arrow_up_resource_id, |
| 59 jint close_icon_resource_id, | 60 jint close_icon_resource_id, |
| 60 jint progress_bar_background_resource_id, | 61 jint progress_bar_background_resource_id, |
| 61 jint progress_bar_resource_id, | 62 jint progress_bar_resource_id, |
| 62 jint search_promo_resource_id, | 63 jint search_promo_resource_id, |
| 63 jint peek_promo_ripple_resource_id, | 64 jint peek_promo_ripple_resource_id, |
| 64 jint peek_promo_text_resource_id, | 65 jint peek_promo_text_resource_id, |
| 65 jfloat dp_to_px, | 66 jfloat dp_to_px, |
| 66 jfloat base_page_brightness, | 67 jfloat base_page_brightness, |
| 67 jfloat base_page_offset, | 68 jfloat base_page_offset, |
| 68 const JavaParamRef<jobject>& jcontent_view_core, | 69 const JavaParamRef<jobject>& jweb_contents, |
| 69 jboolean search_promo_visible, | 70 jboolean search_promo_visible, |
| 70 jfloat search_promo_height, | 71 jfloat search_promo_height, |
| 71 jfloat search_promo_opacity, | 72 jfloat search_promo_opacity, |
| 72 jboolean search_peek_promo_visible, | 73 jboolean search_peek_promo_visible, |
| 73 jfloat search_peek_promo_height, | 74 jfloat search_peek_promo_height, |
| 74 jfloat search_peek_promo_padding, | 75 jfloat search_peek_promo_padding, |
| 75 jfloat search_peek_promo_ripple_width, | 76 jfloat search_peek_promo_ripple_width, |
| 76 jfloat search_peek_promo_ripple_opacity, | 77 jfloat search_peek_promo_ripple_opacity, |
| 77 jfloat search_peek_promo_text_opacity, | 78 jfloat search_peek_promo_text_opacity, |
| 78 jfloat search_panel_x, | 79 jfloat search_panel_x, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 91 jfloat search_bar_shadow_opacity, | 92 jfloat search_bar_shadow_opacity, |
| 92 jboolean search_provider_icon_sprite_visible, | 93 jboolean search_provider_icon_sprite_visible, |
| 93 jfloat search_provider_icon_sprite_completion_percentage, | 94 jfloat search_provider_icon_sprite_completion_percentage, |
| 94 jfloat arrow_icon_opacity, | 95 jfloat arrow_icon_opacity, |
| 95 jfloat arrow_icon_rotation, | 96 jfloat arrow_icon_rotation, |
| 96 jfloat close_icon_opacity, | 97 jfloat close_icon_opacity, |
| 97 jboolean progress_bar_visible, | 98 jboolean progress_bar_visible, |
| 98 jfloat progress_bar_height, | 99 jfloat progress_bar_height, |
| 99 jfloat progress_bar_opacity, | 100 jfloat progress_bar_opacity, |
| 100 jint progress_bar_completion) { | 101 jint progress_bar_completion) { |
| 101 // NOTE(pedrosimonetti): The ContentViewCore might not exist at this time if | 102 // NOTE(pedrosimonetti): The WebContents might not exist at this time if |
| 102 // the Contextual Search Result has not been requested yet. In this case, | 103 // the Contextual Search Result has not been requested yet. In this case, |
| 103 // we'll pass NULL to Contextual Search's Layer Tree. | 104 // we'll pass NULL to Contextual Search's Layer Tree. |
| 104 content::ContentViewCore* content_view_core = | 105 content::WebContents* web_contents = |
| 105 !jcontent_view_core ? NULL | 106 content::WebContents::FromJavaWebContents(jweb_contents); |
| 106 : content::ContentViewCore::GetNativeContentViewCore( | 107 |
| 107 env, jcontent_view_core); | 108 scoped_refptr<cc::Layer> content_layer = |
| 109 web_contents ? web_contents->GetNativeView()->GetLayer() : nullptr; |
| 108 | 110 |
| 109 // Fade the base page out. | 111 // Fade the base page out. |
| 110 if (base_page_brightness_ != base_page_brightness) { | 112 if (base_page_brightness_ != base_page_brightness) { |
| 111 base_page_brightness_ = base_page_brightness; | 113 base_page_brightness_ = base_page_brightness; |
| 112 cc::FilterOperations filters; | 114 cc::FilterOperations filters; |
| 113 if (base_page_brightness < 1.f) { | 115 if (base_page_brightness < 1.f) { |
| 114 filters.Append( | 116 filters.Append( |
| 115 cc::FilterOperation::CreateBrightnessFilter(base_page_brightness)); | 117 cc::FilterOperation::CreateBrightnessFilter(base_page_brightness)); |
| 116 } | 118 } |
| 117 content_container_->SetFilters(filters); | 119 content_container_->SetFilters(filters); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 129 panel_icon_resource_id, | 131 panel_icon_resource_id, |
| 130 search_provider_icon_sprite_metadata_resource_id, | 132 search_provider_icon_sprite_metadata_resource_id, |
| 131 arrow_up_resource_id, | 133 arrow_up_resource_id, |
| 132 close_icon_resource_id, | 134 close_icon_resource_id, |
| 133 progress_bar_background_resource_id, | 135 progress_bar_background_resource_id, |
| 134 progress_bar_resource_id, | 136 progress_bar_resource_id, |
| 135 search_promo_resource_id, | 137 search_promo_resource_id, |
| 136 peek_promo_ripple_resource_id, | 138 peek_promo_ripple_resource_id, |
| 137 peek_promo_text_resource_id, | 139 peek_promo_text_resource_id, |
| 138 dp_to_px, | 140 dp_to_px, |
| 139 content_view_core, | 141 content_layer, |
| 140 search_promo_visible, | 142 search_promo_visible, |
| 141 search_promo_height, | 143 search_promo_height, |
| 142 search_promo_opacity, | 144 search_promo_opacity, |
| 143 search_peek_promo_visible, | 145 search_peek_promo_visible, |
| 144 search_peek_promo_height, | 146 search_peek_promo_height, |
| 145 search_peek_promo_padding, | 147 search_peek_promo_padding, |
| 146 search_peek_promo_ripple_width, | 148 search_peek_promo_ripple_width, |
| 147 search_peek_promo_ripple_opacity, | 149 search_peek_promo_ripple_opacity, |
| 148 search_peek_promo_text_opacity, | 150 search_peek_promo_text_opacity, |
| 149 search_panel_x, | 151 search_panel_x, |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 new ContextualSearchSceneLayer(env, jobj); | 209 new ContextualSearchSceneLayer(env, jobj); |
| 208 return reinterpret_cast<intptr_t>(tree_provider); | 210 return reinterpret_cast<intptr_t>(tree_provider); |
| 209 } | 211 } |
| 210 | 212 |
| 211 bool RegisterContextualSearchSceneLayer(JNIEnv* env) { | 213 bool RegisterContextualSearchSceneLayer(JNIEnv* env) { |
| 212 return RegisterNativesImpl(env); | 214 return RegisterNativesImpl(env); |
| 213 } | 215 } |
| 214 | 216 |
| 215 } // namespace android | 217 } // namespace android |
| 216 } // namespace chrome | 218 } // namespace chrome |
| OLD | NEW |