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.
4
5 #include "cc/quads/checkerboard_draw_quad.h"
6
7 #include "base/logging.h"
8 #include "base/values.h"
9
10 namespace cc {
11
CheckerboardDrawQuad()12 CheckerboardDrawQuad::CheckerboardDrawQuad() : color(0) {}
13
Create()14 scoped_ptr<CheckerboardDrawQuad> CheckerboardDrawQuad::Create() {
15 return make_scoped_ptr(new CheckerboardDrawQuad);
16 }
17
SetNew(const SharedQuadState * shared_quad_state,gfx::Rect rect,SkColor color)18 void CheckerboardDrawQuad::SetNew(const SharedQuadState* shared_quad_state,
19 gfx::Rect rect,
20 SkColor color) {
21 gfx::Rect opaque_rect = SkColorGetA(color) == 255 ? rect : gfx::Rect();
22 gfx::Rect visible_rect = rect;
23 bool needs_blending = false;
24 DrawQuad::SetAll(shared_quad_state, DrawQuad::CHECKERBOARD, rect, opaque_rect,
25 visible_rect, needs_blending);
26 this->color = color;
27 }
28
SetAll(const SharedQuadState * shared_quad_state,gfx::Rect rect,gfx::Rect opaque_rect,gfx::Rect visible_rect,bool needs_blending,SkColor color)29 void CheckerboardDrawQuad::SetAll(const SharedQuadState* shared_quad_state,
30 gfx::Rect rect,
31 gfx::Rect opaque_rect,
32 gfx::Rect visible_rect,
33 bool needs_blending,
34 SkColor color) {
35 DrawQuad::SetAll(shared_quad_state, DrawQuad::CHECKERBOARD, rect, opaque_rect,
36 visible_rect, needs_blending);
37 this->color = color;
38 }
39
IterateResources(const ResourceIteratorCallback & callback)40 void CheckerboardDrawQuad::IterateResources(
41 const ResourceIteratorCallback& callback) {}
42
MaterialCast(const DrawQuad * quad)43 const CheckerboardDrawQuad* CheckerboardDrawQuad::MaterialCast(
44 const DrawQuad* quad) {
45 DCHECK(quad->material == DrawQuad::CHECKERBOARD);
46 return static_cast<const CheckerboardDrawQuad*>(quad);
47 }
48
ExtendValue(base::DictionaryValue * value) const49 void CheckerboardDrawQuad::ExtendValue(base::DictionaryValue* value) const {
50 value->SetInteger("color", color);
51 }
52
53 } // namespace cc
54