| 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/resources/tile_manager.h" | 5 #include "cc/resources/tile_manager.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/debug/trace_event_argument.h" | 12 #include "base/debug/trace_event_argument.h" |
| 13 #include "base/json/json_writer.h" | 13 #include "base/json/json_writer.h" |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/metrics/histogram.h" | 15 #include "base/metrics/histogram.h" |
| 16 #include "cc/debug/devtools_instrumentation.h" | 16 #include "cc/debug/devtools_instrumentation.h" |
| 17 #include "cc/debug/frame_viewer_instrumentation.h" | 17 #include "cc/debug/frame_viewer_instrumentation.h" |
| 18 #include "cc/debug/traced_value.h" | 18 #include "cc/debug/traced_value.h" |
| 19 #include "cc/layers/picture_layer_impl.h" | 19 #include "cc/layers/picture_layer_impl.h" |
| 20 #include "cc/resources/raster_buffer.h" |
| 20 #include "cc/resources/rasterizer.h" | 21 #include "cc/resources/rasterizer.h" |
| 21 #include "cc/resources/tile.h" | 22 #include "cc/resources/tile.h" |
| 22 #include "skia/ext/paint_simplifier.h" | 23 #include "skia/ext/paint_simplifier.h" |
| 23 #include "third_party/skia/include/core/SkBitmap.h" | 24 #include "third_party/skia/include/core/SkBitmap.h" |
| 24 #include "third_party/skia/include/core/SkPixelRef.h" | 25 #include "third_party/skia/include/core/SkPixelRef.h" |
| 25 #include "ui/gfx/rect_conversions.h" | 26 #include "ui/gfx/rect_conversions.h" |
| 26 | 27 |
| 27 namespace cc { | 28 namespace cc { |
| 28 namespace { | 29 namespace { |
| 29 | 30 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 51 picture_pile_(picture_pile), | 52 picture_pile_(picture_pile), |
| 52 content_rect_(content_rect), | 53 content_rect_(content_rect), |
| 53 contents_scale_(contents_scale), | 54 contents_scale_(contents_scale), |
| 54 raster_mode_(raster_mode), | 55 raster_mode_(raster_mode), |
| 55 tile_resolution_(tile_resolution), | 56 tile_resolution_(tile_resolution), |
| 56 layer_id_(layer_id), | 57 layer_id_(layer_id), |
| 57 tile_id_(tile_id), | 58 tile_id_(tile_id), |
| 58 source_frame_number_(source_frame_number), | 59 source_frame_number_(source_frame_number), |
| 59 analyze_picture_(analyze_picture), | 60 analyze_picture_(analyze_picture), |
| 60 rendering_stats_(rendering_stats), | 61 rendering_stats_(rendering_stats), |
| 61 reply_(reply), | 62 reply_(reply) {} |
| 62 raster_buffer_(NULL) {} | |
| 63 | 63 |
| 64 // Overridden from Task: | 64 // Overridden from Task: |
| 65 virtual void RunOnWorkerThread() OVERRIDE { | 65 virtual void RunOnWorkerThread() OVERRIDE { |
| 66 TRACE_EVENT0("cc", "RasterizerTaskImpl::RunOnWorkerThread"); | 66 TRACE_EVENT0("cc", "RasterizerTaskImpl::RunOnWorkerThread"); |
| 67 | 67 |
| 68 DCHECK(picture_pile_.get()); | 68 DCHECK(picture_pile_.get()); |
| 69 DCHECK(raster_buffer_); | 69 DCHECK(raster_buffer_); |
| 70 | 70 |
| 71 if (analyze_picture_) { | 71 if (analyze_picture_) { |
| 72 Analyze(picture_pile_.get()); | 72 Analyze(picture_pile_.get()); |
| 73 if (analysis_.is_solid_color) | 73 if (analysis_.is_solid_color) |
| 74 return; | 74 return; |
| 75 } | 75 } |
| 76 | 76 |
| 77 Raster(picture_pile_.get()); | 77 Raster(picture_pile_.get()); |
| 78 } | 78 } |
| 79 | 79 |
| 80 // Overridden from RasterizerTask: | 80 // Overridden from RasterizerTask: |
| 81 virtual void ScheduleOnOriginThread(RasterizerTaskClient* client) OVERRIDE { | 81 virtual void ScheduleOnOriginThread(RasterizerTaskClient* client) OVERRIDE { |
| 82 DCHECK(!raster_buffer_); | 82 DCHECK(!raster_buffer_); |
| 83 raster_buffer_ = client->AcquireBufferForRaster(this); | 83 raster_buffer_ = client->AcquireBufferForRaster(resource()); |
| 84 } | 84 } |
| 85 virtual void CompleteOnOriginThread(RasterizerTaskClient* client) OVERRIDE { | 85 virtual void CompleteOnOriginThread(RasterizerTaskClient* client) OVERRIDE { |
| 86 raster_buffer_ = NULL; | 86 client->ReleaseBufferForRaster(raster_buffer_.Pass()); |
| 87 client->ReleaseBufferForRaster(this); | |
| 88 } | 87 } |
| 89 virtual void RunReplyOnOriginThread() OVERRIDE { | 88 virtual void RunReplyOnOriginThread() OVERRIDE { |
| 90 DCHECK(!raster_buffer_); | 89 DCHECK(!raster_buffer_); |
| 91 reply_.Run(analysis_, !HasFinishedRunning()); | 90 reply_.Run(analysis_, !HasFinishedRunning()); |
| 92 } | 91 } |
| 93 | 92 |
| 94 protected: | 93 protected: |
| 95 virtual ~RasterTaskImpl() { DCHECK(!raster_buffer_); } | 94 virtual ~RasterTaskImpl() { DCHECK(!raster_buffer_); } |
| 96 | 95 |
| 97 private: | 96 private: |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 gfx::Rect content_rect_; | 169 gfx::Rect content_rect_; |
| 171 float contents_scale_; | 170 float contents_scale_; |
| 172 RasterMode raster_mode_; | 171 RasterMode raster_mode_; |
| 173 TileResolution tile_resolution_; | 172 TileResolution tile_resolution_; |
| 174 int layer_id_; | 173 int layer_id_; |
| 175 const void* tile_id_; | 174 const void* tile_id_; |
| 176 int source_frame_number_; | 175 int source_frame_number_; |
| 177 bool analyze_picture_; | 176 bool analyze_picture_; |
| 178 RenderingStatsInstrumentation* rendering_stats_; | 177 RenderingStatsInstrumentation* rendering_stats_; |
| 179 const base::Callback<void(const PicturePileImpl::Analysis&, bool)> reply_; | 178 const base::Callback<void(const PicturePileImpl::Analysis&, bool)> reply_; |
| 180 RasterBuffer* raster_buffer_; | 179 scoped_ptr<RasterBuffer> raster_buffer_; |
| 181 | 180 |
| 182 DISALLOW_COPY_AND_ASSIGN(RasterTaskImpl); | 181 DISALLOW_COPY_AND_ASSIGN(RasterTaskImpl); |
| 183 }; | 182 }; |
| 184 | 183 |
| 185 class ImageDecodeTaskImpl : public ImageDecodeTask { | 184 class ImageDecodeTaskImpl : public ImageDecodeTask { |
| 186 public: | 185 public: |
| 187 ImageDecodeTaskImpl(SkPixelRef* pixel_ref, | 186 ImageDecodeTaskImpl(SkPixelRef* pixel_ref, |
| 188 int layer_id, | 187 int layer_id, |
| 189 RenderingStatsInstrumentation* rendering_stats, | 188 RenderingStatsInstrumentation* rendering_stats, |
| 190 const base::Callback<void(bool was_canceled)>& reply) | 189 const base::Callback<void(bool was_canceled)>& reply) |
| (...skipping 977 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1168 TRACE_EVENT0("cc", "TileManager::CheckIfReadyToActivate"); | 1167 TRACE_EVENT0("cc", "TileManager::CheckIfReadyToActivate"); |
| 1169 | 1168 |
| 1170 rasterizer_->CheckForCompletedTasks(); | 1169 rasterizer_->CheckForCompletedTasks(); |
| 1171 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; | 1170 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; |
| 1172 | 1171 |
| 1173 if (IsReadyToActivate()) | 1172 if (IsReadyToActivate()) |
| 1174 client_->NotifyReadyToActivate(); | 1173 client_->NotifyReadyToActivate(); |
| 1175 } | 1174 } |
| 1176 | 1175 |
| 1177 } // namespace cc | 1176 } // namespace cc |
| OLD | NEW |