| 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 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 | 219 |
| 220 void AddColor(SkColor color) { | 220 void AddColor(SkColor color) { |
| 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->ExtractBitmap(); |
| 230 paint_size_ = gfx::Size(contents.width(), contents.height()); | 230 paint_size_ = gfx::Size(contents.width(), contents.height()); |
| 231 canvas->FillRect(gfx::Rect(paint_size_), colors_[color_index_]); | 231 canvas->FillRect(gfx::Rect(paint_size_), colors_[color_index_]); |
| 232 color_index_ = (color_index_ + 1) % static_cast<int>(colors_.size()); | 232 color_index_ = (color_index_ + 1) % static_cast<int>(colors_.size()); |
| 233 } | 233 } |
| 234 | 234 |
| 235 private: | 235 private: |
| 236 std::vector<SkColor> colors_; | 236 std::vector<SkColor> colors_; |
| 237 int color_index_; | 237 int color_index_; |
| 238 gfx::Size paint_size_; | 238 gfx::Size paint_size_; |
| 239 | 239 |
| (...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1014 EXPECT_TRUE(schedule_draw_invoked_); | 1014 EXPECT_TRUE(schedule_draw_invoked_); |
| 1015 // Because SchedulePaint() was invoked from OnPaintLayer() |child| should | 1015 // Because SchedulePaint() was invoked from OnPaintLayer() |child| should |
| 1016 // still need to be painted. | 1016 // still need to be painted. |
| 1017 DrawTree(root.get()); | 1017 DrawTree(root.get()); |
| 1018 EXPECT_EQ(1, child_delegate.GetPaintCountAndClear()); | 1018 EXPECT_EQ(1, child_delegate.GetPaintCountAndClear()); |
| 1019 EXPECT_TRUE(child_delegate.last_clip_rect().Contains( | 1019 EXPECT_TRUE(child_delegate.last_clip_rect().Contains( |
| 1020 gfx::Rect(10, 10, 30, 30))); | 1020 gfx::Rect(10, 10, 30, 30))); |
| 1021 } | 1021 } |
| 1022 | 1022 |
| 1023 } // namespace ui | 1023 } // namespace ui |
| OLD | NEW |