Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(121)

Side by Side Diff: cc/layers/video_layer_impl.cc

Issue 388643002: Rotation into Video Layer + Content Transform (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Alternative transform Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 20 matching lines...) Expand all
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),
41 frame_(NULL) {} 41 frame_(NULL),
42 video_rotation_(media::VIDEO_ROTATION_0) {
43 }
42 44
43 VideoLayerImpl::~VideoLayerImpl() { 45 VideoLayerImpl::~VideoLayerImpl() {
44 if (!provider_client_impl_->Stopped()) { 46 if (!provider_client_impl_->Stopped()) {
45 // In impl side painting, we may have a pending and active layer 47 // 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 48 // associated with the video provider at the same time. Both have a ref
47 // on the VideoFrameProviderClientImpl, but we stop when the first 49 // on the VideoFrameProviderClientImpl, but we stop when the first
48 // LayerImpl (the one on the pending tree) is destroyed since we know 50 // LayerImpl (the one on the pending tree) is destroyed since we know
49 // the main thread is blocked for this commit. 51 // the main thread is blocked for this commit.
50 DCHECK(layer_tree_impl()->proxy()->IsImplThread()); 52 DCHECK(layer_tree_impl()->proxy()->IsImplThread());
51 DCHECK(layer_tree_impl()->proxy()->IsMainThreadBlocked()); 53 DCHECK(layer_tree_impl()->proxy()->IsMainThreadBlocked());
52 provider_client_impl_->Stop(); 54 provider_client_impl_->Stop();
53 } 55 }
54 } 56 }
55 57
56 scoped_ptr<LayerImpl> VideoLayerImpl::CreateLayerImpl( 58 scoped_ptr<LayerImpl> VideoLayerImpl::CreateLayerImpl(
57 LayerTreeImpl* tree_impl) { 59 LayerTreeImpl* tree_impl) {
58 return scoped_ptr<LayerImpl>(new VideoLayerImpl(tree_impl, id())); 60 VideoLayerImpl* impl = new VideoLayerImpl(tree_impl, id());
61 return scoped_ptr<LayerImpl>(impl);
59 } 62 }
60 63
61 void VideoLayerImpl::PushPropertiesTo(LayerImpl* layer) { 64 void VideoLayerImpl::PushPropertiesTo(LayerImpl* layer) {
62 LayerImpl::PushPropertiesTo(layer); 65 LayerImpl::PushPropertiesTo(layer);
63 66
64 VideoLayerImpl* other = static_cast<VideoLayerImpl*>(layer); 67 VideoLayerImpl* other = static_cast<VideoLayerImpl*>(layer);
65 other->SetProviderClientImpl(provider_client_impl_); 68 other->SetProviderClientImpl(provider_client_impl_);
69 other->set_video_rotation(video_rotation_);
66 } 70 }
67 71
68 void VideoLayerImpl::DidBecomeActive() { 72 void VideoLayerImpl::DidBecomeActive() {
69 provider_client_impl_->set_active_video_layer(this); 73 provider_client_impl_->set_active_video_layer(this);
70 } 74 }
71 75
72 bool VideoLayerImpl::WillDraw(DrawMode draw_mode, 76 bool VideoLayerImpl::WillDraw(DrawMode draw_mode,
73 ResourceProvider* resource_provider) { 77 ResourceProvider* resource_provider) {
74 if (draw_mode == DRAW_MODE_RESOURCELESS_SOFTWARE) 78 if (draw_mode == DRAW_MODE_RESOURCELESS_SOFTWARE)
75 return false; 79 return false;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 void VideoLayerImpl::AppendQuads( 131 void VideoLayerImpl::AppendQuads(
128 RenderPass* render_pass, 132 RenderPass* render_pass,
129 const OcclusionTracker<LayerImpl>& occlusion_tracker, 133 const OcclusionTracker<LayerImpl>& occlusion_tracker,
130 AppendQuadsData* append_quads_data) { 134 AppendQuadsData* append_quads_data) {
131 DCHECK(frame_.get()); 135 DCHECK(frame_.get());
132 136
133 SharedQuadState* shared_quad_state = 137 SharedQuadState* shared_quad_state =
134 render_pass->CreateAndAppendSharedQuadState(); 138 render_pass->CreateAndAppendSharedQuadState();
135 PopulateSharedQuadState(shared_quad_state); 139 PopulateSharedQuadState(shared_quad_state);
136 140
141 gfx::Transform transform = draw_transform();
142 transform.Scale(content_bounds().width(), content_bounds().height());
143
144 switch (video_rotation_) {
145 case media::VIDEO_ROTATION_90:
146 transform.Rotate(90);
danakj 2014/07/17 20:19:05 90.0
147 transform.Translate(0, -1.0);
danakj 2014/07/17 20:19:05 0.0, etc. (double literals to methods expecting a
148 break;
149 case media::VIDEO_ROTATION_180:
150 transform.Rotate(180);
151 transform.Translate(-1.0, -1.0);
152 break;
153 case media::VIDEO_ROTATION_270:
154 transform.Rotate(270);
155 transform.Translate(-1.0, 0);
156 case media::VIDEO_ROTATION_0:
157 break;
158 }
159
160 shared_quad_state->SetAll(transform,
161 content_bounds(),
162 visible_content_rect(),
163 clip_rect(),
164 is_clipped(),
165 draw_opacity(),
166 blend_mode(),
167 sorting_context_id());
168
137 AppendDebugBorderQuad( 169 AppendDebugBorderQuad(
138 render_pass, content_bounds(), shared_quad_state, append_quads_data); 170 render_pass, content_bounds(), shared_quad_state, append_quads_data);
139 171
140 gfx::Rect quad_rect(content_bounds()); 172 gfx::Rect quad_rect(1.0, 1.0);
danakj 2014/07/17 20:19:05 Rect is integer, these should be ints
141 gfx::Rect opaque_rect(contents_opaque() ? quad_rect : gfx::Rect()); 173 gfx::Rect opaque_rect(contents_opaque() ? quad_rect : gfx::Rect());
142 gfx::Rect visible_rect = frame_->visible_rect(); 174 gfx::Rect visible_rect = frame_->visible_rect();
143 gfx::Size coded_size = frame_->coded_size(); 175 gfx::Size coded_size = frame_->coded_size();
144 176
145 gfx::Rect visible_quad_rect = occlusion_tracker.UnoccludedContentRect( 177 gfx::Rect visible_quad_rect =
146 quad_rect, draw_properties().target_space_transform); 178 occlusion_tracker.UnoccludedContentRect(quad_rect, transform);
147 if (visible_quad_rect.IsEmpty()) 179 if (visible_quad_rect.IsEmpty())
148 return; 180 return;
149 181
150 // Pixels for macroblocked formats. 182 // Pixels for macroblocked formats.
151 const float tex_width_scale = 183 const float tex_width_scale =
152 static_cast<float>(visible_rect.width()) / coded_size.width(); 184 static_cast<float>(visible_rect.width()) / coded_size.width();
153 const float tex_height_scale = 185 const float tex_height_scale =
154 static_cast<float>(visible_rect.height()) / coded_size.height(); 186 static_cast<float>(visible_rect.height()) / coded_size.height();
155 const float tex_x_offset = 187 const float tex_x_offset =
156 static_cast<float>(visible_rect.x()) / coded_size.width(); 188 static_cast<float>(visible_rect.x()) / coded_size.width();
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 void VideoLayerImpl::SetProviderClientImpl( 364 void VideoLayerImpl::SetProviderClientImpl(
333 scoped_refptr<VideoFrameProviderClientImpl> provider_client_impl) { 365 scoped_refptr<VideoFrameProviderClientImpl> provider_client_impl) {
334 provider_client_impl_ = provider_client_impl; 366 provider_client_impl_ = provider_client_impl;
335 } 367 }
336 368
337 const char* VideoLayerImpl::LayerTypeAsString() const { 369 const char* VideoLayerImpl::LayerTypeAsString() const {
338 return "cc::VideoLayerImpl"; 370 return "cc::VideoLayerImpl";
339 } 371 }
340 372
341 } // namespace cc 373 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698