James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 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 | |
Elliot Glaysher | eae4929 | 2015-01-28 10:47:32 -0800 | [diff] [blame] | 7 | #include "base/trace_event/trace_event_argument.h" |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 8 | #include "base/values.h" |
| 9 | #include "cc/base/math_util.h" |
| 10 | #include "cc/resources/platform_color.h" |
| 11 | |
| 12 | namespace cc { |
| 13 | |
| 14 | PictureDrawQuad::PictureDrawQuad() { |
| 15 | } |
| 16 | |
| 17 | PictureDrawQuad::~PictureDrawQuad() { |
| 18 | } |
| 19 | |
| 20 | void PictureDrawQuad::SetNew(const SharedQuadState* shared_quad_state, |
| 21 | const gfx::Rect& rect, |
| 22 | const gfx::Rect& opaque_rect, |
| 23 | const gfx::Rect& visible_rect, |
| 24 | const gfx::RectF& tex_coord_rect, |
| 25 | const gfx::Size& texture_size, |
Etienne Membrives | b1556b3 | 2014-12-16 13:56:09 +0100 | [diff] [blame] | 26 | bool nearest_neighbor, |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 27 | ResourceFormat texture_format, |
| 28 | const gfx::Rect& content_rect, |
| 29 | float contents_scale, |
James Robinson | 6e9a1c9 | 2014-11-13 17:05:42 -0800 | [diff] [blame] | 30 | scoped_refptr<RasterSource> raster_source) { |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 31 | ContentDrawQuadBase::SetNew( |
| 32 | shared_quad_state, |
| 33 | DrawQuad::PICTURE_CONTENT, |
| 34 | rect, |
| 35 | opaque_rect, |
| 36 | visible_rect, |
| 37 | tex_coord_rect, |
| 38 | texture_size, |
Etienne Membrives | b1556b3 | 2014-12-16 13:56:09 +0100 | [diff] [blame] | 39 | !PlatformColor::SameComponentOrder(texture_format), |
| 40 | nearest_neighbor); |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 41 | this->content_rect = content_rect; |
| 42 | this->contents_scale = contents_scale; |
James Robinson | 6e9a1c9 | 2014-11-13 17:05:42 -0800 | [diff] [blame] | 43 | this->raster_source = raster_source; |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 44 | this->texture_format = texture_format; |
| 45 | } |
| 46 | |
| 47 | void PictureDrawQuad::SetAll(const SharedQuadState* shared_quad_state, |
| 48 | const gfx::Rect& rect, |
| 49 | const gfx::Rect& opaque_rect, |
| 50 | const gfx::Rect& visible_rect, |
| 51 | bool needs_blending, |
| 52 | const gfx::RectF& tex_coord_rect, |
| 53 | const gfx::Size& texture_size, |
Etienne Membrives | b1556b3 | 2014-12-16 13:56:09 +0100 | [diff] [blame] | 54 | bool nearest_neighbor, |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 55 | ResourceFormat texture_format, |
| 56 | const gfx::Rect& content_rect, |
| 57 | float contents_scale, |
James Robinson | 6e9a1c9 | 2014-11-13 17:05:42 -0800 | [diff] [blame] | 58 | scoped_refptr<RasterSource> raster_source) { |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 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( |
Etienne Membrives | b1556b3 | 2014-12-16 13:56:09 +0100 | [diff] [blame] | 68 | texture_format), |
| 69 | nearest_neighbor); |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 70 | this->content_rect = content_rect; |
| 71 | this->contents_scale = contents_scale; |
James Robinson | 6e9a1c9 | 2014-11-13 17:05:42 -0800 | [diff] [blame] | 72 | this->raster_source = raster_source; |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 73 | this->texture_format = texture_format; |
| 74 | } |
| 75 | |
| 76 | void PictureDrawQuad::IterateResources( |
| 77 | const ResourceIteratorCallback& callback) { |
| 78 | // TODO(danakj): Convert to TextureDrawQuad? |
| 79 | NOTIMPLEMENTED(); |
| 80 | } |
| 81 | |
| 82 | const PictureDrawQuad* PictureDrawQuad::MaterialCast(const DrawQuad* quad) { |
| 83 | DCHECK(quad->material == DrawQuad::PICTURE_CONTENT); |
| 84 | return static_cast<const PictureDrawQuad*>(quad); |
| 85 | } |
| 86 | |
Etienne Membrives | 386015a | 2015-02-19 17:27:12 +0100 | [diff] [blame] | 87 | void PictureDrawQuad::ExtendValue(base::trace_event::TracedValue* value) const { |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 88 | ContentDrawQuadBase::ExtendValue(value); |
James Robinson | 5e66a79 | 2015-01-21 17:02:08 -0800 | [diff] [blame] | 89 | MathUtil::AddToTracedValue("content_rect", content_rect, value); |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 90 | value->SetDouble("contents_scale", contents_scale); |
| 91 | value->SetInteger("texture_format", texture_format); |
James Robinson | 6e9a1c9 | 2014-11-13 17:05:42 -0800 | [diff] [blame] | 92 | // TODO(piman): raster_source? |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 93 | } |
| 94 | |
| 95 | } // namespace cc |