OLD | NEW |
1 // Copyright 2010 The Chromium Authors. All rights reserved. | 1 // Copyright 2010 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 "cc/layers/layer.h" | 5 #include "cc/layers/layer.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
| 9 #include "base/location.h" |
9 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| 11 #include "base/single_thread_task_runner.h" |
10 #include "cc/animation/animation.h" | 12 #include "cc/animation/animation.h" |
11 #include "cc/animation/animation_events.h" | 13 #include "cc/animation/animation_events.h" |
12 #include "cc/animation/layer_animation_controller.h" | 14 #include "cc/animation/layer_animation_controller.h" |
13 #include "cc/base/thread.h" | |
14 #include "cc/layers/layer_impl.h" | 15 #include "cc/layers/layer_impl.h" |
15 #include "cc/output/copy_output_request.h" | 16 #include "cc/output/copy_output_request.h" |
16 #include "cc/trees/layer_tree_host.h" | 17 #include "cc/trees/layer_tree_host.h" |
17 #include "cc/trees/layer_tree_impl.h" | 18 #include "cc/trees/layer_tree_impl.h" |
18 #include "third_party/WebKit/public/platform/WebAnimationDelegate.h" | 19 #include "third_party/WebKit/public/platform/WebAnimationDelegate.h" |
19 #include "third_party/WebKit/public/platform/WebLayerScrollClient.h" | 20 #include "third_party/WebKit/public/platform/WebLayerScrollClient.h" |
20 #include "third_party/skia/include/core/SkImageFilter.h" | 21 #include "third_party/skia/include/core/SkImageFilter.h" |
21 #include "ui/gfx/rect_conversions.h" | 22 #include "ui/gfx/rect_conversions.h" |
22 | 23 |
23 namespace cc { | 24 namespace cc { |
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
650 position_constraint_ = constraint; | 651 position_constraint_ = constraint; |
651 SetNeedsCommit(); | 652 SetNeedsCommit(); |
652 } | 653 } |
653 | 654 |
654 static void RunCopyCallbackOnMainThread(scoped_ptr<CopyOutputRequest> request, | 655 static void RunCopyCallbackOnMainThread(scoped_ptr<CopyOutputRequest> request, |
655 scoped_ptr<SkBitmap> bitmap) { | 656 scoped_ptr<SkBitmap> bitmap) { |
656 if (request->HasBitmapRequest()) | 657 if (request->HasBitmapRequest()) |
657 request->SendBitmapResult(bitmap.Pass()); | 658 request->SendBitmapResult(bitmap.Pass()); |
658 } | 659 } |
659 | 660 |
660 static void PostCopyCallbackToMainThread(Thread* main_thread, | 661 static void PostCopyCallbackToMainThread( |
661 scoped_ptr<CopyOutputRequest> request, | 662 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner, |
662 scoped_ptr<SkBitmap> bitmap) { | 663 scoped_ptr<CopyOutputRequest> request, |
663 main_thread->PostTask(base::Bind(&RunCopyCallbackOnMainThread, | 664 scoped_ptr<SkBitmap> bitmap) { |
664 base::Passed(&request), | 665 main_thread_task_runner->PostTask(FROM_HERE, |
665 base::Passed(&bitmap))); | 666 base::Bind(&RunCopyCallbackOnMainThread, |
| 667 base::Passed(&request), |
| 668 base::Passed(&bitmap))); |
666 } | 669 } |
667 | 670 |
668 void Layer::PushPropertiesTo(LayerImpl* layer) { | 671 void Layer::PushPropertiesTo(LayerImpl* layer) { |
669 layer->SetAnchorPoint(anchor_point_); | 672 layer->SetAnchorPoint(anchor_point_); |
670 layer->SetAnchorPointZ(anchor_point_z_); | 673 layer->SetAnchorPointZ(anchor_point_z_); |
671 layer->SetBackgroundColor(background_color_); | 674 layer->SetBackgroundColor(background_color_); |
672 layer->SetBounds(paint_properties_.bounds); | 675 layer->SetBounds(paint_properties_.bounds); |
673 layer->SetContentBounds(content_bounds()); | 676 layer->SetContentBounds(content_bounds()); |
674 layer->SetContentsScale(contents_scale_x(), contents_scale_y()); | 677 layer->SetContentsScale(contents_scale_x(), contents_scale_y()); |
675 layer->SetDebugName(debug_name_); | 678 layer->SetDebugName(debug_name_); |
(...skipping 29 matching lines...) Expand all Loading... |
705 | 708 |
706 layer->SetScrollable(scrollable_); | 709 layer->SetScrollable(scrollable_); |
707 layer->SetScrollOffset(scroll_offset_); | 710 layer->SetScrollOffset(scroll_offset_); |
708 layer->SetMaxScrollOffset(max_scroll_offset_); | 711 layer->SetMaxScrollOffset(max_scroll_offset_); |
709 | 712 |
710 // Wrap the copy_requests_ in a PostTask to the main thread. | 713 // Wrap the copy_requests_ in a PostTask to the main thread. |
711 ScopedPtrVector<CopyOutputRequest> main_thread_copy_requests; | 714 ScopedPtrVector<CopyOutputRequest> main_thread_copy_requests; |
712 for (ScopedPtrVector<CopyOutputRequest>::iterator it = copy_requests_.begin(); | 715 for (ScopedPtrVector<CopyOutputRequest>::iterator it = copy_requests_.begin(); |
713 it != copy_requests_.end(); | 716 it != copy_requests_.end(); |
714 ++it) { | 717 ++it) { |
| 718 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner = |
| 719 layer_tree_host()->proxy()->MainThreadTaskRunner(); |
715 scoped_ptr<CopyOutputRequest> original_request = copy_requests_.take(it); | 720 scoped_ptr<CopyOutputRequest> original_request = copy_requests_.take(it); |
716 scoped_ptr<CopyOutputRequest> main_thread_request = | 721 scoped_ptr<CopyOutputRequest> main_thread_request = |
717 CopyOutputRequest::CreateBitmapRequest(base::Bind( | 722 CopyOutputRequest::CreateBitmapRequest(base::Bind( |
718 &PostCopyCallbackToMainThread, | 723 &PostCopyCallbackToMainThread, |
719 layer_tree_host()->proxy()->MainThread(), | 724 main_thread_task_runner, |
720 base::Passed(&original_request))); | 725 base::Passed(&original_request))); |
721 main_thread_copy_requests.push_back(main_thread_request.Pass()); | 726 main_thread_copy_requests.push_back(main_thread_request.Pass()); |
722 } | 727 } |
723 copy_requests_.clear(); | 728 copy_requests_.clear(); |
724 layer->PassCopyRequests(&main_thread_copy_requests); | 729 layer->PassCopyRequests(&main_thread_copy_requests); |
725 | 730 |
726 // If the main thread commits multiple times before the impl thread actually | 731 // If the main thread commits multiple times before the impl thread actually |
727 // draws, then damage tracking will become incorrect if we simply clobber the | 732 // draws, then damage tracking will become incorrect if we simply clobber the |
728 // update_rect here. The LayerImpl's update_rect needs to accumulate (i.e. | 733 // update_rect here. The LayerImpl's update_rect needs to accumulate (i.e. |
729 // union) any update changes that have occurred on the main thread. | 734 // union) any update changes that have occurred on the main thread. |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
880 | 885 |
881 RenderingStatsInstrumentation* Layer::rendering_stats_instrumentation() const { | 886 RenderingStatsInstrumentation* Layer::rendering_stats_instrumentation() const { |
882 return layer_tree_host_->rendering_stats_instrumentation(); | 887 return layer_tree_host_->rendering_stats_instrumentation(); |
883 } | 888 } |
884 | 889 |
885 bool Layer::SupportsLCDText() const { | 890 bool Layer::SupportsLCDText() const { |
886 return false; | 891 return false; |
887 } | 892 } |
888 | 893 |
889 } // namespace cc | 894 } // namespace cc |
OLD | NEW |