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 "components/viz/common/quads/tile_draw_quad.h"
6 
7 #include "base/check.h"
8 #include "base/trace_event/traced_value.h"
9 #include "base/values.h"
10 
11 namespace viz {
12 
13 TileDrawQuad::TileDrawQuad() = default;
14 
15 TileDrawQuad::~TileDrawQuad() = default;
16 
SetNew(const SharedQuadState * shared_quad_state,const gfx::Rect & rect,const gfx::Rect & visible_rect,bool needs_blending,unsigned resource_id,const gfx::RectF & tex_coord_rect,const gfx::Size & texture_size,bool is_premultiplied,bool nearest_neighbor,bool force_anti_aliasing_off)17 void TileDrawQuad::SetNew(const SharedQuadState* shared_quad_state,
18                           const gfx::Rect& rect,
19                           const gfx::Rect& visible_rect,
20                           bool needs_blending,
21                           unsigned resource_id,
22                           const gfx::RectF& tex_coord_rect,
23                           const gfx::Size& texture_size,
24                           bool is_premultiplied,
25                           bool nearest_neighbor,
26                           bool force_anti_aliasing_off) {
27   ContentDrawQuadBase::SetNew(
28       shared_quad_state, DrawQuad::Material::kTiledContent, rect, visible_rect,
29       needs_blending, tex_coord_rect, texture_size, is_premultiplied,
30       nearest_neighbor, force_anti_aliasing_off);
31   resources.ids[kResourceIdIndex] = resource_id;
32   resources.count = 1;
33 }
34 
SetAll(const SharedQuadState * shared_quad_state,const gfx::Rect & rect,const gfx::Rect & visible_rect,bool needs_blending,unsigned resource_id,const gfx::RectF & tex_coord_rect,const gfx::Size & texture_size,bool is_premultiplied,bool nearest_neighbor,bool force_anti_aliasing_off)35 void TileDrawQuad::SetAll(const SharedQuadState* shared_quad_state,
36                           const gfx::Rect& rect,
37                           const gfx::Rect& visible_rect,
38                           bool needs_blending,
39                           unsigned resource_id,
40                           const gfx::RectF& tex_coord_rect,
41                           const gfx::Size& texture_size,
42                           bool is_premultiplied,
43                           bool nearest_neighbor,
44                           bool force_anti_aliasing_off) {
45   ContentDrawQuadBase::SetAll(
46       shared_quad_state, DrawQuad::Material::kTiledContent, rect, visible_rect,
47       needs_blending, tex_coord_rect, texture_size, is_premultiplied,
48       nearest_neighbor, force_anti_aliasing_off);
49   resources.ids[kResourceIdIndex] = resource_id;
50   resources.count = 1;
51 }
52 
MaterialCast(const DrawQuad * quad)53 const TileDrawQuad* TileDrawQuad::MaterialCast(const DrawQuad* quad) {
54   DCHECK(quad->material == DrawQuad::Material::kTiledContent);
55   return static_cast<const TileDrawQuad*>(quad);
56 }
57 
ExtendValue(base::trace_event::TracedValue * value) const58 void TileDrawQuad::ExtendValue(base::trace_event::TracedValue* value) const {
59   ContentDrawQuadBase::ExtendValue(value);
60   value->SetInteger("resource_id", resources.ids[kResourceIdIndex]);
61 }
62 
63 }  // namespace viz
64