1// Copyright 2013 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/content_draw_quad_base.h"
6
7#include "base/debug/trace_event_argument.h"
8#include "base/logging.h"
9#include "base/values.h"
10#include "cc/base/math_util.h"
11
12namespace cc {
13
14ContentDrawQuadBase::ContentDrawQuadBase()
15    : swizzle_contents(false) {
16}
17
18ContentDrawQuadBase::~ContentDrawQuadBase() {
19}
20
21void ContentDrawQuadBase::SetNew(const SharedQuadState* shared_quad_state,
22                                 DrawQuad::Material material,
23                                 const gfx::Rect& rect,
24                                 const gfx::Rect& opaque_rect,
25                                 const gfx::Rect& visible_rect,
26                                 const gfx::RectF& tex_coord_rect,
27                                 const gfx::Size& texture_size,
28                                 bool swizzle_contents) {
29  bool needs_blending = false;
30  DrawQuad::SetAll(shared_quad_state, material, rect, opaque_rect,
31                   visible_rect, needs_blending);
32  this->tex_coord_rect = tex_coord_rect;
33  this->texture_size = texture_size;
34  this->swizzle_contents = swizzle_contents;
35}
36
37void ContentDrawQuadBase::SetAll(const SharedQuadState* shared_quad_state,
38                                 DrawQuad::Material material,
39                                 const gfx::Rect& rect,
40                                 const gfx::Rect& opaque_rect,
41                                 const gfx::Rect& visible_rect,
42                                 bool needs_blending,
43                                 const gfx::RectF& tex_coord_rect,
44                                 const gfx::Size& texture_size,
45                                 bool swizzle_contents) {
46  DrawQuad::SetAll(shared_quad_state, material, rect, opaque_rect,
47                   visible_rect, needs_blending);
48  this->tex_coord_rect = tex_coord_rect;
49  this->texture_size = texture_size;
50  this->swizzle_contents = swizzle_contents;
51}
52
53void ContentDrawQuadBase::ExtendValue(base::debug::TracedValue* value) const {
54  value->BeginArray("tex_coord_rect");
55  MathUtil::AddToTracedValue(tex_coord_rect, value);
56  value->EndArray();
57
58  value->BeginDictionary("texture_size");
59  MathUtil::AddToTracedValue(texture_size, value);
60  value->EndDictionary();
61
62  value->SetBoolean("swizzle_contents", swizzle_contents);
63}
64
65}  // namespace cc
66