Roll src/third_party/skia 7b05ff1:dab1f60
[chromium-blink-merge.git] / cc / quads / yuv_video_draw_quad.cc
blobf9a878a93e999c16e4aa982d6a8a74cc6657d3e5
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"
12 namespace cc {
14 YUVVideoDrawQuad::YUVVideoDrawQuad() {
16 YUVVideoDrawQuad::~YUVVideoDrawQuad() {}
18 void YUVVideoDrawQuad::SetNew(const SharedQuadState* shared_quad_state,
19 const gfx::Rect& rect,
20 const gfx::Rect& opaque_rect,
21 const gfx::Rect& visible_rect,
22 const gfx::RectF& ya_tex_coord_rect,
23 const gfx::RectF& uv_tex_coord_rect,
24 const gfx::Size& ya_tex_size,
25 const gfx::Size& uv_tex_size,
26 unsigned y_plane_resource_id,
27 unsigned u_plane_resource_id,
28 unsigned v_plane_resource_id,
29 unsigned a_plane_resource_id,
30 ColorSpace color_space) {
31 bool needs_blending = false;
32 DrawQuad::SetAll(shared_quad_state, DrawQuad::YUV_VIDEO_CONTENT, rect,
33 opaque_rect, visible_rect, needs_blending);
34 this->ya_tex_coord_rect = ya_tex_coord_rect;
35 this->uv_tex_coord_rect = uv_tex_coord_rect;
36 this->ya_tex_size = ya_tex_size;
37 this->uv_tex_size = uv_tex_size;
38 resources.ids[kYPlaneResourceIdIndex] = y_plane_resource_id;
39 resources.ids[kUPlaneResourceIdIndex] = u_plane_resource_id;
40 resources.ids[kVPlaneResourceIdIndex] = v_plane_resource_id;
41 resources.ids[kAPlaneResourceIdIndex] = a_plane_resource_id;
42 resources.count = a_plane_resource_id ? 4 : 3;
43 this->color_space = color_space;
46 void YUVVideoDrawQuad::SetAll(const SharedQuadState* shared_quad_state,
47 const gfx::Rect& rect,
48 const gfx::Rect& opaque_rect,
49 const gfx::Rect& visible_rect,
50 bool needs_blending,
51 const gfx::RectF& ya_tex_coord_rect,
52 const gfx::RectF& uv_tex_coord_rect,
53 const gfx::Size& ya_tex_size,
54 const gfx::Size& uv_tex_size,
55 unsigned y_plane_resource_id,
56 unsigned u_plane_resource_id,
57 unsigned v_plane_resource_id,
58 unsigned a_plane_resource_id,
59 ColorSpace color_space) {
60 DrawQuad::SetAll(shared_quad_state, DrawQuad::YUV_VIDEO_CONTENT, rect,
61 opaque_rect, visible_rect, needs_blending);
62 this->ya_tex_coord_rect = ya_tex_coord_rect;
63 this->uv_tex_coord_rect = uv_tex_coord_rect;
64 this->ya_tex_size = ya_tex_size;
65 this->uv_tex_size = uv_tex_size;
66 resources.ids[kYPlaneResourceIdIndex] = y_plane_resource_id;
67 resources.ids[kUPlaneResourceIdIndex] = u_plane_resource_id;
68 resources.ids[kVPlaneResourceIdIndex] = v_plane_resource_id;
69 resources.ids[kAPlaneResourceIdIndex] = a_plane_resource_id;
70 resources.count = resources.ids[kAPlaneResourceIdIndex] ? 4 : 3;
71 this->color_space = color_space;
74 const YUVVideoDrawQuad* YUVVideoDrawQuad::MaterialCast(
75 const DrawQuad* quad) {
76 DCHECK(quad->material == DrawQuad::YUV_VIDEO_CONTENT);
77 return static_cast<const YUVVideoDrawQuad*>(quad);
80 void YUVVideoDrawQuad::ExtendValue(
81 base::trace_event::TracedValue* value) const {
82 MathUtil::AddToTracedValue("ya_tex_coord_rect", ya_tex_coord_rect, value);
83 MathUtil::AddToTracedValue("uv_tex_coord_rect", uv_tex_coord_rect, value);
84 MathUtil::AddToTracedValue("ya_tex_size", ya_tex_size, value);
85 MathUtil::AddToTracedValue("uv_tex_size", uv_tex_size, value);
86 value->SetInteger("y_plane_resource_id",
87 resources.ids[kYPlaneResourceIdIndex]);
88 value->SetInteger("u_plane_resource_id",
89 resources.ids[kUPlaneResourceIdIndex]);
90 value->SetInteger("v_plane_resource_id",
91 resources.ids[kVPlaneResourceIdIndex]);
92 value->SetInteger("a_plane_resource_id",
93 resources.ids[kAPlaneResourceIdIndex]);
96 } // namespace cc