| 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 "base/trace_event/trace_event_argument.h" | 8 #include "base/trace_event/trace_event_argument.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "cc/base/math_util.h" | 10 #include "cc/base/math_util.h" |
| 11 #include "ui/gfx/geometry/vector2d_f.h" | 11 #include "ui/gfx/geometry/vector2d_f.h" |
| 12 | 12 |
| 13 namespace cc { | 13 namespace cc { |
| 14 | 14 |
| 15 TextureDrawQuad::TextureDrawQuad() | 15 TextureDrawQuad::TextureDrawQuad() |
| 16 : resource_id(0), | 16 : premultiplied_alpha(false), |
| 17 premultiplied_alpha(false), | |
| 18 background_color(SK_ColorTRANSPARENT), | 17 background_color(SK_ColorTRANSPARENT), |
| 19 y_flipped(false), | 18 y_flipped(false), |
| 20 nearest_neighbor(false) { | 19 nearest_neighbor(false) { |
| 21 this->vertex_opacity[0] = 0.f; | 20 this->vertex_opacity[0] = 0.f; |
| 22 this->vertex_opacity[1] = 0.f; | 21 this->vertex_opacity[1] = 0.f; |
| 23 this->vertex_opacity[2] = 0.f; | 22 this->vertex_opacity[2] = 0.f; |
| 24 this->vertex_opacity[3] = 0.f; | 23 this->vertex_opacity[3] = 0.f; |
| 25 } | 24 } |
| 26 | 25 |
| 27 void TextureDrawQuad::SetNew(const SharedQuadState* shared_quad_state, | 26 void TextureDrawQuad::SetNew(const SharedQuadState* shared_quad_state, |
| 28 const gfx::Rect& rect, | 27 const gfx::Rect& rect, |
| 29 const gfx::Rect& opaque_rect, | 28 const gfx::Rect& opaque_rect, |
| 30 const gfx::Rect& visible_rect, | 29 const gfx::Rect& visible_rect, |
| 31 unsigned resource_id, | 30 unsigned resource_id, |
| 32 bool premultiplied_alpha, | 31 bool premultiplied_alpha, |
| 33 const gfx::PointF& uv_top_left, | 32 const gfx::PointF& uv_top_left, |
| 34 const gfx::PointF& uv_bottom_right, | 33 const gfx::PointF& uv_bottom_right, |
| 35 SkColor background_color, | 34 SkColor background_color, |
| 36 const float vertex_opacity[4], | 35 const float vertex_opacity[4], |
| 37 bool y_flipped, | 36 bool y_flipped, |
| 38 bool nearest_neighbor) { | 37 bool nearest_neighbor) { |
| 39 bool needs_blending = vertex_opacity[0] != 1.0f || vertex_opacity[1] != 1.0f | 38 bool needs_blending = vertex_opacity[0] != 1.0f || vertex_opacity[1] != 1.0f |
| 40 || vertex_opacity[2] != 1.0f || vertex_opacity[3] != 1.0f; | 39 || vertex_opacity[2] != 1.0f || vertex_opacity[3] != 1.0f; |
| 41 DrawQuad::SetAll(shared_quad_state, DrawQuad::TEXTURE_CONTENT, rect, | 40 DrawQuad::SetAll(shared_quad_state, DrawQuad::TEXTURE_CONTENT, rect, |
| 42 opaque_rect, visible_rect, needs_blending); | 41 opaque_rect, visible_rect, needs_blending); |
| 43 this->resource_id = resource_id; | 42 resources.ids[kResourceIdIndex] = resource_id; |
| 43 resources.count = 1; |
| 44 this->premultiplied_alpha = premultiplied_alpha; | 44 this->premultiplied_alpha = premultiplied_alpha; |
| 45 this->uv_top_left = uv_top_left; | 45 this->uv_top_left = uv_top_left; |
| 46 this->uv_bottom_right = uv_bottom_right; | 46 this->uv_bottom_right = uv_bottom_right; |
| 47 this->background_color = background_color; | 47 this->background_color = background_color; |
| 48 this->vertex_opacity[0] = vertex_opacity[0]; | 48 this->vertex_opacity[0] = vertex_opacity[0]; |
| 49 this->vertex_opacity[1] = vertex_opacity[1]; | 49 this->vertex_opacity[1] = vertex_opacity[1]; |
| 50 this->vertex_opacity[2] = vertex_opacity[2]; | 50 this->vertex_opacity[2] = vertex_opacity[2]; |
| 51 this->vertex_opacity[3] = vertex_opacity[3]; | 51 this->vertex_opacity[3] = vertex_opacity[3]; |
| 52 this->y_flipped = y_flipped; | 52 this->y_flipped = y_flipped; |
| 53 this->nearest_neighbor = nearest_neighbor; | 53 this->nearest_neighbor = nearest_neighbor; |
| 54 } | 54 } |
| 55 | 55 |
| 56 void TextureDrawQuad::SetAll(const SharedQuadState* shared_quad_state, | 56 void TextureDrawQuad::SetAll(const SharedQuadState* shared_quad_state, |
| 57 const gfx::Rect& rect, | 57 const gfx::Rect& rect, |
| 58 const gfx::Rect& opaque_rect, | 58 const gfx::Rect& opaque_rect, |
| 59 const gfx::Rect& visible_rect, | 59 const gfx::Rect& visible_rect, |
| 60 bool needs_blending, | 60 bool needs_blending, |
| 61 unsigned resource_id, | 61 unsigned resource_id, |
| 62 bool premultiplied_alpha, | 62 bool premultiplied_alpha, |
| 63 const gfx::PointF& uv_top_left, | 63 const gfx::PointF& uv_top_left, |
| 64 const gfx::PointF& uv_bottom_right, | 64 const gfx::PointF& uv_bottom_right, |
| 65 SkColor background_color, | 65 SkColor background_color, |
| 66 const float vertex_opacity[4], | 66 const float vertex_opacity[4], |
| 67 bool y_flipped, | 67 bool y_flipped, |
| 68 bool nearest_neighbor) { | 68 bool nearest_neighbor) { |
| 69 DrawQuad::SetAll(shared_quad_state, DrawQuad::TEXTURE_CONTENT, rect, | 69 DrawQuad::SetAll(shared_quad_state, DrawQuad::TEXTURE_CONTENT, rect, |
| 70 opaque_rect, visible_rect, needs_blending); | 70 opaque_rect, visible_rect, needs_blending); |
| 71 this->resource_id = resource_id; | 71 resources.ids[kResourceIdIndex] = resource_id; |
| 72 resources.count = 1; |
| 72 this->premultiplied_alpha = premultiplied_alpha; | 73 this->premultiplied_alpha = premultiplied_alpha; |
| 73 this->uv_top_left = uv_top_left; | 74 this->uv_top_left = uv_top_left; |
| 74 this->uv_bottom_right = uv_bottom_right; | 75 this->uv_bottom_right = uv_bottom_right; |
| 75 this->background_color = background_color; | 76 this->background_color = background_color; |
| 76 this->vertex_opacity[0] = vertex_opacity[0]; | 77 this->vertex_opacity[0] = vertex_opacity[0]; |
| 77 this->vertex_opacity[1] = vertex_opacity[1]; | 78 this->vertex_opacity[1] = vertex_opacity[1]; |
| 78 this->vertex_opacity[2] = vertex_opacity[2]; | 79 this->vertex_opacity[2] = vertex_opacity[2]; |
| 79 this->vertex_opacity[3] = vertex_opacity[3]; | 80 this->vertex_opacity[3] = vertex_opacity[3]; |
| 80 this->y_flipped = y_flipped; | 81 this->y_flipped = y_flipped; |
| 81 this->nearest_neighbor = nearest_neighbor; | 82 this->nearest_neighbor = nearest_neighbor; |
| 82 } | 83 } |
| 83 | 84 |
| 84 void TextureDrawQuad::IterateResources( | |
| 85 const ResourceIteratorCallback& callback) { | |
| 86 resource_id = callback.Run(resource_id); | |
| 87 } | |
| 88 | |
| 89 const TextureDrawQuad* TextureDrawQuad::MaterialCast(const DrawQuad* quad) { | 85 const TextureDrawQuad* TextureDrawQuad::MaterialCast(const DrawQuad* quad) { |
| 90 DCHECK(quad->material == DrawQuad::TEXTURE_CONTENT); | 86 DCHECK(quad->material == DrawQuad::TEXTURE_CONTENT); |
| 91 return static_cast<const TextureDrawQuad*>(quad); | 87 return static_cast<const TextureDrawQuad*>(quad); |
| 92 } | 88 } |
| 93 | 89 |
| 94 void TextureDrawQuad::ExtendValue(base::trace_event::TracedValue* value) const { | 90 void TextureDrawQuad::ExtendValue(base::trace_event::TracedValue* value) const { |
| 95 value->SetInteger("resource_id", resource_id); | 91 value->SetInteger("resource_id", resources.ids[kResourceIdIndex]); |
| 96 value->SetBoolean("premultiplied_alpha", premultiplied_alpha); | 92 value->SetBoolean("premultiplied_alpha", premultiplied_alpha); |
| 97 | 93 |
| 98 MathUtil::AddToTracedValue("uv_top_left", uv_top_left, value); | 94 MathUtil::AddToTracedValue("uv_top_left", uv_top_left, value); |
| 99 MathUtil::AddToTracedValue("uv_bottom_right", uv_bottom_right, value); | 95 MathUtil::AddToTracedValue("uv_bottom_right", uv_bottom_right, value); |
| 100 | 96 |
| 101 value->SetInteger("background_color", background_color); | 97 value->SetInteger("background_color", background_color); |
| 102 | 98 |
| 103 value->BeginArray("vertex_opacity"); | 99 value->BeginArray("vertex_opacity"); |
| 104 for (size_t i = 0; i < 4; ++i) | 100 for (size_t i = 0; i < 4; ++i) |
| 105 value->AppendDouble(vertex_opacity[i]); | 101 value->AppendDouble(vertex_opacity[i]); |
| 106 value->EndArray(); | 102 value->EndArray(); |
| 107 | 103 |
| 108 value->SetBoolean("y_flipped", y_flipped); | 104 value->SetBoolean("y_flipped", y_flipped); |
| 109 value->SetBoolean("nearest_neighbor", nearest_neighbor); | 105 value->SetBoolean("nearest_neighbor", nearest_neighbor); |
| 110 } | 106 } |
| 111 | 107 |
| 112 } // namespace cc | 108 } // namespace cc |
| OLD | NEW |