OLD | NEW |
---|---|
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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/layers/video_layer_impl.h" | 5 #include "cc/layers/video_layer_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "cc/layers/video_frame_provider_client_impl.h" | 9 #include "cc/layers/video_frame_provider_client_impl.h" |
10 #include "cc/quads/io_surface_draw_quad.h" | 10 #include "cc/quads/io_surface_draw_quad.h" |
(...skipping 10 matching lines...) Expand all Loading... | |
21 #if defined(VIDEO_HOLE) | 21 #if defined(VIDEO_HOLE) |
22 #include "cc/quads/solid_color_draw_quad.h" | 22 #include "cc/quads/solid_color_draw_quad.h" |
23 #endif // defined(VIDEO_HOLE) | 23 #endif // defined(VIDEO_HOLE) |
24 | 24 |
25 namespace cc { | 25 namespace cc { |
26 | 26 |
27 // static | 27 // static |
28 scoped_ptr<VideoLayerImpl> VideoLayerImpl::Create( | 28 scoped_ptr<VideoLayerImpl> VideoLayerImpl::Create( |
29 LayerTreeImpl* tree_impl, | 29 LayerTreeImpl* tree_impl, |
30 int id, | 30 int id, |
31 VideoFrameProvider* provider) { | 31 VideoFrameProvider* provider, |
32 scoped_ptr<VideoLayerImpl> layer(new VideoLayerImpl(tree_impl, id)); | 32 media::VideoRotation video_rotation) { |
33 scoped_ptr<VideoLayerImpl> layer( | |
34 new VideoLayerImpl(tree_impl, id, video_rotation)); | |
33 layer->SetProviderClientImpl(VideoFrameProviderClientImpl::Create(provider)); | 35 layer->SetProviderClientImpl(VideoFrameProviderClientImpl::Create(provider)); |
34 DCHECK(tree_impl->proxy()->IsImplThread()); | 36 DCHECK(tree_impl->proxy()->IsImplThread()); |
35 DCHECK(tree_impl->proxy()->IsMainThreadBlocked()); | 37 DCHECK(tree_impl->proxy()->IsMainThreadBlocked()); |
36 return layer.Pass(); | 38 return layer.Pass(); |
37 } | 39 } |
38 | 40 |
39 VideoLayerImpl::VideoLayerImpl(LayerTreeImpl* tree_impl, int id) | 41 VideoLayerImpl::VideoLayerImpl(LayerTreeImpl* tree_impl, |
40 : LayerImpl(tree_impl, id), | 42 int id, |
41 frame_(NULL) {} | 43 media::VideoRotation video_rotation) |
44 : LayerImpl(tree_impl, id), frame_(NULL), video_rotation_(video_rotation) { | |
45 } | |
42 | 46 |
43 VideoLayerImpl::~VideoLayerImpl() { | 47 VideoLayerImpl::~VideoLayerImpl() { |
44 if (!provider_client_impl_->Stopped()) { | 48 if (!provider_client_impl_->Stopped()) { |
45 // In impl side painting, we may have a pending and active layer | 49 // In impl side painting, we may have a pending and active layer |
46 // associated with the video provider at the same time. Both have a ref | 50 // associated with the video provider at the same time. Both have a ref |
47 // on the VideoFrameProviderClientImpl, but we stop when the first | 51 // on the VideoFrameProviderClientImpl, but we stop when the first |
48 // LayerImpl (the one on the pending tree) is destroyed since we know | 52 // LayerImpl (the one on the pending tree) is destroyed since we know |
49 // the main thread is blocked for this commit. | 53 // the main thread is blocked for this commit. |
50 DCHECK(layer_tree_impl()->proxy()->IsImplThread()); | 54 DCHECK(layer_tree_impl()->proxy()->IsImplThread()); |
51 DCHECK(layer_tree_impl()->proxy()->IsMainThreadBlocked()); | 55 DCHECK(layer_tree_impl()->proxy()->IsMainThreadBlocked()); |
52 provider_client_impl_->Stop(); | 56 provider_client_impl_->Stop(); |
53 } | 57 } |
54 } | 58 } |
55 | 59 |
56 scoped_ptr<LayerImpl> VideoLayerImpl::CreateLayerImpl( | 60 scoped_ptr<LayerImpl> VideoLayerImpl::CreateLayerImpl( |
57 LayerTreeImpl* tree_impl) { | 61 LayerTreeImpl* tree_impl) { |
58 return scoped_ptr<LayerImpl>(new VideoLayerImpl(tree_impl, id())); | 62 VideoLayerImpl* impl = new VideoLayerImpl(tree_impl, id(), video_rotation_); |
63 return scoped_ptr<LayerImpl>(impl); | |
59 } | 64 } |
60 | 65 |
61 void VideoLayerImpl::PushPropertiesTo(LayerImpl* layer) { | 66 void VideoLayerImpl::PushPropertiesTo(LayerImpl* layer) { |
62 LayerImpl::PushPropertiesTo(layer); | 67 LayerImpl::PushPropertiesTo(layer); |
63 | 68 |
64 VideoLayerImpl* other = static_cast<VideoLayerImpl*>(layer); | 69 VideoLayerImpl* other = static_cast<VideoLayerImpl*>(layer); |
65 other->SetProviderClientImpl(provider_client_impl_); | 70 other->SetProviderClientImpl(provider_client_impl_); |
66 } | 71 } |
67 | 72 |
68 void VideoLayerImpl::DidBecomeActive() { | 73 void VideoLayerImpl::DidBecomeActive() { |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
125 } | 130 } |
126 | 131 |
127 void VideoLayerImpl::AppendQuads( | 132 void VideoLayerImpl::AppendQuads( |
128 RenderPass* render_pass, | 133 RenderPass* render_pass, |
129 const OcclusionTracker<LayerImpl>& occlusion_tracker, | 134 const OcclusionTracker<LayerImpl>& occlusion_tracker, |
130 AppendQuadsData* append_quads_data) { | 135 AppendQuadsData* append_quads_data) { |
131 DCHECK(frame_.get()); | 136 DCHECK(frame_.get()); |
132 | 137 |
133 SharedQuadState* shared_quad_state = | 138 SharedQuadState* shared_quad_state = |
134 render_pass->CreateAndAppendSharedQuadState(); | 139 render_pass->CreateAndAppendSharedQuadState(); |
135 PopulateSharedQuadState(shared_quad_state); | 140 PopulateSharedQuadState(shared_quad_state); |
danakj
2014/08/05 20:18:21
drop this, since you do SetALl below. Can you move
| |
136 | 141 |
142 gfx::Transform transform = draw_transform(); | |
143 gfx::Size rotated_size = content_bounds(); | |
144 | |
145 switch (video_rotation_) { | |
146 case media::VIDEO_ROTATION_90: | |
147 rotated_size = gfx::Size(rotated_size.height(), rotated_size.width()); | |
148 transform.Rotate(90.0); | |
149 transform.Translate(0.0, -rotated_size.height()); | |
150 break; | |
151 case media::VIDEO_ROTATION_180: | |
152 transform.Rotate(180.0); | |
153 transform.Translate(-rotated_size.width(), -rotated_size.height()); | |
154 break; | |
155 case media::VIDEO_ROTATION_270: | |
156 rotated_size = gfx::Size(rotated_size.height(), rotated_size.width()); | |
157 transform.Rotate(270.0); | |
158 transform.Translate(-rotated_size.width(), 0); | |
159 case media::VIDEO_ROTATION_0: | |
160 break; | |
161 } | |
162 | |
163 shared_quad_state->SetAll(transform, | |
164 rotated_size, | |
165 visible_content_rect(), | |
166 clip_rect(), | |
167 is_clipped(), | |
168 draw_opacity(), | |
169 blend_mode(), | |
170 sorting_context_id()); | |
171 | |
137 AppendDebugBorderQuad( | 172 AppendDebugBorderQuad( |
138 render_pass, content_bounds(), shared_quad_state, append_quads_data); | 173 render_pass, rotated_size, shared_quad_state, append_quads_data); |
139 | 174 |
140 gfx::Rect quad_rect(content_bounds()); | 175 gfx::Rect quad_rect(rotated_size); |
141 gfx::Rect opaque_rect(contents_opaque() ? quad_rect : gfx::Rect()); | 176 gfx::Rect opaque_rect(contents_opaque() ? quad_rect : gfx::Rect()); |
142 gfx::Rect visible_rect = frame_->visible_rect(); | 177 gfx::Rect visible_rect = frame_->visible_rect(); |
143 gfx::Size coded_size = frame_->coded_size(); | 178 gfx::Size coded_size = frame_->coded_size(); |
144 | 179 |
145 gfx::Rect visible_quad_rect = occlusion_tracker.UnoccludedContentRect( | 180 gfx::Rect visible_quad_rect = |
146 quad_rect, draw_properties().target_space_transform); | 181 occlusion_tracker.UnoccludedContentRect(quad_rect, transform); |
147 if (visible_quad_rect.IsEmpty()) | 182 if (visible_quad_rect.IsEmpty()) |
148 return; | 183 return; |
149 | 184 |
150 // Pixels for macroblocked formats. | 185 // Pixels for macroblocked formats. |
151 const float tex_width_scale = | 186 const float tex_width_scale = |
152 static_cast<float>(visible_rect.width()) / coded_size.width(); | 187 static_cast<float>(visible_rect.width()) / coded_size.width(); |
153 const float tex_height_scale = | 188 const float tex_height_scale = |
154 static_cast<float>(visible_rect.height()) / coded_size.height(); | 189 static_cast<float>(visible_rect.height()) / coded_size.height(); |
155 const float tex_x_offset = | 190 const float tex_x_offset = |
156 static_cast<float>(visible_rect.x()) / coded_size.width(); | 191 static_cast<float>(visible_rect.x()) / coded_size.width(); |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
332 void VideoLayerImpl::SetProviderClientImpl( | 367 void VideoLayerImpl::SetProviderClientImpl( |
333 scoped_refptr<VideoFrameProviderClientImpl> provider_client_impl) { | 368 scoped_refptr<VideoFrameProviderClientImpl> provider_client_impl) { |
334 provider_client_impl_ = provider_client_impl; | 369 provider_client_impl_ = provider_client_impl; |
335 } | 370 } |
336 | 371 |
337 const char* VideoLayerImpl::LayerTypeAsString() const { | 372 const char* VideoLayerImpl::LayerTypeAsString() const { |
338 return "cc::VideoLayerImpl"; | 373 return "cc::VideoLayerImpl"; |
339 } | 374 } |
340 | 375 |
341 } // namespace cc | 376 } // namespace cc |
OLD | NEW |