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

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

Issue 2684993005: (NotForReview) Enable YUV video overlay on Skylake ChromeOS.
Patch Set: rebase to ToT (Mar/27) Created 3 years, 9 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 | « cc/layers/video_layer_impl.h ('k') | cc/output/overlay_candidate.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 <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"
11 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "cc/layers/video_frame_provider_client_impl.h" 12 #include "cc/layers/video_frame_provider_client_impl.h"
13 #include "cc/quads/stream_video_draw_quad.h" 13 #include "cc/quads/stream_video_draw_quad.h"
14 #include "cc/quads/texture_draw_quad.h" 14 #include "cc/quads/texture_draw_quad.h"
15 #include "cc/quads/yuv_video_draw_quad.h" 15 #include "cc/quads/yuv_video_draw_quad.h"
16 #include "cc/resources/resource_provider.h" 16 #include "cc/resources/resource_provider.h"
17 #include "cc/resources/single_release_callback_impl.h" 17 #include "cc/resources/single_release_callback_impl.h"
18 #include "cc/trees/layer_tree_impl.h" 18 #include "cc/trees/layer_tree_impl.h"
19 #include "cc/trees/occlusion.h" 19 #include "cc/trees/occlusion.h"
20 #include "cc/trees/task_runner_provider.h" 20 #include "cc/trees/task_runner_provider.h"
21 #include "media/base/video_frame.h" 21 #include "media/base/video_frame.h"
22 #include "ui/gfx/color_space.h" 22 #include "ui/gfx/color_space.h"
23 23
24 namespace cc { 24 namespace cc {
25 25
26 namespace {
27
28 gfx::BufferFormat GetBufferFormat(media::VideoPixelFormat pixel_format) {
29 switch (pixel_format) {
30 case media::PIXEL_FORMAT_YV12:
31 return gfx::BufferFormat::YVU_420;
32 case media::PIXEL_FORMAT_NV12:
33 return gfx::BufferFormat::YUV_420_BIPLANAR;
34 case media::PIXEL_FORMAT_UYVY:
35 return gfx::BufferFormat::UYVY_422;
36 case media::PIXEL_FORMAT_YUY2:
37 return gfx::BufferFormat::YUYV_422;
38 case media::PIXEL_FORMAT_ARGB:
39 return gfx::BufferFormat::BGRA_8888;
40 case media::PIXEL_FORMAT_XRGB:
41 return gfx::BufferFormat::BGRX_8888;
42 case media::PIXEL_FORMAT_RGB32:
43 return gfx::BufferFormat::RGBX_8888;
44 case media::PIXEL_FORMAT_Y8:
45 return gfx::BufferFormat::R_8;
46 case media::PIXEL_FORMAT_Y16:
47 return gfx::BufferFormat::RG_88;
48 case media::PIXEL_FORMAT_UNKNOWN:
49 case media::PIXEL_FORMAT_I420:
50 case media::PIXEL_FORMAT_YV16:
51 case media::PIXEL_FORMAT_YV12A:
52 case media::PIXEL_FORMAT_YV24:
53 case media::PIXEL_FORMAT_NV21:
54 case media::PIXEL_FORMAT_RGB24:
55 case media::PIXEL_FORMAT_MJPEG:
56 case media::PIXEL_FORMAT_MT21:
57 case media::PIXEL_FORMAT_YUV420P9:
58 case media::PIXEL_FORMAT_YUV420P10:
59 case media::PIXEL_FORMAT_YUV422P9:
60 case media::PIXEL_FORMAT_YUV422P10:
61 case media::PIXEL_FORMAT_YUV444P9:
62 case media::PIXEL_FORMAT_YUV444P10:
63 case media::PIXEL_FORMAT_YUV420P12:
64 case media::PIXEL_FORMAT_YUV422P12:
65 case media::PIXEL_FORMAT_YUV444P12:
66 case media::PIXEL_FORMAT_I422:
67 break;
68 }
69 NOTREACHED();
70 return gfx::BufferFormat::BGRA_8888;
71 }
72
73 } // namespace
74
26 // static 75 // static
27 std::unique_ptr<VideoLayerImpl> VideoLayerImpl::Create( 76 std::unique_ptr<VideoLayerImpl> VideoLayerImpl::Create(
28 LayerTreeImpl* tree_impl, 77 LayerTreeImpl* tree_impl,
29 int id, 78 int id,
30 VideoFrameProvider* provider, 79 VideoFrameProvider* provider,
31 media::VideoRotation video_rotation) { 80 media::VideoRotation video_rotation) {
32 DCHECK(tree_impl->task_runner_provider()->IsMainThreadBlocked()); 81 DCHECK(tree_impl->task_runner_provider()->IsMainThreadBlocked());
33 DCHECK(tree_impl->task_runner_provider()->IsImplThread()); 82 DCHECK(tree_impl->task_runner_provider()->IsImplThread());
34 83
35 scoped_refptr<VideoFrameProviderClientImpl> provider_client_impl = 84 scoped_refptr<VideoFrameProviderClientImpl> provider_client_impl =
36 VideoFrameProviderClientImpl::Create( 85 VideoFrameProviderClientImpl::Create(
37 provider, tree_impl->GetVideoFrameControllerClient()); 86 provider, tree_impl->GetVideoFrameControllerClient());
38 87
39 return base::WrapUnique(new VideoLayerImpl( 88 return base::WrapUnique(new VideoLayerImpl(
40 tree_impl, id, std::move(provider_client_impl), video_rotation)); 89 tree_impl, id, std::move(provider_client_impl), video_rotation));
41 } 90 }
42 91
43 VideoLayerImpl::VideoLayerImpl( 92 VideoLayerImpl::VideoLayerImpl(
44 LayerTreeImpl* tree_impl, 93 LayerTreeImpl* tree_impl,
45 int id, 94 int id,
46 scoped_refptr<VideoFrameProviderClientImpl> provider_client_impl, 95 scoped_refptr<VideoFrameProviderClientImpl> provider_client_impl,
47 media::VideoRotation video_rotation) 96 media::VideoRotation video_rotation)
48 : LayerImpl(tree_impl, id), 97 : LayerImpl(tree_impl, id),
49 provider_client_impl_(std::move(provider_client_impl)), 98 provider_client_impl_(std::move(provider_client_impl)),
50 frame_(nullptr), 99 frame_(nullptr),
51 video_rotation_(video_rotation) { 100 video_rotation_(video_rotation),
101 frame_resource_type_(VideoFrameExternalResources::NONE),
102 frame_pixel_format_(media::PIXEL_FORMAT_UNKNOWN),
103 frame_resource_offset_(0.0f),
104 frame_resource_multiplier_(1.0f),
105 frame_bits_per_channel_(8) {
52 set_may_contain_video(true); 106 set_may_contain_video(true);
53 } 107 }
54 108
55 VideoLayerImpl::~VideoLayerImpl() { 109 VideoLayerImpl::~VideoLayerImpl() {
56 if (!provider_client_impl_->Stopped()) { 110 if (!provider_client_impl_->Stopped()) {
57 // In impl side painting, we may have a pending and active layer 111 // In impl side painting, we may have a pending and active layer
58 // associated with the video provider at the same time. Both have a ref 112 // associated with the video provider at the same time. Both have a ref
59 // on the VideoFrameProviderClientImpl, but we stop when the first 113 // on the VideoFrameProviderClientImpl, but we stop when the first
60 // LayerImpl (the one on the pending tree) is destroyed since we know 114 // LayerImpl (the one on the pending tree) is destroyed since we know
61 // the main thread is blocked for this commit. 115 // the main thread is blocked for this commit.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 156
103 if (!updater_) { 157 if (!updater_) {
104 updater_.reset( 158 updater_.reset(
105 new VideoResourceUpdater(layer_tree_impl()->context_provider(), 159 new VideoResourceUpdater(layer_tree_impl()->context_provider(),
106 layer_tree_impl()->resource_provider())); 160 layer_tree_impl()->resource_provider()));
107 } 161 }
108 162
109 VideoFrameExternalResources external_resources = 163 VideoFrameExternalResources external_resources =
110 updater_->CreateExternalResourcesFromVideoFrame(frame_); 164 updater_->CreateExternalResourcesFromVideoFrame(frame_);
111 frame_resource_type_ = external_resources.type; 165 frame_resource_type_ = external_resources.type;
166 frame_pixel_format_ = external_resources.pixel_format;
112 167
113 if (external_resources.type == 168 if (external_resources.type ==
114 VideoFrameExternalResources::SOFTWARE_RESOURCE) { 169 VideoFrameExternalResources::SOFTWARE_RESOURCE) {
115 software_resources_ = external_resources.software_resources; 170 software_resources_ = external_resources.software_resources;
116 software_release_callback_ = 171 software_release_callback_ =
117 external_resources.software_release_callback; 172 external_resources.software_release_callback;
118 return true; 173 return true;
119 } 174 }
120 frame_resource_offset_ = external_resources.offset; 175 frame_resource_offset_ = external_resources.offset;
121 frame_resource_multiplier_ = external_resources.multiplier; 176 frame_resource_multiplier_ = external_resources.multiplier;
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 case VideoFrameExternalResources::STREAM_TEXTURE_RESOURCE: { 368 case VideoFrameExternalResources::STREAM_TEXTURE_RESOURCE: {
314 DCHECK_EQ(frame_resources_.size(), 1u); 369 DCHECK_EQ(frame_resources_.size(), 1u);
315 if (frame_resources_.size() < 1u) 370 if (frame_resources_.size() < 1u)
316 break; 371 break;
317 gfx::Transform scale; 372 gfx::Transform scale;
318 scale.Scale(tex_width_scale, tex_height_scale); 373 scale.Scale(tex_width_scale, tex_height_scale);
319 StreamVideoDrawQuad* stream_video_quad = 374 StreamVideoDrawQuad* stream_video_quad =
320 render_pass->CreateAndAppendDrawQuad<StreamVideoDrawQuad>(); 375 render_pass->CreateAndAppendDrawQuad<StreamVideoDrawQuad>();
321 stream_video_quad->SetNew(shared_quad_state, quad_rect, opaque_rect, 376 stream_video_quad->SetNew(shared_quad_state, quad_rect, opaque_rect,
322 visible_quad_rect, frame_resources_[0].id, 377 visible_quad_rect, frame_resources_[0].id,
323 frame_resources_[0].size_in_pixels, scale); 378 frame_resources_[0].size_in_pixels,
379 GetBufferFormat(frame_pixel_format_), scale);
324 ValidateQuadResources(stream_video_quad); 380 ValidateQuadResources(stream_video_quad);
325 break; 381 break;
326 } 382 }
327 case VideoFrameExternalResources::NONE: 383 case VideoFrameExternalResources::NONE:
328 NOTIMPLEMENTED(); 384 NOTIMPLEMENTED();
329 break; 385 break;
330 } 386 }
331 } 387 }
332 388
333 void VideoLayerImpl::DidDraw(ResourceProvider* resource_provider) { 389 void VideoLayerImpl::DidDraw(ResourceProvider* resource_provider) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 void VideoLayerImpl::SetNeedsRedraw() { 428 void VideoLayerImpl::SetNeedsRedraw() {
373 SetUpdateRect(gfx::UnionRects(update_rect(), gfx::Rect(bounds()))); 429 SetUpdateRect(gfx::UnionRects(update_rect(), gfx::Rect(bounds())));
374 layer_tree_impl()->SetNeedsRedraw(); 430 layer_tree_impl()->SetNeedsRedraw();
375 } 431 }
376 432
377 const char* VideoLayerImpl::LayerTypeAsString() const { 433 const char* VideoLayerImpl::LayerTypeAsString() const {
378 return "cc::VideoLayerImpl"; 434 return "cc::VideoLayerImpl";
379 } 435 }
380 436
381 } // namespace cc 437 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/video_layer_impl.h ('k') | cc/output/overlay_candidate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698