OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/test/fake_picture_pile_impl.h" | 5 #include "cc/test/fake_picture_pile_impl.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "cc/test/impl_side_painting_settings.h" | 10 #include "cc/test/impl_side_painting_settings.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 #include "ui/gfx/skia_util.h" |
12 | 13 |
13 namespace cc { | 14 namespace cc { |
14 | 15 |
15 FakePicturePileImpl::FakePicturePileImpl() {} | 16 FakePicturePileImpl::FakePicturePileImpl() {} |
16 | 17 |
17 FakePicturePileImpl::~FakePicturePileImpl() {} | 18 FakePicturePileImpl::~FakePicturePileImpl() {} |
18 | 19 |
19 scoped_refptr<FakePicturePileImpl> FakePicturePileImpl::CreateFilledPile( | 20 scoped_refptr<FakePicturePileImpl> FakePicturePileImpl::CreateFilledPile( |
20 gfx::Size tile_size, | 21 gfx::Size tile_size, |
21 gfx::Size layer_bounds) { | 22 gfx::Size layer_bounds) { |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 | 101 |
101 void FakePicturePileImpl::RerecordPile() { | 102 void FakePicturePileImpl::RerecordPile() { |
102 for (int y = 0; y < num_tiles_y(); ++y) { | 103 for (int y = 0; y < num_tiles_y(); ++y) { |
103 for (int x = 0; x < num_tiles_x(); ++x) { | 104 for (int x = 0; x < num_tiles_x(); ++x) { |
104 RemoveRecordingAt(x, y); | 105 RemoveRecordingAt(x, y); |
105 AddRecordingAt(x, y); | 106 AddRecordingAt(x, y); |
106 } | 107 } |
107 } | 108 } |
108 } | 109 } |
109 | 110 |
| 111 void FakePicturePileImpl::AnalyzeInRect(gfx::Rect content_rect, |
| 112 float contents_scale, |
| 113 Analysis* analysis) { |
| 114 // Create and raster to a bitmap of content_rect size, even though the |
| 115 // analysis_rect may be smaller to simulate edge tiles where recorded content |
| 116 // doesn't cover the entire content_rect. |
| 117 SkBitmap empty_bitmap; |
| 118 empty_bitmap.setConfig(SkBitmap::kNo_Config, |
| 119 content_rect.width(), |
| 120 content_rect.height()); |
| 121 |
| 122 gfx::Rect analysis_rect( |
| 123 AnalysisRectForRaster(content_rect, contents_scale)); |
| 124 skia::AnalysisDevice device(empty_bitmap, gfx::RectToSkRect(analysis_rect)); |
| 125 skia::AnalysisCanvas canvas(&device); |
| 126 |
| 127 RasterDirect(&canvas, content_rect, contents_scale, NULL); |
| 128 |
| 129 analysis->is_solid_color = canvas.GetColorIfSolid(&analysis->solid_color); |
| 130 analysis->has_text = canvas.HasText(); |
| 131 } |
| 132 |
110 } // namespace cc | 133 } // namespace cc |
OLD | NEW |