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 // Add a rectangle to the middle that doesn't fill |paint_rect| so that solid
44 // color analysis will fail.
45 if (fill_with_nonsolid_color_
) {
46 gfx::RectF draw_rect
= paint_rect
;
47 draw_rect
.Inset(draw_rect
.width() / 4.0f
, draw_rect
.height() / 4.0f
);
49 canvas
->drawRectCoords(draw_rect
.x(),
57 bool FakeContentLayerClient::FillsBoundsCompletely() const { return false; }