OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/compiler_specific.h" | 6 #include "base/compiler_specific.h" |
7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 colors_.push_back(color); | 221 colors_.push_back(color); |
222 } | 222 } |
223 | 223 |
224 gfx::Size paint_size() const { return paint_size_; } | 224 gfx::Size paint_size() const { return paint_size_; } |
225 int color_index() const { return color_index_; } | 225 int color_index() const { return color_index_; } |
226 | 226 |
227 // Overridden from LayerDelegate: | 227 // Overridden from LayerDelegate: |
228 virtual void OnPaintLayer(gfx::Canvas* canvas) OVERRIDE { | 228 virtual void OnPaintLayer(gfx::Canvas* canvas) OVERRIDE { |
229 SkBitmap contents = canvas->AsCanvasSkia()->ExtractBitmap(); | 229 SkBitmap contents = canvas->AsCanvasSkia()->ExtractBitmap(); |
230 paint_size_ = gfx::Size(contents.width(), contents.height()); | 230 paint_size_ = gfx::Size(contents.width(), contents.height()); |
231 canvas->FillRect(colors_[color_index_], | 231 canvas->FillRect(gfx::Rect(gfx::Point(), paint_size_), |
232 gfx::Rect(gfx::Point(), paint_size_)); | 232 colors_[color_index_]); |
233 color_index_ = (color_index_ + 1) % static_cast<int>(colors_.size()); | 233 color_index_ = (color_index_ + 1) % static_cast<int>(colors_.size()); |
234 } | 234 } |
235 | 235 |
236 private: | 236 private: |
237 std::vector<SkColor> colors_; | 237 std::vector<SkColor> colors_; |
238 int color_index_; | 238 int color_index_; |
239 gfx::Size paint_size_; | 239 gfx::Size paint_size_; |
240 | 240 |
241 DISALLOW_COPY_AND_ASSIGN(TestLayerDelegate); | 241 DISALLOW_COPY_AND_ASSIGN(TestLayerDelegate); |
242 }; | 242 }; |
(...skipping 772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1015 EXPECT_TRUE(schedule_draw_invoked_); | 1015 EXPECT_TRUE(schedule_draw_invoked_); |
1016 // Because SchedulePaint() was invoked from OnPaintLayer() |child| should | 1016 // Because SchedulePaint() was invoked from OnPaintLayer() |child| should |
1017 // still need to be painted. | 1017 // still need to be painted. |
1018 DrawTree(root.get()); | 1018 DrawTree(root.get()); |
1019 EXPECT_EQ(1, child_delegate.GetPaintCountAndClear()); | 1019 EXPECT_EQ(1, child_delegate.GetPaintCountAndClear()); |
1020 EXPECT_TRUE(child_delegate.last_clip_rect().Contains( | 1020 EXPECT_TRUE(child_delegate.last_clip_rect().Contains( |
1021 gfx::Rect(10, 10, 30, 30))); | 1021 gfx::Rect(10, 10, 30, 30))); |
1022 } | 1022 } |
1023 | 1023 |
1024 } // namespace ui | 1024 } // namespace ui |
OLD | NEW |