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

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

Issue 1427543002: Modified old wait sync point functions to also accept new sync tokens. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: format 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
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), sync_point_(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 gl->BindTexImage2DCHROMIUM(GL_TEXTURE_2D, image_id_);
31 31
32 gl->GenMailboxCHROMIUM(mailbox_.name); 32 gl->GenMailboxCHROMIUM(mailbox_.name);
33 gl->ProduceTextureDirectCHROMIUM(texture_, GL_TEXTURE_2D, mailbox_.name); 33 gl->ProduceTextureDirectCHROMIUM(texture_, GL_TEXTURE_2D, mailbox_.name);
34 34
35 sync_point_ = gl->InsertSyncPointCHROMIUM(); 35 sync_token_ = gpu::SyncToken(gl->InsertSyncPointCHROMIUM());
36 } 36 }
37 } 37 }
38 38
39 HoleFrameFactory::~HoleFrameFactory() { 39 HoleFrameFactory::~HoleFrameFactory() {
40 if (texture_) { 40 if (texture_) {
41 scoped_ptr<::media::GpuVideoAcceleratorFactories::ScopedGLContextLock> lock( 41 scoped_ptr<::media::GpuVideoAcceleratorFactories::ScopedGLContextLock> lock(
42 gpu_factories_->GetGLContextLock()); 42 gpu_factories_->GetGLContextLock());
43 CHECK(lock); 43 CHECK(lock);
44 gpu::gles2::GLES2Interface* gl = lock->ContextGL(); 44 gpu::gles2::GLES2Interface* gl = lock->ContextGL();
45 gl->BindTexture(GL_TEXTURE_2D, texture_); 45 gl->BindTexture(GL_TEXTURE_2D, texture_);
46 gl->ReleaseTexImage2DCHROMIUM(GL_TEXTURE_2D, image_id_); 46 gl->ReleaseTexImage2DCHROMIUM(GL_TEXTURE_2D, image_id_);
47 gl->DeleteTextures(1, &texture_); 47 gl->DeleteTextures(1, &texture_);
48 gl->DestroyImageCHROMIUM(image_id_); 48 gl->DestroyImageCHROMIUM(image_id_);
49 } 49 }
50 } 50 }
51 51
52 scoped_refptr<::media::VideoFrame> HoleFrameFactory::CreateHoleFrame( 52 scoped_refptr<::media::VideoFrame> HoleFrameFactory::CreateHoleFrame(
53 const gfx::Size& size) { 53 const gfx::Size& size) {
54 if (texture_) { 54 if (texture_) {
55 scoped_refptr<::media::VideoFrame> frame = 55 scoped_refptr<::media::VideoFrame> frame =
56 ::media::VideoFrame::WrapNativeTexture( 56 ::media::VideoFrame::WrapNativeTexture(
57 ::media::PIXEL_FORMAT_XRGB, 57 ::media::PIXEL_FORMAT_XRGB,
58 gpu::MailboxHolder(mailbox_, GL_TEXTURE_2D, sync_point_), 58 gpu::MailboxHolder(mailbox_, sync_token_, GL_TEXTURE_2D),
59 ::media::VideoFrame::ReleaseMailboxCB(), 59 ::media::VideoFrame::ReleaseMailboxCB(),
60 size, // coded_size 60 size, // coded_size
61 gfx::Rect(size), // visible rect 61 gfx::Rect(size), // visible rect
62 size, // natural size 62 size, // natural size
63 base::TimeDelta()); // timestamp 63 base::TimeDelta()); // timestamp
64 frame->metadata()->SetBoolean(::media::VideoFrameMetadata::ALLOW_OVERLAY, 64 frame->metadata()->SetBoolean(::media::VideoFrameMetadata::ALLOW_OVERLAY,
65 true); 65 true);
66 return frame; 66 return frame;
67 } else { 67 } else {
68 // This case is needed for audio-only devices. 68 // This case is needed for audio-only devices.
69 return ::media::VideoFrame::CreateBlackFrame(gfx::Size(1, 1)); 69 return ::media::VideoFrame::CreateBlackFrame(gfx::Size(1, 1));
70 } 70 }
71 } 71 }
72 72
73 } // namespace media 73 } // namespace media
74 } // namespace chromecast 74 } // namespace chromecast
OLDNEW
« no previous file with comments | « chromecast/renderer/media/hole_frame_factory.h ('k') | components/mus/public/interfaces/compositor_frame.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698