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 19 matching lines...) Expand all Loading... | |
30 int id, | 30 int id, |
31 VideoFrameProvider* provider) { | 31 VideoFrameProvider* provider) { |
32 scoped_ptr<VideoLayerImpl> layer(new VideoLayerImpl(tree_impl, id)); | 32 scoped_ptr<VideoLayerImpl> layer(new VideoLayerImpl(tree_impl, id)); |
33 layer->SetProviderClientImpl(VideoFrameProviderClientImpl::Create(provider)); | 33 layer->SetProviderClientImpl(VideoFrameProviderClientImpl::Create(provider)); |
34 DCHECK(tree_impl->proxy()->IsImplThread()); | 34 DCHECK(tree_impl->proxy()->IsImplThread()); |
35 DCHECK(tree_impl->proxy()->IsMainThreadBlocked()); | 35 DCHECK(tree_impl->proxy()->IsMainThreadBlocked()); |
36 return layer.Pass(); | 36 return layer.Pass(); |
37 } | 37 } |
38 | 38 |
39 VideoLayerImpl::VideoLayerImpl(LayerTreeImpl* tree_impl, int id) | 39 VideoLayerImpl::VideoLayerImpl(LayerTreeImpl* tree_impl, int id) |
40 : LayerImpl(tree_impl, id), | 40 : LayerImpl(tree_impl, id), frame_(NULL) { |
41 frame_(NULL) {} | 41 } |
42 | 42 |
43 VideoLayerImpl::~VideoLayerImpl() { | 43 VideoLayerImpl::~VideoLayerImpl() { |
44 if (!provider_client_impl_->Stopped()) { | 44 if (!provider_client_impl_->Stopped()) { |
45 // In impl side painting, we may have a pending and active layer | 45 // 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 | 46 // associated with the video provider at the same time. Both have a ref |
47 // on the VideoFrameProviderClientImpl, but we stop when the first | 47 // on the VideoFrameProviderClientImpl, but we stop when the first |
48 // LayerImpl (the one on the pending tree) is destroyed since we know | 48 // LayerImpl (the one on the pending tree) is destroyed since we know |
49 // the main thread is blocked for this commit. | 49 // the main thread is blocked for this commit. |
50 DCHECK(layer_tree_impl()->proxy()->IsImplThread()); | 50 DCHECK(layer_tree_impl()->proxy()->IsImplThread()); |
51 DCHECK(layer_tree_impl()->proxy()->IsMainThreadBlocked()); | 51 DCHECK(layer_tree_impl()->proxy()->IsMainThreadBlocked()); |
52 provider_client_impl_->Stop(); | 52 provider_client_impl_->Stop(); |
53 } | 53 } |
54 } | 54 } |
55 | 55 |
56 scoped_ptr<LayerImpl> VideoLayerImpl::CreateLayerImpl( | 56 scoped_ptr<LayerImpl> VideoLayerImpl::CreateLayerImpl( |
57 LayerTreeImpl* tree_impl) { | 57 LayerTreeImpl* tree_impl) { |
58 return scoped_ptr<LayerImpl>(new VideoLayerImpl(tree_impl, id())); | 58 VideoLayerImpl* impl = new VideoLayerImpl(tree_impl, id()); |
59 impl->set_video_rotation(video_rotation_); | |
enne (OOO)
2014/07/21 23:42:49
Properties should get pushed in push properties, n
suderman
2014/07/22 00:05:20
ditto
| |
60 return scoped_ptr<LayerImpl>(impl); | |
59 } | 61 } |
60 | 62 |
61 void VideoLayerImpl::PushPropertiesTo(LayerImpl* layer) { | 63 void VideoLayerImpl::PushPropertiesTo(LayerImpl* layer) { |
62 LayerImpl::PushPropertiesTo(layer); | 64 LayerImpl::PushPropertiesTo(layer); |
63 | 65 |
64 VideoLayerImpl* other = static_cast<VideoLayerImpl*>(layer); | 66 VideoLayerImpl* other = static_cast<VideoLayerImpl*>(layer); |
65 other->SetProviderClientImpl(provider_client_impl_); | 67 other->SetProviderClientImpl(provider_client_impl_); |
66 } | 68 } |
67 | 69 |
68 void VideoLayerImpl::DidBecomeActive() { | 70 void VideoLayerImpl::DidBecomeActive() { |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
127 void VideoLayerImpl::AppendQuads( | 129 void VideoLayerImpl::AppendQuads( |
128 RenderPass* render_pass, | 130 RenderPass* render_pass, |
129 const OcclusionTracker<LayerImpl>& occlusion_tracker, | 131 const OcclusionTracker<LayerImpl>& occlusion_tracker, |
130 AppendQuadsData* append_quads_data) { | 132 AppendQuadsData* append_quads_data) { |
131 DCHECK(frame_.get()); | 133 DCHECK(frame_.get()); |
132 | 134 |
133 SharedQuadState* shared_quad_state = | 135 SharedQuadState* shared_quad_state = |
134 render_pass->CreateAndAppendSharedQuadState(); | 136 render_pass->CreateAndAppendSharedQuadState(); |
135 PopulateSharedQuadState(shared_quad_state); | 137 PopulateSharedQuadState(shared_quad_state); |
136 | 138 |
139 gfx::Transform transform = draw_transform(); | |
enne (OOO)
2014/07/22 21:10:39
I think you also need to move the draw transform o
suderman
2014/07/22 21:48:16
I'll move the transform into push properties and (
suderman
2014/07/22 22:53:59
Unfortunately draw_transform is not set via PushPr
enne (OOO)
2014/07/22 22:55:37
Sorry, I was trying to suggest that you modify Lay
| |
140 transform.Scale(content_bounds().width(), content_bounds().height()); | |
141 | |
142 switch (video_rotation_) { | |
143 case media::VIDEO_ROTATION_90: | |
144 transform.Rotate(90.0); | |
145 transform.Translate(0.0, -1.0); | |
146 break; | |
147 case media::VIDEO_ROTATION_180: | |
148 transform.Rotate(180.0); | |
149 transform.Translate(-1.0, -1.0); | |
150 break; | |
151 case media::VIDEO_ROTATION_270: | |
152 transform.Rotate(270.0); | |
153 transform.Translate(-1.0, 0); | |
154 case media::VIDEO_ROTATION_0: | |
155 break; | |
156 } | |
157 | |
158 shared_quad_state->SetAll(transform, | |
159 content_bounds(), | |
160 visible_content_rect(), | |
enne (OOO)
2014/07/21 23:42:49
This seems a bit wrong. Quad rects and visible co
suderman
2014/07/22 00:05:20
Previous version used width/height translation w/o
| |
161 clip_rect(), | |
162 is_clipped(), | |
163 draw_opacity(), | |
164 blend_mode(), | |
165 sorting_context_id()); | |
166 | |
137 AppendDebugBorderQuad( | 167 AppendDebugBorderQuad( |
138 render_pass, content_bounds(), shared_quad_state, append_quads_data); | 168 render_pass, content_bounds(), shared_quad_state, append_quads_data); |
139 | 169 |
140 gfx::Rect quad_rect(content_bounds()); | 170 gfx::Rect quad_rect(1, 1); |
141 gfx::Rect opaque_rect(contents_opaque() ? quad_rect : gfx::Rect()); | 171 gfx::Rect opaque_rect(contents_opaque() ? quad_rect : gfx::Rect()); |
142 gfx::Rect visible_rect = frame_->visible_rect(); | 172 gfx::Rect visible_rect = frame_->visible_rect(); |
143 gfx::Size coded_size = frame_->coded_size(); | 173 gfx::Size coded_size = frame_->coded_size(); |
144 | 174 |
145 gfx::Rect visible_quad_rect = occlusion_tracker.UnoccludedContentRect( | 175 gfx::Rect visible_quad_rect = |
146 quad_rect, draw_properties().target_space_transform); | 176 occlusion_tracker.UnoccludedContentRect(quad_rect, transform); |
147 if (visible_quad_rect.IsEmpty()) | 177 if (visible_quad_rect.IsEmpty()) |
148 return; | 178 return; |
149 | 179 |
150 // Pixels for macroblocked formats. | 180 // Pixels for macroblocked formats. |
151 const float tex_width_scale = | 181 const float tex_width_scale = |
152 static_cast<float>(visible_rect.width()) / coded_size.width(); | 182 static_cast<float>(visible_rect.width()) / coded_size.width(); |
153 const float tex_height_scale = | 183 const float tex_height_scale = |
154 static_cast<float>(visible_rect.height()) / coded_size.height(); | 184 static_cast<float>(visible_rect.height()) / coded_size.height(); |
155 const float tex_x_offset = | 185 const float tex_x_offset = |
156 static_cast<float>(visible_rect.x()) / coded_size.width(); | 186 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( | 362 void VideoLayerImpl::SetProviderClientImpl( |
333 scoped_refptr<VideoFrameProviderClientImpl> provider_client_impl) { | 363 scoped_refptr<VideoFrameProviderClientImpl> provider_client_impl) { |
334 provider_client_impl_ = provider_client_impl; | 364 provider_client_impl_ = provider_client_impl; |
335 } | 365 } |
336 | 366 |
337 const char* VideoLayerImpl::LayerTypeAsString() const { | 367 const char* VideoLayerImpl::LayerTypeAsString() const { |
338 return "cc::VideoLayerImpl"; | 368 return "cc::VideoLayerImpl"; |
339 } | 369 } |
340 | 370 |
341 } // namespace cc | 371 } // namespace cc |
OLD | NEW |