| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "cc/test/fake_content_layer_client.h" | 5 #include "cc/test/fake_content_layer_client.h" |
| 6 | 6 |
| 7 #include "third_party/skia/include/core/SkCanvas.h" | 7 #include "third_party/skia/include/core/SkCanvas.h" |
| 8 #include "ui/gfx/skia_util.h" | 8 #include "ui/gfx/skia_util.h" |
| 9 | 9 |
| 10 namespace cc { | 10 namespace cc { |
| 11 | 11 |
| 12 FakeContentLayerClient::FakeContentLayerClient() | 12 FakeContentLayerClient::FakeContentLayerClient() : last_canvas_(NULL) { |
| 13 : paint_all_opaque_(false), last_canvas_(NULL) {} | 13 } |
| 14 | 14 |
| 15 FakeContentLayerClient::~FakeContentLayerClient() { | 15 FakeContentLayerClient::~FakeContentLayerClient() { |
| 16 } | 16 } |
| 17 | 17 |
| 18 void FakeContentLayerClient::PaintContents( | 18 void FakeContentLayerClient::PaintContents( |
| 19 SkCanvas* canvas, | 19 SkCanvas* canvas, |
| 20 const gfx::Rect& paint_rect, | 20 const gfx::Rect& paint_rect, |
| 21 gfx::RectF* opaque_rect, | |
| 22 ContentLayerClient::GraphicsContextStatus gc_status) { | 21 ContentLayerClient::GraphicsContextStatus gc_status) { |
| 23 last_canvas_ = canvas; | 22 last_canvas_ = canvas; |
| 24 last_context_status_ = gc_status; | 23 last_context_status_ = gc_status; |
| 25 | 24 |
| 26 if (paint_all_opaque_) | |
| 27 *opaque_rect = paint_rect; | |
| 28 | |
| 29 canvas->clipRect(gfx::RectToSkRect(paint_rect)); | 25 canvas->clipRect(gfx::RectToSkRect(paint_rect)); |
| 30 for (RectPaintVector::const_iterator it = draw_rects_.begin(); | 26 for (RectPaintVector::const_iterator it = draw_rects_.begin(); |
| 31 it != draw_rects_.end(); ++it) { | 27 it != draw_rects_.end(); ++it) { |
| 32 const gfx::RectF& draw_rect = it->first; | 28 const gfx::RectF& draw_rect = it->first; |
| 33 const SkPaint& paint = it->second; | 29 const SkPaint& paint = it->second; |
| 34 canvas->drawRectCoords(draw_rect.x(), | 30 canvas->drawRectCoords(draw_rect.x(), |
| 35 draw_rect.y(), | 31 draw_rect.y(), |
| 36 draw_rect.right(), | 32 draw_rect.right(), |
| 37 draw_rect.bottom(), | 33 draw_rect.bottom(), |
| 38 paint); | 34 paint); |
| 39 } | 35 } |
| 40 | 36 |
| 41 for (BitmapVector::const_iterator it = draw_bitmaps_.begin(); | 37 for (BitmapVector::const_iterator it = draw_bitmaps_.begin(); |
| 42 it != draw_bitmaps_.end(); ++it) { | 38 it != draw_bitmaps_.end(); ++it) { |
| 43 canvas->drawBitmap(it->bitmap, it->point.x(), it->point.y(), &it->paint); | 39 canvas->drawBitmap(it->bitmap, it->point.x(), it->point.y(), &it->paint); |
| 44 } | 40 } |
| 45 } | 41 } |
| 46 | 42 |
| 47 bool FakeContentLayerClient::FillsBoundsCompletely() const { return false; } | 43 bool FakeContentLayerClient::FillsBoundsCompletely() const { return false; } |
| 48 | 44 |
| 49 } // namespace cc | 45 } // namespace cc |
| OLD | NEW |