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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 | 128 |
124 return true; | 129 return true; |
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 |
| 138 gfx::Transform transform = draw_transform(); |
| 139 gfx::Size rotated_size = content_bounds(); |
| 140 |
| 141 switch (video_rotation_) { |
| 142 case media::VIDEO_ROTATION_90: |
| 143 rotated_size = gfx::Size(rotated_size.height(), rotated_size.width()); |
| 144 transform.Rotate(90.0); |
| 145 transform.Translate(0.0, -rotated_size.height()); |
| 146 break; |
| 147 case media::VIDEO_ROTATION_180: |
| 148 transform.Rotate(180.0); |
| 149 transform.Translate(-rotated_size.width(), -rotated_size.height()); |
| 150 break; |
| 151 case media::VIDEO_ROTATION_270: |
| 152 rotated_size = gfx::Size(rotated_size.height(), rotated_size.width()); |
| 153 transform.Rotate(270.0); |
| 154 transform.Translate(-rotated_size.width(), 0); |
| 155 case media::VIDEO_ROTATION_0: |
| 156 break; |
| 157 } |
| 158 |
133 SharedQuadState* shared_quad_state = | 159 SharedQuadState* shared_quad_state = |
134 render_pass->CreateAndAppendSharedQuadState(); | 160 render_pass->CreateAndAppendSharedQuadState(); |
135 PopulateSharedQuadState(shared_quad_state); | 161 shared_quad_state->SetAll(transform, |
| 162 rotated_size, |
| 163 visible_content_rect(), |
| 164 clip_rect(), |
| 165 is_clipped(), |
| 166 draw_opacity(), |
| 167 blend_mode(), |
| 168 sorting_context_id()); |
136 | 169 |
137 AppendDebugBorderQuad( | 170 AppendDebugBorderQuad( |
138 render_pass, content_bounds(), shared_quad_state, append_quads_data); | 171 render_pass, rotated_size, shared_quad_state, append_quads_data); |
139 | 172 |
140 gfx::Rect quad_rect(content_bounds()); | 173 gfx::Rect quad_rect(rotated_size); |
141 gfx::Rect opaque_rect(contents_opaque() ? quad_rect : gfx::Rect()); | 174 gfx::Rect opaque_rect(contents_opaque() ? quad_rect : gfx::Rect()); |
142 gfx::Rect visible_rect = frame_->visible_rect(); | 175 gfx::Rect visible_rect = frame_->visible_rect(); |
143 gfx::Size coded_size = frame_->coded_size(); | 176 gfx::Size coded_size = frame_->coded_size(); |
144 | 177 |
145 gfx::Rect visible_quad_rect = occlusion_tracker.UnoccludedContentRect( | 178 gfx::Rect visible_quad_rect = |
146 quad_rect, draw_properties().target_space_transform); | 179 occlusion_tracker.UnoccludedContentRect(quad_rect, transform); |
147 if (visible_quad_rect.IsEmpty()) | 180 if (visible_quad_rect.IsEmpty()) |
148 return; | 181 return; |
149 | 182 |
150 // Pixels for macroblocked formats. | 183 // Pixels for macroblocked formats. |
151 const float tex_width_scale = | 184 const float tex_width_scale = |
152 static_cast<float>(visible_rect.width()) / coded_size.width(); | 185 static_cast<float>(visible_rect.width()) / coded_size.width(); |
153 const float tex_height_scale = | 186 const float tex_height_scale = |
154 static_cast<float>(visible_rect.height()) / coded_size.height(); | 187 static_cast<float>(visible_rect.height()) / coded_size.height(); |
155 const float tex_x_offset = | 188 const float tex_x_offset = |
156 static_cast<float>(visible_rect.x()) / coded_size.width(); | 189 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( | 365 void VideoLayerImpl::SetProviderClientImpl( |
333 scoped_refptr<VideoFrameProviderClientImpl> provider_client_impl) { | 366 scoped_refptr<VideoFrameProviderClientImpl> provider_client_impl) { |
334 provider_client_impl_ = provider_client_impl; | 367 provider_client_impl_ = provider_client_impl; |
335 } | 368 } |
336 | 369 |
337 const char* VideoLayerImpl::LayerTypeAsString() const { | 370 const char* VideoLayerImpl::LayerTypeAsString() const { |
338 return "cc::VideoLayerImpl"; | 371 return "cc::VideoLayerImpl"; |
339 } | 372 } |
340 | 373 |
341 } // namespace cc | 374 } // namespace cc |
OLD | NEW |