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/quads/yuv_video_draw_quad.h"
7 #include "base/logging.h"
8 #include "base/trace_event/trace_event_argument.h"
9 #include "base/values.h"
10 #include "cc/base/math_util.h"
14 YUVVideoDrawQuad::YUVVideoDrawQuad()
15 : y_plane_resource_id(0),
16 u_plane_resource_id(0),
17 v_plane_resource_id(0),
18 a_plane_resource_id(0) {}
19 YUVVideoDrawQuad::~YUVVideoDrawQuad() {}
21 void YUVVideoDrawQuad::SetNew(const SharedQuadState
* shared_quad_state
,
22 const gfx::Rect
& rect
,
23 const gfx::Rect
& opaque_rect
,
24 const gfx::Rect
& visible_rect
,
25 const gfx::RectF
& ya_tex_coord_rect
,
26 const gfx::RectF
& uv_tex_coord_rect
,
27 const gfx::Size
& ya_tex_size
,
28 const gfx::Size
& uv_tex_size
,
29 unsigned y_plane_resource_id
,
30 unsigned u_plane_resource_id
,
31 unsigned v_plane_resource_id
,
32 unsigned a_plane_resource_id
,
33 ColorSpace color_space
) {
34 bool needs_blending
= false;
35 DrawQuad::SetAll(shared_quad_state
, DrawQuad::YUV_VIDEO_CONTENT
, rect
,
36 opaque_rect
, visible_rect
, needs_blending
);
37 this->ya_tex_coord_rect
= ya_tex_coord_rect
;
38 this->uv_tex_coord_rect
= uv_tex_coord_rect
;
39 this->ya_tex_size
= ya_tex_size
;
40 this->uv_tex_size
= uv_tex_size
;
41 this->y_plane_resource_id
= y_plane_resource_id
;
42 this->u_plane_resource_id
= u_plane_resource_id
;
43 this->v_plane_resource_id
= v_plane_resource_id
;
44 this->a_plane_resource_id
= a_plane_resource_id
;
45 this->color_space
= color_space
;
48 void YUVVideoDrawQuad::SetAll(const SharedQuadState
* shared_quad_state
,
49 const gfx::Rect
& rect
,
50 const gfx::Rect
& opaque_rect
,
51 const gfx::Rect
& visible_rect
,
53 const gfx::RectF
& ya_tex_coord_rect
,
54 const gfx::RectF
& uv_tex_coord_rect
,
55 const gfx::Size
& ya_tex_size
,
56 const gfx::Size
& uv_tex_size
,
57 unsigned y_plane_resource_id
,
58 unsigned u_plane_resource_id
,
59 unsigned v_plane_resource_id
,
60 unsigned a_plane_resource_id
,
61 ColorSpace color_space
) {
62 DrawQuad::SetAll(shared_quad_state
, DrawQuad::YUV_VIDEO_CONTENT
, rect
,
63 opaque_rect
, visible_rect
, needs_blending
);
64 this->ya_tex_coord_rect
= ya_tex_coord_rect
;
65 this->uv_tex_coord_rect
= uv_tex_coord_rect
;
66 this->ya_tex_size
= ya_tex_size
;
67 this->uv_tex_size
= uv_tex_size
;
68 this->y_plane_resource_id
= y_plane_resource_id
;
69 this->u_plane_resource_id
= u_plane_resource_id
;
70 this->v_plane_resource_id
= v_plane_resource_id
;
71 this->a_plane_resource_id
= a_plane_resource_id
;
72 this->color_space
= color_space
;
75 void YUVVideoDrawQuad::IterateResources(
76 const ResourceIteratorCallback
& callback
) {
77 y_plane_resource_id
= callback
.Run(y_plane_resource_id
);
78 u_plane_resource_id
= callback
.Run(u_plane_resource_id
);
79 v_plane_resource_id
= callback
.Run(v_plane_resource_id
);
80 if (a_plane_resource_id
)
81 a_plane_resource_id
= callback
.Run(a_plane_resource_id
);
84 const YUVVideoDrawQuad
* YUVVideoDrawQuad::MaterialCast(
85 const DrawQuad
* quad
) {
86 DCHECK(quad
->material
== DrawQuad::YUV_VIDEO_CONTENT
);
87 return static_cast<const YUVVideoDrawQuad
*>(quad
);
90 void YUVVideoDrawQuad::ExtendValue(
91 base::trace_event::TracedValue
* value
) const {
92 MathUtil::AddToTracedValue("ya_tex_coord_rect", ya_tex_coord_rect
, value
);
93 MathUtil::AddToTracedValue("uv_tex_coord_rect", uv_tex_coord_rect
, value
);
94 MathUtil::AddToTracedValue("ya_tex_size", ya_tex_size
, value
);
95 MathUtil::AddToTracedValue("uv_tex_size", uv_tex_size
, value
);
96 value
->SetInteger("y_plane_resource_id", y_plane_resource_id
);
97 value
->SetInteger("u_plane_resource_id", u_plane_resource_id
);
98 value
->SetInteger("v_plane_resource_id", v_plane_resource_id
);
99 value
->SetInteger("a_plane_resource_id", a_plane_resource_id
);