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

Side by Side Diff: content/common/gpu/media/vt_video_decode_accelerator_mac.cc

Issue 1822153002: Attempt at suspend fix (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <algorithm> 5 #include <algorithm>
6 6
7 #include <CoreVideo/CoreVideo.h> 7 #include <CoreVideo/CoreVideo.h>
8 #include <OpenGL/CGLIOSurface.h> 8 #include <OpenGL/CGLIOSurface.h>
9 #include <OpenGL/gl.h> 9 #include <OpenGL/gl.h>
10 #include <stddef.h> 10 #include <stddef.h>
(...skipping 843 matching lines...) Expand 10 before | Expand all | Expand 10 after
854 // they will be broken if they are used before that happens. So, schedule 854 // they will be broken if they are used before that happens. So, schedule
855 // future work after that happens. 855 // future work after that happens.
856 gpu_task_runner_->PostTask(FROM_HERE, base::Bind( 856 gpu_task_runner_->PostTask(FROM_HERE, base::Bind(
857 &VTVideoDecodeAccelerator::ProcessWorkQueues, weak_this_)); 857 &VTVideoDecodeAccelerator::ProcessWorkQueues, weak_this_));
858 } 858 }
859 859
860 void VTVideoDecodeAccelerator::ReusePictureBuffer(int32_t picture_id) { 860 void VTVideoDecodeAccelerator::ReusePictureBuffer(int32_t picture_id) {
861 DCHECK(gpu_thread_checker_.CalledOnValidThread()); 861 DCHECK(gpu_thread_checker_.CalledOnValidThread());
862 DCHECK(picture_info_map_.count(picture_id)); 862 DCHECK(picture_info_map_.count(picture_id));
863 PictureInfo* picture_info = picture_info_map_.find(picture_id)->second.get(); 863 PictureInfo* picture_info = picture_info_map_.find(picture_id)->second.get();
864 DCHECK_EQ(CFGetRetainCount(picture_info->cv_image), 1); 864 DCHECK_EQ(CFGetRetainCount(picture_info->cv_image), 2);
865 picture_info->cv_image.reset(); 865 picture_info->cv_image.reset();
866 picture_info->gl_image->Destroy(false); 866 picture_info->gl_image->Destroy(false);
867 picture_info->gl_image = nullptr; 867 picture_info->gl_image = nullptr;
868 868
869 if (assigned_picture_ids_.count(picture_id) != 0) { 869 if (assigned_picture_ids_.count(picture_id) != 0) {
870 available_picture_ids_.push_back(picture_id); 870 available_picture_ids_.push_back(picture_id);
871 ProcessWorkQueues(); 871 ProcessWorkQueues();
872 } else { 872 } else {
873 client_->DismissPictureBuffer(picture_id); 873 client_->DismissPictureBuffer(picture_id);
874 } 874 }
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
1027 PictureInfo* picture_info = picture_info_map_.find(picture_id)->second.get(); 1027 PictureInfo* picture_info = picture_info_map_.find(picture_id)->second.get();
1028 DCHECK(!picture_info->cv_image); 1028 DCHECK(!picture_info->cv_image);
1029 DCHECK(!picture_info->gl_image); 1029 DCHECK(!picture_info->gl_image);
1030 1030
1031 if (!make_context_current_.Run()) { 1031 if (!make_context_current_.Run()) {
1032 DLOG(ERROR) << "Failed to make GL context current"; 1032 DLOG(ERROR) << "Failed to make GL context current";
1033 NotifyError(PLATFORM_FAILURE, SFT_PLATFORM_ERROR); 1033 NotifyError(PLATFORM_FAILURE, SFT_PLATFORM_ERROR);
1034 return false; 1034 return false;
1035 } 1035 }
1036 1036
1037 IOSurfaceRef surface = CVPixelBufferGetIOSurface(frame.image.get()); 1037 CVPixelBufferRef cv_pixel_buffer = frame.image.get();
1038 IOSurfaceRef io_surface = CVPixelBufferGetIOSurface(cv_pixel_buffer);
1038 if (gfx::GetGLImplementation() != gfx::kGLImplementationDesktopGLCoreProfile) 1039 if (gfx::GetGLImplementation() != gfx::kGLImplementationDesktopGLCoreProfile)
1039 glEnable(GL_TEXTURE_RECTANGLE_ARB); 1040 glEnable(GL_TEXTURE_RECTANGLE_ARB);
1040 gfx::ScopedTextureBinder texture_binder(GL_TEXTURE_RECTANGLE_ARB, 1041 gfx::ScopedTextureBinder texture_binder(GL_TEXTURE_RECTANGLE_ARB,
1041 picture_info->service_texture_id); 1042 picture_info->service_texture_id);
1042 CGLContextObj cgl_context = 1043 CGLContextObj cgl_context =
1043 static_cast<CGLContextObj>(gfx::GLContext::GetCurrent()->GetHandle()); 1044 static_cast<CGLContextObj>(gfx::GLContext::GetCurrent()->GetHandle());
1044 CGLError status = CGLTexImageIOSurface2D( 1045 CGLError status = CGLTexImageIOSurface2D(
1045 cgl_context, // ctx 1046 cgl_context, // ctx
1046 GL_TEXTURE_RECTANGLE_ARB, // target 1047 GL_TEXTURE_RECTANGLE_ARB, // target
1047 GL_RGB, // internal_format 1048 GL_RGB, // internal_format
1048 frame.coded_size.width(), // width 1049 frame.coded_size.width(), // width
1049 frame.coded_size.height(), // height 1050 frame.coded_size.height(), // height
1050 GL_YCBCR_422_APPLE, // format 1051 GL_YCBCR_422_APPLE, // format
1051 GL_UNSIGNED_SHORT_8_8_APPLE, // type 1052 GL_UNSIGNED_SHORT_8_8_APPLE, // type
1052 surface, // io_surface 1053 io_surface, // io_surface
1053 0); // plane 1054 0); // plane
1054 if (gfx::GetGLImplementation() != gfx::kGLImplementationDesktopGLCoreProfile) 1055 if (gfx::GetGLImplementation() != gfx::kGLImplementationDesktopGLCoreProfile)
1055 glDisable(GL_TEXTURE_RECTANGLE_ARB); 1056 glDisable(GL_TEXTURE_RECTANGLE_ARB);
1056 if (status != kCGLNoError) { 1057 if (status != kCGLNoError) {
1057 NOTIFY_STATUS("CGLTexImageIOSurface2D()", status, SFT_PLATFORM_ERROR); 1058 NOTIFY_STATUS("CGLTexImageIOSurface2D()", status, SFT_PLATFORM_ERROR);
1058 return false; 1059 return false;
1059 } 1060 }
1060 1061
1061 bool allow_overlay = false; 1062 bool allow_overlay = false;
1062 scoped_refptr<gl::GLImageIOSurface> gl_image( 1063 scoped_refptr<gl::GLImageIOSurface> gl_image(
1063 new gl::GLImageIOSurface(frame.coded_size, GL_BGRA_EXT)); 1064 new gl::GLImageIOSurface(frame.coded_size, GL_BGRA_EXT));
1064 if (gl_image->Initialize(surface, gfx::GenericSharedMemoryId(), 1065 if (gl_image->Initialize(io_surface, cv_pixel_buffer,
1066 gfx::GenericSharedMemoryId(),
1065 gfx::BufferFormat::BGRA_8888)) { 1067 gfx::BufferFormat::BGRA_8888)) {
1066 allow_overlay = true; 1068 allow_overlay = true;
1067 } else { 1069 } else {
1068 gl_image = nullptr; 1070 gl_image = nullptr;
1069 } 1071 }
1070 bind_image_.Run(picture_info->client_texture_id, GL_TEXTURE_RECTANGLE_ARB, 1072 bind_image_.Run(picture_info->client_texture_id, GL_TEXTURE_RECTANGLE_ARB,
1071 gl_image); 1073 gl_image);
1072 1074
1073 // Assign the new image(s) to the the picture info. 1075 // Assign the new image(s) to the the picture info.
1074 picture_info->gl_image = gl_image; 1076 picture_info->gl_image = gl_image;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
1157 SupportedProfile profile; 1159 SupportedProfile profile;
1158 profile.profile = supported_profile; 1160 profile.profile = supported_profile;
1159 profile.min_resolution.SetSize(16, 16); 1161 profile.min_resolution.SetSize(16, 16);
1160 profile.max_resolution.SetSize(4096, 2160); 1162 profile.max_resolution.SetSize(4096, 2160);
1161 profiles.push_back(profile); 1163 profiles.push_back(profile);
1162 } 1164 }
1163 return profiles; 1165 return profiles;
1164 } 1166 }
1165 1167
1166 } // namespace content 1168 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/gpu_memory_buffer_factory_io_surface.cc ('k') | media/blink/webmediaplayer_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698