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

Side by Side Diff: gpu/command_buffer/service/gles2_cmd_decoder.cc

Issue 2021413003: Remove GL_CHROMIUM_iosurface extension (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 6 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "gpu/command_buffer/service/gles2_cmd_decoder.h" 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
6 6
7 #include <limits.h> 7 #include <limits.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 #include <stdio.h> 10 #include <stdio.h>
(...skipping 958 matching lines...) Expand 10 before | Expand all | Expand 10 after
969 void DoCopyTexSubImage2D( 969 void DoCopyTexSubImage2D(
970 GLenum target, 970 GLenum target,
971 GLint level, 971 GLint level,
972 GLint xoffset, 972 GLint xoffset,
973 GLint yoffset, 973 GLint yoffset,
974 GLint x, 974 GLint x,
975 GLint y, 975 GLint y,
976 GLsizei width, 976 GLsizei width,
977 GLsizei height); 977 GLsizei height);
978 978
979 // Wrapper for TexImageIOSurface2DCHROMIUM.
980 void DoTexImageIOSurface2DCHROMIUM(
981 GLenum target,
982 GLsizei width,
983 GLsizei height,
984 GLuint io_surface_id,
985 GLuint plane);
986
987 void DoCopyTextureCHROMIUM(GLuint source_id, 979 void DoCopyTextureCHROMIUM(GLuint source_id,
988 GLuint dest_id, 980 GLuint dest_id,
989 GLenum internal_format, 981 GLenum internal_format,
990 GLenum dest_type, 982 GLenum dest_type,
991 GLboolean unpack_flip_y, 983 GLboolean unpack_flip_y,
992 GLboolean unpack_premultiply_alpha, 984 GLboolean unpack_premultiply_alpha,
993 GLboolean unpack_unmultiply_alpha); 985 GLboolean unpack_unmultiply_alpha);
994 986
995 void DoCopySubTextureCHROMIUM(GLuint source_id, 987 void DoCopySubTextureCHROMIUM(GLuint source_id,
996 GLuint dest_id, 988 GLuint dest_id,
(...skipping 866 matching lines...) Expand 10 before | Expand all | Expand 10 after
1863 GLuint* service_id, 1855 GLuint* service_id,
1864 SizedResult<T>** result, 1856 SizedResult<T>** result,
1865 GLenum* result_type, 1857 GLenum* result_type,
1866 GLsizei* result_size); 1858 GLsizei* result_size);
1867 1859
1868 bool WasContextLost() const override; 1860 bool WasContextLost() const override;
1869 bool WasContextLostByRobustnessExtension() const override; 1861 bool WasContextLostByRobustnessExtension() const override;
1870 void MarkContextLost(error::ContextLostReason reason) override; 1862 void MarkContextLost(error::ContextLostReason reason) override;
1871 bool CheckResetStatus(); 1863 bool CheckResetStatus();
1872 1864
1873 #if defined(OS_MACOSX)
1874 void ReleaseIOSurfaceForTexture(GLuint texture_id);
1875 #endif
1876
1877 bool GetCompressedTexSizeInBytes( 1865 bool GetCompressedTexSizeInBytes(
1878 const char* function_name, GLsizei width, GLsizei height, GLsizei depth, 1866 const char* function_name, GLsizei width, GLsizei height, GLsizei depth,
1879 GLenum format, GLsizei* size_in_bytes); 1867 GLenum format, GLsizei* size_in_bytes);
1880 1868
1881 bool ValidateCompressedTexDimensions( 1869 bool ValidateCompressedTexDimensions(
1882 const char* function_name, GLenum target, GLint level, 1870 const char* function_name, GLenum target, GLint level,
1883 GLsizei width, GLsizei height, GLsizei depth, GLenum format); 1871 GLsizei width, GLsizei height, GLsizei depth, GLenum format);
1884 bool ValidateCompressedTexFuncData( 1872 bool ValidateCompressedTexFuncData(
1885 const char* function_name, GLsizei width, GLsizei height, GLsizei depth, 1873 const char* function_name, GLsizei width, GLsizei height, GLsizei depth,
1886 GLenum format, GLsizei size); 1874 GLenum format, GLsizei size);
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
2171 bool shader_texture_lod_explicitly_enabled_; 2159 bool shader_texture_lod_explicitly_enabled_;
2172 2160
2173 bool compile_shader_always_succeeds_; 2161 bool compile_shader_always_succeeds_;
2174 2162
2175 // An optional behaviour to lose the context and group when OOM. 2163 // An optional behaviour to lose the context and group when OOM.
2176 bool lose_context_when_out_of_memory_; 2164 bool lose_context_when_out_of_memory_;
2177 2165
2178 // Log extra info. 2166 // Log extra info.
2179 bool service_logging_; 2167 bool service_logging_;
2180 2168
2181 #if defined(OS_MACOSX)
2182 typedef std::map<GLuint, IOSurfaceRef> TextureToIOSurfaceMap;
2183 TextureToIOSurfaceMap texture_to_io_surface_map_;
2184 #endif
2185
2186 std::unique_ptr<CopyTextureCHROMIUMResourceManager> copy_texture_CHROMIUM_; 2169 std::unique_ptr<CopyTextureCHROMIUMResourceManager> copy_texture_CHROMIUM_;
2187 std::unique_ptr<ClearFramebufferResourceManager> clear_framebuffer_blit_; 2170 std::unique_ptr<ClearFramebufferResourceManager> clear_framebuffer_blit_;
2188 2171
2189 // Cached values of the currently assigned viewport dimensions. 2172 // Cached values of the currently assigned viewport dimensions.
2190 GLsizei viewport_max_width_; 2173 GLsizei viewport_max_width_;
2191 GLsizei viewport_max_height_; 2174 GLsizei viewport_max_height_;
2192 2175
2193 // Command buffer stats. 2176 // Command buffer stats.
2194 base::TimeDelta total_processing_commands_time_; 2177 base::TimeDelta total_processing_commands_time_;
2195 2178
(...skipping 1565 matching lines...) Expand 10 before | Expand all | Expand 10 after
3761 if (framebuffer_state_.bound_draw_framebuffer.get()) { 3744 if (framebuffer_state_.bound_draw_framebuffer.get()) {
3762 framebuffer_state_.bound_draw_framebuffer 3745 framebuffer_state_.bound_draw_framebuffer
3763 ->UnbindTexture(GL_DRAW_FRAMEBUFFER_EXT, texture_ref); 3746 ->UnbindTexture(GL_DRAW_FRAMEBUFFER_EXT, texture_ref);
3764 } 3747 }
3765 } else { 3748 } else {
3766 if (framebuffer_state_.bound_draw_framebuffer.get()) { 3749 if (framebuffer_state_.bound_draw_framebuffer.get()) {
3767 framebuffer_state_.bound_draw_framebuffer 3750 framebuffer_state_.bound_draw_framebuffer
3768 ->UnbindTexture(GL_FRAMEBUFFER, texture_ref); 3751 ->UnbindTexture(GL_FRAMEBUFFER, texture_ref);
3769 } 3752 }
3770 } 3753 }
3771 #if defined(OS_MACOSX)
3772 GLuint service_id = texture->service_id();
3773 if (texture->target() == GL_TEXTURE_RECTANGLE_ARB) {
3774 ReleaseIOSurfaceForTexture(service_id);
3775 }
3776 #endif
3777 RemoveTexture(client_ids[ii]); 3754 RemoveTexture(client_ids[ii]);
3778 } 3755 }
3779 } 3756 }
3780 } 3757 }
3781 3758
3782 void GLES2DecoderImpl::DeleteSamplersHelper( 3759 void GLES2DecoderImpl::DeleteSamplersHelper(
3783 GLsizei n, const GLuint* client_ids) { 3760 GLsizei n, const GLuint* client_ids) {
3784 for (GLsizei ii = 0; ii < n; ++ii) { 3761 for (GLsizei ii = 0; ii < n; ++ii) {
3785 Sampler* sampler = GetSampler(client_ids[ii]); 3762 Sampler* sampler = GetSampler(client_ids[ii]);
3786 if (sampler && !sampler->IsDeleted()) { 3763 if (sampler && !sampler->IsDeleted()) {
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after
4382 4359
4383 if (group_.get()) { 4360 if (group_.get()) {
4384 group_->Destroy(this, have_context); 4361 group_->Destroy(this, have_context);
4385 group_ = NULL; 4362 group_ = NULL;
4386 } 4363 }
4387 4364
4388 if (context_.get()) { 4365 if (context_.get()) {
4389 context_->ReleaseCurrent(NULL); 4366 context_->ReleaseCurrent(NULL);
4390 context_ = NULL; 4367 context_ = NULL;
4391 } 4368 }
4392
4393 #if defined(OS_MACOSX)
4394 for (TextureToIOSurfaceMap::iterator it = texture_to_io_surface_map_.begin();
4395 it != texture_to_io_surface_map_.end(); ++it) {
4396 CFRelease(it->second);
4397 }
4398 texture_to_io_surface_map_.clear();
4399 #endif
4400 } 4369 }
4401 4370
4402 void GLES2DecoderImpl::SetSurface(const scoped_refptr<gl::GLSurface>& surface) { 4371 void GLES2DecoderImpl::SetSurface(const scoped_refptr<gl::GLSurface>& surface) {
4403 DCHECK(context_->IsCurrent(NULL)); 4372 DCHECK(context_->IsCurrent(NULL));
4404 DCHECK(surface); 4373 DCHECK(surface);
4405 surface_ = surface; 4374 surface_ = surface;
4406 RestoreCurrentFramebufferBindings(); 4375 RestoreCurrentFramebufferBindings();
4407 } 4376 }
4408 4377
4409 void GLES2DecoderImpl::ReleaseSurface() { 4378 void GLES2DecoderImpl::ReleaseSurface() {
(...skipping 9725 matching lines...) Expand 10 before | Expand all | Expand 10 after
14135 GLuint service_id = 0; 14104 GLuint service_id = 0;
14136 return path_manager()->GetPath(client_id, &service_id) && 14105 return path_manager()->GetPath(client_id, &service_id) &&
14137 glIsPathNV(service_id) == GL_TRUE; 14106 glIsPathNV(service_id) == GL_TRUE;
14138 } 14107 }
14139 14108
14140 bool GLES2DecoderImpl::DoIsSync(GLuint client_id) { 14109 bool GLES2DecoderImpl::DoIsSync(GLuint client_id) {
14141 GLsync service_sync = 0; 14110 GLsync service_sync = 0;
14142 return group_->GetSyncServiceId(client_id, &service_sync); 14111 return group_->GetSyncServiceId(client_id, &service_sync);
14143 } 14112 }
14144 14113
14145 #if defined(OS_MACOSX)
14146 void GLES2DecoderImpl::ReleaseIOSurfaceForTexture(GLuint texture_id) {
14147 TextureToIOSurfaceMap::iterator it = texture_to_io_surface_map_.find(
14148 texture_id);
14149 if (it != texture_to_io_surface_map_.end()) {
14150 // Found a previous IOSurface bound to this texture; release it.
14151 IOSurfaceRef surface = it->second;
14152 CFRelease(surface);
14153 texture_to_io_surface_map_.erase(it);
14154 }
14155 }
14156 #endif
14157
14158 void GLES2DecoderImpl::DoTexImageIOSurface2DCHROMIUM(
14159 GLenum target, GLsizei width, GLsizei height,
14160 GLuint io_surface_id, GLuint plane) {
14161 #if defined(OS_MACOSX)
14162 if (gl::GetGLImplementation() != gl::kGLImplementationDesktopGL) {
14163 LOCAL_SET_GL_ERROR(
14164 GL_INVALID_OPERATION,
14165 "glTexImageIOSurface2DCHROMIUM", "only supported on desktop GL.");
14166 return;
14167 }
14168
14169 if (target != GL_TEXTURE_RECTANGLE_ARB) {
14170 // This might be supported in the future, and if we could require
14171 // support for binding an IOSurface to a NPOT TEXTURE_2D texture, we
14172 // could delete a lot of code. For now, perform strict validation so we
14173 // know what's going on.
14174 LOCAL_SET_GL_ERROR(
14175 GL_INVALID_OPERATION,
14176 "glTexImageIOSurface2DCHROMIUM",
14177 "requires TEXTURE_RECTANGLE_ARB target");
14178 return;
14179 }
14180
14181 // Default target might be conceptually valid, but disallow it to avoid
14182 // accidents.
14183 TextureRef* texture_ref =
14184 texture_manager()->GetTextureInfoForTargetUnlessDefault(&state_, target);
14185 if (!texture_ref) {
14186 LOCAL_SET_GL_ERROR(
14187 GL_INVALID_OPERATION,
14188 "glTexImageIOSurface2DCHROMIUM", "no rectangle texture bound");
14189 return;
14190 }
14191
14192 // Look up the new IOSurface. Note that because of asynchrony
14193 // between processes this might fail; during live resizing the
14194 // plugin process might allocate and release an IOSurface before
14195 // this process gets a chance to look it up. Hold on to any old
14196 // IOSurface in this case.
14197 IOSurfaceRef surface = IOSurfaceLookup(io_surface_id);
14198 if (!surface) {
14199 LOCAL_SET_GL_ERROR(
14200 GL_INVALID_OPERATION,
14201 "glTexImageIOSurface2DCHROMIUM", "no IOSurface with the given ID");
14202 return;
14203 }
14204
14205 // Release any IOSurface previously bound to this texture.
14206 ReleaseIOSurfaceForTexture(texture_ref->service_id());
14207
14208 // Make sure we release the IOSurface even if CGLTexImageIOSurface2D fails.
14209 texture_to_io_surface_map_.insert(
14210 std::make_pair(texture_ref->service_id(), surface));
14211
14212 CGLContextObj context =
14213 static_cast<CGLContextObj>(context_->GetHandle());
14214
14215 CGLError err = CGLTexImageIOSurface2D(
14216 context,
14217 target,
14218 GL_RGBA,
14219 width,
14220 height,
14221 GL_BGRA,
14222 GL_UNSIGNED_INT_8_8_8_8_REV,
14223 surface,
14224 plane);
14225
14226 if (err != kCGLNoError) {
14227 LOCAL_SET_GL_ERROR(
14228 GL_INVALID_OPERATION,
14229 "glTexImageIOSurface2DCHROMIUM", "error in CGLTexImageIOSurface2D");
14230 return;
14231 }
14232
14233 texture_manager()->SetLevelInfo(
14234 texture_ref, target, 0, GL_RGBA, width, height, 1, 0, GL_BGRA,
14235 GL_UNSIGNED_INT_8_8_8_8_REV, gfx::Rect(width, height));
14236
14237 #else
14238 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION,
14239 "glTexImageIOSurface2DCHROMIUM", "not supported.");
14240 #endif
14241 }
14242
14243 bool GLES2DecoderImpl::ValidateCopyTextureCHROMIUMTextures( 14114 bool GLES2DecoderImpl::ValidateCopyTextureCHROMIUMTextures(
14244 const char* function_name, 14115 const char* function_name,
14245 TextureRef* source_texture_ref, 14116 TextureRef* source_texture_ref,
14246 TextureRef* dest_texture_ref) { 14117 TextureRef* dest_texture_ref) {
14247 if (!source_texture_ref || !dest_texture_ref) { 14118 if (!source_texture_ref || !dest_texture_ref) {
14248 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, "unknown texture id"); 14119 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, "unknown texture id");
14249 return false; 14120 return false;
14250 } 14121 }
14251 14122
14252 Texture* source_texture = source_texture_ref->texture(); 14123 Texture* source_texture = source_texture_ref->texture();
(...skipping 2663 matching lines...) Expand 10 before | Expand all | Expand 10 after
16916 } 16787 }
16917 16788
16918 // Include the auto-generated part of this file. We split this because it means 16789 // Include the auto-generated part of this file. We split this because it means
16919 // we can easily edit the non-auto generated parts right here in this file 16790 // we can easily edit the non-auto generated parts right here in this file
16920 // instead of having to edit some template or the code generator. 16791 // instead of having to edit some template or the code generator.
16921 #include "base/macros.h" 16792 #include "base/macros.h"
16922 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 16793 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
16923 16794
16924 } // namespace gles2 16795 } // namespace gles2
16925 } // namespace gpu 16796 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/feature_info.cc ('k') | gpu/command_buffer/service/gles2_cmd_decoder_autogen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698