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