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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 | 88 |
88 void FakePicturePileImpl::RerecordPile() { | 89 void FakePicturePileImpl::RerecordPile() { |
89 for (int y = 0; y < num_tiles_y(); ++y) { | 90 for (int y = 0; y < num_tiles_y(); ++y) { |
90 for (int x = 0; x < num_tiles_x(); ++x) { | 91 for (int x = 0; x < num_tiles_x(); ++x) { |
91 RemoveRecordingAt(x, y); | 92 RemoveRecordingAt(x, y); |
92 AddRecordingAt(x, y); | 93 AddRecordingAt(x, y); |
93 } | 94 } |
94 } | 95 } |
95 } | 96 } |
96 | 97 |
| 98 void FakePicturePileImpl::AnalyzeInRect(gfx::Rect content_rect, |
| 99 float contents_scale, |
| 100 Analysis* analysis) { |
| 101 // Create and raster to a bitmap of content_rect size, even though the |
| 102 // analysis_rect may be smaller to simulate edge tiles where recorded content |
| 103 // doesn't cover the entire content_rect. |
| 104 SkBitmap empty_bitmap; |
| 105 empty_bitmap.setConfig(SkBitmap::kNo_Config, |
| 106 content_rect.width(), |
| 107 content_rect.height()); |
| 108 |
| 109 gfx::Rect analysis_rect( |
| 110 AnalysisRectForRaster(content_rect, contents_scale)); |
| 111 skia::AnalysisDevice device(empty_bitmap, gfx::RectToSkRect(analysis_rect)); |
| 112 skia::AnalysisCanvas canvas(&device); |
| 113 |
| 114 RasterDirect(&canvas, content_rect, contents_scale, NULL); |
| 115 |
| 116 analysis->is_solid_color = canvas.GetColorIfSolid(&analysis->solid_color); |
| 117 analysis->has_text = canvas.HasText(); |
| 118 } |
| 119 |
97 } // namespace cc | 120 } // namespace cc |
OLD | NEW |