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

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

Issue 1125303005: cc: VideoLayerImpl VideoFrame::TEXTURE_YUV_420 support. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: No alpha for native textures. DCHECK_IMPLIES. Created 5 years, 7 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
« no previous file with comments | « no previous file | cc/layers/video_layer_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 uv_bottom_right, 214 uv_bottom_right,
215 SK_ColorTRANSPARENT, 215 SK_ColorTRANSPARENT,
216 opacity, 216 opacity,
217 flipped, 217 flipped,
218 nearest_neighbor); 218 nearest_neighbor);
219 ValidateQuadResources(texture_quad); 219 ValidateQuadResources(texture_quad);
220 break; 220 break;
221 } 221 }
222 case VideoFrameExternalResources::YUV_RESOURCE: { 222 case VideoFrameExternalResources::YUV_RESOURCE: {
223 DCHECK_GE(frame_resources_.size(), 3u); 223 DCHECK_GE(frame_resources_.size(), 3u);
224 if (frame_resources_.size() < 3u) 224
225 break;
226 YUVVideoDrawQuad::ColorSpace color_space = YUVVideoDrawQuad::REC_601; 225 YUVVideoDrawQuad::ColorSpace color_space = YUVVideoDrawQuad::REC_601;
227 if (frame_->format() == media::VideoFrame::YV12J) { 226 if (frame_->format() == media::VideoFrame::YV12J) {
228 color_space = YUVVideoDrawQuad::JPEG; 227 color_space = YUVVideoDrawQuad::JPEG;
229 } else if (frame_->format() == media::VideoFrame::YV12HD) { 228 } else if (frame_->format() == media::VideoFrame::YV12HD) {
230 color_space = YUVVideoDrawQuad::REC_709; 229 color_space = YUVVideoDrawQuad::REC_709;
231 } 230 }
232 231
233 const gfx::Size ya_tex_size = coded_size; 232 const gfx::Size ya_tex_size = coded_size;
234 const gfx::Size uv_tex_size = media::VideoFrame::PlaneSize( 233 gfx::Size uv_tex_size;
235 frame_->format(), media::VideoFrame::kUPlane, coded_size); 234
236 DCHECK(uv_tex_size == 235 if (frame_->format() == media::VideoFrame::NATIVE_TEXTURE) {
237 media::VideoFrame::PlaneSize( 236 DCHECK_EQ(media::VideoFrame::TEXTURE_YUV_420, frame_->texture_format());
238 frame_->format(), media::VideoFrame::kVPlane, coded_size)); 237 DCHECK_EQ(3u, frame_resources_.size()); // Alpha is not supported yet.
239 if (frame_resources_.size() > 3) { 238 DCHECK(visible_rect.origin().IsOrigin());
240 DCHECK(ya_tex_size == 239 DCHECK(visible_rect.size() == coded_size);
240 uv_tex_size.SetSize((ya_tex_size.width() + 1) / 2,
241 (ya_tex_size.height() + 1) / 2);
242 } else {
243 uv_tex_size = media::VideoFrame::PlaneSize(
244 frame_->format(), media::VideoFrame::kUPlane, coded_size);
245 DCHECK(uv_tex_size ==
241 media::VideoFrame::PlaneSize( 246 media::VideoFrame::PlaneSize(
242 frame_->format(), media::VideoFrame::kAPlane, coded_size)); 247 frame_->format(), media::VideoFrame::kVPlane, coded_size));
248 DCHECK_IMPLIES(
249 frame_resources_.size() > 3,
250 ya_tex_size ==
251 media::VideoFrame::PlaneSize(
252 frame_->format(), media::VideoFrame::kAPlane, coded_size));
243 } 253 }
244 254
245 gfx::RectF tex_coord_rect( 255 gfx::RectF tex_coord_rect(
246 tex_x_offset, tex_y_offset, tex_width_scale, tex_height_scale); 256 tex_x_offset, tex_y_offset, tex_width_scale, tex_height_scale);
247 YUVVideoDrawQuad* yuv_video_quad = 257 YUVVideoDrawQuad* yuv_video_quad =
248 render_pass->CreateAndAppendDrawQuad<YUVVideoDrawQuad>(); 258 render_pass->CreateAndAppendDrawQuad<YUVVideoDrawQuad>();
249 yuv_video_quad->SetNew( 259 yuv_video_quad->SetNew(
250 shared_quad_state, quad_rect, opaque_rect, visible_quad_rect, 260 shared_quad_state, quad_rect, opaque_rect, visible_quad_rect,
251 tex_coord_rect, ya_tex_size, uv_tex_size, frame_resources_[0], 261 tex_coord_rect, ya_tex_size, uv_tex_size, frame_resources_[0],
252 frame_resources_[1], frame_resources_[2], 262 frame_resources_[1], frame_resources_[2],
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 void VideoLayerImpl::SetNeedsRedraw() { 386 void VideoLayerImpl::SetNeedsRedraw() {
377 SetUpdateRect(gfx::UnionRects(update_rect(), gfx::Rect(bounds()))); 387 SetUpdateRect(gfx::UnionRects(update_rect(), gfx::Rect(bounds())));
378 layer_tree_impl()->SetNeedsRedraw(); 388 layer_tree_impl()->SetNeedsRedraw();
379 } 389 }
380 390
381 const char* VideoLayerImpl::LayerTypeAsString() const { 391 const char* VideoLayerImpl::LayerTypeAsString() const {
382 return "cc::VideoLayerImpl"; 392 return "cc::VideoLayerImpl";
383 } 393 }
384 394
385 } // namespace cc 395 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/layers/video_layer_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698