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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 gfx::Canvas* CreateCanvasForLayer(const Layer* layer) { | 62 gfx::Canvas* CreateCanvasForLayer(const Layer* layer) { |
63 return gfx::Canvas::CreateCanvas(layer->bounds().width(), | 63 return gfx::Canvas::CreateCanvas(layer->bounds().width(), |
64 layer->bounds().height(), | 64 layer->bounds().height(), |
65 false); | 65 false); |
66 } | 66 } |
67 | 67 |
68 void PaintColorToLayer(Layer* layer, SkColor color) { | 68 void PaintColorToLayer(Layer* layer, SkColor color) { |
69 scoped_ptr<gfx::Canvas> canvas(CreateCanvasForLayer(layer)); | 69 scoped_ptr<gfx::Canvas> canvas(CreateCanvasForLayer(layer)); |
70 canvas->FillRectInt(color, 0, 0, layer->bounds().width(), | 70 canvas->FillRectInt(color, 0, 0, layer->bounds().width(), |
71 layer->bounds().height()); | 71 layer->bounds().height()); |
72 layer->SetCanvas(*canvas->AsCanvasSkia(), layer->bounds().origin()); | 72 layer->SetCanvas(*canvas->GetSkCanvas(), layer->bounds().origin()); |
73 } | 73 } |
74 | 74 |
75 void DrawTree(Layer* root) { | 75 void DrawTree(Layer* root) { |
76 GetCompositor()->SetRootLayer(root); | 76 GetCompositor()->SetRootLayer(root); |
77 GetCompositor()->Draw(false); | 77 GetCompositor()->Draw(false); |
78 } | 78 } |
79 | 79 |
80 void RunPendingMessages() { | 80 void RunPendingMessages() { |
81 MessageLoopForUI::current()->RunAllPending(); | 81 MessageLoopForUI::current()->RunAllPending(); |
82 } | 82 } |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 gfx::Canvas* CreateCanvasForLayer(const Layer* layer) { | 229 gfx::Canvas* CreateCanvasForLayer(const Layer* layer) { |
230 return gfx::Canvas::CreateCanvas(layer->bounds().width(), | 230 return gfx::Canvas::CreateCanvas(layer->bounds().width(), |
231 layer->bounds().height(), | 231 layer->bounds().height(), |
232 false); | 232 false); |
233 } | 233 } |
234 | 234 |
235 void PaintColorToLayer(Layer* layer, SkColor color) { | 235 void PaintColorToLayer(Layer* layer, SkColor color) { |
236 scoped_ptr<gfx::Canvas> canvas(CreateCanvasForLayer(layer)); | 236 scoped_ptr<gfx::Canvas> canvas(CreateCanvasForLayer(layer)); |
237 canvas->FillRectInt(color, 0, 0, layer->bounds().width(), | 237 canvas->FillRectInt(color, 0, 0, layer->bounds().width(), |
238 layer->bounds().height()); | 238 layer->bounds().height()); |
239 layer->SetCanvas(*canvas->AsCanvasSkia(), layer->bounds().origin()); | 239 layer->SetCanvas(canvas->GetSkCanvas(), layer->bounds().origin()); |
240 } | 240 } |
241 | 241 |
242 void DrawTree(Layer* root) { | 242 void DrawTree(Layer* root) { |
243 compositor()->SetRootLayer(root); | 243 compositor()->SetRootLayer(root); |
244 compositor()->Draw(false); | 244 compositor()->Draw(false); |
245 } | 245 } |
246 | 246 |
247 // Invalidates the entire contents of the layer. | 247 // Invalidates the entire contents of the layer. |
248 void SchedulePaintForLayer(Layer* layer) { | 248 void SchedulePaintForLayer(Layer* layer) { |
249 layer->SchedulePaint( | 249 layer->SchedulePaint( |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
617 EXPECT_TRUE(NULL != l122->texture()); | 617 EXPECT_TRUE(NULL != l122->texture()); |
618 | 618 |
619 // Toggling l2's visibility should drop all sub-layer textures. | 619 // Toggling l2's visibility should drop all sub-layer textures. |
620 l12->SetVisible(false); | 620 l12->SetVisible(false); |
621 EXPECT_EQ(NULL, l12->texture()); | 621 EXPECT_EQ(NULL, l12->texture()); |
622 EXPECT_EQ(NULL, l121->texture()); | 622 EXPECT_EQ(NULL, l121->texture()); |
623 EXPECT_EQ(NULL, l122->texture()); | 623 EXPECT_EQ(NULL, l122->texture()); |
624 } | 624 } |
625 | 625 |
626 } // namespace ui | 626 } // namespace ui |
OLD | NEW |