| 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/raster_buffer.h" |
| 21 #include "cc/resources/rasterizer.h" | 21 #include "cc/resources/rasterizer.h" |
| 22 #include "cc/resources/tile.h" | 22 #include "cc/resources/tile.h" |
| 23 #include "third_party/skia/include/core/SkBitmap.h" | |
| 24 #include "third_party/skia/include/core/SkPixelRef.h" | |
| 25 #include "ui/gfx/rect_conversions.h" | 23 #include "ui/gfx/rect_conversions.h" |
| 26 | 24 |
| 27 namespace cc { | 25 namespace cc { |
| 28 namespace { | 26 namespace { |
| 29 | 27 |
| 30 // Flag to indicate whether we should try and detect that | 28 // Flag to indicate whether we should try and detect that |
| 31 // a tile is of solid color. | 29 // a tile is of solid color. |
| 32 const bool kUseColorEstimator = true; | 30 const bool kUseColorEstimator = true; |
| 33 | 31 |
| 34 class RasterTaskImpl : public RasterTask { | 32 class RasterTaskImpl : public RasterTask { |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 // Clear the flag if we're not using the estimator. | 105 // Clear the flag if we're not using the estimator. |
| 108 analysis_.is_solid_color &= kUseColorEstimator; | 106 analysis_.is_solid_color &= kUseColorEstimator; |
| 109 } | 107 } |
| 110 | 108 |
| 111 void Raster(const PicturePileImpl* picture_pile) { | 109 void Raster(const PicturePileImpl* picture_pile) { |
| 112 frame_viewer_instrumentation::ScopedRasterTask raster_task( | 110 frame_viewer_instrumentation::ScopedRasterTask raster_task( |
| 113 tile_id_, tile_resolution_, source_frame_number_, layer_id_); | 111 tile_id_, tile_resolution_, source_frame_number_, layer_id_); |
| 114 devtools_instrumentation::ScopedLayerTask layer_task( | 112 devtools_instrumentation::ScopedLayerTask layer_task( |
| 115 devtools_instrumentation::kRasterTask, layer_id_); | 113 devtools_instrumentation::kRasterTask, layer_id_); |
| 116 | 114 |
| 117 skia::RefPtr<SkCanvas> canvas = raster_buffer_->AcquireSkCanvas(); | |
| 118 DCHECK(canvas); | |
| 119 | |
| 120 base::TimeDelta prev_rasterize_time = | 115 base::TimeDelta prev_rasterize_time = |
| 121 rendering_stats_->impl_thread_rendering_stats().rasterize_time; | 116 rendering_stats_->impl_thread_rendering_stats().rasterize_time; |
| 122 | 117 |
| 123 // Only record rasterization time for highres tiles, because | 118 // Only record rasterization time for highres tiles, because |
| 124 // lowres tiles are not required for activation and therefore | 119 // lowres tiles are not required for activation and therefore |
| 125 // introduce noise in the measurement (sometimes they get rasterized | 120 // introduce noise in the measurement (sometimes they get rasterized |
| 126 // before we draw and sometimes they aren't) | 121 // before we draw and sometimes they aren't) |
| 127 RenderingStatsInstrumentation* stats = | 122 RenderingStatsInstrumentation* stats = |
| 128 tile_resolution_ == HIGH_RESOLUTION ? rendering_stats_ : NULL; | 123 tile_resolution_ == HIGH_RESOLUTION ? rendering_stats_ : NULL; |
| 129 DCHECK(picture_pile); | 124 DCHECK(picture_pile); |
| 130 picture_pile->RasterToBitmap( | 125 |
| 131 canvas.get(), content_rect_, contents_scale_, stats); | 126 raster_buffer_->Playback( |
| 127 picture_pile_.get(), content_rect_, contents_scale_, stats); |
| 132 | 128 |
| 133 if (rendering_stats_->record_rendering_stats()) { | 129 if (rendering_stats_->record_rendering_stats()) { |
| 134 base::TimeDelta current_rasterize_time = | 130 base::TimeDelta current_rasterize_time = |
| 135 rendering_stats_->impl_thread_rendering_stats().rasterize_time; | 131 rendering_stats_->impl_thread_rendering_stats().rasterize_time; |
| 136 LOCAL_HISTOGRAM_CUSTOM_COUNTS( | 132 LOCAL_HISTOGRAM_CUSTOM_COUNTS( |
| 137 "Renderer4.PictureRasterTimeUS", | 133 "Renderer4.PictureRasterTimeUS", |
| 138 (current_rasterize_time - prev_rasterize_time).InMicroseconds(), | 134 (current_rasterize_time - prev_rasterize_time).InMicroseconds(), |
| 139 0, | 135 0, |
| 140 100000, | 136 100000, |
| 141 100); | 137 100); |
| 142 } | 138 } |
| 143 | |
| 144 raster_buffer_->ReleaseSkCanvas(canvas); | |
| 145 } | 139 } |
| 146 | 140 |
| 147 PicturePileImpl::Analysis analysis_; | 141 PicturePileImpl::Analysis analysis_; |
| 148 scoped_refptr<PicturePileImpl> picture_pile_; | 142 scoped_refptr<PicturePileImpl> picture_pile_; |
| 149 gfx::Rect content_rect_; | 143 gfx::Rect content_rect_; |
| 150 float contents_scale_; | 144 float contents_scale_; |
| 151 TileResolution tile_resolution_; | 145 TileResolution tile_resolution_; |
| 152 int layer_id_; | 146 int layer_id_; |
| 153 const void* tile_id_; | 147 const void* tile_id_; |
| 154 int source_frame_number_; | 148 int source_frame_number_; |
| (...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 905 result -= other; | 899 result -= other; |
| 906 return result; | 900 return result; |
| 907 } | 901 } |
| 908 | 902 |
| 909 bool TileManager::MemoryUsage::Exceeds(const MemoryUsage& limit) const { | 903 bool TileManager::MemoryUsage::Exceeds(const MemoryUsage& limit) const { |
| 910 return memory_bytes_ > limit.memory_bytes_ || | 904 return memory_bytes_ > limit.memory_bytes_ || |
| 911 resource_count_ > limit.resource_count_; | 905 resource_count_ > limit.resource_count_; |
| 912 } | 906 } |
| 913 | 907 |
| 914 } // namespace cc | 908 } // namespace cc |
| OLD | NEW |