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

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

Issue 1852923002: Enable sampling from DXGI NV12 formats in GLRenderer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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/output/gl_renderer.h » ('j') | cc/output/gl_renderer.cc » ('J')
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 uv_top_left, 225 uv_top_left,
226 uv_bottom_right, 226 uv_bottom_right,
227 SK_ColorTRANSPARENT, 227 SK_ColorTRANSPARENT,
228 opacity, 228 opacity,
229 flipped, 229 flipped,
230 nearest_neighbor); 230 nearest_neighbor);
231 ValidateQuadResources(texture_quad); 231 ValidateQuadResources(texture_quad);
232 break; 232 break;
233 } 233 }
234 case VideoFrameExternalResources::YUV_RESOURCE: { 234 case VideoFrameExternalResources::YUV_RESOURCE: {
235 DCHECK_GE(frame_resources_.size(), 3u);
236
237 YUVVideoDrawQuad::ColorSpace color_space = YUVVideoDrawQuad::REC_601; 235 YUVVideoDrawQuad::ColorSpace color_space = YUVVideoDrawQuad::REC_601;
238 int videoframe_color_space; 236 int videoframe_color_space;
239 if (frame_->metadata()->GetInteger(media::VideoFrameMetadata::COLOR_SPACE, 237 if (frame_->metadata()->GetInteger(media::VideoFrameMetadata::COLOR_SPACE,
240 &videoframe_color_space)) { 238 &videoframe_color_space)) {
241 if (videoframe_color_space == media::COLOR_SPACE_JPEG) { 239 if (videoframe_color_space == media::COLOR_SPACE_JPEG) {
242 color_space = YUVVideoDrawQuad::JPEG; 240 color_space = YUVVideoDrawQuad::JPEG;
243 } else if (videoframe_color_space == media::COLOR_SPACE_HD_REC709) { 241 } else if (videoframe_color_space == media::COLOR_SPACE_HD_REC709) {
244 color_space = YUVVideoDrawQuad::REC_709; 242 color_space = YUVVideoDrawQuad::REC_709;
245 } 243 }
246 } 244 }
247 245
248 const gfx::Size ya_tex_size = coded_size; 246 const gfx::Size ya_tex_size = coded_size;
249 gfx::Size uv_tex_size = media::VideoFrame::PlaneSize( 247 gfx::Size uv_tex_size = media::VideoFrame::PlaneSize(
250 frame_->format(), media::VideoFrame::kUPlane, coded_size); 248 frame_->format(), media::VideoFrame::kUPlane, coded_size);
251 249
252 if (frame_->HasTextures()) { 250 if (frame_->HasTextures()) {
253 DCHECK_EQ(media::PIXEL_FORMAT_I420, frame_->format()); 251 if (frame_->format() == media::PIXEL_FORMAT_NV12) {
254 DCHECK_EQ(3u, frame_resources_.size()); // Alpha is not supported yet. 252 DCHECK_EQ(2u, frame_resources_.size());
253 } else {
254 DCHECK_EQ(media::PIXEL_FORMAT_I420, frame_->format());
255 DCHECK_EQ(3u,
256 frame_resources_.size()); // Alpha is not supported yet.
257 }
255 } else { 258 } else {
256 DCHECK(uv_tex_size == 259 DCHECK(uv_tex_size ==
257 media::VideoFrame::PlaneSize( 260 media::VideoFrame::PlaneSize(
258 frame_->format(), media::VideoFrame::kVPlane, coded_size)); 261 frame_->format(), media::VideoFrame::kVPlane, coded_size));
262 DCHECK_GE(frame_resources_.size(), 3u);
259 DCHECK(frame_resources_.size() <= 3 || 263 DCHECK(frame_resources_.size() <= 3 ||
260 ya_tex_size == media::VideoFrame::PlaneSize( 264 ya_tex_size == media::VideoFrame::PlaneSize(
261 frame_->format(), media::VideoFrame::kAPlane, 265 frame_->format(), media::VideoFrame::kAPlane,
262 coded_size)); 266 coded_size));
263 } 267 }
264 268
265 // Compute the UV sub-sampling factor based on the ratio between 269 // Compute the UV sub-sampling factor based on the ratio between
266 // |ya_tex_size| and |uv_tex_size|. 270 // |ya_tex_size| and |uv_tex_size|.
267 float uv_subsampling_factor_x = 271 float uv_subsampling_factor_x =
268 static_cast<float>(ya_tex_size.width()) / uv_tex_size.width(); 272 static_cast<float>(ya_tex_size.width()) / uv_tex_size.width();
269 float uv_subsampling_factor_y = 273 float uv_subsampling_factor_y =
270 static_cast<float>(ya_tex_size.height()) / uv_tex_size.height(); 274 static_cast<float>(ya_tex_size.height()) / uv_tex_size.height();
271 gfx::RectF ya_tex_coord_rect(visible_sample_rect); 275 gfx::RectF ya_tex_coord_rect(visible_sample_rect);
272 gfx::RectF uv_tex_coord_rect( 276 gfx::RectF uv_tex_coord_rect(
273 visible_sample_rect.x() / uv_subsampling_factor_x, 277 visible_sample_rect.x() / uv_subsampling_factor_x,
274 visible_sample_rect.y() / uv_subsampling_factor_y, 278 visible_sample_rect.y() / uv_subsampling_factor_y,
275 visible_sample_rect.width() / uv_subsampling_factor_x, 279 visible_sample_rect.width() / uv_subsampling_factor_x,
276 visible_sample_rect.height() / uv_subsampling_factor_y); 280 visible_sample_rect.height() / uv_subsampling_factor_y);
277 281
278 YUVVideoDrawQuad* yuv_video_quad = 282 YUVVideoDrawQuad* yuv_video_quad =
279 render_pass->CreateAndAppendDrawQuad<YUVVideoDrawQuad>(); 283 render_pass->CreateAndAppendDrawQuad<YUVVideoDrawQuad>();
280 yuv_video_quad->SetNew( 284 yuv_video_quad->SetNew(
281 shared_quad_state, quad_rect, opaque_rect, visible_quad_rect, 285 shared_quad_state, quad_rect, opaque_rect, visible_quad_rect,
282 ya_tex_coord_rect, uv_tex_coord_rect, ya_tex_size, uv_tex_size, 286 ya_tex_coord_rect, uv_tex_coord_rect, ya_tex_size, uv_tex_size,
283 frame_resources_[0].id, frame_resources_[1].id, 287 frame_resources_[0].id, frame_resources_[1].id,
284 frame_resources_[2].id, 288 frame_resources_.size() > 2 ? frame_resources_[2].id
289 : frame_resources_[1].id,
285 frame_resources_.size() > 3 ? frame_resources_[3].id : 0, color_space, 290 frame_resources_.size() > 3 ? frame_resources_[3].id : 0, color_space,
286 frame_resource_offset_, frame_resource_multiplier_); 291 frame_resource_offset_, frame_resource_multiplier_);
287 ValidateQuadResources(yuv_video_quad); 292 ValidateQuadResources(yuv_video_quad);
288 break; 293 break;
289 } 294 }
290 case VideoFrameExternalResources::RGBA_RESOURCE: 295 case VideoFrameExternalResources::RGBA_RESOURCE:
291 case VideoFrameExternalResources::RGBA_PREMULTIPLIED_RESOURCE: 296 case VideoFrameExternalResources::RGBA_PREMULTIPLIED_RESOURCE:
292 case VideoFrameExternalResources::RGB_RESOURCE: { 297 case VideoFrameExternalResources::RGB_RESOURCE: {
293 DCHECK_EQ(frame_resources_.size(), 1u); 298 DCHECK_EQ(frame_resources_.size(), 1u);
294 if (frame_resources_.size() < 1u) 299 if (frame_resources_.size() < 1u)
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 void VideoLayerImpl::SetNeedsRedraw() { 416 void VideoLayerImpl::SetNeedsRedraw() {
412 SetUpdateRect(gfx::UnionRects(update_rect(), gfx::Rect(bounds()))); 417 SetUpdateRect(gfx::UnionRects(update_rect(), gfx::Rect(bounds())));
413 layer_tree_impl()->SetNeedsRedraw(); 418 layer_tree_impl()->SetNeedsRedraw();
414 } 419 }
415 420
416 const char* VideoLayerImpl::LayerTypeAsString() const { 421 const char* VideoLayerImpl::LayerTypeAsString() const {
417 return "cc::VideoLayerImpl"; 422 return "cc::VideoLayerImpl";
418 } 423 }
419 424
420 } // namespace cc 425 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/output/gl_renderer.h » ('j') | cc/output/gl_renderer.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698