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/stream_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 StreamVideoDrawQuad::StreamVideoDrawQuad() {
17 void StreamVideoDrawQuad::SetNew(const SharedQuadState
* shared_quad_state
,
18 const gfx::Rect
& rect
,
19 const gfx::Rect
& opaque_rect
,
20 const gfx::Rect
& visible_rect
,
22 gfx::Size resource_size_in_pixels
,
24 const gfx::Transform
& matrix
) {
25 bool needs_blending
= false;
26 DrawQuad::SetAll(shared_quad_state
, DrawQuad::STREAM_VIDEO_CONTENT
, rect
,
27 opaque_rect
, visible_rect
, needs_blending
);
28 resources
.ids
[kResourceIdIndex
] = resource_id
;
29 overlay_resources
.size_in_pixels
[kResourceIdIndex
] = resource_size_in_pixels
;
30 overlay_resources
.allow_overlay
[kResourceIdIndex
] = allow_overlay
;
32 this->matrix
= matrix
;
35 void StreamVideoDrawQuad::SetAll(const SharedQuadState
* shared_quad_state
,
36 const gfx::Rect
& rect
,
37 const gfx::Rect
& opaque_rect
,
38 const gfx::Rect
& visible_rect
,
41 gfx::Size resource_size_in_pixels
,
43 const gfx::Transform
& matrix
) {
44 DrawQuad::SetAll(shared_quad_state
, DrawQuad::STREAM_VIDEO_CONTENT
, rect
,
45 opaque_rect
, visible_rect
, needs_blending
);
46 resources
.ids
[kResourceIdIndex
] = resource_id
;
47 overlay_resources
.size_in_pixels
[kResourceIdIndex
] = resource_size_in_pixels
;
48 overlay_resources
.allow_overlay
[kResourceIdIndex
] = allow_overlay
;
50 this->matrix
= matrix
;
53 const StreamVideoDrawQuad
* StreamVideoDrawQuad::MaterialCast(
54 const DrawQuad
* quad
) {
55 DCHECK(quad
->material
== DrawQuad::STREAM_VIDEO_CONTENT
);
56 return static_cast<const StreamVideoDrawQuad
*>(quad
);
59 void StreamVideoDrawQuad::ExtendValue(
60 base::trace_event::TracedValue
* value
) const {
61 value
->SetInteger("resource_id", resources
.ids
[kResourceIdIndex
]);
62 MathUtil::AddToTracedValue("matrix", matrix
, value
);
65 StreamVideoDrawQuad::OverlayResources::OverlayResources() {
66 for (size_t i
= 0; i
< Resources::kMaxResourceIdCount
; ++i
)
67 allow_overlay
[i
] = false;