| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/quads/texture_draw_quad.h" | 5 #include "cc/quads/texture_draw_quad.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "ui/gfx/vector2d_f.h" | 8 #include "ui/gfx/vector2d_f.h" |
| 9 | 9 |
| 10 namespace cc { | 10 namespace cc { |
| 11 | 11 |
| 12 TextureDrawQuad::TextureDrawQuad() | 12 TextureDrawQuad::TextureDrawQuad() |
| 13 : resource_id(0), | 13 : resource_id(0), |
| 14 premultiplied_alpha(false), | 14 premultiplied_alpha(false), |
| 15 background_color(SK_ColorTRANSPARENT), |
| 15 flipped(false) { | 16 flipped(false) { |
| 16 this->vertex_opacity[0] = 0.f; | 17 this->vertex_opacity[0] = 0.f; |
| 17 this->vertex_opacity[1] = 0.f; | 18 this->vertex_opacity[1] = 0.f; |
| 18 this->vertex_opacity[2] = 0.f; | 19 this->vertex_opacity[2] = 0.f; |
| 19 this->vertex_opacity[3] = 0.f; | 20 this->vertex_opacity[3] = 0.f; |
| 20 } | 21 } |
| 21 | 22 |
| 22 scoped_ptr<TextureDrawQuad> TextureDrawQuad::Create() { | 23 scoped_ptr<TextureDrawQuad> TextureDrawQuad::Create() { |
| 23 return make_scoped_ptr(new TextureDrawQuad); | 24 return make_scoped_ptr(new TextureDrawQuad); |
| 24 } | 25 } |
| 25 | 26 |
| 26 void TextureDrawQuad::SetNew(const SharedQuadState* shared_quad_state, | 27 void TextureDrawQuad::SetNew(const SharedQuadState* shared_quad_state, |
| 27 gfx::Rect rect, gfx::Rect opaque_rect, | 28 gfx::Rect rect, gfx::Rect opaque_rect, |
| 28 unsigned resource_id, bool premultiplied_alpha, | 29 unsigned resource_id, bool premultiplied_alpha, |
| 29 gfx::PointF uv_top_left, | 30 gfx::PointF uv_top_left, |
| 30 gfx::PointF uv_bottom_right, | 31 gfx::PointF uv_bottom_right, |
| 31 const float vertex_opacity[4], bool flipped) { | 32 SkColor background_color, |
| 33 const float vertex_opacity[4], |
| 34 bool flipped) { |
| 32 gfx::Rect visible_rect = rect; | 35 gfx::Rect visible_rect = rect; |
| 33 bool needs_blending = vertex_opacity[0] != 1.0f || vertex_opacity[1] != 1.0f | 36 bool needs_blending = vertex_opacity[0] != 1.0f || vertex_opacity[1] != 1.0f |
| 34 || vertex_opacity[2] != 1.0f || vertex_opacity[3] != 1.0f; | 37 || vertex_opacity[2] != 1.0f || vertex_opacity[3] != 1.0f; |
| 35 DrawQuad::SetAll(shared_quad_state, DrawQuad::TEXTURE_CONTENT, rect, | 38 DrawQuad::SetAll(shared_quad_state, DrawQuad::TEXTURE_CONTENT, rect, |
| 36 opaque_rect, visible_rect, needs_blending); | 39 opaque_rect, visible_rect, needs_blending); |
| 37 this->resource_id = resource_id; | 40 this->resource_id = resource_id; |
| 38 this->premultiplied_alpha = premultiplied_alpha; | 41 this->premultiplied_alpha = premultiplied_alpha; |
| 39 this->uv_top_left = uv_top_left; | 42 this->uv_top_left = uv_top_left; |
| 40 this->uv_bottom_right = uv_bottom_right; | 43 this->uv_bottom_right = uv_bottom_right; |
| 44 this->background_color = background_color; |
| 41 this->vertex_opacity[0] = vertex_opacity[0]; | 45 this->vertex_opacity[0] = vertex_opacity[0]; |
| 42 this->vertex_opacity[1] = vertex_opacity[1]; | 46 this->vertex_opacity[1] = vertex_opacity[1]; |
| 43 this->vertex_opacity[2] = vertex_opacity[2]; | 47 this->vertex_opacity[2] = vertex_opacity[2]; |
| 44 this->vertex_opacity[3] = vertex_opacity[3]; | 48 this->vertex_opacity[3] = vertex_opacity[3]; |
| 45 this->flipped = flipped; | 49 this->flipped = flipped; |
| 46 } | 50 } |
| 47 | 51 |
| 48 void TextureDrawQuad::SetAll(const SharedQuadState* shared_quad_state, | 52 void TextureDrawQuad::SetAll(const SharedQuadState* shared_quad_state, |
| 49 gfx::Rect rect, gfx::Rect opaque_rect, | 53 gfx::Rect rect, gfx::Rect opaque_rect, |
| 50 gfx::Rect visible_rect, bool needs_blending, | 54 gfx::Rect visible_rect, bool needs_blending, |
| 51 unsigned resource_id, bool premultiplied_alpha, | 55 unsigned resource_id, bool premultiplied_alpha, |
| 52 gfx::PointF uv_top_left, | 56 gfx::PointF uv_top_left, |
| 53 gfx::PointF uv_bottom_right, | 57 gfx::PointF uv_bottom_right, |
| 54 const float vertex_opacity[4], bool flipped) { | 58 SkColor background_color, |
| 59 const float vertex_opacity[4], |
| 60 bool flipped) { |
| 55 DrawQuad::SetAll(shared_quad_state, DrawQuad::TEXTURE_CONTENT, rect, | 61 DrawQuad::SetAll(shared_quad_state, DrawQuad::TEXTURE_CONTENT, rect, |
| 56 opaque_rect, visible_rect, needs_blending); | 62 opaque_rect, visible_rect, needs_blending); |
| 57 this->resource_id = resource_id; | 63 this->resource_id = resource_id; |
| 58 this->premultiplied_alpha = premultiplied_alpha; | 64 this->premultiplied_alpha = premultiplied_alpha; |
| 59 this->uv_top_left = uv_top_left; | 65 this->uv_top_left = uv_top_left; |
| 60 this->uv_bottom_right = uv_bottom_right; | 66 this->uv_bottom_right = uv_bottom_right; |
| 67 this->background_color = background_color; |
| 61 this->vertex_opacity[0] = vertex_opacity[0]; | 68 this->vertex_opacity[0] = vertex_opacity[0]; |
| 62 this->vertex_opacity[1] = vertex_opacity[1]; | 69 this->vertex_opacity[1] = vertex_opacity[1]; |
| 63 this->vertex_opacity[2] = vertex_opacity[2]; | 70 this->vertex_opacity[2] = vertex_opacity[2]; |
| 64 this->vertex_opacity[3] = vertex_opacity[3]; | 71 this->vertex_opacity[3] = vertex_opacity[3]; |
| 65 this->flipped = flipped; | 72 this->flipped = flipped; |
| 66 } | 73 } |
| 67 | 74 |
| 68 void TextureDrawQuad::IterateResources( | 75 void TextureDrawQuad::IterateResources( |
| 69 const ResourceIteratorCallback& callback) { | 76 const ResourceIteratorCallback& callback) { |
| 70 resource_id = callback.Run(resource_id); | 77 resource_id = callback.Run(resource_id); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 clipped_rect -= offset; | 150 clipped_rect -= offset; |
| 144 clipped_rect.Scale(1.0f / x_scale, 1.0f / y_scale); | 151 clipped_rect.Scale(1.0f / x_scale, 1.0f / y_scale); |
| 145 rect = gfx::Rect(static_cast<int>(clipped_rect.x() + 0.5f), | 152 rect = gfx::Rect(static_cast<int>(clipped_rect.x() + 0.5f), |
| 146 static_cast<int>(clipped_rect.y() + 0.5f), | 153 static_cast<int>(clipped_rect.y() + 0.5f), |
| 147 static_cast<int>(clipped_rect.width() + 0.5f), | 154 static_cast<int>(clipped_rect.width() + 0.5f), |
| 148 static_cast<int>(clipped_rect.height() + 0.5f)); | 155 static_cast<int>(clipped_rect.height() + 0.5f)); |
| 149 return true; | 156 return true; |
| 150 } | 157 } |
| 151 | 158 |
| 152 } // namespace cc | 159 } // namespace cc |
| OLD | NEW |