OLD | NEW |
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 std::unique_ptr<::media::GpuVideoAcceleratorFactories::ScopedGLContextLock> |
22 gpu_factories_->GetGLContextLock()); | 22 lock(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 CHECK(image_id_); | 30 CHECK(image_id_); |
31 gl->BindTexImage2DCHROMIUM(GL_TEXTURE_2D, image_id_); | 31 gl->BindTexImage2DCHROMIUM(GL_TEXTURE_2D, image_id_); |
32 | 32 |
33 gl->GenMailboxCHROMIUM(mailbox_.name); | 33 gl->GenMailboxCHROMIUM(mailbox_.name); |
34 gl->ProduceTextureDirectCHROMIUM(texture_, GL_TEXTURE_2D, mailbox_.name); | 34 gl->ProduceTextureDirectCHROMIUM(texture_, GL_TEXTURE_2D, mailbox_.name); |
35 | 35 |
36 const GLuint64 fence_sync = gl->InsertFenceSyncCHROMIUM(); | 36 const GLuint64 fence_sync = gl->InsertFenceSyncCHROMIUM(); |
37 gl->ShallowFlushCHROMIUM(); | 37 gl->ShallowFlushCHROMIUM(); |
38 gl->GenSyncTokenCHROMIUM(fence_sync, sync_token_.GetData()); | 38 gl->GenSyncTokenCHROMIUM(fence_sync, sync_token_.GetData()); |
39 } | 39 } |
40 } | 40 } |
41 | 41 |
42 HoleFrameFactory::~HoleFrameFactory() { | 42 HoleFrameFactory::~HoleFrameFactory() { |
43 if (texture_) { | 43 if (texture_) { |
44 scoped_ptr<::media::GpuVideoAcceleratorFactories::ScopedGLContextLock> lock( | 44 std::unique_ptr<::media::GpuVideoAcceleratorFactories::ScopedGLContextLock> |
45 gpu_factories_->GetGLContextLock()); | 45 lock(gpu_factories_->GetGLContextLock()); |
46 CHECK(lock); | 46 CHECK(lock); |
47 gpu::gles2::GLES2Interface* gl = lock->ContextGL(); | 47 gpu::gles2::GLES2Interface* gl = lock->ContextGL(); |
48 gl->BindTexture(GL_TEXTURE_2D, texture_); | 48 gl->BindTexture(GL_TEXTURE_2D, texture_); |
49 gl->ReleaseTexImage2DCHROMIUM(GL_TEXTURE_2D, image_id_); | 49 gl->ReleaseTexImage2DCHROMIUM(GL_TEXTURE_2D, image_id_); |
50 gl->DeleteTextures(1, &texture_); | 50 gl->DeleteTextures(1, &texture_); |
51 gl->DestroyImageCHROMIUM(image_id_); | 51 gl->DestroyImageCHROMIUM(image_id_); |
52 } | 52 } |
53 } | 53 } |
54 | 54 |
55 scoped_refptr<::media::VideoFrame> HoleFrameFactory::CreateHoleFrame( | 55 scoped_refptr<::media::VideoFrame> HoleFrameFactory::CreateHoleFrame( |
(...skipping 17 matching lines...) Expand all Loading... |
73 size, // natural size | 73 size, // natural size |
74 base::TimeDelta()); // timestamp | 74 base::TimeDelta()); // timestamp |
75 CHECK(frame); | 75 CHECK(frame); |
76 frame->metadata()->SetBoolean(::media::VideoFrameMetadata::ALLOW_OVERLAY, | 76 frame->metadata()->SetBoolean(::media::VideoFrameMetadata::ALLOW_OVERLAY, |
77 true); | 77 true); |
78 return frame; | 78 return frame; |
79 } | 79 } |
80 | 80 |
81 } // namespace media | 81 } // namespace media |
82 } // namespace chromecast | 82 } // namespace chromecast |
OLD | NEW |