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

Side by Side Diff: chrome/browser/android/compositor/layer/contextual_search_layer.cc

Issue 2746483003: ui/android: Fix Resource meta-data sharing with ResourceManager. (Closed)
Patch Set: jni Created 3 years, 9 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 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 "chrome/browser/android/compositor/layer/contextual_search_layer.h" 5 #include "chrome/browser/android/compositor/layer/contextual_search_layer.h"
6 6
7 #include "cc/layers/layer.h" 7 #include "cc/layers/layer.h"
8 #include "cc/layers/nine_patch_layer.h" 8 #include "cc/layers/nine_patch_layer.h"
9 #include "cc/layers/solid_color_layer.h" 9 #include "cc/layers/solid_color_layer.h"
10 #include "cc/layers/ui_resource_layer.h" 10 #include "cc/layers/ui_resource_layer.h"
11 #include "cc/resources/scoped_ui_resource.h" 11 #include "cc/resources/scoped_ui_resource.h"
12 #include "chrome/browser/android/compositor/layer/crushed_sprite_layer.h" 12 #include "chrome/browser/android/compositor/layer/crushed_sprite_layer.h"
13 #include "content/public/browser/android/compositor.h" 13 #include "content/public/browser/android/compositor.h"
14 #include "third_party/skia/include/core/SkColor.h" 14 #include "third_party/skia/include/core/SkColor.h"
15 #include "ui/android/resources/crushed_sprite_resource.h" 15 #include "ui/android/resources/crushed_sprite_resource.h"
16 #include "ui/android/resources/nine_patch_resource.h"
16 #include "ui/android/resources/resource_manager.h" 17 #include "ui/android/resources/resource_manager.h"
17 #include "ui/base/l10n/l10n_util_android.h" 18 #include "ui/base/l10n/l10n_util_android.h"
18 #include "ui/gfx/color_utils.h" 19 #include "ui/gfx/color_utils.h"
19 20
20 namespace { 21 namespace {
21 22
22 const SkColor kSearchBackgroundColor = SkColorSetRGB(0xee, 0xee, 0xee); 23 const SkColor kSearchBackgroundColor = SkColorSetRGB(0xee, 0xee, 0xee);
23 const SkColor kSearchBarBackgroundColor = SkColorSetRGB(0xff, 0xff, 0xff); 24 const SkColor kSearchBarBackgroundColor = SkColorSetRGB(0xff, 0xff, 0xff);
24 const SkColor kPeekPromoRippleBackgroundColor = SkColorSetRGB(0x42, 0x85, 0xF4); 25 const SkColor kPeekPromoRippleBackgroundColor = SkColorSetRGB(0x42, 0x85, 0xF4);
25 const SkColor kTouchHighlightColor = SkColorSetARGB(0x33, 0x99, 0x99, 0x99); 26 const SkColor kTouchHighlightColor = SkColorSetARGB(0x33, 0x99, 0x99, 0x99);
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 search_bar_shadow_opacity, 144 search_bar_shadow_opacity,
144 close_icon_opacity); 145 close_icon_opacity);
145 146
146 bool is_rtl = l10n_util::IsLayoutRtl(); 147 bool is_rtl = l10n_util::IsLayoutRtl();
147 148
148 // --------------------------------------------------------------------------- 149 // ---------------------------------------------------------------------------
149 // Peek Promo 150 // Peek Promo
150 // --------------------------------------------------------------------------- 151 // ---------------------------------------------------------------------------
151 if (search_peek_promo_visible) { 152 if (search_peek_promo_visible) {
152 // Grabs the Search Opt Out Promo resource. 153 // Grabs the Search Opt Out Promo resource.
153 ui::ResourceManager::Resource* peek_promo_text_resource = 154 ui::Resource* peek_promo_text_resource = resource_manager_->GetResource(
154 resource_manager_->GetResource(ui::ANDROID_RESOURCE_TYPE_DYNAMIC, 155 ui::ANDROID_RESOURCE_TYPE_DYNAMIC, peek_promo_text_resource_id);
155 peek_promo_text_resource_id);
156 156
157 ui::ResourceManager::Resource* peek_promo_ripple_resource = 157 ui::NinePatchResource* peek_promo_ripple_resource =
158 resource_manager_->GetResource(ui::ANDROID_RESOURCE_TYPE_STATIC, 158 ui::NinePatchResource::From(resource_manager_->GetResource(
159 peek_promo_ripple_resource_id); 159 ui::ANDROID_RESOURCE_TYPE_STATIC, peek_promo_ripple_resource_id));
160 160
161 // ----------------------------------------------------------------- 161 // -----------------------------------------------------------------
162 // Peek Promo Container 162 // Peek Promo Container
163 // ----------------------------------------------------------------- 163 // -----------------------------------------------------------------
164 if (peek_promo_container_->parent() != layer_) { 164 if (peek_promo_container_->parent() != layer_) {
165 layer_->AddChild(peek_promo_container_); 165 layer_->AddChild(peek_promo_container_);
166 } 166 }
167 167
168 gfx::Size peek_promo_size(search_panel_width, search_peek_promo_height); 168 gfx::Size peek_promo_size(search_panel_width, search_peek_promo_height);
169 peek_promo_container_->SetBounds(peek_promo_size); 169 peek_promo_container_->SetBounds(peek_promo_size);
(...skipping 25 matching lines...) Expand all
195 195
196 float ripple_rotation = 0.f; 196 float ripple_rotation = 0.f;
197 float ripple_left = 0.f; 197 float ripple_left = 0.f;
198 if (is_rtl) { 198 if (is_rtl) {
199 // Rotate the ripple 180 degrees to make it point to the left side. 199 // Rotate the ripple 180 degrees to make it point to the left side.
200 ripple_rotation = 180.f; 200 ripple_rotation = 180.f;
201 ripple_left = search_panel_width - peek_promo_ripple_size.width(); 201 ripple_left = search_panel_width - peek_promo_ripple_size.width();
202 } 202 }
203 203
204 peek_promo_ripple_->SetUIResourceId( 204 peek_promo_ripple_->SetUIResourceId(
205 peek_promo_ripple_resource->ui_resource->id()); 205 peek_promo_ripple_resource->ui_resource()->id());
206 peek_promo_ripple_->SetBorder(peek_promo_ripple_border); 206 peek_promo_ripple_->SetBorder(peek_promo_ripple_border);
207 peek_promo_ripple_->SetAperture(peek_promo_ripple_resource->aperture); 207 peek_promo_ripple_->SetAperture(peek_promo_ripple_resource->aperture());
208 peek_promo_ripple_->SetBounds(peek_promo_ripple_size); 208 peek_promo_ripple_->SetBounds(peek_promo_ripple_size);
209 peek_promo_ripple_->SetPosition(gfx::PointF(ripple_left, 0.f)); 209 peek_promo_ripple_->SetPosition(gfx::PointF(ripple_left, 0.f));
210 peek_promo_ripple_->SetOpacity(search_peek_promo_ripple_opacity); 210 peek_promo_ripple_->SetOpacity(search_peek_promo_ripple_opacity);
211 211
212 if (ripple_rotation != 0.f) { 212 if (ripple_rotation != 0.f) {
213 // Apply rotation about the center of the resource. 213 // Apply rotation about the center of the resource.
214 float pivot_x = floor(peek_promo_ripple_size.width() / 2); 214 float pivot_x = floor(peek_promo_ripple_size.width() / 2);
215 float pivot_y = floor(peek_promo_ripple_size.height() / 2); 215 float pivot_y = floor(peek_promo_ripple_size.height() / 2);
216 gfx::PointF pivot_origin(pivot_x, pivot_y); 216 gfx::PointF pivot_origin(pivot_x, pivot_y);
217 gfx::Transform transform; 217 gfx::Transform transform;
218 transform.Translate(pivot_origin.x(), pivot_origin.y()); 218 transform.Translate(pivot_origin.x(), pivot_origin.y());
219 transform.RotateAboutZAxis(ripple_rotation); 219 transform.RotateAboutZAxis(ripple_rotation);
220 transform.Translate(-pivot_origin.x(), -pivot_origin.y()); 220 transform.Translate(-pivot_origin.x(), -pivot_origin.y());
221 peek_promo_ripple_->SetTransform(transform); 221 peek_promo_ripple_->SetTransform(transform);
222 } 222 }
223 223
224 // ----------------------------------------------------------------- 224 // -----------------------------------------------------------------
225 // Peek Promo Text 225 // Peek Promo Text
226 // ----------------------------------------------------------------- 226 // -----------------------------------------------------------------
227 if (peek_promo_text_resource) { 227 if (peek_promo_text_resource) {
228 peek_promo_text_->SetUIResourceId( 228 peek_promo_text_->SetUIResourceId(
229 peek_promo_text_resource->ui_resource->id()); 229 peek_promo_text_resource->ui_resource()->id());
230 peek_promo_text_->SetBounds(peek_promo_text_resource->size); 230 peek_promo_text_->SetBounds(peek_promo_text_resource->size());
231 peek_promo_text_->SetPosition( 231 peek_promo_text_->SetPosition(
232 gfx::PointF(0.f, search_peek_promo_padding)); 232 gfx::PointF(0.f, search_peek_promo_padding));
233 peek_promo_text_->SetOpacity(search_peek_promo_text_opacity); 233 peek_promo_text_->SetOpacity(search_peek_promo_text_opacity);
234 } 234 }
235 } else { 235 } else {
236 // Peek Promo Container 236 // Peek Promo Container
237 if (peek_promo_container_.get() && peek_promo_container_->parent()) 237 if (peek_promo_container_.get() && peek_promo_container_->parent())
238 peek_promo_container_->RemoveFromParent(); 238 peek_promo_container_->RemoveFromParent();
239 } 239 }
240 240
241 // --------------------------------------------------------------------------- 241 // ---------------------------------------------------------------------------
242 // Search Term, Context and Search Caption 242 // Search Term, Context and Search Caption
243 // --------------------------------------------------------------------------- 243 // ---------------------------------------------------------------------------
244 SetupTextLayer( 244 SetupTextLayer(
245 search_bar_top, 245 search_bar_top,
246 search_bar_height, 246 search_bar_height,
247 search_text_layer_min_height, 247 search_text_layer_min_height,
248 search_caption_resource_id, 248 search_caption_resource_id,
249 search_caption_visible, 249 search_caption_visible,
250 search_caption_animation_percentage, 250 search_caption_animation_percentage,
251 search_term_opacity, 251 search_term_opacity,
252 search_context_resource_id, 252 search_context_resource_id,
253 search_context_opacity, 253 search_context_opacity,
254 search_term_caption_spacing); 254 search_term_caption_spacing);
255 255
256 // --------------------------------------------------------------------------- 256 // ---------------------------------------------------------------------------
257 // Arrow Icon 257 // Arrow Icon
258 // --------------------------------------------------------------------------- 258 // ---------------------------------------------------------------------------
259 // Grabs the arrow icon resource. 259 // Grabs the arrow icon resource.
260 ui::ResourceManager::Resource* arrow_icon_resource = 260 ui::Resource* arrow_icon_resource = resource_manager_->GetResource(
261 resource_manager_->GetResource(ui::ANDROID_RESOURCE_TYPE_STATIC, 261 ui::ANDROID_RESOURCE_TYPE_STATIC, arrow_up_resource_id);
262 arrow_up_resource_id);
263 262
264 // Positions the icon at the end of the bar. 263 // Positions the icon at the end of the bar.
265 float arrow_icon_left; 264 float arrow_icon_left;
266 if (is_rtl) { 265 if (is_rtl) {
267 arrow_icon_left = search_bar_margin_side; 266 arrow_icon_left = search_bar_margin_side;
268 } else { 267 } else {
269 arrow_icon_left = search_panel_width - arrow_icon_resource->size.width() 268 arrow_icon_left = search_panel_width - arrow_icon_resource->size().width() -
270 - search_bar_margin_side; 269 search_bar_margin_side;
271 } 270 }
272 271
273 // Centers the Arrow Icon vertically in the bar. 272 // Centers the Arrow Icon vertically in the bar.
274 float arrow_icon_top = search_bar_top + search_bar_height / 2 - 273 float arrow_icon_top = search_bar_top + search_bar_height / 2 -
275 arrow_icon_resource->size.height() / 2; 274 arrow_icon_resource->size().height() / 2;
276 275
277 arrow_icon_->SetUIResourceId(arrow_icon_resource->ui_resource->id()); 276 arrow_icon_->SetUIResourceId(arrow_icon_resource->ui_resource()->id());
278 arrow_icon_->SetBounds(arrow_icon_resource->size); 277 arrow_icon_->SetBounds(arrow_icon_resource->size());
279 arrow_icon_->SetPosition( 278 arrow_icon_->SetPosition(
280 gfx::PointF(arrow_icon_left, arrow_icon_top)); 279 gfx::PointF(arrow_icon_left, arrow_icon_top));
281 arrow_icon_->SetOpacity(arrow_icon_opacity); 280 arrow_icon_->SetOpacity(arrow_icon_opacity);
282 281
283 gfx::Transform transform; 282 gfx::Transform transform;
284 if (arrow_icon_rotation != 0.f) { 283 if (arrow_icon_rotation != 0.f) {
285 // Apply rotation about the center of the icon. 284 // Apply rotation about the center of the icon.
286 float pivot_x = floor(arrow_icon_resource->size.width() / 2); 285 float pivot_x = floor(arrow_icon_resource->size().width() / 2);
287 float pivot_y = floor(arrow_icon_resource->size.height() / 2); 286 float pivot_y = floor(arrow_icon_resource->size().height() / 2);
288 gfx::PointF pivot_origin(pivot_x, pivot_y); 287 gfx::PointF pivot_origin(pivot_x, pivot_y);
289 transform.Translate(pivot_origin.x(), pivot_origin.y()); 288 transform.Translate(pivot_origin.x(), pivot_origin.y());
290 transform.RotateAboutZAxis(arrow_icon_rotation); 289 transform.RotateAboutZAxis(arrow_icon_rotation);
291 transform.Translate(-pivot_origin.x(), -pivot_origin.y()); 290 transform.Translate(-pivot_origin.x(), -pivot_origin.y());
292 } 291 }
293 arrow_icon_->SetTransform(transform); 292 arrow_icon_->SetTransform(transform);
294 293
295 // --------------------------------------------------------------------------- 294 // ---------------------------------------------------------------------------
296 // Search Promo 295 // Search Promo
297 // --------------------------------------------------------------------------- 296 // ---------------------------------------------------------------------------
298 if (search_promo_visible) { 297 if (search_promo_visible) {
299 // Grabs the Search Opt Out Promo resource. 298 // Grabs the Search Opt Out Promo resource.
300 ui::ResourceManager::Resource* search_promo_resource = 299 ui::Resource* search_promo_resource = resource_manager_->GetResource(
301 resource_manager_->GetResource(ui::ANDROID_RESOURCE_TYPE_DYNAMIC, 300 ui::ANDROID_RESOURCE_TYPE_DYNAMIC, search_promo_resource_id);
302 search_promo_resource_id);
303 // Search Promo Container 301 // Search Promo Container
304 if (search_promo_container_->parent() != layer_) { 302 if (search_promo_container_->parent() != layer_) {
305 // NOTE(pedrosimonetti): The Promo layer should be always placed before 303 // NOTE(pedrosimonetti): The Promo layer should be always placed before
306 // Search Bar Shadow to make sure it won't occlude the shadow. 304 // Search Bar Shadow to make sure it won't occlude the shadow.
307 layer_->InsertChild(search_promo_container_, 0); 305 layer_->InsertChild(search_promo_container_, 0);
308 } 306 }
309 307
310 if (search_promo_resource) { 308 if (search_promo_resource) {
311 int search_promo_content_height = search_promo_resource->size.height(); 309 int search_promo_content_height = search_promo_resource->size().height();
312 gfx::Size search_promo_size(search_panel_width, search_promo_height); 310 gfx::Size search_promo_size(search_panel_width, search_promo_height);
313 search_promo_container_->SetBounds(search_promo_size); 311 search_promo_container_->SetBounds(search_promo_size);
314 search_promo_container_->SetPosition(gfx::PointF(0.f, search_bar_bottom)); 312 search_promo_container_->SetPosition(gfx::PointF(0.f, search_bar_bottom));
315 search_promo_container_->SetMasksToBounds(true); 313 search_promo_container_->SetMasksToBounds(true);
316 314
317 // Search Promo 315 // Search Promo
318 if (search_promo_->parent() != search_promo_container_) 316 if (search_promo_->parent() != search_promo_container_)
319 search_promo_container_->AddChild(search_promo_); 317 search_promo_container_->AddChild(search_promo_);
320 318
321 search_promo_->SetUIResourceId(search_promo_resource->ui_resource->id()); 319 search_promo_->SetUIResourceId(
322 search_promo_->SetBounds(search_promo_resource->size); 320 search_promo_resource->ui_resource()->id());
321 search_promo_->SetBounds(search_promo_resource->size());
323 // Align promo at the bottom of the container so the confirmation button 322 // Align promo at the bottom of the container so the confirmation button
324 // is is not clipped when resizing the promo. 323 // is is not clipped when resizing the promo.
325 search_promo_->SetPosition( 324 search_promo_->SetPosition(
326 gfx::PointF(0.f, search_promo_height - search_promo_content_height)); 325 gfx::PointF(0.f, search_promo_height - search_promo_content_height));
327 search_promo_->SetOpacity(search_promo_opacity); 326 search_promo_->SetOpacity(search_promo_opacity);
328 } 327 }
329 } else { 328 } else {
330 // Search Promo Container 329 // Search Promo Container
331 if (search_promo_container_.get() && search_promo_container_->parent()) 330 if (search_promo_container_.get() && search_promo_container_->parent())
332 search_promo_container_->RemoveFromParent(); 331 search_promo_container_->RemoveFromParent();
333 } 332 }
334 333
335 // --------------------------------------------------------------------------- 334 // ---------------------------------------------------------------------------
336 // Progress Bar 335 // Progress Bar
337 // --------------------------------------------------------------------------- 336 // ---------------------------------------------------------------------------
338 if (should_render_progress_bar) { 337 if (should_render_progress_bar) {
339 // Grabs Progress Bar resources. 338 // Grabs Progress Bar resources.
340 ui::ResourceManager::Resource* progress_bar_background_resource = 339 ui::NinePatchResource* progress_bar_background_resource =
341 resource_manager_->GetResource(ui::ANDROID_RESOURCE_TYPE_STATIC, 340 ui::NinePatchResource::From(resource_manager_->GetResource(
342 progress_bar_background_resource_id); 341 ui::ANDROID_RESOURCE_TYPE_STATIC,
343 ui::ResourceManager::Resource* progress_bar_resource = 342 progress_bar_background_resource_id));
344 resource_manager_->GetResource(ui::ANDROID_RESOURCE_TYPE_STATIC, 343 ui::NinePatchResource* progress_bar_resource =
345 progress_bar_resource_id); 344 ui::NinePatchResource::From(resource_manager_->GetResource(
345 ui::ANDROID_RESOURCE_TYPE_STATIC, progress_bar_resource_id));
346 346
347 DCHECK(progress_bar_background_resource); 347 DCHECK(progress_bar_background_resource);
348 DCHECK(progress_bar_resource); 348 DCHECK(progress_bar_resource);
349 349
350 // Progress Bar Background 350 // Progress Bar Background
351 if (progress_bar_background_->parent() != layer_) 351 if (progress_bar_background_->parent() != layer_)
352 layer_->AddChild(progress_bar_background_); 352 layer_->AddChild(progress_bar_background_);
353 353
354 float progress_bar_y = search_bar_bottom - progress_bar_height; 354 float progress_bar_y = search_bar_bottom - progress_bar_height;
355 gfx::Size progress_bar_background_size(search_panel_width, 355 gfx::Size progress_bar_background_size(search_panel_width,
356 progress_bar_height); 356 progress_bar_height);
357 357
358 progress_bar_background_->SetUIResourceId( 358 progress_bar_background_->SetUIResourceId(
359 progress_bar_background_resource->ui_resource->id()); 359 progress_bar_background_resource->ui_resource()->id());
360 progress_bar_background_->SetBorder( 360 progress_bar_background_->SetBorder(
361 progress_bar_background_resource->Border(progress_bar_background_size)); 361 progress_bar_background_resource->Border(progress_bar_background_size));
362 progress_bar_background_->SetAperture( 362 progress_bar_background_->SetAperture(
363 progress_bar_background_resource->aperture); 363 progress_bar_background_resource->aperture());
364 progress_bar_background_->SetBounds(progress_bar_background_size); 364 progress_bar_background_->SetBounds(progress_bar_background_size);
365 progress_bar_background_->SetPosition(gfx::PointF(0.f, progress_bar_y)); 365 progress_bar_background_->SetPosition(gfx::PointF(0.f, progress_bar_y));
366 progress_bar_background_->SetOpacity(progress_bar_opacity); 366 progress_bar_background_->SetOpacity(progress_bar_opacity);
367 367
368 // Progress Bar 368 // Progress Bar
369 if (progress_bar_->parent() != layer_) 369 if (progress_bar_->parent() != layer_)
370 layer_->AddChild(progress_bar_); 370 layer_->AddChild(progress_bar_);
371 371
372 float progress_bar_width = 372 float progress_bar_width =
373 floor(search_panel_width * progress_bar_completion / 100.f); 373 floor(search_panel_width * progress_bar_completion / 100.f);
374 gfx::Size progress_bar_size(progress_bar_width, progress_bar_height); 374 gfx::Size progress_bar_size(progress_bar_width, progress_bar_height);
375 progress_bar_->SetUIResourceId(progress_bar_resource->ui_resource->id()); 375 progress_bar_->SetUIResourceId(progress_bar_resource->ui_resource()->id());
376 progress_bar_->SetBorder(progress_bar_resource->Border(progress_bar_size)); 376 progress_bar_->SetBorder(progress_bar_resource->Border(progress_bar_size));
377 progress_bar_->SetAperture(progress_bar_resource->aperture); 377 progress_bar_->SetAperture(progress_bar_resource->aperture());
378 progress_bar_->SetBounds(progress_bar_size); 378 progress_bar_->SetBounds(progress_bar_size);
379 progress_bar_->SetPosition(gfx::PointF(0.f, progress_bar_y)); 379 progress_bar_->SetPosition(gfx::PointF(0.f, progress_bar_y));
380 progress_bar_->SetOpacity(progress_bar_opacity); 380 progress_bar_->SetOpacity(progress_bar_opacity);
381 } else { 381 } else {
382 // Removes Progress Bar and its Background from the Layer Tree. 382 // Removes Progress Bar and its Background from the Layer Tree.
383 if (progress_bar_background_.get() && progress_bar_background_->parent()) 383 if (progress_bar_background_.get() && progress_bar_background_->parent())
384 progress_bar_background_->RemoveFromParent(); 384 progress_bar_background_->RemoveFromParent();
385 385
386 if (progress_bar_.get() && progress_bar_->parent()) 386 if (progress_bar_.get() && progress_bar_->parent())
387 progress_bar_->RemoveFromParent(); 387 progress_bar_->RemoveFromParent();
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 float static_image_visibility_percentage) { 452 float static_image_visibility_percentage) {
453 icon_layer_->SetBounds(gfx::Size(static_image_size_, static_image_size_)); 453 icon_layer_->SetBounds(gfx::Size(static_image_size_, static_image_size_));
454 icon_layer_->SetMasksToBounds(true); 454 icon_layer_->SetMasksToBounds(true);
455 455
456 scoped_refptr<cc::UIResourceLayer> static_image_layer; 456 scoped_refptr<cc::UIResourceLayer> static_image_layer;
457 457
458 if (quick_action_icon_visible) { 458 if (quick_action_icon_visible) {
459 if (quick_action_icon_layer_->parent() != icon_layer_) 459 if (quick_action_icon_layer_->parent() != icon_layer_)
460 icon_layer_->AddChild(quick_action_icon_layer_); 460 icon_layer_->AddChild(quick_action_icon_layer_);
461 461
462 ui::ResourceManager::Resource* quick_action_icon_resource = 462 ui::Resource* quick_action_icon_resource = resource_manager_->GetResource(
463 resource_manager_->GetResource(ui::ANDROID_RESOURCE_TYPE_DYNAMIC, 463 ui::ANDROID_RESOURCE_TYPE_DYNAMIC, quick_action_icon_resource_id);
464 quick_action_icon_resource_id);
465 if (quick_action_icon_resource) { 464 if (quick_action_icon_resource) {
466 quick_action_icon_layer_->SetUIResourceId( 465 quick_action_icon_layer_->SetUIResourceId(
467 quick_action_icon_resource->ui_resource->id()); 466 quick_action_icon_resource->ui_resource()->id());
468 quick_action_icon_layer_->SetBounds(gfx::Size(static_image_size_, 467 quick_action_icon_layer_->SetBounds(gfx::Size(static_image_size_,
469 static_image_size_)); 468 static_image_size_));
470 469
471 SetStaticImageProperties(quick_action_icon_layer_, 0, 0, 470 SetStaticImageProperties(quick_action_icon_layer_, 0, 0,
472 static_image_visibility_percentage); 471 static_image_visibility_percentage);
473 } 472 }
474 } else if (quick_action_icon_layer_->parent()) { 473 } else if (quick_action_icon_layer_->parent()) {
475 quick_action_icon_layer_->RemoveFromParent(); 474 quick_action_icon_layer_->RemoveFromParent();
476 } 475 }
477 476
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 float term_caption_spacing) { 545 float term_caption_spacing) {
547 // --------------------------------------------------------------------------- 546 // ---------------------------------------------------------------------------
548 // Setup the Drawing Hierarchy 547 // Setup the Drawing Hierarchy
549 // --------------------------------------------------------------------------- 548 // ---------------------------------------------------------------------------
550 // Search Term 549 // Search Term
551 bool bar_text_visible = search_term_opacity > 0.0f; 550 bool bar_text_visible = search_term_opacity > 0.0f;
552 if (bar_text_visible && bar_text_->parent() != text_layer_) 551 if (bar_text_visible && bar_text_->parent() != text_layer_)
553 text_layer_->AddChild(bar_text_); 552 text_layer_->AddChild(bar_text_);
554 553
555 // Search Context 554 // Search Context
556 ui::ResourceManager::Resource* context_resource = 555 ui::Resource* context_resource = resource_manager_->GetResource(
557 resource_manager_->GetResource( 556 ui::ANDROID_RESOURCE_TYPE_DYNAMIC, context_resource_id);
558 ui::ANDROID_RESOURCE_TYPE_DYNAMIC, context_resource_id);
559 if (context_resource) { 557 if (context_resource) {
560 search_context_->SetUIResourceId(context_resource->ui_resource->id()); 558 search_context_->SetUIResourceId(context_resource->ui_resource()->id());
561 search_context_->SetBounds(context_resource->size); 559 search_context_->SetBounds(context_resource->size());
562 } 560 }
563 561
564 // Search Caption 562 // Search Caption
565 ui::ResourceManager::Resource* caption_resource = nullptr; 563 ui::Resource* caption_resource = nullptr;
566 if (caption_visible) { 564 if (caption_visible) {
567 // Grabs the dynamic Search Caption resource so we can get a snapshot. 565 // Grabs the dynamic Search Caption resource so we can get a snapshot.
568 caption_resource = resource_manager_->GetResource( 566 caption_resource = resource_manager_->GetResource(
569 ui::ANDROID_RESOURCE_TYPE_DYNAMIC, caption_resource_id); 567 ui::ANDROID_RESOURCE_TYPE_DYNAMIC, caption_resource_id);
570 } 568 }
571 569
572 if (caption_visible && animation_percentage != 0.f) { 570 if (caption_visible && animation_percentage != 0.f) {
573 if (search_caption_->parent() != text_layer_) { 571 if (search_caption_->parent() != text_layer_) {
574 text_layer_->AddChild(search_caption_); 572 text_layer_->AddChild(search_caption_);
575 } 573 }
576 if (caption_resource) { 574 if (caption_resource) {
577 search_caption_->SetUIResourceId(caption_resource->ui_resource->id()); 575 search_caption_->SetUIResourceId(caption_resource->ui_resource()->id());
578 search_caption_->SetBounds(caption_resource->size); 576 search_caption_->SetBounds(caption_resource->size());
579 } 577 }
580 } else if (search_caption_->parent()) { 578 } else if (search_caption_->parent()) {
581 search_caption_->RemoveFromParent(); 579 search_caption_->RemoveFromParent();
582 } 580 }
583 581
584 // --------------------------------------------------------------------------- 582 // ---------------------------------------------------------------------------
585 // Calculate Text Layer Size 583 // Calculate Text Layer Size
586 // --------------------------------------------------------------------------- 584 // ---------------------------------------------------------------------------
587 // If space allows, the Term, Context and Caption should occupy a Text 585 // If space allows, the Term, Context and Caption should occupy a Text
588 // section of fixed size. 586 // section of fixed size.
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
818 816
819 // Touch Highlight Layer 817 // Touch Highlight Layer
820 touch_highlight_layer_->SetIsDrawable(true); 818 touch_highlight_layer_->SetIsDrawable(true);
821 touch_highlight_layer_->SetBackgroundColor(kTouchHighlightColor); 819 touch_highlight_layer_->SetBackgroundColor(kTouchHighlightColor);
822 } 820 }
823 821
824 ContextualSearchLayer::~ContextualSearchLayer() { 822 ContextualSearchLayer::~ContextualSearchLayer() {
825 } 823 }
826 824
827 } // namespace android 825 } // namespace android
OLDNEW
« no previous file with comments | « chrome/browser/android/compositor/decoration_title.cc ('k') | chrome/browser/android/compositor/layer/overlay_panel_layer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698