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

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: Address hendrikw@'s comments. 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
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(visible_rect.origin().IsOrigin());
239 if (frame_resources_.size() > 3) { 238 DCHECK(visible_rect.size() == coded_size);
240 DCHECK(ya_tex_size == 239 uv_tex_size.SetSize(ya_tex_size.width() / 2, ya_tex_size.height() / 2);
danakj 2015/05/14 23:08:33 is this right if coded_size is odd?
Daniele Castagna 2015/05/14 23:26:20 No. Done.
240 } else {
241 uv_tex_size = media::VideoFrame::PlaneSize(
242 frame_->format(), media::VideoFrame::kUPlane, coded_size);
243 DCHECK(uv_tex_size ==
241 media::VideoFrame::PlaneSize( 244 media::VideoFrame::PlaneSize(
242 frame_->format(), media::VideoFrame::kAPlane, coded_size)); 245 frame_->format(), media::VideoFrame::kVPlane, coded_size));
246 if (frame_resources_.size() > 3) {
danakj 2015/05/14 23:08:33 should this not also be true for NATIVE_TEXTURE? Y
Daniele Castagna 2015/05/14 23:26:20 NATIVE_TEXTURE doesn't support alpha channel right
danakj 2015/05/14 23:33:56 How about move this out of the else, and DCHECK th
Daniele Castagna 2015/05/14 23:52:08 Added DCHECK_EQ(3u, frame_resources_.size()) Repl
247 DCHECK(ya_tex_size ==
248 media::VideoFrame::PlaneSize(
249 frame_->format(), media::VideoFrame::kAPlane, coded_size));
250 }
243 } 251 }
244 252
245 gfx::RectF tex_coord_rect( 253 gfx::RectF tex_coord_rect(
246 tex_x_offset, tex_y_offset, tex_width_scale, tex_height_scale); 254 tex_x_offset, tex_y_offset, tex_width_scale, tex_height_scale);
247 YUVVideoDrawQuad* yuv_video_quad = 255 YUVVideoDrawQuad* yuv_video_quad =
248 render_pass->CreateAndAppendDrawQuad<YUVVideoDrawQuad>(); 256 render_pass->CreateAndAppendDrawQuad<YUVVideoDrawQuad>();
249 yuv_video_quad->SetNew( 257 yuv_video_quad->SetNew(
250 shared_quad_state, quad_rect, opaque_rect, visible_quad_rect, 258 shared_quad_state, quad_rect, opaque_rect, visible_quad_rect,
251 tex_coord_rect, ya_tex_size, uv_tex_size, frame_resources_[0], 259 tex_coord_rect, ya_tex_size, uv_tex_size, frame_resources_[0],
252 frame_resources_[1], frame_resources_[2], 260 frame_resources_[1], frame_resources_[2],
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 void VideoLayerImpl::SetNeedsRedraw() { 384 void VideoLayerImpl::SetNeedsRedraw() {
377 SetUpdateRect(gfx::UnionRects(update_rect(), gfx::Rect(bounds()))); 385 SetUpdateRect(gfx::UnionRects(update_rect(), gfx::Rect(bounds())));
378 layer_tree_impl()->SetNeedsRedraw(); 386 layer_tree_impl()->SetNeedsRedraw();
379 } 387 }
380 388
381 const char* VideoLayerImpl::LayerTypeAsString() const { 389 const char* VideoLayerImpl::LayerTypeAsString() const {
382 return "cc::VideoLayerImpl"; 390 return "cc::VideoLayerImpl";
383 } 391 }
384 392
385 } // namespace cc 393 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/layers/video_layer_impl_unittest.cc » ('j') | cc/layers/video_layer_impl_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698