Home | History | Annotate | Download | only in quads
      1 // Copyright 2013 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/picture_draw_quad.h"
      6 
      7 #include "base/values.h"
      8 #include "cc/base/math_util.h"
      9 #include "cc/resources/platform_color.h"
     10 
     11 namespace cc {
     12 
     13 PictureDrawQuad::PictureDrawQuad() {
     14 }
     15 
     16 PictureDrawQuad::~PictureDrawQuad() {
     17 }
     18 
     19 scoped_ptr<PictureDrawQuad> PictureDrawQuad::Create() {
     20   return make_scoped_ptr(new PictureDrawQuad);
     21 }
     22 
     23 void PictureDrawQuad::SetNew(const SharedQuadState* shared_quad_state,
     24                              const gfx::Rect& rect,
     25                              const gfx::Rect& opaque_rect,
     26                              const gfx::Rect& visible_rect,
     27                              const gfx::RectF& tex_coord_rect,
     28                              const gfx::Size& texture_size,
     29                              ResourceFormat texture_format,
     30                              const gfx::Rect& content_rect,
     31                              float contents_scale,
     32                              scoped_refptr<PicturePileImpl> picture_pile) {
     33   ContentDrawQuadBase::SetNew(
     34       shared_quad_state,
     35       DrawQuad::PICTURE_CONTENT,
     36       rect,
     37       opaque_rect,
     38       visible_rect,
     39       tex_coord_rect,
     40       texture_size,
     41       !PlatformColor::SameComponentOrder(texture_format));
     42   this->content_rect = content_rect;
     43   this->contents_scale = contents_scale;
     44   this->picture_pile = picture_pile;
     45   this->texture_format = texture_format;
     46 }
     47 
     48 void PictureDrawQuad::SetAll(const SharedQuadState* shared_quad_state,
     49                              const gfx::Rect& rect,
     50                              const gfx::Rect& opaque_rect,
     51                              const gfx::Rect& visible_rect,
     52                              bool needs_blending,
     53                              const gfx::RectF& tex_coord_rect,
     54                              const gfx::Size& texture_size,
     55                              ResourceFormat texture_format,
     56                              const gfx::Rect& content_rect,
     57                              float contents_scale,
     58                              scoped_refptr<PicturePileImpl> picture_pile) {
     59   ContentDrawQuadBase::SetAll(shared_quad_state,
     60                               DrawQuad::PICTURE_CONTENT,
     61                               rect,
     62                               opaque_rect,
     63                               visible_rect,
     64                               needs_blending,
     65                               tex_coord_rect,
     66                               texture_size,
     67                               !PlatformColor::SameComponentOrder(
     68                                   texture_format));
     69   this->content_rect = content_rect;
     70   this->contents_scale = contents_scale;
     71   this->picture_pile = picture_pile;
     72   this->texture_format = texture_format;
     73 }
     74 
     75 void PictureDrawQuad::IterateResources(
     76     const ResourceIteratorCallback& callback) {
     77   // TODO(danakj): Convert to TextureDrawQuad?
     78   NOTIMPLEMENTED();
     79 }
     80 
     81 const PictureDrawQuad* PictureDrawQuad::MaterialCast(const DrawQuad* quad) {
     82   DCHECK(quad->material == DrawQuad::PICTURE_CONTENT);
     83   return static_cast<const PictureDrawQuad*>(quad);
     84 }
     85 
     86 void PictureDrawQuad::ExtendValue(base::DictionaryValue* value) const {
     87   ContentDrawQuadBase::ExtendValue(value);
     88   value->Set("content_rect", MathUtil::AsValue(content_rect).release());
     89   value->SetDouble("contents_scale", contents_scale);
     90   value->SetInteger("texture_format", texture_format);
     91   // TODO(piman): picture_pile?
     92 }
     93 
     94 }  // namespace cc
     95