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
3 // found in the LICENSE file.
5 #include "cc/test/fake_content_layer_client.h"
7 #include "third_party/skia/include/core/SkCanvas.h"
8 #include "ui/gfx/skia_util.h"
12 FakeContentLayerClient::FakeContentLayerClient()
13 : fill_with_nonsolid_color_(false), last_canvas_(NULL) {
16 FakeContentLayerClient::~FakeContentLayerClient() {
19 void FakeContentLayerClient::PaintContents(
21 const gfx::Rect& paint_rect,
22 ContentLayerClient::GraphicsContextStatus gc_status) {
23 last_canvas_ = canvas;
24 last_context_status_ = gc_status;
26 canvas->clipRect(gfx::RectToSkRect(paint_rect));
27 for (RectPaintVector::const_iterator it = draw_rects_.begin();
28 it != draw_rects_.end(); ++it) {
29 const gfx::RectF& draw_rect = it->first;
30 const SkPaint& paint = it->second;
31 canvas->drawRectCoords(draw_rect.x(),
38 for (BitmapVector::const_iterator it = draw_bitmaps_.begin();
39 it != draw_bitmaps_.end(); ++it) {
40 canvas->drawBitmap(it->bitmap, it->point.x(), it->point.y(), &it->paint);
43 if (fill_with_nonsolid_color_) {
44 gfx::RectF draw_rect = paint_rect;
46 while (!draw_rect.IsEmpty()) {
48 paint.setColor(red ? SK_ColorRED : SK_ColorBLUE);
49 canvas->drawRect(gfx::RectFToSkRect(draw_rect), paint);
50 draw_rect.Inset(1, 1);
55 bool FakeContentLayerClient::FillsBoundsCompletely() const { return false; }