Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(90)

Side by Side Diff: chrome/browser/android/compositor/scene_layer/contextual_search_scene_layer.cc

Issue 1337703002: [Contextual Search] Add support for crushed sprites and animate the search provider icon (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Manually scale crushed sprites Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "chrome/browser/android/compositor/layer/contextual_search_layer.h" 9 #include "chrome/browser/android/compositor/layer/contextual_search_layer.h"
9 #include "content/public/browser/android/content_view_core.h" 10 #include "content/public/browser/android/content_view_core.h"
10 #include "jni/ContextualSearchSceneLayer_jni.h" 11 #include "jni/ContextualSearchSceneLayer_jni.h"
11 #include "ui/android/resources/resource_manager_impl.h" 12 #include "ui/android/resources/resource_manager_impl.h"
12 13
13 namespace chrome { 14 namespace chrome {
14 namespace android { 15 namespace android {
15 16
16 ContextualSearchSceneLayer::ContextualSearchSceneLayer(JNIEnv* env, 17 ContextualSearchSceneLayer::ContextualSearchSceneLayer(JNIEnv* env,
17 jobject jobj) 18 jobject jobj)
18 : SceneLayer(env, jobj) { 19 : SceneLayer(env, jobj) {
19 } 20 }
20 21
21 ContextualSearchSceneLayer::~ContextualSearchSceneLayer() { 22 ContextualSearchSceneLayer::~ContextualSearchSceneLayer() {
22 } 23 }
23 24
24 void ContextualSearchSceneLayer::UpdateContextualSearchLayer( 25 void ContextualSearchSceneLayer::UpdateContextualSearchLayer(
25 JNIEnv* env, 26 JNIEnv* env,
26 jobject object, 27 jobject object,
27 jint search_bar_background_resource_id, 28 jint search_bar_background_resource_id,
28 jint search_context_resource_id, 29 jint search_context_resource_id,
29 jint search_term_resource_id, 30 jint search_term_resource_id,
30 jint search_bar_shadow_resource_id, 31 jint search_bar_shadow_resource_id,
31 jint search_provider_icon_resource_id,
32 jint arrow_up_resource_id, 32 jint arrow_up_resource_id,
33 jint close_icon_resource_id, 33 jint close_icon_resource_id,
34 jint progress_bar_background_resource_id, 34 jint progress_bar_background_resource_id,
35 jint progress_bar_resource_id, 35 jint progress_bar_resource_id,
36 jint search_promo_resource_id, 36 jint search_promo_resource_id,
37 jobject jcontent_view_core, 37 jobject jcontent_view_core,
38 jboolean search_promo_visible, 38 jboolean search_promo_visible,
39 jfloat search_promo_height, 39 jfloat search_promo_height,
40 jfloat search_promo_opacity, 40 jfloat search_promo_opacity,
41 jfloat search_panel_X, 41 jfloat search_panel_X,
42 jfloat search_panel_y, 42 jfloat search_panel_y,
43 jfloat search_panel_width, 43 jfloat search_panel_width,
44 jfloat search_panel_height, 44 jfloat search_panel_height,
45 jfloat search_bar_margin_side, 45 jfloat search_bar_margin_side,
46 jfloat search_bar_height, 46 jfloat search_bar_height,
47 jfloat search_context_opacity, 47 jfloat search_context_opacity,
48 jfloat search_term_opacity, 48 jfloat search_term_opacity,
49 jboolean search_bar_border_visible, 49 jboolean search_bar_border_visible,
50 jfloat search_bar_border_y, 50 jfloat search_bar_border_y,
51 jfloat search_bar_border_height, 51 jfloat search_bar_border_height,
52 jboolean search_bar_shadow_visible, 52 jboolean search_bar_shadow_visible,
53 jfloat search_bar_shadow_opacity, 53 jfloat search_bar_shadow_opacity,
54 jboolean search_provider_icon_sprite_visible,
55 jfloat search_provider_icon_sprite_size,
56 jfloat search_provider_icon_sprite_scale,
57 jobject search_provider_icon_sprite_bitmap,
58 jintArray search_provider_icon_sprite_rects,
59 jboolean search_provider_icon_sprite_paint_previous_frames,
54 jfloat arrow_icon_opacity, 60 jfloat arrow_icon_opacity,
55 jfloat arrow_icon_rotation, 61 jfloat arrow_icon_rotation,
56 jfloat close_icon_opacity, 62 jfloat close_icon_opacity,
57 jboolean progress_bar_visible, 63 jboolean progress_bar_visible,
58 jfloat progress_bar_y, 64 jfloat progress_bar_y,
59 jfloat progress_bar_height, 65 jfloat progress_bar_height,
60 jfloat progress_bar_opacity, 66 jfloat progress_bar_opacity,
61 jint progress_bar_completion, 67 jint progress_bar_completion,
62 jobject jresource_manager) { 68 jobject jresource_manager) {
63 ui::ResourceManager* resource_manager = 69 ui::ResourceManager* resource_manager =
64 ui::ResourceManagerImpl::FromJavaObject(jresource_manager); 70 ui::ResourceManagerImpl::FromJavaObject(jresource_manager);
65 // Lazily construct the contextual search layer, as the feature is only 71 // Lazily construct the contextual search layer, as the feature is only
66 // conditionally enabled. 72 // conditionally enabled.
67 if (!contextual_search_layer_.get()) { 73 if (!contextual_search_layer_.get()) {
68 if (!resource_manager) 74 if (!resource_manager)
69 return; 75 return;
70 contextual_search_layer_ = ContextualSearchLayer::Create(resource_manager); 76 contextual_search_layer_ = ContextualSearchLayer::Create(resource_manager);
71 layer_->AddChild(contextual_search_layer_->layer()); 77 layer_->AddChild(contextual_search_layer_->layer());
72 } 78 }
73 79
74 // NOTE(pedrosimonetti): The ContentViewCore might not exist at this time if 80 // NOTE(pedrosimonetti): The ContentViewCore might not exist at this time if
75 // the Contextual Search Result has not been requested yet. In this case, 81 // the Contextual Search Result has not been requested yet. In this case,
76 // we'll pass NULL to Contextual Search's Layer Tree. 82 // we'll pass NULL to Contextual Search's Layer Tree.
77 content::ContentViewCore* content_view_core = 83 content::ContentViewCore* content_view_core =
78 !jcontent_view_core ? NULL 84 !jcontent_view_core ? NULL
79 : content::ContentViewCore::GetNativeContentViewCore( 85 : content::ContentViewCore::GetNativeContentViewCore(
80 env, jcontent_view_core); 86 env, jcontent_view_core);
81 87
88 std::vector<int> search_provider_icon_sprite_rects_array;
89 base::android::JavaIntArrayToIntVector(
90 env, search_provider_icon_sprite_rects,
91 &search_provider_icon_sprite_rects_array);
92
93 SkBitmap search_provider_icon_sprite_skbitmap =
94 gfx::CreateSkBitmapFromJavaBitmap(
95 gfx::JavaBitmap(search_provider_icon_sprite_bitmap));
96
82 contextual_search_layer_->SetProperties( 97 contextual_search_layer_->SetProperties(
83 search_bar_background_resource_id, 98 search_bar_background_resource_id,
84 search_context_resource_id, 99 search_context_resource_id,
85 search_term_resource_id, 100 search_term_resource_id,
86 search_bar_shadow_resource_id, 101 search_bar_shadow_resource_id,
87 search_provider_icon_resource_id,
88 arrow_up_resource_id, 102 arrow_up_resource_id,
89 close_icon_resource_id, 103 close_icon_resource_id,
90 progress_bar_background_resource_id, 104 progress_bar_background_resource_id,
91 progress_bar_resource_id, 105 progress_bar_resource_id,
92 search_promo_resource_id, 106 search_promo_resource_id,
93 content_view_core, 107 content_view_core,
94 search_promo_visible, 108 search_promo_visible,
95 search_promo_height, 109 search_promo_height,
96 search_promo_opacity, 110 search_promo_opacity,
97 search_panel_X, 111 search_panel_X,
98 search_panel_y, 112 search_panel_y,
99 search_panel_width, 113 search_panel_width,
100 search_panel_height, 114 search_panel_height,
101 search_bar_margin_side, 115 search_bar_margin_side,
102 search_bar_height, 116 search_bar_height,
103 search_context_opacity, 117 search_context_opacity,
104 search_term_opacity, 118 search_term_opacity,
105 search_bar_border_visible, 119 search_bar_border_visible,
106 search_bar_border_y, 120 search_bar_border_y,
107 search_bar_border_height, 121 search_bar_border_height,
108 search_bar_shadow_visible, 122 search_bar_shadow_visible,
109 search_bar_shadow_opacity, 123 search_bar_shadow_opacity,
124 search_provider_icon_sprite_visible,
125 search_provider_icon_sprite_size,
126 search_provider_icon_sprite_scale,
127 search_provider_icon_sprite_skbitmap,
128 search_provider_icon_sprite_rects_array,
129 search_provider_icon_sprite_paint_previous_frames,
110 arrow_icon_opacity, 130 arrow_icon_opacity,
111 arrow_icon_rotation, 131 arrow_icon_rotation,
112 close_icon_opacity, 132 close_icon_opacity,
113 progress_bar_visible, 133 progress_bar_visible,
114 progress_bar_y, 134 progress_bar_y,
115 progress_bar_height, 135 progress_bar_height,
116 progress_bar_opacity, 136 progress_bar_opacity,
117 progress_bar_completion); 137 progress_bar_completion);
118 } 138 }
119 139
120 static jlong Init(JNIEnv* env, const JavaParamRef<jobject>& jobj) { 140 static jlong Init(JNIEnv* env, const JavaParamRef<jobject>& jobj) {
121 // This will automatically bind to the Java object and pass ownership there. 141 // This will automatically bind to the Java object and pass ownership there.
122 ContextualSearchSceneLayer* tree_provider = 142 ContextualSearchSceneLayer* tree_provider =
123 new ContextualSearchSceneLayer(env, jobj); 143 new ContextualSearchSceneLayer(env, jobj);
124 return reinterpret_cast<intptr_t>(tree_provider); 144 return reinterpret_cast<intptr_t>(tree_provider);
125 } 145 }
126 146
127 bool RegisterContextualSearchSceneLayer(JNIEnv* env) { 147 bool RegisterContextualSearchSceneLayer(JNIEnv* env) {
128 return RegisterNativesImpl(env); 148 return RegisterNativesImpl(env);
129 } 149 }
130 150
131 } // namespace android 151 } // namespace android
132 } // namespace chrome 152 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698