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" | |
13 | 12 |
14 namespace cc { | 13 namespace cc { |
15 | 14 |
16 FakePicturePileImpl::FakePicturePileImpl() {} | 15 FakePicturePileImpl::FakePicturePileImpl() {} |
17 | 16 |
18 FakePicturePileImpl::~FakePicturePileImpl() {} | 17 FakePicturePileImpl::~FakePicturePileImpl() {} |
19 | 18 |
20 scoped_refptr<FakePicturePileImpl> FakePicturePileImpl::CreateFilledPile( | 19 scoped_refptr<FakePicturePileImpl> FakePicturePileImpl::CreateFilledPile( |
21 gfx::Size tile_size, | 20 gfx::Size tile_size, |
22 gfx::Size layer_bounds) { | 21 gfx::Size layer_bounds) { |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 | 100 |
102 void FakePicturePileImpl::RerecordPile() { | 101 void FakePicturePileImpl::RerecordPile() { |
103 for (int y = 0; y < num_tiles_y(); ++y) { | 102 for (int y = 0; y < num_tiles_y(); ++y) { |
104 for (int x = 0; x < num_tiles_x(); ++x) { | 103 for (int x = 0; x < num_tiles_x(); ++x) { |
105 RemoveRecordingAt(x, y); | 104 RemoveRecordingAt(x, y); |
106 AddRecordingAt(x, y); | 105 AddRecordingAt(x, y); |
107 } | 106 } |
108 } | 107 } |
109 } | 108 } |
110 | 109 |
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 | |
133 } // namespace cc | 110 } // namespace cc |
OLD | NEW |