Home | History | Annotate | Download | only in quads
      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.
      4 
      5 #include "cc/quads/stream_video_draw_quad.h"
      6 
      7 #include "base/debug/trace_event_argument.h"
      8 #include "base/logging.h"
      9 #include "base/values.h"
     10 #include "cc/base/math_util.h"
     11 
     12 namespace cc {
     13 
     14 StreamVideoDrawQuad::StreamVideoDrawQuad() : resource_id(0) {}
     15 
     16 void StreamVideoDrawQuad::SetNew(const SharedQuadState* shared_quad_state,
     17                                  const gfx::Rect& rect,
     18                                  const gfx::Rect& opaque_rect,
     19                                  const gfx::Rect& visible_rect,
     20                                  unsigned resource_id,
     21                                  const gfx::Transform& matrix) {
     22   bool needs_blending = false;
     23   DrawQuad::SetAll(shared_quad_state, DrawQuad::STREAM_VIDEO_CONTENT, rect,
     24                    opaque_rect, visible_rect, needs_blending);
     25   this->resource_id = resource_id;
     26   this->matrix = matrix;
     27 }
     28 
     29 void StreamVideoDrawQuad::SetAll(const SharedQuadState* shared_quad_state,
     30                                  const gfx::Rect& rect,
     31                                  const gfx::Rect& opaque_rect,
     32                                  const gfx::Rect& visible_rect,
     33                                  bool needs_blending,
     34                                  unsigned resource_id,
     35                                  const gfx::Transform& matrix) {
     36   DrawQuad::SetAll(shared_quad_state, DrawQuad::STREAM_VIDEO_CONTENT, rect,
     37                    opaque_rect, visible_rect, needs_blending);
     38   this->resource_id = resource_id;
     39   this->matrix = matrix;
     40 }
     41 
     42 void StreamVideoDrawQuad::IterateResources(
     43     const ResourceIteratorCallback& callback) {
     44   resource_id = callback.Run(resource_id);
     45 }
     46 
     47 const StreamVideoDrawQuad* StreamVideoDrawQuad::MaterialCast(
     48     const DrawQuad* quad) {
     49   DCHECK(quad->material == DrawQuad::STREAM_VIDEO_CONTENT);
     50   return static_cast<const StreamVideoDrawQuad*>(quad);
     51 }
     52 
     53 void StreamVideoDrawQuad::ExtendValue(base::debug::TracedValue* value) const {
     54   value->SetInteger("resource_id", resource_id);
     55   value->BeginArray("matrix");
     56   MathUtil::AddToTracedValue(matrix, value);
     57   value->EndArray();
     58 }
     59 
     60 }  // namespace cc
     61