| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 #include "ui/gfx/canvas_skia.h" | 9 #include "ui/gfx/canvas_skia.h" |
| 10 #include "ui/gfx/compositor/compositor_observer.h" | 10 #include "ui/gfx/compositor/compositor_observer.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 gfx::Size paint_size() const { return paint_size_; } | 27 gfx::Size paint_size() const { return paint_size_; } |
| 28 int color_index() const { return color_index_; } | 28 int color_index() const { return color_index_; } |
| 29 | 29 |
| 30 // Overridden from LayerDelegate: | 30 // Overridden from LayerDelegate: |
| 31 virtual void OnPaintLayer(gfx::Canvas* canvas) OVERRIDE { | 31 virtual void OnPaintLayer(gfx::Canvas* canvas) OVERRIDE { |
| 32 SkBitmap contents = canvas->AsCanvasSkia()->ExtractBitmap(); | 32 SkBitmap contents = canvas->AsCanvasSkia()->ExtractBitmap(); |
| 33 paint_size_ = gfx::Size(contents.width(), contents.height()); | 33 paint_size_ = gfx::Size(contents.width(), contents.height()); |
| 34 canvas->FillRectInt(colors_.at(color_index_), 0, 0, | 34 canvas->FillRectInt(colors_.at(color_index_), 0, 0, |
| 35 contents.width(), | 35 contents.width(), |
| 36 contents.height()); | 36 contents.height()); |
| 37 color_index_ = ++color_index_ % colors_.size(); | 37 color_index_ = (color_index_ + 1) % static_cast<int>(colors_.size()); |
| 38 } | 38 } |
| 39 | 39 |
| 40 private: | 40 private: |
| 41 Layer* owner_; | 41 Layer* owner_; |
| 42 std::vector<SkColor> colors_; | 42 std::vector<SkColor> colors_; |
| 43 int color_index_; | 43 int color_index_; |
| 44 gfx::Size paint_size_; | 44 gfx::Size paint_size_; |
| 45 | 45 |
| 46 DISALLOW_COPY_AND_ASSIGN(TestLayerDelegate); | 46 DISALLOW_COPY_AND_ASSIGN(TestLayerDelegate); |
| 47 }; | 47 }; |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 RunPendingMessages(); | 295 RunPendingMessages(); |
| 296 | 296 |
| 297 // |d2| should not have received a paint notification since it has no texture. | 297 // |d2| should not have received a paint notification since it has no texture. |
| 298 EXPECT_FALSE(d2.painted()); | 298 EXPECT_FALSE(d2.painted()); |
| 299 // |d3| should have received a paint notification. | 299 // |d3| should have received a paint notification. |
| 300 EXPECT_TRUE(d3.painted()); | 300 EXPECT_TRUE(d3.painted()); |
| 301 } | 301 } |
| 302 | 302 |
| 303 } // namespace ui | 303 } // namespace ui |
| 304 | 304 |
| OLD | NEW |