| 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 <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/json/json_writer.h" | 11 #include "base/json/json_writer.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
| 14 #include "cc/debug/debug_colors.h" | |
| 15 #include "cc/debug/devtools_instrumentation.h" | 14 #include "cc/debug/devtools_instrumentation.h" |
| 16 #include "cc/debug/traced_value.h" | 15 #include "cc/debug/traced_value.h" |
| 17 #include "cc/resources/raster_worker_pool.h" | 16 #include "cc/resources/raster_worker_pool.h" |
| 18 #include "cc/resources/resource_pool.h" | 17 #include "cc/resources/resource_pool.h" |
| 19 #include "cc/resources/tile.h" | 18 #include "cc/resources/tile.h" |
| 20 #include "third_party/skia/include/core/SkDevice.h" | 19 #include "third_party/skia/include/core/SkDevice.h" |
| 21 #include "ui/gfx/rect_conversions.h" | 20 #include "ui/gfx/rect_conversions.h" |
| 22 | 21 |
| 23 namespace cc { | 22 namespace cc { |
| 24 | 23 |
| (...skipping 876 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 901 | 900 |
| 902 if (analysis->is_solid_color) | 901 if (analysis->is_solid_color) |
| 903 return; | 902 return; |
| 904 | 903 |
| 905 SkBitmap bitmap; | 904 SkBitmap bitmap; |
| 906 bitmap.setConfig(SkBitmap::kARGB_8888_Config, rect.width(), rect.height()); | 905 bitmap.setConfig(SkBitmap::kARGB_8888_Config, rect.width(), rect.height()); |
| 907 bitmap.setPixels(buffer); | 906 bitmap.setPixels(buffer); |
| 908 SkDevice device(bitmap); | 907 SkDevice device(bitmap); |
| 909 SkCanvas canvas(&device); | 908 SkCanvas canvas(&device); |
| 910 | 909 |
| 911 #ifndef NDEBUG | |
| 912 // Any non-painted areas will be left in this color. | |
| 913 canvas.clear(DebugColors::NonPaintedFillColor()); | |
| 914 #endif // NDEBUG | |
| 915 | |
| 916 if (stats_instrumentation->record_rendering_stats()) { | 910 if (stats_instrumentation->record_rendering_stats()) { |
| 917 PicturePileImpl::RasterStats raster_stats; | 911 PicturePileImpl::RasterStats raster_stats; |
| 918 picture_pile->Raster(&canvas, rect, contents_scale, &raster_stats); | 912 picture_pile->RasterToBitmap(&canvas, rect, contents_scale, &raster_stats); |
| 919 stats_instrumentation->AddRaster( | 913 stats_instrumentation->AddRaster( |
| 920 raster_stats.total_rasterize_time, | 914 raster_stats.total_rasterize_time, |
| 921 raster_stats.best_rasterize_time, | 915 raster_stats.best_rasterize_time, |
| 922 raster_stats.total_pixels_rasterized, | 916 raster_stats.total_pixels_rasterized, |
| 923 metadata.is_tile_in_pending_tree_now_bin); | 917 metadata.is_tile_in_pending_tree_now_bin); |
| 924 | 918 |
| 925 HISTOGRAM_CUSTOM_COUNTS( | 919 HISTOGRAM_CUSTOM_COUNTS( |
| 926 "Renderer4.PictureRasterTimeUS", | 920 "Renderer4.PictureRasterTimeUS", |
| 927 raster_stats.total_rasterize_time.InMicroseconds(), | 921 raster_stats.total_rasterize_time.InMicroseconds(), |
| 928 0, | 922 0, |
| 929 100000, | 923 100000, |
| 930 100); | 924 100); |
| 931 } else { | 925 } else { |
| 932 picture_pile->Raster(&canvas, rect, contents_scale, NULL); | 926 picture_pile->RasterToBitmap(&canvas, rect, contents_scale, NULL); |
| 933 } | 927 } |
| 934 } | 928 } |
| 935 | 929 |
| 936 // static | 930 // static |
| 937 void TileManager::RunImageDecodeTask( | 931 void TileManager::RunImageDecodeTask( |
| 938 skia::LazyPixelRef* pixel_ref, | 932 skia::LazyPixelRef* pixel_ref, |
| 939 int layer_id, | 933 int layer_id, |
| 940 RenderingStatsInstrumentation* stats_instrumentation) { | 934 RenderingStatsInstrumentation* stats_instrumentation) { |
| 941 TRACE_EVENT0("cc", "TileManager::RunImageDecodeTask"); | 935 TRACE_EVENT0("cc", "TileManager::RunImageDecodeTask"); |
| 942 devtools_instrumentation::ScopedImageDecodeTask image_decode_task(layer_id); | 936 devtools_instrumentation::ScopedImageDecodeTask image_decode_task(layer_id); |
| 943 base::TimeTicks start_time = stats_instrumentation->StartRecording(); | 937 base::TimeTicks start_time = stats_instrumentation->StartRecording(); |
| 944 pixel_ref->Decode(); | 938 pixel_ref->Decode(); |
| 945 base::TimeDelta duration = stats_instrumentation->EndRecording(start_time); | 939 base::TimeDelta duration = stats_instrumentation->EndRecording(start_time); |
| 946 stats_instrumentation->AddDeferredImageDecode(duration); | 940 stats_instrumentation->AddDeferredImageDecode(duration); |
| 947 } | 941 } |
| 948 | 942 |
| 949 } // namespace cc | 943 } // namespace cc |
| OLD | NEW |