Chromium Code Reviews| OLD | NEW |
|---|---|
| 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" |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 36 ui::ResourceManager* resource_manager) { | 36 ui::ResourceManager* resource_manager) { |
| 37 return make_scoped_refptr(new ContextualSearchLayer(resource_manager)); | 37 return make_scoped_refptr(new ContextualSearchLayer(resource_manager)); |
| 38 } | 38 } |
| 39 | 39 |
| 40 void ContextualSearchLayer::SetProperties( | 40 void ContextualSearchLayer::SetProperties( |
| 41 int panel_shadow_resource_id, | 41 int panel_shadow_resource_id, |
| 42 int search_context_resource_id, | 42 int search_context_resource_id, |
| 43 int search_term_resource_id, | 43 int search_term_resource_id, |
| 44 int search_caption_resource_id, | 44 int search_caption_resource_id, |
| 45 int search_bar_shadow_resource_id, | 45 int search_bar_shadow_resource_id, |
| 46 int panel_icon_resource_id, | 46 int sprite_resource_id, |
| 47 int search_provider_icon_sprite_metadata_resource_id, | 47 int search_provider_icon_sprite_metadata_resource_id, |
| 48 int static_icon_resource_id, | |
| 48 int arrow_up_resource_id, | 49 int arrow_up_resource_id, |
| 49 int close_icon_resource_id, | 50 int close_icon_resource_id, |
| 50 int progress_bar_background_resource_id, | 51 int progress_bar_background_resource_id, |
| 51 int progress_bar_resource_id, | 52 int progress_bar_resource_id, |
| 52 int search_promo_resource_id, | 53 int search_promo_resource_id, |
| 53 int peek_promo_ripple_resource_id, | 54 int peek_promo_ripple_resource_id, |
| 54 int peek_promo_text_resource_id, | 55 int peek_promo_text_resource_id, |
| 55 float dp_to_px, | 56 float dp_to_px, |
| 56 const scoped_refptr<cc::Layer>& content_layer, | 57 const scoped_refptr<cc::Layer>& content_layer, |
| 57 bool search_promo_visible, | 58 bool search_promo_visible, |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 74 float search_term_opacity, | 75 float search_term_opacity, |
| 75 float search_term_caption_spacing, | 76 float search_term_caption_spacing, |
| 76 float search_caption_animation_percentage, | 77 float search_caption_animation_percentage, |
| 77 bool search_caption_visible, | 78 bool search_caption_visible, |
| 78 bool search_bar_border_visible, | 79 bool search_bar_border_visible, |
| 79 float search_bar_border_height, | 80 float search_bar_border_height, |
| 80 bool search_bar_shadow_visible, | 81 bool search_bar_shadow_visible, |
| 81 float search_bar_shadow_opacity, | 82 float search_bar_shadow_opacity, |
| 82 bool search_provider_icon_sprite_visible, | 83 bool search_provider_icon_sprite_visible, |
| 83 float search_provider_icon_sprite_completion_percentage, | 84 float search_provider_icon_sprite_completion_percentage, |
| 85 bool static_icon_visible, | |
| 84 bool thumbnail_visible, | 86 bool thumbnail_visible, |
| 85 float thumbnail_visibility_percentage, | 87 float static_image_visibility_percentage, |
| 86 int thumbnail_size, | 88 int static_image_size, |
| 87 float arrow_icon_opacity, | 89 float arrow_icon_opacity, |
| 88 float arrow_icon_rotation, | 90 float arrow_icon_rotation, |
| 89 float close_icon_opacity, | 91 float close_icon_opacity, |
| 90 bool progress_bar_visible, | 92 bool progress_bar_visible, |
| 91 float progress_bar_height, | 93 float progress_bar_height, |
| 92 float progress_bar_opacity, | 94 float progress_bar_opacity, |
| 93 int progress_bar_completion) { | 95 int progress_bar_completion) { |
| 94 | 96 |
| 95 // Round values to avoid pixel gap between layers. | 97 // Round values to avoid pixel gap between layers. |
| 96 search_bar_height = floor(search_bar_height); | 98 search_bar_height = floor(search_bar_height); |
| 97 | 99 |
| 98 float search_bar_top = search_peek_promo_height; | 100 float search_bar_top = search_peek_promo_height; |
| 99 float search_bar_bottom = search_bar_top + search_bar_height; | 101 float search_bar_bottom = search_bar_top + search_bar_height; |
| 100 bool should_render_progress_bar = | 102 bool should_render_progress_bar = |
| 101 progress_bar_visible && progress_bar_opacity > 0.f; | 103 progress_bar_visible && progress_bar_opacity > 0.f; |
| 102 | 104 |
| 103 OverlayPanelLayer::SetResourceIds( | 105 OverlayPanelLayer::SetResourceIds( |
| 104 search_term_resource_id, | 106 search_term_resource_id, |
| 105 panel_shadow_resource_id, | 107 panel_shadow_resource_id, |
| 106 search_bar_shadow_resource_id, | 108 search_bar_shadow_resource_id, |
| 107 panel_icon_resource_id, | 109 sprite_resource_id, |
| 108 close_icon_resource_id); | 110 close_icon_resource_id); |
| 109 | 111 |
| 110 float content_view_top = search_bar_bottom + search_promo_height; | 112 float content_view_top = search_bar_bottom + search_promo_height; |
| 111 float should_render_bar_border = search_bar_border_visible | 113 float should_render_bar_border = search_bar_border_visible |
| 112 && !should_render_progress_bar; | 114 && !should_render_progress_bar; |
| 113 | 115 |
| 114 // ----------------------------------------------------------------- | 116 // ----------------------------------------------------------------- |
| 115 // Overlay Panel | 117 // Overlay Panel |
| 116 // ----------------------------------------------------------------- | 118 // ----------------------------------------------------------------- |
| 117 OverlayPanelLayer::SetProperties( | 119 OverlayPanelLayer::SetProperties( |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 371 if (progress_bar_background_.get() && progress_bar_background_->parent()) | 373 if (progress_bar_background_.get() && progress_bar_background_->parent()) |
| 372 progress_bar_background_->RemoveFromParent(); | 374 progress_bar_background_->RemoveFromParent(); |
| 373 | 375 |
| 374 if (progress_bar_.get() && progress_bar_->parent()) | 376 if (progress_bar_.get() && progress_bar_->parent()) |
| 375 progress_bar_->RemoveFromParent(); | 377 progress_bar_->RemoveFromParent(); |
| 376 } | 378 } |
| 377 | 379 |
| 378 // --------------------------------------------------------------------------- | 380 // --------------------------------------------------------------------------- |
| 379 // Icon Layer | 381 // Icon Layer |
| 380 // --------------------------------------------------------------------------- | 382 // --------------------------------------------------------------------------- |
| 381 thumbnail_size_ = thumbnail_size; | 383 static_image_size_ = static_image_size; |
| 382 SetupIconLayer(search_provider_icon_sprite_visible, | 384 SetupIconLayer(search_provider_icon_sprite_visible, |
| 383 search_provider_icon_sprite_metadata_resource_id, | 385 search_provider_icon_sprite_metadata_resource_id, |
| 384 search_provider_icon_sprite_completion_percentage, | 386 search_provider_icon_sprite_completion_percentage, |
| 387 static_icon_visible, | |
| 388 static_icon_resource_id, | |
| 385 thumbnail_visible, | 389 thumbnail_visible, |
| 386 thumbnail_visibility_percentage); | 390 static_image_visibility_percentage); |
| 387 } | 391 } |
| 388 | 392 |
| 389 scoped_refptr<cc::Layer> ContextualSearchLayer::GetIconLayer() { | 393 scoped_refptr<cc::Layer> ContextualSearchLayer::GetIconLayer() { |
| 390 return icon_layer_; | 394 return icon_layer_; |
| 391 } | 395 } |
| 392 | 396 |
| 393 void ContextualSearchLayer::SetupIconLayer( | 397 void ContextualSearchLayer::SetupIconLayer( |
| 394 bool search_provider_icon_sprite_visible, | 398 bool search_provider_icon_sprite_visible, |
| 395 int search_provider_icon_sprite_metadata_resource_id, | 399 int search_provider_icon_sprite_metadata_resource_id, |
| 396 float search_provider_icon_sprite_completion_percentage, | 400 float search_provider_icon_sprite_completion_percentage, |
| 401 bool static_icon_visible, | |
| 402 int static_icon_resource_id, | |
| 397 bool thumbnail_visible, | 403 bool thumbnail_visible, |
| 398 float thumbnail_visibility_percentage) { | 404 float static_image_visibility_percentage) { |
| 399 icon_layer_->SetBounds(gfx::Size(thumbnail_size_, thumbnail_size_)); | 405 icon_layer_->SetBounds(gfx::Size(static_image_size_, static_image_size_)); |
| 400 icon_layer_->SetMasksToBounds(true); | 406 icon_layer_->SetMasksToBounds(true); |
| 401 | 407 |
| 408 scoped_refptr<cc::UIResourceLayer> static_image_layer; | |
| 409 | |
| 410 if (static_icon_visible) { | |
| 411 if (static_icon_layer_->parent() != icon_layer_) | |
| 412 icon_layer_->AddChild(static_icon_layer_); | |
| 413 | |
| 414 ui::ResourceManager::Resource* static_icon_resource = | |
| 415 resource_manager_->GetResource(ui::ANDROID_RESOURCE_TYPE_STATIC, | |
| 416 static_icon_resource_id); | |
| 417 static_icon_layer_->SetUIResourceId( | |
| 418 static_icon_resource->ui_resource->id()); | |
| 419 static_icon_layer_->SetBounds(gfx::Size(static_image_size_, | |
| 420 static_image_size_)); | |
| 421 | |
| 422 SetStaticImageProperties(static_icon_layer_, 0, 0, | |
| 423 static_image_visibility_percentage); | |
| 424 } else if (static_icon_layer_->parent()) { | |
| 425 static_icon_layer_->RemoveFromParent(); | |
| 426 } | |
| 427 | |
| 402 // Thumbnail | 428 // Thumbnail |
| 403 if (thumbnail_visible) { | 429 if (!static_icon_visible && thumbnail_visible) { |
| 404 if (thumbnail_layer_->parent() != icon_layer_) | 430 if (thumbnail_layer_->parent() != icon_layer_) |
| 405 icon_layer_->AddChild(thumbnail_layer_); | 431 icon_layer_->AddChild(thumbnail_layer_); |
| 406 | 432 |
| 407 thumbnail_layer_->SetOpacity(thumbnail_visibility_percentage); | 433 SetStaticImageProperties(thumbnail_layer_, |
| 408 | 434 thumbnail_top_margin_, |
| 409 // When animating, the thumbnail and icon sprite slide through | 435 thumbnail_side_margin_, |
| 410 // |icon_layer_|. This effect is achieved by changing the y-offset | 436 static_image_visibility_percentage); |
| 411 // for each child layer. | |
| 412 // If the thumbnail has a height less than |thumbnail_size_|, it will have | |
| 413 // a top margin that needs to be accounted for while running the | |
| 414 // animation. The final |thumbnail_y_offset| should be equal to | |
| 415 // |thumbnail_top_margin_|. | |
| 416 float thumbnail_y_offset = | |
| 417 (thumbnail_size_ * (1.f - thumbnail_visibility_percentage)) | |
| 418 + thumbnail_top_margin_; | |
| 419 thumbnail_layer_->SetPosition( | |
| 420 gfx::PointF(thumbnail_side_margin_, thumbnail_y_offset)); | |
| 421 } else if (thumbnail_layer_->parent()) { | 437 } else if (thumbnail_layer_->parent()) { |
| 422 thumbnail_layer_->RemoveFromParent(); | 438 thumbnail_layer_->RemoveFromParent(); |
| 423 } | 439 } |
| 424 | 440 |
| 425 // Search Provider Icon Sprite | 441 // Search Provider Icon Sprite |
| 426 if (search_provider_icon_sprite_visible) { | 442 if (search_provider_icon_sprite_visible) { |
| 427 if (search_provider_icon_sprite_->layer()->parent() != icon_layer_) | 443 if (search_provider_icon_sprite_->layer()->parent() != icon_layer_) |
| 428 icon_layer_->AddChild(search_provider_icon_sprite_->layer().get()); | 444 icon_layer_->AddChild(search_provider_icon_sprite_->layer().get()); |
| 429 | 445 |
| 430 search_provider_icon_sprite_->DrawSpriteFrame( | 446 search_provider_icon_sprite_->DrawSpriteFrame( |
| 431 resource_manager_, | 447 resource_manager_, |
| 432 panel_icon_resource_id_, | 448 panel_icon_resource_id_, |
| 433 search_provider_icon_sprite_metadata_resource_id, | 449 search_provider_icon_sprite_metadata_resource_id, |
| 434 search_provider_icon_sprite_completion_percentage); | 450 search_provider_icon_sprite_completion_percentage); |
| 435 | 451 |
| 436 search_provider_icon_sprite_->layer()->SetOpacity( | 452 search_provider_icon_sprite_->layer()->SetOpacity( |
| 437 1.f - thumbnail_visibility_percentage); | 453 1.f - static_image_visibility_percentage); |
| 438 | 454 |
| 439 float icon_y_offset = | 455 float icon_y_offset = |
| 440 -(thumbnail_size_ * thumbnail_visibility_percentage); | 456 -(static_image_size_ * static_image_visibility_percentage); |
| 441 search_provider_icon_sprite_->layer()->SetPosition( | 457 search_provider_icon_sprite_->layer()->SetPosition( |
| 442 gfx::PointF(0.f, icon_y_offset)); | 458 gfx::PointF(0.f, icon_y_offset)); |
| 443 | 459 |
| 444 } else if (search_provider_icon_sprite_->layer().get() && | 460 } else if (search_provider_icon_sprite_->layer().get() && |
| 445 search_provider_icon_sprite_->layer()->parent()) { | 461 search_provider_icon_sprite_->layer()->parent()) { |
| 446 search_provider_icon_sprite_->layer()->RemoveFromParent(); | 462 search_provider_icon_sprite_->layer()->RemoveFromParent(); |
| 447 } | 463 } |
| 448 } | 464 } |
| 449 | 465 |
| 466 void ContextualSearchLayer::SetStaticImageProperties( | |
| 467 scoped_refptr<cc::UIResourceLayer> static_image_layer, | |
| 468 float top_margin, | |
| 469 float side_margin, | |
| 470 float visibility_percentage) { | |
| 471 static_image_layer->SetOpacity(visibility_percentage); | |
| 472 | |
| 473 // When animating, the static image and icon sprite slide through | |
| 474 // |icon_layer_|. This effect is achieved by changing the y-offset | |
| 475 // for each child layer. | |
| 476 // If the static image has a height less than |static_image_size_|, it will | |
| 477 // have a top margin that needs to be accounted for while running the | |
| 478 // animation. The final |static_image_y_offset| should be equal to | |
| 479 // |tpp_margin|. | |
| 480 float thumbnail_y_offset = | |
|
Donn Denman
2016/10/24 23:56:20
Nit: change to static_image_y_offset.
Theresa
2016/10/25 00:32:48
Done.
| |
| 481 (static_image_size_ * (1.f - visibility_percentage)) | |
| 482 + top_margin; | |
| 483 static_image_layer->SetPosition( | |
| 484 gfx::PointF(side_margin, thumbnail_y_offset)); | |
| 485 } | |
| 486 | |
| 450 void ContextualSearchLayer::SetupTextLayer( | 487 void ContextualSearchLayer::SetupTextLayer( |
| 451 float bar_top, | 488 float bar_top, |
| 452 float bar_height, | 489 float bar_height, |
| 453 float search_text_layer_min_height, | 490 float search_text_layer_min_height, |
| 454 int caption_resource_id, | 491 int caption_resource_id, |
| 455 bool caption_visible, | 492 bool caption_visible, |
| 456 float animation_percentage, | 493 float animation_percentage, |
| 457 int context_resource_id, | 494 int context_resource_id, |
| 458 float context_opacity, | 495 float context_opacity, |
| 459 float term_caption_spacing) { | 496 float term_caption_spacing) { |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 569 float caption_top = layer_height * (1.f - animation_percentage) | 606 float caption_top = layer_height * (1.f - animation_percentage) |
| 570 + caption_top_end * animation_percentage; | 607 + caption_top_end * animation_percentage; |
| 571 | 608 |
| 572 bar_text_->SetPosition(gfx::PointF(0.f, term_top)); | 609 bar_text_->SetPosition(gfx::PointF(0.f, term_top)); |
| 573 search_context_->SetPosition(gfx::PointF(0.f, term_top)); | 610 search_context_->SetPosition(gfx::PointF(0.f, term_top)); |
| 574 search_caption_->SetPosition(gfx::PointF(0.f, caption_top)); | 611 search_caption_->SetPosition(gfx::PointF(0.f, caption_top)); |
| 575 } | 612 } |
| 576 | 613 |
| 577 void ContextualSearchLayer::SetThumbnail(const SkBitmap* thumbnail) { | 614 void ContextualSearchLayer::SetThumbnail(const SkBitmap* thumbnail) { |
| 578 // Determine the scaled thumbnail width and height. If both the height and | 615 // Determine the scaled thumbnail width and height. If both the height and |
| 579 // width of |thumbnail| are larger than |thumbnail_size_|, the thumbnail will | 616 // width of |thumbnail| are larger than |static_image_size_|, the thumbnail |
| 580 // be scaled down by a call to Layer::SetBounds() below. | 617 // will be scaled down by a call to Layer::SetBounds() below. |
| 581 int min_dimension = std::min(thumbnail->width(), thumbnail->height()); | 618 int min_dimension = std::min(thumbnail->width(), thumbnail->height()); |
| 582 int scaled_thumbnail_width = thumbnail->width(); | 619 int scaled_thumbnail_width = thumbnail->width(); |
| 583 int scaled_thumbnail_height = thumbnail->height(); | 620 int scaled_thumbnail_height = thumbnail->height(); |
| 584 if (min_dimension > thumbnail_size_) { | 621 if (min_dimension > static_image_size_) { |
| 585 scaled_thumbnail_width = | 622 scaled_thumbnail_width = |
| 586 scaled_thumbnail_width * thumbnail_size_ / min_dimension; | 623 scaled_thumbnail_width * static_image_size_ / min_dimension; |
| 587 scaled_thumbnail_height = | 624 scaled_thumbnail_height = |
| 588 scaled_thumbnail_height * thumbnail_size_ / min_dimension; | 625 scaled_thumbnail_height * static_image_size_ / min_dimension; |
| 589 } | 626 } |
| 590 | 627 |
| 591 // Determine the UV transform coordinates. This will crop the thumbnail. | 628 // Determine the UV transform coordinates. This will crop the thumbnail. |
| 592 // (0, 0) is the default top left corner. (1, 1) is the default bottom | 629 // (0, 0) is the default top left corner. (1, 1) is the default bottom |
| 593 // right corner. | 630 // right corner. |
| 594 float top_left_x = 0; | 631 float top_left_x = 0; |
| 595 float top_left_y = 0; | 632 float top_left_y = 0; |
| 596 float bottom_right_x = 1; | 633 float bottom_right_x = 1; |
| 597 float bottom_right_y = 1; | 634 float bottom_right_y = 1; |
| 598 | 635 |
| 599 if (scaled_thumbnail_width > thumbnail_size_) { | 636 if (scaled_thumbnail_width > static_image_size_) { |
| 600 // Crop an even amount on the left and right sides of the thumbnail. | 637 // Crop an even amount on the left and right sides of the thumbnail. |
| 601 float top_left_x_px = (scaled_thumbnail_width - thumbnail_size_) / 2.f; | 638 float top_left_x_px = (scaled_thumbnail_width - static_image_size_) / 2.f; |
| 602 float bottom_right_x_px = top_left_x_px + thumbnail_size_; | 639 float bottom_right_x_px = top_left_x_px + static_image_size_; |
| 603 | 640 |
| 604 top_left_x = top_left_x_px / scaled_thumbnail_width; | 641 top_left_x = top_left_x_px / scaled_thumbnail_width; |
| 605 bottom_right_x = bottom_right_x_px / scaled_thumbnail_width; | 642 bottom_right_x = bottom_right_x_px / scaled_thumbnail_width; |
| 606 } else if (scaled_thumbnail_height > thumbnail_size_) { | 643 } else if (scaled_thumbnail_height > static_image_size_) { |
| 607 // Crop an even amount on the top and bottom of the thumbnail. | 644 // Crop an even amount on the top and bottom of the thumbnail. |
| 608 float top_left_y_px = (scaled_thumbnail_height - thumbnail_size_) / 2.f; | 645 float top_left_y_px = (scaled_thumbnail_height - static_image_size_) / 2.f; |
| 609 float bottom_right_y_px = top_left_y_px + thumbnail_size_; | 646 float bottom_right_y_px = top_left_y_px + static_image_size_; |
| 610 | 647 |
| 611 top_left_y = top_left_y_px / scaled_thumbnail_height; | 648 top_left_y = top_left_y_px / scaled_thumbnail_height; |
| 612 bottom_right_y = bottom_right_y_px / scaled_thumbnail_height; | 649 bottom_right_y = bottom_right_y_px / scaled_thumbnail_height; |
| 613 } | 650 } |
| 614 | 651 |
| 615 // If the original |thumbnail| height or width is smaller than | 652 // If the original |thumbnail| height or width is smaller than |
| 616 // |thumbnail_size_| determine the side and top margins needed to center | 653 // |static_image_size_| determine the side and top margins needed to center |
| 617 // the thumbnail. | 654 // the thumbnail. |
| 618 thumbnail_side_margin_ = 0; | 655 thumbnail_side_margin_ = 0; |
| 619 thumbnail_top_margin_ = 0; | 656 thumbnail_top_margin_ = 0; |
| 620 | 657 |
| 621 if (scaled_thumbnail_width < thumbnail_size_) { | 658 if (scaled_thumbnail_width < static_image_size_) { |
| 622 thumbnail_side_margin_ = (thumbnail_size_ - scaled_thumbnail_width) / 2.f; | 659 thumbnail_side_margin_ = |
| 660 (static_image_size_ - scaled_thumbnail_width) / 2.f; | |
| 623 } | 661 } |
| 624 | 662 |
| 625 if (scaled_thumbnail_height < thumbnail_size_) { | 663 if (scaled_thumbnail_height < static_image_size_) { |
| 626 thumbnail_top_margin_ = (thumbnail_size_ - scaled_thumbnail_height) / 2.f; | 664 thumbnail_top_margin_ = |
| 665 (static_image_size_ - scaled_thumbnail_height) / 2.f; | |
| 627 } | 666 } |
| 628 | 667 |
| 629 // Determine the layer bounds. This will down scale the thumbnail if | 668 // Determine the layer bounds. This will down scale the thumbnail if |
| 630 // necessary and ensure it is displayed at |thumbnail_size_|. If | 669 // necessary and ensure it is displayed at |static_image_size_|. If |
| 631 // either the original |thumbnail| height or width is smaller than | 670 // either the original |thumbnail| height or width is smaller than |
| 632 // |thumbnail_size_|, the thumbnail will not be scaled. | 671 // |static_image_size_|, the thumbnail will not be scaled. |
| 633 int layer_width = std::min(thumbnail_size_, scaled_thumbnail_width); | 672 int layer_width = std::min(static_image_size_, scaled_thumbnail_width); |
| 634 int layer_height = std::min(thumbnail_size_, scaled_thumbnail_height); | 673 int layer_height = std::min(static_image_size_, scaled_thumbnail_height); |
| 635 | 674 |
| 636 // UIResourceLayer requires an immutable copy of the input |thumbnail|. | 675 // UIResourceLayer requires an immutable copy of the input |thumbnail|. |
| 637 SkBitmap thumbnail_copy; | 676 SkBitmap thumbnail_copy; |
| 638 if (thumbnail->isImmutable()) { | 677 if (thumbnail->isImmutable()) { |
| 639 thumbnail_copy = *thumbnail; | 678 thumbnail_copy = *thumbnail; |
| 640 } else { | 679 } else { |
| 641 thumbnail->copyTo(&thumbnail_copy); | 680 thumbnail->copyTo(&thumbnail_copy); |
| 642 thumbnail_copy.setImmutable(); | 681 thumbnail_copy.setImmutable(); |
| 643 } | 682 } |
| 644 | 683 |
| 645 thumbnail_layer_->SetBitmap(thumbnail_copy); | 684 thumbnail_layer_->SetBitmap(thumbnail_copy); |
| 646 thumbnail_layer_->SetBounds(gfx::Size(layer_width, layer_height)); | 685 thumbnail_layer_->SetBounds(gfx::Size(layer_width, layer_height)); |
| 647 thumbnail_layer_->SetPosition( | 686 thumbnail_layer_->SetPosition( |
| 648 gfx::PointF(thumbnail_side_margin_, thumbnail_top_margin_)); | 687 gfx::PointF(thumbnail_side_margin_, thumbnail_top_margin_)); |
| 649 thumbnail_layer_->SetUV(gfx::PointF(top_left_x, top_left_y), | 688 thumbnail_layer_->SetUV(gfx::PointF(top_left_x, top_left_y), |
| 650 gfx::PointF(bottom_right_x, bottom_right_y)); | 689 gfx::PointF(bottom_right_x, bottom_right_y)); |
| 651 } | 690 } |
| 652 | 691 |
| 653 ContextualSearchLayer::ContextualSearchLayer( | 692 ContextualSearchLayer::ContextualSearchLayer( |
| 654 ui::ResourceManager* resource_manager) | 693 ui::ResourceManager* resource_manager) |
| 655 : OverlayPanelLayer(resource_manager), | 694 : OverlayPanelLayer(resource_manager), |
| 656 search_context_(cc::UIResourceLayer::Create()), | 695 search_context_(cc::UIResourceLayer::Create()), |
| 657 icon_layer_(cc::Layer::Create()), | 696 icon_layer_(cc::Layer::Create()), |
| 658 search_provider_icon_sprite_(CrushedSpriteLayer::Create()), | 697 search_provider_icon_sprite_(CrushedSpriteLayer::Create()), |
| 659 thumbnail_layer_(cc::UIResourceLayer::Create()), | 698 thumbnail_layer_(cc::UIResourceLayer::Create()), |
| 699 static_icon_layer_(cc::UIResourceLayer::Create()), | |
| 660 arrow_icon_(cc::UIResourceLayer::Create()), | 700 arrow_icon_(cc::UIResourceLayer::Create()), |
| 661 search_promo_(cc::UIResourceLayer::Create()), | 701 search_promo_(cc::UIResourceLayer::Create()), |
| 662 search_promo_container_(cc::SolidColorLayer::Create()), | 702 search_promo_container_(cc::SolidColorLayer::Create()), |
| 663 peek_promo_container_(cc::SolidColorLayer::Create()), | 703 peek_promo_container_(cc::SolidColorLayer::Create()), |
| 664 peek_promo_ripple_(cc::NinePatchLayer::Create()), | 704 peek_promo_ripple_(cc::NinePatchLayer::Create()), |
| 665 peek_promo_text_(cc::UIResourceLayer::Create()), | 705 peek_promo_text_(cc::UIResourceLayer::Create()), |
| 666 progress_bar_(cc::NinePatchLayer::Create()), | 706 progress_bar_(cc::NinePatchLayer::Create()), |
| 667 progress_bar_background_(cc::NinePatchLayer::Create()), | 707 progress_bar_background_(cc::NinePatchLayer::Create()), |
| 668 search_caption_(cc::UIResourceLayer::Create()), | 708 search_caption_(cc::UIResourceLayer::Create()), |
| 669 text_layer_(cc::UIResourceLayer::Create()) { | 709 text_layer_(cc::UIResourceLayer::Create()) { |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 692 search_promo_->SetIsDrawable(true); | 732 search_promo_->SetIsDrawable(true); |
| 693 | 733 |
| 694 // Progress Bar Background | 734 // Progress Bar Background |
| 695 progress_bar_background_->SetIsDrawable(true); | 735 progress_bar_background_->SetIsDrawable(true); |
| 696 progress_bar_background_->SetFillCenter(true); | 736 progress_bar_background_->SetFillCenter(true); |
| 697 | 737 |
| 698 // Progress Bar | 738 // Progress Bar |
| 699 progress_bar_->SetIsDrawable(true); | 739 progress_bar_->SetIsDrawable(true); |
| 700 progress_bar_->SetFillCenter(true); | 740 progress_bar_->SetFillCenter(true); |
| 701 | 741 |
| 702 // Icon | 742 // Icon - holds thumbnail, search provider sprite and/or static icon |
| 703 icon_layer_->SetIsDrawable(true); | 743 icon_layer_->SetIsDrawable(true); |
| 704 layer_->AddChild(icon_layer_); | 744 layer_->AddChild(icon_layer_); |
| 705 | 745 |
| 706 // Thumbnail | 746 // Thumbnail |
| 707 thumbnail_layer_->SetIsDrawable(true); | 747 thumbnail_layer_->SetIsDrawable(true); |
| 708 | 748 |
| 749 // Static icon | |
| 750 static_icon_layer_->SetIsDrawable(true); | |
| 751 | |
| 709 // Content layer | 752 // Content layer |
| 710 text_layer_->SetIsDrawable(true); | 753 text_layer_->SetIsDrawable(true); |
| 711 // NOTE(mdjones): This can be called multiple times to add other text layers. | 754 // NOTE(mdjones): This can be called multiple times to add other text layers. |
| 712 AddBarTextLayer(text_layer_); | 755 AddBarTextLayer(text_layer_); |
| 713 text_layer_->AddChild(search_context_); | 756 text_layer_->AddChild(search_context_); |
| 714 } | 757 } |
| 715 | 758 |
| 716 ContextualSearchLayer::~ContextualSearchLayer() { | 759 ContextualSearchLayer::~ContextualSearchLayer() { |
| 717 } | 760 } |
| 718 | 761 |
| 719 } // namespace android | 762 } // namespace android |
| OLD | NEW |