OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/tiles/tile_manager.h" | 5 #include "cc/tiles/tile_manager.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 30 matching lines...) Expand all Loading... |
41 "Compositing.%s.RasterTask.RasterUs", | 41 "Compositing.%s.RasterTask.RasterUs", |
42 "Compositing.%s.RasterTask.RasterPixelsPerMs"); | 42 "Compositing.%s.RasterTask.RasterPixelsPerMs"); |
43 | 43 |
44 class RasterTaskImpl : public RasterTask { | 44 class RasterTaskImpl : public RasterTask { |
45 public: | 45 public: |
46 RasterTaskImpl(const Resource* resource, | 46 RasterTaskImpl(const Resource* resource, |
47 scoped_refptr<RasterSource> raster_source, | 47 scoped_refptr<RasterSource> raster_source, |
48 const gfx::Rect& content_rect, | 48 const gfx::Rect& content_rect, |
49 const gfx::Rect& invalid_content_rect, | 49 const gfx::Rect& invalid_content_rect, |
50 float contents_scale, | 50 float contents_scale, |
51 bool include_images, | 51 const RasterSource::PlaybackSettings& playback_settings, |
52 TileResolution tile_resolution, | 52 TileResolution tile_resolution, |
53 int layer_id, | 53 int layer_id, |
54 uint64_t source_prepare_tiles_id, | 54 uint64_t source_prepare_tiles_id, |
55 const void* tile, | 55 const void* tile, |
56 uint64_t new_content_id, | 56 uint64_t new_content_id, |
57 uint64_t previous_content_id, | 57 uint64_t previous_content_id, |
58 uint64_t resource_content_id, | 58 uint64_t resource_content_id, |
59 int source_frame_number, | 59 int source_frame_number, |
60 const base::Callback<void(bool)>& reply, | 60 const base::Callback<void(bool)>& reply, |
61 ImageDecodeTask::Vector* dependencies) | 61 ImageDecodeTask::Vector* dependencies) |
62 : RasterTask(dependencies), | 62 : RasterTask(dependencies), |
63 resource_(resource), | 63 resource_(resource), |
64 raster_source_(std::move(raster_source)), | 64 raster_source_(std::move(raster_source)), |
65 content_rect_(content_rect), | 65 content_rect_(content_rect), |
66 invalid_content_rect_(invalid_content_rect), | 66 invalid_content_rect_(invalid_content_rect), |
67 contents_scale_(contents_scale), | 67 contents_scale_(contents_scale), |
68 include_images_(include_images), | 68 playback_settings_(playback_settings), |
69 tile_resolution_(tile_resolution), | 69 tile_resolution_(tile_resolution), |
70 layer_id_(layer_id), | 70 layer_id_(layer_id), |
71 source_prepare_tiles_id_(source_prepare_tiles_id), | 71 source_prepare_tiles_id_(source_prepare_tiles_id), |
72 tile_(tile), | 72 tile_(tile), |
73 new_content_id_(new_content_id), | 73 new_content_id_(new_content_id), |
74 previous_content_id_(previous_content_id), | 74 previous_content_id_(previous_content_id), |
75 resource_content_id_(resource_content_id), | 75 resource_content_id_(resource_content_id), |
76 source_frame_number_(source_frame_number), | 76 source_frame_number_(source_frame_number), |
77 reply_(reply) {} | 77 reply_(reply) {} |
78 | 78 |
79 // Overridden from Task: | 79 // Overridden from Task: |
80 void RunOnWorkerThread() override { | 80 void RunOnWorkerThread() override { |
81 TRACE_EVENT1("cc", "RasterizerTaskImpl::RunOnWorkerThread", | 81 TRACE_EVENT1("cc", "RasterizerTaskImpl::RunOnWorkerThread", |
82 "source_prepare_tiles_id", source_prepare_tiles_id_); | 82 "source_prepare_tiles_id", source_prepare_tiles_id_); |
83 | 83 |
84 DCHECK(raster_source_.get()); | 84 DCHECK(raster_source_.get()); |
85 DCHECK(raster_buffer_); | 85 DCHECK(raster_buffer_); |
86 | 86 |
87 frame_viewer_instrumentation::ScopedRasterTask raster_task( | 87 frame_viewer_instrumentation::ScopedRasterTask raster_task( |
88 tile_, tile_resolution_, source_frame_number_, layer_id_); | 88 tile_, tile_resolution_, source_frame_number_, layer_id_); |
89 ScopedRasterTaskTimer timer; | 89 ScopedRasterTaskTimer timer; |
90 timer.SetArea(content_rect_.size().GetArea()); | 90 timer.SetArea(content_rect_.size().GetArea()); |
91 | 91 |
92 DCHECK(raster_source_); | 92 DCHECK(raster_source_); |
93 | 93 |
94 raster_buffer_->Playback(raster_source_.get(), content_rect_, | 94 raster_buffer_->Playback(raster_source_.get(), content_rect_, |
95 invalid_content_rect_, new_content_id_, | 95 invalid_content_rect_, new_content_id_, |
96 contents_scale_, include_images_); | 96 contents_scale_, playback_settings_); |
97 } | 97 } |
98 | 98 |
99 // Overridden from TileTask: | 99 // Overridden from TileTask: |
100 void ScheduleOnOriginThread(TileTaskClient* client) override { | 100 void ScheduleOnOriginThread(TileTaskClient* client) override { |
101 DCHECK(!raster_buffer_); | 101 DCHECK(!raster_buffer_); |
102 raster_buffer_ = client->AcquireBufferForRaster( | 102 raster_buffer_ = client->AcquireBufferForRaster( |
103 resource_, resource_content_id_, previous_content_id_); | 103 resource_, resource_content_id_, previous_content_id_); |
104 } | 104 } |
105 void CompleteOnOriginThread(TileTaskClient* client) override { | 105 void CompleteOnOriginThread(TileTaskClient* client) override { |
106 client->ReleaseBufferForRaster(std::move(raster_buffer_)); | 106 client->ReleaseBufferForRaster(std::move(raster_buffer_)); |
107 reply_.Run(!HasFinishedRunning()); | 107 reply_.Run(!HasFinishedRunning()); |
108 } | 108 } |
109 | 109 |
110 protected: | 110 protected: |
111 ~RasterTaskImpl() override { DCHECK(!raster_buffer_); } | 111 ~RasterTaskImpl() override { DCHECK(!raster_buffer_); } |
112 | 112 |
113 private: | 113 private: |
114 const Resource* resource_; | 114 const Resource* resource_; |
115 scoped_refptr<RasterSource> raster_source_; | 115 scoped_refptr<RasterSource> raster_source_; |
116 gfx::Rect content_rect_; | 116 gfx::Rect content_rect_; |
117 gfx::Rect invalid_content_rect_; | 117 gfx::Rect invalid_content_rect_; |
118 float contents_scale_; | 118 float contents_scale_; |
119 bool include_images_; | 119 RasterSource::PlaybackSettings playback_settings_; |
120 TileResolution tile_resolution_; | 120 TileResolution tile_resolution_; |
121 int layer_id_; | 121 int layer_id_; |
122 uint64_t source_prepare_tiles_id_; | 122 uint64_t source_prepare_tiles_id_; |
123 const void* tile_; | 123 const void* tile_; |
124 uint64_t new_content_id_; | 124 uint64_t new_content_id_; |
125 uint64_t previous_content_id_; | 125 uint64_t previous_content_id_; |
126 uint64_t resource_content_id_; | 126 uint64_t resource_content_id_; |
127 int source_frame_number_; | 127 int source_frame_number_; |
128 const base::Callback<void(bool)> reply_; | 128 const base::Callback<void(bool)> reply_; |
129 scoped_ptr<RasterBuffer> raster_buffer_; | 129 scoped_ptr<RasterBuffer> raster_buffer_; |
(...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
841 } | 841 } |
842 if (resource) { | 842 if (resource) { |
843 resource_content_id = tile->invalidated_id(); | 843 resource_content_id = tile->invalidated_id(); |
844 DCHECK_EQ(DetermineResourceFormat(tile), resource->format()); | 844 DCHECK_EQ(DetermineResourceFormat(tile), resource->format()); |
845 } else { | 845 } else { |
846 resource = resource_pool_->AcquireResource(tile->desired_texture_size(), | 846 resource = resource_pool_->AcquireResource(tile->desired_texture_size(), |
847 DetermineResourceFormat(tile)); | 847 DetermineResourceFormat(tile)); |
848 } | 848 } |
849 | 849 |
850 // For LOW_RESOLUTION tiles, we don't draw or predecode images. | 850 // For LOW_RESOLUTION tiles, we don't draw or predecode images. |
851 const bool include_images = | 851 RasterSource::PlaybackSettings playback_settings; |
852 prioritized_tile.priority().resolution != LOW_RESOLUTION; | 852 playback_settings.skip_images = |
| 853 prioritized_tile.priority().resolution == LOW_RESOLUTION; |
853 | 854 |
854 // Create and queue all image decode tasks that this tile depends on. | 855 // Create and queue all image decode tasks that this tile depends on. |
855 ImageDecodeTask::Vector decode_tasks; | 856 ImageDecodeTask::Vector decode_tasks; |
856 std::vector<DrawImage>& images = scheduled_draw_images_[tile->id()]; | 857 std::vector<DrawImage>& images = scheduled_draw_images_[tile->id()]; |
857 images.clear(); | 858 images.clear(); |
858 if (include_images) { | 859 if (!playback_settings.skip_images) { |
859 prioritized_tile.raster_source()->GetDiscardableImagesInRect( | 860 prioritized_tile.raster_source()->GetDiscardableImagesInRect( |
860 tile->enclosing_layer_rect(), tile->contents_scale(), &images); | 861 tile->enclosing_layer_rect(), tile->contents_scale(), &images); |
861 } | 862 } |
862 | 863 |
| 864 // TODO(vmpstr): We should disable image hijack canvas in |
| 865 // |playback_settings| here if |images| is empty. |
| 866 |
863 for (auto it = images.begin(); it != images.end();) { | 867 for (auto it = images.begin(); it != images.end();) { |
864 scoped_refptr<ImageDecodeTask> task; | 868 scoped_refptr<ImageDecodeTask> task; |
865 bool need_to_unref_when_finished = | 869 bool need_to_unref_when_finished = |
866 image_decode_controller_->GetTaskForImageAndRef( | 870 image_decode_controller_->GetTaskForImageAndRef( |
867 *it, prepare_tiles_count_, &task); | 871 *it, prepare_tiles_count_, &task); |
868 if (task) | 872 if (task) |
869 decode_tasks.push_back(task); | 873 decode_tasks.push_back(task); |
870 | 874 |
871 if (need_to_unref_when_finished) | 875 if (need_to_unref_when_finished) |
872 ++it; | 876 ++it; |
873 else | 877 else |
874 it = images.erase(it); | 878 it = images.erase(it); |
875 } | 879 } |
876 | 880 |
877 return make_scoped_refptr(new RasterTaskImpl( | 881 return make_scoped_refptr(new RasterTaskImpl( |
878 resource, prioritized_tile.raster_source(), tile->content_rect(), | 882 resource, prioritized_tile.raster_source(), tile->content_rect(), |
879 tile->invalidated_content_rect(), tile->contents_scale(), include_images, | 883 tile->invalidated_content_rect(), tile->contents_scale(), |
880 prioritized_tile.priority().resolution, tile->layer_id(), | 884 playback_settings, prioritized_tile.priority().resolution, |
881 prepare_tiles_count_, static_cast<const void*>(tile), tile->id(), | 885 tile->layer_id(), prepare_tiles_count_, static_cast<const void*>(tile), |
882 tile->invalidated_id(), resource_content_id, tile->source_frame_number(), | 886 tile->id(), tile->invalidated_id(), resource_content_id, |
| 887 tile->source_frame_number(), |
883 base::Bind(&TileManager::OnRasterTaskCompleted, base::Unretained(this), | 888 base::Bind(&TileManager::OnRasterTaskCompleted, base::Unretained(this), |
884 tile->id(), resource), | 889 tile->id(), resource), |
885 &decode_tasks)); | 890 &decode_tasks)); |
886 } | 891 } |
887 | 892 |
888 void TileManager::OnRasterTaskCompleted( | 893 void TileManager::OnRasterTaskCompleted( |
889 Tile::Id tile_id, | 894 Tile::Id tile_id, |
890 Resource* resource, | 895 Resource* resource, |
891 bool was_canceled) { | 896 bool was_canceled) { |
892 DCHECK(tiles_.find(tile_id) != tiles_.end()); | 897 DCHECK(tiles_.find(tile_id) != tiles_.end()); |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1212 void TileManager::Signals::reset() { | 1217 void TileManager::Signals::reset() { |
1213 ready_to_activate = false; | 1218 ready_to_activate = false; |
1214 did_notify_ready_to_activate = false; | 1219 did_notify_ready_to_activate = false; |
1215 ready_to_draw = false; | 1220 ready_to_draw = false; |
1216 did_notify_ready_to_draw = false; | 1221 did_notify_ready_to_draw = false; |
1217 all_tile_tasks_completed = false; | 1222 all_tile_tasks_completed = false; |
1218 did_notify_all_tile_tasks_completed = false; | 1223 did_notify_all_tile_tasks_completed = false; |
1219 } | 1224 } |
1220 | 1225 |
1221 } // namespace cc | 1226 } // namespace cc |
OLD | NEW |