GPU workaround to simulate Out of Memory errors with large textures
[chromium-blink-merge.git] / cc / quads / yuv_video_draw_quad.cc
blob483cc245df8c30efbfec89acb6d4240849dd25cd
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()
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& tex_coord_rect,
26 const gfx::Size& ya_tex_size,
27 const gfx::Size& uv_tex_size,
28 unsigned y_plane_resource_id,
29 unsigned u_plane_resource_id,
30 unsigned v_plane_resource_id,
31 unsigned a_plane_resource_id,
32 ColorSpace color_space) {
33 bool needs_blending = false;
34 DrawQuad::SetAll(shared_quad_state, DrawQuad::YUV_VIDEO_CONTENT, rect,
35 opaque_rect, visible_rect, needs_blending);
36 this->tex_coord_rect = tex_coord_rect;
37 this->ya_tex_size = ya_tex_size;
38 this->uv_tex_size = uv_tex_size;
39 this->y_plane_resource_id = y_plane_resource_id;
40 this->u_plane_resource_id = u_plane_resource_id;
41 this->v_plane_resource_id = v_plane_resource_id;
42 this->a_plane_resource_id = a_plane_resource_id;
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& tex_coord_rect,
52 const gfx::Size& ya_tex_size,
53 const gfx::Size& uv_tex_size,
54 unsigned y_plane_resource_id,
55 unsigned u_plane_resource_id,
56 unsigned v_plane_resource_id,
57 unsigned a_plane_resource_id,
58 ColorSpace color_space) {
59 DrawQuad::SetAll(shared_quad_state, DrawQuad::YUV_VIDEO_CONTENT, rect,
60 opaque_rect, visible_rect, needs_blending);
61 this->tex_coord_rect = tex_coord_rect;
62 this->ya_tex_size = ya_tex_size;
63 this->uv_tex_size = uv_tex_size;
64 this->y_plane_resource_id = y_plane_resource_id;
65 this->u_plane_resource_id = u_plane_resource_id;
66 this->v_plane_resource_id = v_plane_resource_id;
67 this->a_plane_resource_id = a_plane_resource_id;
68 this->color_space = color_space;
71 void YUVVideoDrawQuad::IterateResources(
72 const ResourceIteratorCallback& callback) {
73 y_plane_resource_id = callback.Run(y_plane_resource_id);
74 u_plane_resource_id = callback.Run(u_plane_resource_id);
75 v_plane_resource_id = callback.Run(v_plane_resource_id);
76 if (a_plane_resource_id)
77 a_plane_resource_id = callback.Run(a_plane_resource_id);
80 const YUVVideoDrawQuad* YUVVideoDrawQuad::MaterialCast(
81 const DrawQuad* quad) {
82 DCHECK(quad->material == DrawQuad::YUV_VIDEO_CONTENT);
83 return static_cast<const YUVVideoDrawQuad*>(quad);
86 void YUVVideoDrawQuad::ExtendValue(
87 base::trace_event::TracedValue* value) const {
88 MathUtil::AddToTracedValue("tex_coord_rect", tex_coord_rect, value);
89 MathUtil::AddToTracedValue("ya_tex_size", ya_tex_size, value);
90 MathUtil::AddToTracedValue("uv_tex_size", uv_tex_size, value);
91 value->SetInteger("y_plane_resource_id", y_plane_resource_id);
92 value->SetInteger("u_plane_resource_id", u_plane_resource_id);
93 value->SetInteger("v_plane_resource_id", v_plane_resource_id);
94 value->SetInteger("a_plane_resource_id", a_plane_resource_id);
97 } // namespace cc