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

Side by Side Diff: chromecast/renderer/media/hole_frame_factory.cc

Issue 1431193005: [Chromecast] Adds Browser test for media playback (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nit rm blank line Created 5 years, 1 month 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 | « chromecast/chromecast_tests.gypi ('k') | testing/buildbot/chromium.linux.json » ('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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "chromecast/renderer/media/hole_frame_factory.h" 5 #include "chromecast/renderer/media/hole_frame_factory.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "gpu/GLES2/gl2extchromium.h" 9 #include "gpu/GLES2/gl2extchromium.h"
10 #include "gpu/command_buffer/client/gles2_interface.h" 10 #include "gpu/command_buffer/client/gles2_interface.h"
11 #include "media/base/video_frame.h" 11 #include "media/base/video_frame.h"
12 #include "media/renderers/gpu_video_accelerator_factories.h" 12 #include "media/renderers/gpu_video_accelerator_factories.h"
13 13
14 namespace chromecast { 14 namespace chromecast {
15 namespace media { 15 namespace media {
16 16
17 HoleFrameFactory::HoleFrameFactory( 17 HoleFrameFactory::HoleFrameFactory(
18 ::media::GpuVideoAcceleratorFactories* gpu_factories) 18 ::media::GpuVideoAcceleratorFactories* gpu_factories)
19 : gpu_factories_(gpu_factories), texture_(0), image_id_(0) { 19 : gpu_factories_(gpu_factories), texture_(0), image_id_(0) {
20 if (gpu_factories_) { 20 if (gpu_factories_) {
21 scoped_ptr<::media::GpuVideoAcceleratorFactories::ScopedGLContextLock> lock( 21 scoped_ptr<::media::GpuVideoAcceleratorFactories::ScopedGLContextLock> lock(
22 gpu_factories_->GetGLContextLock()); 22 gpu_factories_->GetGLContextLock());
23 CHECK(lock); 23 CHECK(lock);
24 gpu::gles2::GLES2Interface* gl = lock->ContextGL(); 24 gpu::gles2::GLES2Interface* gl = lock->ContextGL();
25 25
26 gl->GenTextures(1, &texture_); 26 gl->GenTextures(1, &texture_);
27 gl->BindTexture(GL_TEXTURE_2D, texture_); 27 gl->BindTexture(GL_TEXTURE_2D, texture_);
28 image_id_ = gl->CreateGpuMemoryBufferImageCHROMIUM(1, 1, GL_RGBA, 28 image_id_ = gl->CreateGpuMemoryBufferImageCHROMIUM(1, 1, GL_RGBA,
29 GL_READ_WRITE_CHROMIUM); 29 GL_READ_WRITE_CHROMIUM);
30 gl->BindTexImage2DCHROMIUM(GL_TEXTURE_2D, image_id_); 30 if (image_id_) {
31 gl->BindTexImage2DCHROMIUM(GL_TEXTURE_2D, image_id_);
31 32
32 gl->GenMailboxCHROMIUM(mailbox_.name); 33 gl->GenMailboxCHROMIUM(mailbox_.name);
33 gl->ProduceTextureDirectCHROMIUM(texture_, GL_TEXTURE_2D, mailbox_.name); 34 gl->ProduceTextureDirectCHROMIUM(texture_, GL_TEXTURE_2D, mailbox_.name);
34 35
35 sync_token_ = gpu::SyncToken(gl->InsertSyncPointCHROMIUM()); 36 sync_token_ = gpu::SyncToken(gl->InsertSyncPointCHROMIUM());
37 }
36 } 38 }
37 } 39 }
38 40
39 HoleFrameFactory::~HoleFrameFactory() { 41 HoleFrameFactory::~HoleFrameFactory() {
40 if (texture_) { 42 if (texture_) {
41 scoped_ptr<::media::GpuVideoAcceleratorFactories::ScopedGLContextLock> lock( 43 scoped_ptr<::media::GpuVideoAcceleratorFactories::ScopedGLContextLock> lock(
42 gpu_factories_->GetGLContextLock()); 44 gpu_factories_->GetGLContextLock());
43 CHECK(lock); 45 CHECK(lock);
44 gpu::gles2::GLES2Interface* gl = lock->ContextGL(); 46 gpu::gles2::GLES2Interface* gl = lock->ContextGL();
45 gl->BindTexture(GL_TEXTURE_2D, texture_); 47 gl->BindTexture(GL_TEXTURE_2D, texture_);
46 gl->ReleaseTexImage2DCHROMIUM(GL_TEXTURE_2D, image_id_); 48 if (image_id_)
49 gl->ReleaseTexImage2DCHROMIUM(GL_TEXTURE_2D, image_id_);
47 gl->DeleteTextures(1, &texture_); 50 gl->DeleteTextures(1, &texture_);
48 gl->DestroyImageCHROMIUM(image_id_); 51 if (image_id_)
52 gl->DestroyImageCHROMIUM(image_id_);
49 } 53 }
50 } 54 }
51 55
52 scoped_refptr<::media::VideoFrame> HoleFrameFactory::CreateHoleFrame( 56 scoped_refptr<::media::VideoFrame> HoleFrameFactory::CreateHoleFrame(
53 const gfx::Size& size) { 57 const gfx::Size& size) {
54 if (texture_) { 58 if (texture_ && image_id_) {
55 scoped_refptr<::media::VideoFrame> frame = 59 scoped_refptr<::media::VideoFrame> frame =
56 ::media::VideoFrame::WrapNativeTexture( 60 ::media::VideoFrame::WrapNativeTexture(
57 ::media::PIXEL_FORMAT_XRGB, 61 ::media::PIXEL_FORMAT_XRGB,
58 gpu::MailboxHolder(mailbox_, sync_token_, GL_TEXTURE_2D), 62 gpu::MailboxHolder(mailbox_, sync_token_, GL_TEXTURE_2D),
59 ::media::VideoFrame::ReleaseMailboxCB(), 63 ::media::VideoFrame::ReleaseMailboxCB(),
60 size, // coded_size 64 size, // coded_size
61 gfx::Rect(size), // visible rect 65 gfx::Rect(size), // visible rect
62 size, // natural size 66 size, // natural size
63 base::TimeDelta()); // timestamp 67 base::TimeDelta()); // timestamp
64 frame->metadata()->SetBoolean(::media::VideoFrameMetadata::ALLOW_OVERLAY, 68 frame->metadata()->SetBoolean(::media::VideoFrameMetadata::ALLOW_OVERLAY,
65 true); 69 true);
66 return frame; 70 return frame;
67 } else { 71 } else {
68 // This case is needed for audio-only devices. 72 // This case is needed for audio-only devices.
69 return ::media::VideoFrame::CreateBlackFrame(gfx::Size(1, 1)); 73 return ::media::VideoFrame::CreateBlackFrame(gfx::Size(1, 1));
70 } 74 }
71 } 75 }
72 76
73 } // namespace media 77 } // namespace media
74 } // namespace chromecast 78 } // namespace chromecast
OLDNEW
« no previous file with comments | « chromecast/chromecast_tests.gypi ('k') | testing/buildbot/chromium.linux.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698