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"
11 YUVVideoDrawQuad::YUVVideoDrawQuad()
12 : y_plane_resource_id(0),
13 u_plane_resource_id(0),
14 v_plane_resource_id(0) {}
15 YUVVideoDrawQuad::~YUVVideoDrawQuad() {}
17 scoped_ptr
<YUVVideoDrawQuad
> YUVVideoDrawQuad::Create() {
18 return make_scoped_ptr(new YUVVideoDrawQuad
);
21 void YUVVideoDrawQuad::SetNew(const SharedQuadState
* shared_quad_state
,
23 gfx::Rect opaque_rect
,
25 unsigned y_plane_resource_id
,
26 unsigned u_plane_resource_id
,
27 unsigned v_plane_resource_id
) {
28 gfx::Rect visible_rect
= rect
;
29 bool needs_blending
= false;
30 DrawQuad::SetAll(shared_quad_state
, DrawQuad::YUV_VIDEO_CONTENT
, rect
,
31 opaque_rect
, visible_rect
, needs_blending
);
32 this->tex_scale
= tex_scale
;
33 this->y_plane_resource_id
= y_plane_resource_id
;
34 this->u_plane_resource_id
= u_plane_resource_id
;
35 this->v_plane_resource_id
= v_plane_resource_id
;
38 void YUVVideoDrawQuad::SetAll(const SharedQuadState
* shared_quad_state
,
40 gfx::Rect opaque_rect
,
41 gfx::Rect visible_rect
,
44 unsigned y_plane_resource_id
,
45 unsigned u_plane_resource_id
,
46 unsigned v_plane_resource_id
) {
47 DrawQuad::SetAll(shared_quad_state
, DrawQuad::YUV_VIDEO_CONTENT
, rect
,
48 opaque_rect
, visible_rect
, needs_blending
);
49 this->tex_scale
= tex_scale
;
50 this->y_plane_resource_id
= y_plane_resource_id
;
51 this->u_plane_resource_id
= u_plane_resource_id
;
52 this->v_plane_resource_id
= v_plane_resource_id
;
55 void YUVVideoDrawQuad::IterateResources(
56 const ResourceIteratorCallback
& callback
) {
57 y_plane_resource_id
= callback
.Run(y_plane_resource_id
);
58 u_plane_resource_id
= callback
.Run(u_plane_resource_id
);
59 v_plane_resource_id
= callback
.Run(v_plane_resource_id
);
62 const YUVVideoDrawQuad
* YUVVideoDrawQuad::MaterialCast(
63 const DrawQuad
* quad
) {
64 DCHECK(quad
->material
== DrawQuad::YUV_VIDEO_CONTENT
);
65 return static_cast<const YUVVideoDrawQuad
*>(quad
);