OLD | NEW |
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 <stdio.h> | 7 #include <stdio.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <list> | 10 #include <list> |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 #include "gpu/command_buffer/service/mailbox_manager.h" | 45 #include "gpu/command_buffer/service/mailbox_manager.h" |
46 #include "gpu/command_buffer/service/memory_tracking.h" | 46 #include "gpu/command_buffer/service/memory_tracking.h" |
47 #include "gpu/command_buffer/service/program_manager.h" | 47 #include "gpu/command_buffer/service/program_manager.h" |
48 #include "gpu/command_buffer/service/query_manager.h" | 48 #include "gpu/command_buffer/service/query_manager.h" |
49 #include "gpu/command_buffer/service/renderbuffer_manager.h" | 49 #include "gpu/command_buffer/service/renderbuffer_manager.h" |
50 #include "gpu/command_buffer/service/shader_manager.h" | 50 #include "gpu/command_buffer/service/shader_manager.h" |
51 #include "gpu/command_buffer/service/shader_translator.h" | 51 #include "gpu/command_buffer/service/shader_translator.h" |
52 #include "gpu/command_buffer/service/shader_translator_cache.h" | 52 #include "gpu/command_buffer/service/shader_translator_cache.h" |
53 #include "gpu/command_buffer/service/stream_texture.h" | 53 #include "gpu/command_buffer/service/stream_texture.h" |
54 #include "gpu/command_buffer/service/stream_texture_manager.h" | 54 #include "gpu/command_buffer/service/stream_texture_manager.h" |
55 #include "gpu/command_buffer/service/texture_definition.h" | |
56 #include "gpu/command_buffer/service/texture_manager.h" | 55 #include "gpu/command_buffer/service/texture_manager.h" |
57 #include "gpu/command_buffer/service/vertex_attrib_manager.h" | 56 #include "gpu/command_buffer/service/vertex_attrib_manager.h" |
58 #include "gpu/command_buffer/service/vertex_array_manager.h" | 57 #include "gpu/command_buffer/service/vertex_array_manager.h" |
59 #include "gpu/command_buffer/service/async_pixel_transfer_delegate.h" | 58 #include "gpu/command_buffer/service/async_pixel_transfer_delegate.h" |
60 #include "ui/gl/gl_bindings.h" | 59 #include "ui/gl/gl_bindings.h" |
61 #include "ui/gl/gl_image.h" | 60 #include "ui/gl/gl_image.h" |
62 #include "ui/gl/gl_implementation.h" | 61 #include "ui/gl/gl_implementation.h" |
63 #include "ui/gl/gl_surface.h" | 62 #include "ui/gl/gl_surface.h" |
64 #if defined(OS_MACOSX) | 63 #if defined(OS_MACOSX) |
65 #include "ui/surface/io_surface_support_mac.h" | 64 #include "ui/surface/io_surface_support_mac.h" |
(...skipping 2188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2254 state_.texture_units[tt].bound_texture_2d = ref; | 2253 state_.texture_units[tt].bound_texture_2d = ref; |
2255 glBindTexture(GL_TEXTURE_2D, ref->service_id()); | 2254 glBindTexture(GL_TEXTURE_2D, ref->service_id()); |
2256 } | 2255 } |
2257 glActiveTexture(GL_TEXTURE0); | 2256 glActiveTexture(GL_TEXTURE0); |
2258 CHECK_GL_ERROR(); | 2257 CHECK_GL_ERROR(); |
2259 | 2258 |
2260 ContextCreationAttribParser attrib_parser; | 2259 ContextCreationAttribParser attrib_parser; |
2261 if (!attrib_parser.Parse(attribs)) | 2260 if (!attrib_parser.Parse(attribs)) |
2262 return false; | 2261 return false; |
2263 | 2262 |
2264 // These are NOT if the back buffer has these proprorties. They are | |
2265 // if we want the command buffer to enforce them regardless of what | |
2266 // the real backbuffer is assuming the real back buffer gives us more than | |
2267 // we ask for. In other words, if we ask for RGB and we get RGBA then we'll | |
2268 // make it appear RGB. If on the other hand we ask for RGBA nd get RGB we | |
2269 // can't do anything about that. | |
2270 | |
2271 GLint v = 0; | |
2272 glGetIntegerv(GL_ALPHA_BITS, &v); | |
2273 // This checks if the user requested RGBA and we have RGBA then RGBA. If the | |
2274 // user requested RGB then RGB. If the user did not specify a preference than | |
2275 // use whatever we were given. Same for DEPTH and STENCIL. | |
2276 back_buffer_color_format_ = | |
2277 (attrib_parser.alpha_size_ != 0 && v > 0) ? GL_RGBA : GL_RGB; | |
2278 glGetIntegerv(GL_DEPTH_BITS, &v); | |
2279 back_buffer_has_depth_ = attrib_parser.depth_size_ != 0 && v > 0; | |
2280 glGetIntegerv(GL_STENCIL_BITS, &v); | |
2281 back_buffer_has_stencil_ = attrib_parser.stencil_size_ != 0 && v > 0; | |
2282 | |
2283 if (offscreen) { | 2263 if (offscreen) { |
2284 if (attrib_parser.samples_ > 0 && attrib_parser.sample_buffers_ > 0 && | 2264 if (attrib_parser.samples_ > 0 && attrib_parser.sample_buffers_ > 0 && |
2285 features().chromium_framebuffer_multisample) { | 2265 features().chromium_framebuffer_multisample) { |
2286 // Per ext_framebuffer_multisample spec, need max bound on sample count. | 2266 // Per ext_framebuffer_multisample spec, need max bound on sample count. |
2287 // max_sample_count must be initialized to a sane value. If | 2267 // max_sample_count must be initialized to a sane value. If |
2288 // glGetIntegerv() throws a GL error, it leaves its argument unchanged. | 2268 // glGetIntegerv() throws a GL error, it leaves its argument unchanged. |
2289 GLint max_sample_count = 1; | 2269 GLint max_sample_count = 1; |
2290 glGetIntegerv(GL_MAX_SAMPLES_EXT, &max_sample_count); | 2270 glGetIntegerv(GL_MAX_SAMPLES_EXT, &max_sample_count); |
2291 offscreen_target_samples_ = std::min(attrib_parser.samples_, | 2271 offscreen_target_samples_ = std::min(attrib_parser.samples_, |
2292 max_sample_count); | 2272 max_sample_count); |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2401 if (offscreen_saved_frame_buffer_->CheckStatus() != | 2381 if (offscreen_saved_frame_buffer_->CheckStatus() != |
2402 GL_FRAMEBUFFER_COMPLETE) { | 2382 GL_FRAMEBUFFER_COMPLETE) { |
2403 LOG(ERROR) << "Offscreen saved FBO was incomplete."; | 2383 LOG(ERROR) << "Offscreen saved FBO was incomplete."; |
2404 Destroy(true); | 2384 Destroy(true); |
2405 return false; | 2385 return false; |
2406 } | 2386 } |
2407 | 2387 |
2408 // Bind to the new default frame buffer (the offscreen target frame buffer). | 2388 // Bind to the new default frame buffer (the offscreen target frame buffer). |
2409 // This should now be associated with ID zero. | 2389 // This should now be associated with ID zero. |
2410 DoBindFramebuffer(GL_FRAMEBUFFER, 0); | 2390 DoBindFramebuffer(GL_FRAMEBUFFER, 0); |
| 2391 } else { |
| 2392 glBindFramebufferEXT(GL_FRAMEBUFFER, GetBackbufferServiceId()); |
| 2393 // These are NOT if the back buffer has these proprorties. They are |
| 2394 // if we want the command buffer to enforce them regardless of what |
| 2395 // the real backbuffer is assuming the real back buffer gives us more than |
| 2396 // we ask for. In other words, if we ask for RGB and we get RGBA then we'll |
| 2397 // make it appear RGB. If on the other hand we ask for RGBA nd get RGB we |
| 2398 // can't do anything about that. |
| 2399 |
| 2400 GLint v = 0; |
| 2401 glGetIntegerv(GL_ALPHA_BITS, &v); |
| 2402 // This checks if the user requested RGBA and we have RGBA then RGBA. If the |
| 2403 // user requested RGB then RGB. If the user did not specify a preference |
| 2404 // than use whatever we were given. Same for DEPTH and STENCIL. |
| 2405 back_buffer_color_format_ = |
| 2406 (attrib_parser.alpha_size_ != 0 && v > 0) ? GL_RGBA : GL_RGB; |
| 2407 glGetIntegerv(GL_DEPTH_BITS, &v); |
| 2408 back_buffer_has_depth_ = attrib_parser.depth_size_ != 0 && v > 0; |
| 2409 glGetIntegerv(GL_STENCIL_BITS, &v); |
| 2410 back_buffer_has_stencil_ = attrib_parser.stencil_size_ != 0 && v > 0; |
2411 } | 2411 } |
2412 | 2412 |
2413 // OpenGL ES 2.0 implicitly enables the desktop GL capability | 2413 // OpenGL ES 2.0 implicitly enables the desktop GL capability |
2414 // VERTEX_PROGRAM_POINT_SIZE and doesn't expose this enum. This fact | 2414 // VERTEX_PROGRAM_POINT_SIZE and doesn't expose this enum. This fact |
2415 // isn't well documented; it was discovered in the Khronos OpenGL ES | 2415 // isn't well documented; it was discovered in the Khronos OpenGL ES |
2416 // mailing list archives. It also implicitly enables the desktop GL | 2416 // mailing list archives. It also implicitly enables the desktop GL |
2417 // capability GL_POINT_SPRITE to provide access to the gl_PointCoord | 2417 // capability GL_POINT_SPRITE to provide access to the gl_PointCoord |
2418 // variable in fragment shaders. | 2418 // variable in fragment shaders. |
2419 if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) { | 2419 if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) { |
2420 glEnable(GL_VERTEX_PROGRAM_POINT_SIZE); | 2420 glEnable(GL_VERTEX_PROGRAM_POINT_SIZE); |
(...skipping 806 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3227 // already been destroyed. | 3227 // already been destroyed. |
3228 if (parent_) { | 3228 if (parent_) { |
3229 ChildList::iterator it = std::find( | 3229 ChildList::iterator it = std::find( |
3230 parent_->children_.begin(), | 3230 parent_->children_.begin(), |
3231 parent_->children_.end(), | 3231 parent_->children_.end(), |
3232 this); | 3232 this); |
3233 DCHECK(it != parent_->children_.end()); | 3233 DCHECK(it != parent_->children_.end()); |
3234 parent_->children_.erase(it); | 3234 parent_->children_.erase(it); |
3235 // First check the texture has been mapped into the parent. This might not | 3235 // First check the texture has been mapped into the parent. This might not |
3236 // be the case if initialization failed midway through. | 3236 // be the case if initialization failed midway through. |
3237 GLuint service_id = offscreen_saved_color_texture_->id(); | 3237 if (offscreen_saved_color_texture_info_ && |
3238 GLuint client_id = 0; | 3238 offscreen_saved_color_texture_info_->client_id()) { |
3239 if (parent_->texture_manager()->GetClientId(service_id, &client_id)) { | 3239 parent_->texture_manager()->RemoveTexture( |
3240 parent_->texture_manager()->RemoveTexture(client_id); | 3240 offscreen_saved_color_texture_info_->client_id()); |
3241 } | 3241 } |
3242 } | 3242 } |
3243 | 3243 |
3244 GLES2DecoderImpl* new_parent_impl = static_cast<GLES2DecoderImpl*>( | 3244 GLES2DecoderImpl* new_parent_impl = static_cast<GLES2DecoderImpl*>( |
3245 new_parent); | 3245 new_parent); |
3246 if (new_parent_impl) { | 3246 if (new_parent_impl) { |
3247 #ifndef NDEBUG | 3247 #ifndef NDEBUG |
3248 ChildList::iterator it = std::find( | 3248 ChildList::iterator it = std::find( |
3249 new_parent_impl->children_.begin(), | 3249 new_parent_impl->children_.begin(), |
3250 new_parent_impl->children_.end(), | 3250 new_parent_impl->children_.end(), |
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3697 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER, service_id); | 3697 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER, service_id); |
3698 service_id = state_.bound_read_framebuffer ? | 3698 service_id = state_.bound_read_framebuffer ? |
3699 state_.bound_read_framebuffer->service_id() : | 3699 state_.bound_read_framebuffer->service_id() : |
3700 GetBackbufferServiceId(); | 3700 GetBackbufferServiceId(); |
3701 glBindFramebufferEXT(GL_READ_FRAMEBUFFER, service_id); | 3701 glBindFramebufferEXT(GL_READ_FRAMEBUFFER, service_id); |
3702 } | 3702 } |
3703 OnFboChanged(); | 3703 OnFboChanged(); |
3704 } | 3704 } |
3705 | 3705 |
3706 void GLES2DecoderImpl::RestoreTextureState(unsigned service_id) const { | 3706 void GLES2DecoderImpl::RestoreTextureState(unsigned service_id) const { |
3707 GLuint client_id = 0; | 3707 Texture* texture = texture_manager()->GetTextureForServiceId(service_id); |
3708 if (texture_manager()->GetClientId(service_id, &client_id)) { | 3708 if (texture) { |
3709 Texture* texture = GetTexture(client_id)->texture(); | |
3710 GLenum target = texture->target(); | 3709 GLenum target = texture->target(); |
3711 glBindTexture(target, service_id); | 3710 glBindTexture(target, service_id); |
3712 glTexParameteri( | 3711 glTexParameteri( |
3713 target, GL_TEXTURE_WRAP_S, texture->wrap_s()); | 3712 target, GL_TEXTURE_WRAP_S, texture->wrap_s()); |
3714 glTexParameteri( | 3713 glTexParameteri( |
3715 target, GL_TEXTURE_WRAP_T, texture->wrap_t()); | 3714 target, GL_TEXTURE_WRAP_T, texture->wrap_t()); |
3716 glTexParameteri( | 3715 glTexParameteri( |
3717 target, GL_TEXTURE_MIN_FILTER, texture->min_filter()); | 3716 target, GL_TEXTURE_MIN_FILTER, texture->min_filter()); |
3718 glTexParameteri( | 3717 glTexParameteri( |
3719 target, GL_TEXTURE_MAG_FILTER, texture->mag_filter()); | 3718 target, GL_TEXTURE_MAG_FILTER, texture->mag_filter()); |
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4206 *params = 0; | 4205 *params = 0; |
4207 } | 4206 } |
4208 } | 4207 } |
4209 return true; | 4208 return true; |
4210 case GL_RENDERBUFFER_BINDING: | 4209 case GL_RENDERBUFFER_BINDING: |
4211 *num_written = 1; | 4210 *num_written = 1; |
4212 if (params) { | 4211 if (params) { |
4213 Renderbuffer* renderbuffer = | 4212 Renderbuffer* renderbuffer = |
4214 GetRenderbufferInfoForTarget(GL_RENDERBUFFER); | 4213 GetRenderbufferInfoForTarget(GL_RENDERBUFFER); |
4215 if (renderbuffer) { | 4214 if (renderbuffer) { |
4216 GLuint client_id = 0; | 4215 *params = renderbuffer->client_id(); |
4217 renderbuffer_manager()->GetClientId( | |
4218 renderbuffer->service_id(), &client_id); | |
4219 *params = client_id; | |
4220 } else { | 4216 } else { |
4221 *params = 0; | 4217 *params = 0; |
4222 } | 4218 } |
4223 } | 4219 } |
4224 return true; | 4220 return true; |
4225 case GL_CURRENT_PROGRAM: | 4221 case GL_CURRENT_PROGRAM: |
4226 *num_written = 1; | 4222 *num_written = 1; |
4227 if (params) { | 4223 if (params) { |
4228 if (state_.current_program) { | 4224 if (state_.current_program) { |
4229 GLuint client_id = 0; | 4225 GLuint client_id = 0; |
(...skipping 16 matching lines...) Expand all Loading... |
4246 } else { | 4242 } else { |
4247 *params = 0; | 4243 *params = 0; |
4248 } | 4244 } |
4249 } | 4245 } |
4250 return true; | 4246 return true; |
4251 case GL_TEXTURE_BINDING_2D: | 4247 case GL_TEXTURE_BINDING_2D: |
4252 *num_written = 1; | 4248 *num_written = 1; |
4253 if (params) { | 4249 if (params) { |
4254 TextureUnit& unit = state_.texture_units[state_.active_texture_unit]; | 4250 TextureUnit& unit = state_.texture_units[state_.active_texture_unit]; |
4255 if (unit.bound_texture_2d) { | 4251 if (unit.bound_texture_2d) { |
4256 GLuint client_id = 0; | 4252 *params = unit.bound_texture_2d->client_id(); |
4257 texture_manager()->GetClientId( | |
4258 unit.bound_texture_2d->service_id(), &client_id); | |
4259 *params = client_id; | |
4260 } else { | 4253 } else { |
4261 *params = 0; | 4254 *params = 0; |
4262 } | 4255 } |
4263 } | 4256 } |
4264 return true; | 4257 return true; |
4265 case GL_TEXTURE_BINDING_CUBE_MAP: | 4258 case GL_TEXTURE_BINDING_CUBE_MAP: |
4266 *num_written = 1; | 4259 *num_written = 1; |
4267 if (params) { | 4260 if (params) { |
4268 TextureUnit& unit = state_.texture_units[state_.active_texture_unit]; | 4261 TextureUnit& unit = state_.texture_units[state_.active_texture_unit]; |
4269 if (unit.bound_texture_cube_map) { | 4262 if (unit.bound_texture_cube_map) { |
4270 GLuint client_id = 0; | 4263 *params = unit.bound_texture_cube_map->client_id(); |
4271 texture_manager()->GetClientId( | |
4272 unit.bound_texture_cube_map->service_id(), &client_id); | |
4273 *params = client_id; | |
4274 } else { | 4264 } else { |
4275 *params = 0; | 4265 *params = 0; |
4276 } | 4266 } |
4277 } | 4267 } |
4278 return true; | 4268 return true; |
4279 case GL_TEXTURE_BINDING_EXTERNAL_OES: | 4269 case GL_TEXTURE_BINDING_EXTERNAL_OES: |
4280 *num_written = 1; | 4270 *num_written = 1; |
4281 if (params) { | 4271 if (params) { |
4282 TextureUnit& unit = state_.texture_units[state_.active_texture_unit]; | 4272 TextureUnit& unit = state_.texture_units[state_.active_texture_unit]; |
4283 if (unit.bound_texture_external_oes) { | 4273 if (unit.bound_texture_external_oes) { |
4284 GLuint client_id = 0; | 4274 *params = unit.bound_texture_external_oes->client_id(); |
4285 texture_manager()->GetClientId( | |
4286 unit.bound_texture_external_oes->service_id(), &client_id); | |
4287 *params = client_id; | |
4288 } else { | 4275 } else { |
4289 *params = 0; | 4276 *params = 0; |
4290 } | 4277 } |
4291 } | 4278 } |
4292 return true; | 4279 return true; |
4293 case GL_TEXTURE_BINDING_RECTANGLE_ARB: | 4280 case GL_TEXTURE_BINDING_RECTANGLE_ARB: |
4294 *num_written = 1; | 4281 *num_written = 1; |
4295 if (params) { | 4282 if (params) { |
4296 TextureUnit& unit = state_.texture_units[state_.active_texture_unit]; | 4283 TextureUnit& unit = state_.texture_units[state_.active_texture_unit]; |
4297 if (unit.bound_texture_rectangle_arb) { | 4284 if (unit.bound_texture_rectangle_arb) { |
4298 GLuint client_id = 0; | 4285 *params = unit.bound_texture_rectangle_arb->client_id(); |
4299 texture_manager()->GetClientId( | |
4300 unit.bound_texture_rectangle_arb->service_id(), &client_id); | |
4301 *params = client_id; | |
4302 } else { | 4286 } else { |
4303 *params = 0; | 4287 *params = 0; |
4304 } | 4288 } |
4305 } | 4289 } |
4306 return true; | 4290 return true; |
4307 case GL_UNPACK_FLIP_Y_CHROMIUM: | 4291 case GL_UNPACK_FLIP_Y_CHROMIUM: |
4308 *num_written = 1; | 4292 *num_written = 1; |
4309 if (params) { | 4293 if (params) { |
4310 params[0] = unpack_flip_y_; | 4294 params[0] = unpack_flip_y_; |
4311 } | 4295 } |
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4925 | 4909 |
4926 void GLES2DecoderImpl::DoGetFramebufferAttachmentParameteriv( | 4910 void GLES2DecoderImpl::DoGetFramebufferAttachmentParameteriv( |
4927 GLenum target, GLenum attachment, GLenum pname, GLint* params) { | 4911 GLenum target, GLenum attachment, GLenum pname, GLint* params) { |
4928 Framebuffer* framebuffer = GetFramebufferInfoForTarget(target); | 4912 Framebuffer* framebuffer = GetFramebufferInfoForTarget(target); |
4929 if (!framebuffer) { | 4913 if (!framebuffer) { |
4930 LOCAL_SET_GL_ERROR( | 4914 LOCAL_SET_GL_ERROR( |
4931 GL_INVALID_OPERATION, | 4915 GL_INVALID_OPERATION, |
4932 "glFramebufferAttachmentParameteriv", "no framebuffer bound"); | 4916 "glFramebufferAttachmentParameteriv", "no framebuffer bound"); |
4933 return; | 4917 return; |
4934 } | 4918 } |
4935 glGetFramebufferAttachmentParameterivEXT(target, attachment, pname, params); | |
4936 if (pname == GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME) { | 4919 if (pname == GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME) { |
4937 GLint type = 0; | 4920 const Framebuffer::Attachment* attachment_object = |
4938 GLuint client_id = 0; | 4921 framebuffer->GetAttachment(attachment); |
4939 glGetFramebufferAttachmentParameterivEXT( | 4922 *params = attachment_object ? attachment_object->object_name() : 0; |
4940 target, attachment, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, &type); | 4923 } else { |
4941 switch (type) { | 4924 glGetFramebufferAttachmentParameterivEXT(target, attachment, pname, params); |
4942 case GL_RENDERBUFFER: { | |
4943 renderbuffer_manager()->GetClientId(*params, &client_id); | |
4944 break; | |
4945 } | |
4946 case GL_TEXTURE: { | |
4947 texture_manager()->GetClientId(*params, &client_id); | |
4948 break; | |
4949 } | |
4950 default: | |
4951 break; | |
4952 } | |
4953 *params = client_id; | |
4954 } | 4925 } |
4955 } | 4926 } |
4956 | 4927 |
4957 void GLES2DecoderImpl::DoGetRenderbufferParameteriv( | 4928 void GLES2DecoderImpl::DoGetRenderbufferParameteriv( |
4958 GLenum target, GLenum pname, GLint* params) { | 4929 GLenum target, GLenum pname, GLint* params) { |
4959 Renderbuffer* renderbuffer = | 4930 Renderbuffer* renderbuffer = |
4960 GetRenderbufferInfoForTarget(GL_RENDERBUFFER); | 4931 GetRenderbufferInfoForTarget(GL_RENDERBUFFER); |
4961 if (!renderbuffer) { | 4932 if (!renderbuffer) { |
4962 LOCAL_SET_GL_ERROR( | 4933 LOCAL_SET_GL_ERROR( |
4963 GL_INVALID_OPERATION, | 4934 GL_INVALID_OPERATION, |
(...skipping 4887 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9851 "mailbox[0]", static_cast<unsigned char>(mailbox[0])); | 9822 "mailbox[0]", static_cast<unsigned char>(mailbox[0])); |
9852 | 9823 |
9853 TextureRef* texture_ref = GetTextureInfoForTarget(target); | 9824 TextureRef* texture_ref = GetTextureInfoForTarget(target); |
9854 if (!texture_ref) { | 9825 if (!texture_ref) { |
9855 LOCAL_SET_GL_ERROR( | 9826 LOCAL_SET_GL_ERROR( |
9856 GL_INVALID_OPERATION, | 9827 GL_INVALID_OPERATION, |
9857 "glProduceTextureCHROMIUM", "unknown texture for target"); | 9828 "glProduceTextureCHROMIUM", "unknown texture for target"); |
9858 return; | 9829 return; |
9859 } | 9830 } |
9860 | 9831 |
9861 TextureDefinition* definition = texture_manager()->Save(texture_ref); | 9832 Texture* produced = texture_manager()->Produce(texture_ref); |
9862 if (!definition) { | 9833 if (!produced) { |
9863 LOCAL_SET_GL_ERROR( | 9834 LOCAL_SET_GL_ERROR( |
9864 GL_INVALID_OPERATION, | 9835 GL_INVALID_OPERATION, |
9865 "glProduceTextureCHROMIUM", "invalid texture"); | 9836 "glProduceTextureCHROMIUM", "invalid texture"); |
9866 return; | 9837 return; |
9867 } | 9838 } |
9868 | 9839 |
9869 if (!group_->mailbox_manager()->ProduceTexture( | 9840 if (!group_->mailbox_manager()->ProduceTexture( |
9870 target, | 9841 target, |
9871 *reinterpret_cast<const MailboxName*>(mailbox), | 9842 *reinterpret_cast<const MailboxName*>(mailbox), |
9872 definition, | 9843 produced)) { |
9873 texture_manager())) { | |
9874 bool success = texture_manager()->Restore( | |
9875 "glProductTextureCHROMIUM", this, texture_ref, definition); | |
9876 DCHECK(success); | |
9877 LOCAL_SET_GL_ERROR( | 9844 LOCAL_SET_GL_ERROR( |
9878 GL_INVALID_OPERATION, | 9845 GL_INVALID_OPERATION, |
9879 "glProduceTextureCHROMIUM", "invalid mailbox name"); | 9846 "glProduceTextureCHROMIUM", "invalid mailbox name"); |
9880 return; | 9847 return; |
9881 } | 9848 } |
9882 | |
9883 glBindTexture(texture_ref->texture()->target(), texture_ref->service_id()); | |
9884 } | 9849 } |
9885 | 9850 |
9886 void GLES2DecoderImpl::DoConsumeTextureCHROMIUM(GLenum target, | 9851 void GLES2DecoderImpl::DoConsumeTextureCHROMIUM(GLenum target, |
9887 const GLbyte* mailbox) { | 9852 const GLbyte* mailbox) { |
9888 TRACE_EVENT2("gpu", "GLES2DecoderImpl::DoConsumeTextureCHROMIUM", | 9853 TRACE_EVENT2("gpu", "GLES2DecoderImpl::DoConsumeTextureCHROMIUM", |
9889 "context", logger_.GetLogPrefix(), | 9854 "context", logger_.GetLogPrefix(), |
9890 "mailbox[0]", static_cast<unsigned char>(mailbox[0])); | 9855 "mailbox[0]", static_cast<unsigned char>(mailbox[0])); |
9891 | 9856 |
9892 TextureRef* texture_ref = GetTextureInfoForTarget(target); | 9857 scoped_refptr<TextureRef> texture_ref = |
| 9858 GetTextureInfoForTargetUnlessDefault(target); |
9893 if (!texture_ref) { | 9859 if (!texture_ref) { |
9894 LOCAL_SET_GL_ERROR( | 9860 LOCAL_SET_GL_ERROR( |
9895 GL_INVALID_OPERATION, | 9861 GL_INVALID_OPERATION, |
9896 "glConsumeTextureCHROMIUM", "unknown texture for target"); | 9862 "glConsumeTextureCHROMIUM", "unknown texture for target"); |
9897 return; | 9863 return; |
9898 } | 9864 } |
9899 | 9865 GLuint client_id = texture_ref->client_id(); |
9900 scoped_ptr<TextureDefinition> definition( | 9866 if (!client_id) { |
| 9867 LOCAL_SET_GL_ERROR( |
| 9868 GL_INVALID_OPERATION, |
| 9869 "glConsumeTextureCHROMIUM", "unknown texture for target"); |
| 9870 return; |
| 9871 } |
| 9872 Texture* texture = |
9901 group_->mailbox_manager()->ConsumeTexture( | 9873 group_->mailbox_manager()->ConsumeTexture( |
9902 target, | 9874 target, |
9903 *reinterpret_cast<const MailboxName*>(mailbox))); | 9875 *reinterpret_cast<const MailboxName*>(mailbox)); |
9904 if (!definition.get()) { | 9876 if (!texture) { |
9905 LOCAL_SET_GL_ERROR( | 9877 LOCAL_SET_GL_ERROR( |
9906 GL_INVALID_OPERATION, | 9878 GL_INVALID_OPERATION, |
9907 "glConsumeTextureCHROMIUM", "invalid mailbox name"); | 9879 "glConsumeTextureCHROMIUM", "invalid mailbox name"); |
9908 return; | 9880 return; |
9909 } | 9881 } |
9910 | 9882 if (texture->target() != target) { |
9911 if (!texture_manager()->Restore( | |
9912 "glConsumeTextureCHROMIUM", this, texture_ref, definition.release())) { | |
9913 LOCAL_SET_GL_ERROR( | 9883 LOCAL_SET_GL_ERROR( |
9914 GL_INVALID_OPERATION, | 9884 GL_INVALID_OPERATION, |
9915 "glConsumeTextureCHROMIUM", "invalid texture"); | 9885 "glConsumeTextureCHROMIUM", "invalid target"); |
9916 return; | 9886 return; |
9917 } | 9887 } |
| 9888 |
| 9889 DeleteTexturesHelper(1, &client_id); |
| 9890 texture_ref = texture_manager()->Consume(client_id, texture); |
| 9891 glBindTexture(target, texture_ref->service_id()); |
| 9892 |
| 9893 TextureUnit& unit = state_.texture_units[state_.active_texture_unit]; |
| 9894 unit.bind_target = target; |
| 9895 switch (target) { |
| 9896 case GL_TEXTURE_2D: |
| 9897 unit.bound_texture_2d = texture_ref; |
| 9898 break; |
| 9899 case GL_TEXTURE_CUBE_MAP: |
| 9900 unit.bound_texture_cube_map = texture_ref; |
| 9901 break; |
| 9902 case GL_TEXTURE_EXTERNAL_OES: |
| 9903 unit.bound_texture_external_oes = texture_ref; |
| 9904 break; |
| 9905 case GL_TEXTURE_RECTANGLE_ARB: |
| 9906 unit.bound_texture_rectangle_arb = texture_ref; |
| 9907 break; |
| 9908 default: |
| 9909 NOTREACHED(); // Validation should prevent us getting here. |
| 9910 break; |
| 9911 } |
9918 } | 9912 } |
9919 | 9913 |
9920 void GLES2DecoderImpl::DoInsertEventMarkerEXT( | 9914 void GLES2DecoderImpl::DoInsertEventMarkerEXT( |
9921 GLsizei length, const GLchar* marker) { | 9915 GLsizei length, const GLchar* marker) { |
9922 if (!marker) { | 9916 if (!marker) { |
9923 marker = ""; | 9917 marker = ""; |
9924 } | 9918 } |
9925 debug_marker_manager_.SetMarker( | 9919 debug_marker_manager_.SetMarker( |
9926 length ? std::string(marker, length) : std::string(marker)); | 9920 length ? std::string(marker, length) : std::string(marker)); |
9927 } | 9921 } |
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10354 return error::kNoError; | 10348 return error::kNoError; |
10355 } | 10349 } |
10356 | 10350 |
10357 // Include the auto-generated part of this file. We split this because it means | 10351 // Include the auto-generated part of this file. We split this because it means |
10358 // we can easily edit the non-auto generated parts right here in this file | 10352 // we can easily edit the non-auto generated parts right here in this file |
10359 // instead of having to edit some template or the code generator. | 10353 // instead of having to edit some template or the code generator. |
10360 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 10354 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
10361 | 10355 |
10362 } // namespace gles2 | 10356 } // namespace gles2 |
10363 } // namespace gpu | 10357 } // namespace gpu |
OLD | NEW |