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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
177 gfx::Rect visible_quad_rect = | 177 gfx::Rect visible_quad_rect = |
178 occlusion_in_video_space.GetUnoccludedContentRect(quad_rect); | 178 occlusion_in_video_space.GetUnoccludedContentRect(quad_rect); |
179 if (visible_quad_rect.IsEmpty()) | 179 if (visible_quad_rect.IsEmpty()) |
180 return; | 180 return; |
181 | 181 |
182 // Pixels for macroblocked formats. | 182 // Pixels for macroblocked formats. |
183 const float tex_width_scale = | 183 const float tex_width_scale = |
184 static_cast<float>(visible_rect.width()) / coded_size.width(); | 184 static_cast<float>(visible_rect.width()) / coded_size.width(); |
185 const float tex_height_scale = | 185 const float tex_height_scale = |
186 static_cast<float>(visible_rect.height()) / coded_size.height(); | 186 static_cast<float>(visible_rect.height()) / coded_size.height(); |
187 const float tex_x_offset = | |
188 static_cast<float>(visible_rect.x()) / coded_size.width(); | |
189 const float tex_y_offset = | |
190 static_cast<float>(visible_rect.y()) / coded_size.height(); | |
191 | 187 |
192 switch (frame_resource_type_) { | 188 switch (frame_resource_type_) { |
193 // TODO(danakj): Remove this, hide it in the hardware path. | 189 // TODO(danakj): Remove this, hide it in the hardware path. |
194 case VideoFrameExternalResources::SOFTWARE_RESOURCE: { | 190 case VideoFrameExternalResources::SOFTWARE_RESOURCE: { |
195 DCHECK_EQ(frame_resources_.size(), 0u); | 191 DCHECK_EQ(frame_resources_.size(), 0u); |
196 DCHECK_EQ(software_resources_.size(), 1u); | 192 DCHECK_EQ(software_resources_.size(), 1u); |
197 if (software_resources_.size() < 1u) | 193 if (software_resources_.size() < 1u) |
198 break; | 194 break; |
199 bool premultiplied_alpha = true; | 195 bool premultiplied_alpha = true; |
200 gfx::PointF uv_top_left(0.f, 0.f); | 196 gfx::PointF uv_top_left(0.f, 0.f); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
235 frame_->format(), media::VideoFrame::kUPlane, coded_size); | 231 frame_->format(), media::VideoFrame::kUPlane, coded_size); |
236 DCHECK(uv_tex_size == | 232 DCHECK(uv_tex_size == |
237 media::VideoFrame::PlaneSize( | 233 media::VideoFrame::PlaneSize( |
238 frame_->format(), media::VideoFrame::kVPlane, coded_size)); | 234 frame_->format(), media::VideoFrame::kVPlane, coded_size)); |
239 if (frame_resources_.size() > 3) { | 235 if (frame_resources_.size() > 3) { |
240 DCHECK(ya_tex_size == | 236 DCHECK(ya_tex_size == |
241 media::VideoFrame::PlaneSize( | 237 media::VideoFrame::PlaneSize( |
242 frame_->format(), media::VideoFrame::kAPlane, coded_size)); | 238 frame_->format(), media::VideoFrame::kAPlane, coded_size)); |
243 } | 239 } |
244 | 240 |
245 gfx::RectF tex_coord_rect( | 241 // Compute the UV sub-sampling factor based on the ratio between |
246 tex_x_offset, tex_y_offset, tex_width_scale, tex_height_scale); | 242 // |ya_tex_size| and |uv_tex_size|. |
243 float uv_subsampling_factor_x = | |
244 static_cast<float>(ya_tex_size.width()) / uv_tex_size.width(); | |
245 float uv_subsampling_factor_y = | |
246 static_cast<float>(ya_tex_size.height()) / uv_tex_size.height(); | |
247 gfx::RectF ya_tex_coord_rect(visible_rect); | |
danakj
2015/05/12 16:32:12
if these are in pixels not in [0,1] they aren't re
reveman
2015/05/12 17:09:35
If tex coords are normalized or not depend on the
danakj
2015/05/12 17:22:11
Maybe we're a bit inconsistent but this used to be
reveman
2015/05/12 17:40:35
It's "tex_coord_rect" here: https://code.google.co
| |
248 gfx::RectF uv_tex_coord_rect( | |
249 visible_rect.x() / uv_subsampling_factor_x, | |
250 visible_rect.y() / uv_subsampling_factor_y, | |
251 visible_rect.width() / uv_subsampling_factor_x, | |
252 visible_rect.height() / uv_subsampling_factor_y); | |
253 | |
247 YUVVideoDrawQuad* yuv_video_quad = | 254 YUVVideoDrawQuad* yuv_video_quad = |
248 render_pass->CreateAndAppendDrawQuad<YUVVideoDrawQuad>(); | 255 render_pass->CreateAndAppendDrawQuad<YUVVideoDrawQuad>(); |
249 yuv_video_quad->SetNew( | 256 yuv_video_quad->SetNew( |
250 shared_quad_state, quad_rect, opaque_rect, visible_quad_rect, | 257 shared_quad_state, quad_rect, opaque_rect, visible_quad_rect, |
251 tex_coord_rect, ya_tex_size, uv_tex_size, frame_resources_[0], | 258 ya_tex_coord_rect, uv_tex_coord_rect, ya_tex_size, uv_tex_size, |
252 frame_resources_[1], frame_resources_[2], | 259 frame_resources_[0], frame_resources_[1], frame_resources_[2], |
253 frame_resources_.size() > 3 ? frame_resources_[3] : 0, color_space); | 260 frame_resources_.size() > 3 ? frame_resources_[3] : 0, color_space); |
254 ValidateQuadResources(yuv_video_quad); | 261 ValidateQuadResources(yuv_video_quad); |
255 break; | 262 break; |
256 } | 263 } |
257 case VideoFrameExternalResources::RGB_RESOURCE: { | 264 case VideoFrameExternalResources::RGB_RESOURCE: { |
258 DCHECK_EQ(frame_resources_.size(), 1u); | 265 DCHECK_EQ(frame_resources_.size(), 1u); |
259 if (frame_resources_.size() < 1u) | 266 if (frame_resources_.size() < 1u) |
260 break; | 267 break; |
261 bool premultiplied_alpha = true; | 268 bool premultiplied_alpha = true; |
262 gfx::PointF uv_top_left(0.f, 0.f); | 269 gfx::PointF uv_top_left(0.f, 0.f); |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
376 void VideoLayerImpl::SetNeedsRedraw() { | 383 void VideoLayerImpl::SetNeedsRedraw() { |
377 SetUpdateRect(gfx::UnionRects(update_rect(), gfx::Rect(bounds()))); | 384 SetUpdateRect(gfx::UnionRects(update_rect(), gfx::Rect(bounds()))); |
378 layer_tree_impl()->SetNeedsRedraw(); | 385 layer_tree_impl()->SetNeedsRedraw(); |
379 } | 386 } |
380 | 387 |
381 const char* VideoLayerImpl::LayerTypeAsString() const { | 388 const char* VideoLayerImpl::LayerTypeAsString() const { |
382 return "cc::VideoLayerImpl"; | 389 return "cc::VideoLayerImpl"; |
383 } | 390 } |
384 | 391 |
385 } // namespace cc | 392 } // namespace cc |
OLD | NEW |