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

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

Issue 11275088: Remove implicit scoped_refptr operator T* Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 8 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 (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 1223 matching lines...) Expand 10 before | Expand all | Expand 10 after
1234 GLsizei primcount); 1234 GLsizei primcount);
1235 error::Error DoDrawElements( 1235 error::Error DoDrawElements(
1236 const char* function_name, 1236 const char* function_name,
1237 bool instanced, GLenum mode, GLsizei count, GLenum type, 1237 bool instanced, GLenum mode, GLsizei count, GLenum type,
1238 int32 offset, GLsizei primcount); 1238 int32 offset, GLsizei primcount);
1239 1239
1240 // Gets the buffer id for a given target. 1240 // Gets the buffer id for a given target.
1241 BufferManager::BufferInfo* GetBufferInfoForTarget(GLenum target) { 1241 BufferManager::BufferInfo* GetBufferInfoForTarget(GLenum target) {
1242 DCHECK(target == GL_ARRAY_BUFFER || target == GL_ELEMENT_ARRAY_BUFFER); 1242 DCHECK(target == GL_ARRAY_BUFFER || target == GL_ELEMENT_ARRAY_BUFFER);
1243 if (target == GL_ARRAY_BUFFER) { 1243 if (target == GL_ARRAY_BUFFER) {
1244 return state_.bound_array_buffer; 1244 return state_.bound_array_buffer.get();
1245 } else { 1245 } else {
1246 return state_.vertex_attrib_manager->element_array_buffer(); 1246 return state_.vertex_attrib_manager->element_array_buffer();
1247 } 1247 }
1248 } 1248 }
1249 1249
1250 // Gets the texture id for a given target. 1250 // Gets the texture id for a given target.
1251 TextureManager::TextureInfo* GetTextureInfoForTarget(GLenum target) { 1251 TextureManager::TextureInfo* GetTextureInfoForTarget(GLenum target) {
1252 TextureUnit& unit = state_.texture_units[state_.active_texture_unit]; 1252 TextureUnit& unit = state_.texture_units[state_.active_texture_unit];
1253 TextureManager::TextureInfo* info = NULL; 1253 TextureManager::TextureInfo* info = NULL;
1254 switch (target) { 1254 switch (target) {
1255 case GL_TEXTURE_2D: 1255 case GL_TEXTURE_2D:
1256 info = unit.bound_texture_2d; 1256 info = unit.bound_texture_2d.get();
1257 break; 1257 break;
1258 case GL_TEXTURE_CUBE_MAP: 1258 case GL_TEXTURE_CUBE_MAP:
1259 case GL_TEXTURE_CUBE_MAP_POSITIVE_X: 1259 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
1260 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: 1260 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
1261 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: 1261 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
1262 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: 1262 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
1263 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: 1263 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
1264 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: 1264 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
1265 info = unit.bound_texture_cube_map; 1265 info = unit.bound_texture_cube_map.get();
1266 break; 1266 break;
1267 case GL_TEXTURE_EXTERNAL_OES: 1267 case GL_TEXTURE_EXTERNAL_OES:
1268 info = unit.bound_texture_external_oes; 1268 info = unit.bound_texture_external_oes.get();
1269 break; 1269 break;
1270 case GL_TEXTURE_RECTANGLE_ARB: 1270 case GL_TEXTURE_RECTANGLE_ARB:
1271 info = unit.bound_texture_rectangle_arb; 1271 info = unit.bound_texture_rectangle_arb.get();
1272 break; 1272 break;
1273 default: 1273 default:
1274 NOTREACHED(); 1274 NOTREACHED();
1275 return NULL; 1275 return NULL;
1276 } 1276 }
1277 return info; 1277 return info;
1278 } 1278 }
1279 1279
1280 TextureManager::TextureInfo* GetTextureInfoForTargetUnlessDefault( 1280 TextureManager::TextureInfo* GetTextureInfoForTargetUnlessDefault(
1281 GLenum target) { 1281 GLenum target) {
(...skipping 23 matching lines...) Expand all
1305 return 0; 1305 return 0;
1306 } 1306 }
1307 1307
1308 // Gets the framebuffer info for a particular target. 1308 // Gets the framebuffer info for a particular target.
1309 FramebufferManager::FramebufferInfo* GetFramebufferInfoForTarget( 1309 FramebufferManager::FramebufferInfo* GetFramebufferInfoForTarget(
1310 GLenum target) { 1310 GLenum target) {
1311 FramebufferManager::FramebufferInfo* info = NULL; 1311 FramebufferManager::FramebufferInfo* info = NULL;
1312 switch (target) { 1312 switch (target) {
1313 case GL_FRAMEBUFFER: 1313 case GL_FRAMEBUFFER:
1314 case GL_DRAW_FRAMEBUFFER_EXT: 1314 case GL_DRAW_FRAMEBUFFER_EXT:
1315 info = state_.bound_draw_framebuffer; 1315 info = state_.bound_draw_framebuffer.get();
1316 break; 1316 break;
1317 case GL_READ_FRAMEBUFFER_EXT: 1317 case GL_READ_FRAMEBUFFER_EXT:
1318 info = state_.bound_read_framebuffer; 1318 info = state_.bound_read_framebuffer.get();
1319 break; 1319 break;
1320 default: 1320 default:
1321 NOTREACHED(); 1321 NOTREACHED();
1322 break; 1322 break;
1323 } 1323 }
1324 return info; 1324 return info;
1325 } 1325 }
1326 1326
1327 RenderbufferManager::RenderbufferInfo* GetRenderbufferInfoForTarget( 1327 RenderbufferManager::RenderbufferInfo* GetRenderbufferInfoForTarget(
1328 GLenum target) { 1328 GLenum target) {
1329 RenderbufferManager::RenderbufferInfo* info = NULL; 1329 RenderbufferManager::RenderbufferInfo* info = NULL;
1330 switch (target) { 1330 switch (target) {
1331 case GL_RENDERBUFFER: 1331 case GL_RENDERBUFFER:
1332 info = state_.bound_renderbuffer; 1332 info = state_.bound_renderbuffer.get();
1333 break; 1333 break;
1334 default: 1334 default:
1335 NOTREACHED(); 1335 NOTREACHED();
1336 break; 1336 break;
1337 } 1337 }
1338 return info; 1338 return info;
1339 } 1339 }
1340 1340
1341 // Validates the program and location for a glGetUniform call and returns 1341 // Validates the program and location for a glGetUniform call and returns
1342 // a SizeResult setup to receive the result. Returns true if glGetUniform 1342 // a SizeResult setup to receive the result. Returns true if glGetUniform
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1385 const FeatureInfo::FeatureFlags& features() const { 1385 const FeatureInfo::FeatureFlags& features() const {
1386 return feature_info_->feature_flags(); 1386 return feature_info_->feature_flags();
1387 } 1387 }
1388 1388
1389 const FeatureInfo::Workarounds& workarounds() const { 1389 const FeatureInfo::Workarounds& workarounds() const {
1390 return feature_info_->workarounds(); 1390 return feature_info_->workarounds();
1391 } 1391 }
1392 1392
1393 bool ShouldDeferDraws() { 1393 bool ShouldDeferDraws() {
1394 return !offscreen_target_frame_buffer_.get() && 1394 return !offscreen_target_frame_buffer_.get() &&
1395 state_.bound_draw_framebuffer == NULL && 1395 state_.bound_draw_framebuffer.get() == NULL &&
1396 surface_->DeferDraws(); 1396 surface_->DeferDraws();
1397 } 1397 }
1398 1398
1399 void ForceCompileShaderIfPending(ShaderManager::ShaderInfo* info); 1399 void ForceCompileShaderIfPending(ShaderManager::ShaderInfo* info);
1400 1400
1401 // Generate a member function prototype for each command in an automated and 1401 // Generate a member function prototype for each command in an automated and
1402 // typesafe way. 1402 // typesafe way.
1403 #define GLES2_CMD_OP(name) \ 1403 #define GLES2_CMD_OP(name) \
1404 Error Handle ## name( \ 1404 Error Handle ## name( \
1405 uint32 immediate_data_size, \ 1405 uint32 immediate_data_size, \
1406 const gles2::name& args); \ 1406 const gles2::name& args); \
(...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after
2017 CHECK_GL_ERROR(); 2017 CHECK_GL_ERROR();
2018 2018
2019 disallowed_features_ = disallowed_features; 2019 disallowed_features_ = disallowed_features;
2020 2020
2021 default_vertex_attrib_manager_ = new VertexAttribManager(); 2021 default_vertex_attrib_manager_ = new VertexAttribManager();
2022 default_vertex_attrib_manager_->Initialize(group_->max_vertex_attribs()); 2022 default_vertex_attrib_manager_->Initialize(group_->max_vertex_attribs());
2023 2023
2024 // vertex_attrib_manager is set to default_vertex_attrib_manager_ by this call 2024 // vertex_attrib_manager is set to default_vertex_attrib_manager_ by this call
2025 DoBindVertexArrayOES(0); 2025 DoBindVertexArrayOES(0);
2026 2026
2027 query_manager_.reset(new QueryManager(this, feature_info_)); 2027 query_manager_.reset(new QueryManager(this, feature_info_.get()));
2028 vertex_array_manager_.reset(new VertexArrayManager()); 2028 vertex_array_manager_.reset(new VertexArrayManager());
2029 2029
2030 util_.set_num_compressed_texture_formats( 2030 util_.set_num_compressed_texture_formats(
2031 validators_->compressed_texture_format.GetValues().size()); 2031 validators_->compressed_texture_format.GetValues().size());
2032 2032
2033 if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) { 2033 if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) {
2034 // We have to enable vertex array 0 on OpenGL or it won't render. Note that 2034 // We have to enable vertex array 0 on OpenGL or it won't render. Note that
2035 // OpenGL ES 2.0 does not have this issue. 2035 // OpenGL ES 2.0 does not have this issue.
2036 glEnableVertexAttribArray(0); 2036 glEnableVertexAttribArray(0);
2037 } 2037 }
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
2395 } 2395 }
2396 return true; 2396 return true;
2397 } 2397 }
2398 2398
2399 void GLES2DecoderImpl::DeleteBuffersHelper( 2399 void GLES2DecoderImpl::DeleteBuffersHelper(
2400 GLsizei n, const GLuint* client_ids) { 2400 GLsizei n, const GLuint* client_ids) {
2401 for (GLsizei ii = 0; ii < n; ++ii) { 2401 for (GLsizei ii = 0; ii < n; ++ii) {
2402 BufferManager::BufferInfo* buffer = GetBufferInfo(client_ids[ii]); 2402 BufferManager::BufferInfo* buffer = GetBufferInfo(client_ids[ii]);
2403 if (buffer && !buffer->IsDeleted()) { 2403 if (buffer && !buffer->IsDeleted()) {
2404 state_.vertex_attrib_manager->Unbind(buffer); 2404 state_.vertex_attrib_manager->Unbind(buffer);
2405 if (state_.bound_array_buffer == buffer) { 2405 if (state_.bound_array_buffer.get() == buffer) {
2406 state_.bound_array_buffer = NULL; 2406 state_.bound_array_buffer = NULL;
2407 } 2407 }
2408 RemoveBufferInfo(client_ids[ii]); 2408 RemoveBufferInfo(client_ids[ii]);
2409 } 2409 }
2410 } 2410 }
2411 } 2411 }
2412 2412
2413 void GLES2DecoderImpl::DeleteFramebuffersHelper( 2413 void GLES2DecoderImpl::DeleteFramebuffersHelper(
2414 GLsizei n, const GLuint* client_ids) { 2414 GLsizei n, const GLuint* client_ids) {
2415 bool supports_separate_framebuffer_binds = 2415 bool supports_separate_framebuffer_binds =
2416 features().chromium_framebuffer_multisample; 2416 features().chromium_framebuffer_multisample;
2417 2417
2418 for (GLsizei ii = 0; ii < n; ++ii) { 2418 for (GLsizei ii = 0; ii < n; ++ii) {
2419 FramebufferManager::FramebufferInfo* framebuffer = 2419 FramebufferManager::FramebufferInfo* framebuffer =
2420 GetFramebufferInfo(client_ids[ii]); 2420 GetFramebufferInfo(client_ids[ii]);
2421 if (framebuffer && !framebuffer->IsDeleted()) { 2421 if (framebuffer && !framebuffer->IsDeleted()) {
2422 if (framebuffer == state_.bound_draw_framebuffer) { 2422 if (framebuffer == state_.bound_draw_framebuffer.get()) {
2423 state_.bound_draw_framebuffer = NULL; 2423 state_.bound_draw_framebuffer = NULL;
2424 clear_state_dirty_ = true; 2424 clear_state_dirty_ = true;
2425 GLenum target = supports_separate_framebuffer_binds ? 2425 GLenum target = supports_separate_framebuffer_binds ?
2426 GL_DRAW_FRAMEBUFFER_EXT : GL_FRAMEBUFFER; 2426 GL_DRAW_FRAMEBUFFER_EXT : GL_FRAMEBUFFER;
2427 glBindFramebufferEXT(target, GetBackbufferServiceId()); 2427 glBindFramebufferEXT(target, GetBackbufferServiceId());
2428 } 2428 }
2429 if (framebuffer == state_.bound_read_framebuffer) { 2429 if (framebuffer == state_.bound_read_framebuffer.get()) {
2430 state_.bound_read_framebuffer = NULL; 2430 state_.bound_read_framebuffer = NULL;
2431 GLenum target = supports_separate_framebuffer_binds ? 2431 GLenum target = supports_separate_framebuffer_binds ?
2432 GL_READ_FRAMEBUFFER_EXT : GL_FRAMEBUFFER; 2432 GL_READ_FRAMEBUFFER_EXT : GL_FRAMEBUFFER;
2433 glBindFramebufferEXT(target, GetBackbufferServiceId()); 2433 glBindFramebufferEXT(target, GetBackbufferServiceId());
2434 } 2434 }
2435 RemoveFramebufferInfo(client_ids[ii]); 2435 RemoveFramebufferInfo(client_ids[ii]);
2436 } 2436 }
2437 } 2437 }
2438 } 2438 }
2439 2439
2440 void GLES2DecoderImpl::DeleteRenderbuffersHelper( 2440 void GLES2DecoderImpl::DeleteRenderbuffersHelper(
2441 GLsizei n, const GLuint* client_ids) { 2441 GLsizei n, const GLuint* client_ids) {
2442 bool supports_separate_framebuffer_binds = 2442 bool supports_separate_framebuffer_binds =
2443 features().chromium_framebuffer_multisample; 2443 features().chromium_framebuffer_multisample;
2444 for (GLsizei ii = 0; ii < n; ++ii) { 2444 for (GLsizei ii = 0; ii < n; ++ii) {
2445 RenderbufferManager::RenderbufferInfo* renderbuffer = 2445 RenderbufferManager::RenderbufferInfo* renderbuffer =
2446 GetRenderbufferInfo(client_ids[ii]); 2446 GetRenderbufferInfo(client_ids[ii]);
2447 if (renderbuffer && !renderbuffer->IsDeleted()) { 2447 if (renderbuffer && !renderbuffer->IsDeleted()) {
2448 if (state_.bound_renderbuffer == renderbuffer) { 2448 if (state_.bound_renderbuffer.get() == renderbuffer) {
2449 state_.bound_renderbuffer = NULL; 2449 state_.bound_renderbuffer = NULL;
2450 } 2450 }
2451 // Unbind from current framebuffers. 2451 // Unbind from current framebuffers.
2452 if (supports_separate_framebuffer_binds) { 2452 if (supports_separate_framebuffer_binds) {
2453 if (state_.bound_read_framebuffer) { 2453 if (state_.bound_read_framebuffer.get()) {
2454 state_.bound_read_framebuffer->UnbindRenderbuffer( 2454 state_.bound_read_framebuffer->UnbindRenderbuffer(
2455 GL_READ_FRAMEBUFFER_EXT, renderbuffer); 2455 GL_READ_FRAMEBUFFER_EXT, renderbuffer);
2456 } 2456 }
2457 if (state_.bound_draw_framebuffer) { 2457 if (state_.bound_draw_framebuffer.get()) {
2458 state_.bound_draw_framebuffer->UnbindRenderbuffer( 2458 state_.bound_draw_framebuffer->UnbindRenderbuffer(
2459 GL_DRAW_FRAMEBUFFER_EXT, renderbuffer); 2459 GL_DRAW_FRAMEBUFFER_EXT, renderbuffer);
2460 } 2460 }
2461 } else { 2461 } else {
2462 if (state_.bound_draw_framebuffer) { 2462 if (state_.bound_draw_framebuffer.get()) {
2463 state_.bound_draw_framebuffer->UnbindRenderbuffer( 2463 state_.bound_draw_framebuffer->UnbindRenderbuffer(
2464 GL_FRAMEBUFFER, renderbuffer); 2464 GL_FRAMEBUFFER, renderbuffer);
2465 } 2465 }
2466 } 2466 }
2467 clear_state_dirty_ = true; 2467 clear_state_dirty_ = true;
2468 RemoveRenderbufferInfo(client_ids[ii]); 2468 RemoveRenderbufferInfo(client_ids[ii]);
2469 } 2469 }
2470 } 2470 }
2471 } 2471 }
2472 2472
2473 void GLES2DecoderImpl::DeleteTexturesHelper( 2473 void GLES2DecoderImpl::DeleteTexturesHelper(
2474 GLsizei n, const GLuint* client_ids) { 2474 GLsizei n, const GLuint* client_ids) {
2475 bool supports_separate_framebuffer_binds = 2475 bool supports_separate_framebuffer_binds =
2476 features().chromium_framebuffer_multisample; 2476 features().chromium_framebuffer_multisample;
2477 for (GLsizei ii = 0; ii < n; ++ii) { 2477 for (GLsizei ii = 0; ii < n; ++ii) {
2478 TextureManager::TextureInfo* texture = GetTextureInfo(client_ids[ii]); 2478 TextureManager::TextureInfo* texture = GetTextureInfo(client_ids[ii]);
2479 if (texture && !texture->IsDeleted()) { 2479 if (texture && !texture->IsDeleted()) {
2480 if (texture->IsAttachedToFramebuffer()) { 2480 if (texture->IsAttachedToFramebuffer()) {
2481 clear_state_dirty_ = true; 2481 clear_state_dirty_ = true;
2482 } 2482 }
2483 // Unbind texture from texture units. 2483 // Unbind texture from texture units.
2484 for (size_t jj = 0; jj < group_->max_texture_units(); ++jj) { 2484 for (size_t jj = 0; jj < group_->max_texture_units(); ++jj) {
2485 state_.texture_units[jj].Unbind(texture); 2485 state_.texture_units[jj].Unbind(texture);
2486 } 2486 }
2487 // Unbind from current framebuffers. 2487 // Unbind from current framebuffers.
2488 if (supports_separate_framebuffer_binds) { 2488 if (supports_separate_framebuffer_binds) {
2489 if (state_.bound_read_framebuffer) { 2489 if (state_.bound_read_framebuffer.get()) {
2490 state_.bound_read_framebuffer->UnbindTexture( 2490 state_.bound_read_framebuffer->UnbindTexture(
2491 GL_READ_FRAMEBUFFER_EXT, texture); 2491 GL_READ_FRAMEBUFFER_EXT, texture);
2492 } 2492 }
2493 if (state_.bound_draw_framebuffer) { 2493 if (state_.bound_draw_framebuffer.get()) {
2494 state_.bound_draw_framebuffer->UnbindTexture( 2494 state_.bound_draw_framebuffer->UnbindTexture(
2495 GL_DRAW_FRAMEBUFFER_EXT, texture); 2495 GL_DRAW_FRAMEBUFFER_EXT, texture);
2496 } 2496 }
2497 } else { 2497 } else {
2498 if (state_.bound_draw_framebuffer) { 2498 if (state_.bound_draw_framebuffer.get()) {
2499 state_.bound_draw_framebuffer->UnbindTexture(GL_FRAMEBUFFER, texture); 2499 state_.bound_draw_framebuffer->UnbindTexture(GL_FRAMEBUFFER, texture);
2500 } 2500 }
2501 } 2501 }
2502 GLuint service_id = texture->service_id(); 2502 GLuint service_id = texture->service_id();
2503 if (texture->IsStreamTexture() && stream_texture_manager_) { 2503 if (texture->IsStreamTexture() && stream_texture_manager_) {
2504 stream_texture_manager_->DestroyStreamTexture(service_id); 2504 stream_texture_manager_->DestroyStreamTexture(service_id);
2505 } 2505 }
2506 #if defined(OS_MACOSX) 2506 #if defined(OS_MACOSX)
2507 if (texture->target() == GL_TEXTURE_RECTANGLE_ARB) { 2507 if (texture->target() == GL_TEXTURE_RECTANGLE_ARB) {
2508 ReleaseIOSurfaceForTexture(service_id); 2508 ReleaseIOSurfaceForTexture(service_id);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
2568 RebindCurrentFramebuffer( 2568 RebindCurrentFramebuffer(
2569 GL_DRAW_FRAMEBUFFER_EXT, 2569 GL_DRAW_FRAMEBUFFER_EXT,
2570 state_.bound_draw_framebuffer.get(), 2570 state_.bound_draw_framebuffer.get(),
2571 GetBackbufferServiceId()); 2571 GetBackbufferServiceId());
2572 } 2572 }
2573 } 2573 }
2574 2574
2575 void GLES2DecoderImpl::RestoreCurrentTexture2DBindings() { 2575 void GLES2DecoderImpl::RestoreCurrentTexture2DBindings() {
2576 TextureUnit& info = state_.texture_units[0]; 2576 TextureUnit& info = state_.texture_units[0];
2577 GLuint last_id; 2577 GLuint last_id;
2578 if (info.bound_texture_2d) { 2578 if (info.bound_texture_2d.get()) {
2579 last_id = info.bound_texture_2d->service_id(); 2579 last_id = info.bound_texture_2d->service_id();
2580 } else { 2580 } else {
2581 last_id = 0; 2581 last_id = 0;
2582 } 2582 }
2583 2583
2584 glBindTexture(GL_TEXTURE_2D, last_id); 2584 glBindTexture(GL_TEXTURE_2D, last_id);
2585 glActiveTexture(GL_TEXTURE0 + state_.active_texture_unit); 2585 glActiveTexture(GL_TEXTURE0 + state_.active_texture_unit);
2586 } 2586 }
2587 2587
2588 bool GLES2DecoderImpl::CheckFramebufferValid( 2588 bool GLES2DecoderImpl::CheckFramebufferValid(
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
2629 } 2629 }
2630 2630
2631 // NOTE: At this point we don't know if the framebuffer is complete but 2631 // NOTE: At this point we don't know if the framebuffer is complete but
2632 // we DO know that everything that needs to be cleared has been cleared. 2632 // we DO know that everything that needs to be cleared has been cleared.
2633 return true; 2633 return true;
2634 } 2634 }
2635 2635
2636 bool GLES2DecoderImpl::CheckBoundFramebuffersValid(const char* func_name) { 2636 bool GLES2DecoderImpl::CheckBoundFramebuffersValid(const char* func_name) {
2637 if (!features().chromium_framebuffer_multisample) { 2637 if (!features().chromium_framebuffer_multisample) {
2638 return CheckFramebufferValid( 2638 return CheckFramebufferValid(
2639 state_.bound_draw_framebuffer, GL_FRAMEBUFFER_EXT, func_name); 2639 state_.bound_draw_framebuffer.get(), GL_FRAMEBUFFER_EXT, func_name);
2640 } 2640 }
2641 return CheckFramebufferValid( 2641 return CheckFramebufferValid(
2642 state_.bound_draw_framebuffer, 2642 state_.bound_draw_framebuffer.get(),
2643 GL_DRAW_FRAMEBUFFER_EXT, func_name) && 2643 GL_DRAW_FRAMEBUFFER_EXT, func_name) &&
2644 CheckFramebufferValid( 2644 CheckFramebufferValid(
2645 state_.bound_read_framebuffer, 2645 state_.bound_read_framebuffer.get(),
2646 GL_READ_FRAMEBUFFER_EXT, func_name); 2646 GL_READ_FRAMEBUFFER_EXT, func_name);
2647 } 2647 }
2648 2648
2649 gfx::Size GLES2DecoderImpl::GetBoundReadFrameBufferSize() { 2649 gfx::Size GLES2DecoderImpl::GetBoundReadFrameBufferSize() {
2650 FramebufferManager::FramebufferInfo* framebuffer = 2650 FramebufferManager::FramebufferInfo* framebuffer =
2651 GetFramebufferInfoForTarget(GL_READ_FRAMEBUFFER_EXT); 2651 GetFramebufferInfoForTarget(GL_READ_FRAMEBUFFER_EXT);
2652 if (framebuffer != NULL) { 2652 if (framebuffer != NULL) {
2653 const FramebufferManager::FramebufferInfo::Attachment* attachment = 2653 const FramebufferManager::FramebufferInfo::Attachment* attachment =
2654 framebuffer->GetAttachment(GL_COLOR_ATTACHMENT0); 2654 framebuffer->GetAttachment(GL_COLOR_ATTACHMENT0);
2655 if (attachment) { 2655 if (attachment) {
2656 return gfx::Size(attachment->width(), attachment->height()); 2656 return gfx::Size(attachment->width(), attachment->height());
(...skipping 30 matching lines...) Expand all
2687 } 2687 }
2688 } 2688 }
2689 2689
2690 void GLES2DecoderImpl::UpdateParentTextureInfo() { 2690 void GLES2DecoderImpl::UpdateParentTextureInfo() {
2691 if (parent_) { 2691 if (parent_) {
2692 // Update the info about the offscreen saved color texture in the parent. 2692 // Update the info about the offscreen saved color texture in the parent.
2693 // The reference to the parent is a weak pointer and will become null if the 2693 // The reference to the parent is a weak pointer and will become null if the
2694 // parent is later destroyed. 2694 // parent is later destroyed.
2695 TextureManager* parent_texture_manager = parent_->texture_manager(); 2695 TextureManager* parent_texture_manager = parent_->texture_manager();
2696 parent_texture_manager->SetLevelInfo( 2696 parent_texture_manager->SetLevelInfo(
2697 offscreen_saved_color_texture_info_, 2697 offscreen_saved_color_texture_info_.get(),
2698 GL_TEXTURE_2D, 2698 GL_TEXTURE_2D,
2699 0, // level 2699 0, // level
2700 GL_RGBA, 2700 GL_RGBA,
2701 offscreen_size_.width(), 2701 offscreen_size_.width(),
2702 offscreen_size_.height(), 2702 offscreen_size_.height(),
2703 1, // depth 2703 1, // depth
2704 0, // border 2704 0, // border
2705 GL_RGBA, 2705 GL_RGBA,
2706 GL_UNSIGNED_BYTE, 2706 GL_UNSIGNED_BYTE,
2707 true); 2707 true);
2708 parent_texture_manager->SetParameter( 2708 parent_texture_manager->SetParameter(
2709 offscreen_saved_color_texture_info_, 2709 offscreen_saved_color_texture_info_.get(),
2710 GL_TEXTURE_MAG_FILTER, 2710 GL_TEXTURE_MAG_FILTER,
2711 GL_NEAREST); 2711 GL_NEAREST);
2712 parent_texture_manager->SetParameter( 2712 parent_texture_manager->SetParameter(
2713 offscreen_saved_color_texture_info_, 2713 offscreen_saved_color_texture_info_.get(),
2714 GL_TEXTURE_MIN_FILTER, 2714 GL_TEXTURE_MIN_FILTER,
2715 GL_NEAREST); 2715 GL_NEAREST);
2716 parent_texture_manager->SetParameter( 2716 parent_texture_manager->SetParameter(
2717 offscreen_saved_color_texture_info_, 2717 offscreen_saved_color_texture_info_.get(),
2718 GL_TEXTURE_WRAP_S, 2718 GL_TEXTURE_WRAP_S,
2719 GL_CLAMP_TO_EDGE); 2719 GL_CLAMP_TO_EDGE);
2720 parent_texture_manager->SetParameter( 2720 parent_texture_manager->SetParameter(
2721 offscreen_saved_color_texture_info_, 2721 offscreen_saved_color_texture_info_.get(),
2722 GL_TEXTURE_WRAP_T, 2722 GL_TEXTURE_WRAP_T,
2723 GL_CLAMP_TO_EDGE); 2723 GL_CLAMP_TO_EDGE);
2724 } else { 2724 } else {
2725 offscreen_saved_color_texture_info_ = NULL; 2725 offscreen_saved_color_texture_info_ = NULL;
2726 } 2726 }
2727 } 2727 }
2728 2728
2729 void GLES2DecoderImpl::SetResizeCallback( 2729 void GLES2DecoderImpl::SetResizeCallback(
2730 const base::Callback<void(gfx::Size)>& callback) { 2730 const base::Callback<void(gfx::Size)>& callback) {
2731 resize_callback_ = callback; 2731 resize_callback_ = callback;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
2785 state_.bound_read_framebuffer = NULL; 2785 state_.bound_read_framebuffer = NULL;
2786 state_.bound_draw_framebuffer = NULL; 2786 state_.bound_draw_framebuffer = NULL;
2787 state_.bound_renderbuffer = NULL; 2787 state_.bound_renderbuffer = NULL;
2788 2788
2789 if (have_context) { 2789 if (have_context) {
2790 if (copy_texture_CHROMIUM_.get()) { 2790 if (copy_texture_CHROMIUM_.get()) {
2791 copy_texture_CHROMIUM_->Destroy(); 2791 copy_texture_CHROMIUM_->Destroy();
2792 copy_texture_CHROMIUM_.reset(); 2792 copy_texture_CHROMIUM_.reset();
2793 } 2793 }
2794 2794
2795 if (state_.current_program) { 2795 if (state_.current_program.get()) {
2796 program_manager()->UnuseProgram(shader_manager(), state_.current_program); 2796 program_manager()->
2797 UnuseProgram(shader_manager(), state_.current_program.get());
2797 state_.current_program = NULL; 2798 state_.current_program = NULL;
2798 } 2799 }
2799 2800
2800 if (attrib_0_buffer_id_) { 2801 if (attrib_0_buffer_id_) {
2801 glDeleteBuffersARB(1, &attrib_0_buffer_id_); 2802 glDeleteBuffersARB(1, &attrib_0_buffer_id_);
2802 } 2803 }
2803 if (fixed_attrib_buffer_id_) { 2804 if (fixed_attrib_buffer_id_) {
2804 glDeleteBuffersARB(1, &fixed_attrib_buffer_id_); 2805 glDeleteBuffersARB(1, &fixed_attrib_buffer_id_);
2805 } 2806 }
2806 2807
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
2847 if (query_manager_.get()) { 2848 if (query_manager_.get()) {
2848 query_manager_->Destroy(have_context); 2849 query_manager_->Destroy(have_context);
2849 query_manager_.reset(); 2850 query_manager_.reset();
2850 } 2851 }
2851 2852
2852 if (vertex_array_manager_ .get()) { 2853 if (vertex_array_manager_ .get()) {
2853 vertex_array_manager_->Destroy(have_context); 2854 vertex_array_manager_->Destroy(have_context);
2854 vertex_array_manager_.reset(); 2855 vertex_array_manager_.reset();
2855 } 2856 }
2856 2857
2857 if (group_) { 2858 if (group_.get()) {
2858 group_->Destroy(have_context); 2859 group_->Destroy(have_context);
2859 group_ = NULL; 2860 group_ = NULL;
2860 } 2861 }
2861 2862
2862 if (context_.get()) { 2863 if (context_.get()) {
2863 context_->ReleaseCurrent(NULL); 2864 context_->ReleaseCurrent(NULL);
2864 context_ = NULL; 2865 context_ = NULL;
2865 } 2866 }
2866 2867
2867 offscreen_target_frame_buffer_.reset(); 2868 offscreen_target_frame_buffer_.reset();
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
2933 // Replace texture info when ID is already in use by parent. 2934 // Replace texture info when ID is already in use by parent.
2934 if (new_parent_impl->texture_manager()->GetTextureInfo( 2935 if (new_parent_impl->texture_manager()->GetTextureInfo(
2935 new_parent_texture_id)) 2936 new_parent_texture_id))
2936 new_parent_impl->texture_manager()->RemoveTextureInfo( 2937 new_parent_impl->texture_manager()->RemoveTextureInfo(
2937 new_parent_texture_id); 2938 new_parent_texture_id);
2938 2939
2939 offscreen_saved_color_texture_info_ = 2940 offscreen_saved_color_texture_info_ =
2940 new_parent_impl->CreateTextureInfo(new_parent_texture_id, service_id); 2941 new_parent_impl->CreateTextureInfo(new_parent_texture_id, service_id);
2941 offscreen_saved_color_texture_info_->SetNotOwned(); 2942 offscreen_saved_color_texture_info_->SetNotOwned();
2942 new_parent_impl->texture_manager()-> 2943 new_parent_impl->texture_manager()->
2943 SetInfoTarget(offscreen_saved_color_texture_info_, GL_TEXTURE_2D); 2944 SetInfoTarget(offscreen_saved_color_texture_info_.get(), GL_TEXTURE_2D);
2944 2945
2945 parent_ = new_parent_impl->AsWeakPtr(); 2946 parent_ = new_parent_impl->AsWeakPtr();
2946 2947
2947 UpdateParentTextureInfo(); 2948 UpdateParentTextureInfo();
2948 } else { 2949 } else {
2949 parent_.reset(); 2950 parent_.reset();
2950 offscreen_saved_color_texture_info_ = NULL; 2951 offscreen_saved_color_texture_info_ = NULL;
2951 } 2952 }
2952 2953
2953 return true; 2954 return true;
(...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after
3679 return true; 3680 return true;
3680 case GL_SHADER_COMPILER: 3681 case GL_SHADER_COMPILER:
3681 *num_written = 1; 3682 *num_written = 1;
3682 if (params) { 3683 if (params) {
3683 *params = GL_TRUE; 3684 *params = GL_TRUE;
3684 } 3685 }
3685 return true; 3686 return true;
3686 case GL_ARRAY_BUFFER_BINDING: 3687 case GL_ARRAY_BUFFER_BINDING:
3687 *num_written = 1; 3688 *num_written = 1;
3688 if (params) { 3689 if (params) {
3689 if (state_.bound_array_buffer) { 3690 if (state_.bound_array_buffer.get()) {
3690 GLuint client_id = 0; 3691 GLuint client_id = 0;
3691 buffer_manager()->GetClientId(state_.bound_array_buffer->service_id(), 3692 buffer_manager()->GetClientId(state_.bound_array_buffer->service_id(),
3692 &client_id); 3693 &client_id);
3693 *params = client_id; 3694 *params = client_id;
3694 } else { 3695 } else {
3695 *params = 0; 3696 *params = 0;
3696 } 3697 }
3697 } 3698 }
3698 return true; 3699 return true;
3699 case GL_ELEMENT_ARRAY_BUFFER_BINDING: 3700 case GL_ELEMENT_ARRAY_BUFFER_BINDING:
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
3752 renderbuffer->service_id(), &client_id); 3753 renderbuffer->service_id(), &client_id);
3753 *params = client_id; 3754 *params = client_id;
3754 } else { 3755 } else {
3755 *params = 0; 3756 *params = 0;
3756 } 3757 }
3757 } 3758 }
3758 return true; 3759 return true;
3759 case GL_CURRENT_PROGRAM: 3760 case GL_CURRENT_PROGRAM:
3760 *num_written = 1; 3761 *num_written = 1;
3761 if (params) { 3762 if (params) {
3762 if (state_.current_program) { 3763 if (state_.current_program.get()) {
3763 GLuint client_id = 0; 3764 GLuint client_id = 0;
3764 program_manager()->GetClientId( 3765 program_manager()->GetClientId(
3765 state_.current_program->service_id(), &client_id); 3766 state_.current_program->service_id(), &client_id);
3766 *params = client_id; 3767 *params = client_id;
3767 } else { 3768 } else {
3768 *params = 0; 3769 *params = 0;
3769 } 3770 }
3770 } 3771 }
3771 return true; 3772 return true;
3772 case GL_TEXTURE_BINDING_2D: 3773 case GL_TEXTURE_BINDING_2D:
3773 *num_written = 1; 3774 *num_written = 1;
3774 if (params) { 3775 if (params) {
3775 TextureUnit& unit = state_.texture_units[state_.active_texture_unit]; 3776 TextureUnit& unit = state_.texture_units[state_.active_texture_unit];
3776 if (unit.bound_texture_2d) { 3777 if (unit.bound_texture_2d.get()) {
3777 GLuint client_id = 0; 3778 GLuint client_id = 0;
3778 texture_manager()->GetClientId( 3779 texture_manager()->GetClientId(
3779 unit.bound_texture_2d->service_id(), &client_id); 3780 unit.bound_texture_2d->service_id(), &client_id);
3780 *params = client_id; 3781 *params = client_id;
3781 } else { 3782 } else {
3782 *params = 0; 3783 *params = 0;
3783 } 3784 }
3784 } 3785 }
3785 return true; 3786 return true;
3786 case GL_TEXTURE_BINDING_CUBE_MAP: 3787 case GL_TEXTURE_BINDING_CUBE_MAP:
3787 *num_written = 1; 3788 *num_written = 1;
3788 if (params) { 3789 if (params) {
3789 TextureUnit& unit = state_.texture_units[state_.active_texture_unit]; 3790 TextureUnit& unit = state_.texture_units[state_.active_texture_unit];
3790 if (unit.bound_texture_cube_map) { 3791 if (unit.bound_texture_cube_map.get()) {
3791 GLuint client_id = 0; 3792 GLuint client_id = 0;
3792 texture_manager()->GetClientId( 3793 texture_manager()->GetClientId(
3793 unit.bound_texture_cube_map->service_id(), &client_id); 3794 unit.bound_texture_cube_map->service_id(), &client_id);
3794 *params = client_id; 3795 *params = client_id;
3795 } else { 3796 } else {
3796 *params = 0; 3797 *params = 0;
3797 } 3798 }
3798 } 3799 }
3799 return true; 3800 return true;
3800 case GL_TEXTURE_BINDING_EXTERNAL_OES: 3801 case GL_TEXTURE_BINDING_EXTERNAL_OES:
3801 *num_written = 1; 3802 *num_written = 1;
3802 if (params) { 3803 if (params) {
3803 TextureUnit& unit = state_.texture_units[state_.active_texture_unit]; 3804 TextureUnit& unit = state_.texture_units[state_.active_texture_unit];
3804 if (unit.bound_texture_external_oes) { 3805 if (unit.bound_texture_external_oes.get()) {
3805 GLuint client_id = 0; 3806 GLuint client_id = 0;
3806 texture_manager()->GetClientId( 3807 texture_manager()->GetClientId(
3807 unit.bound_texture_external_oes->service_id(), &client_id); 3808 unit.bound_texture_external_oes->service_id(), &client_id);
3808 *params = client_id; 3809 *params = client_id;
3809 } else { 3810 } else {
3810 *params = 0; 3811 *params = 0;
3811 } 3812 }
3812 } 3813 }
3813 return true; 3814 return true;
3814 case GL_TEXTURE_BINDING_RECTANGLE_ARB: 3815 case GL_TEXTURE_BINDING_RECTANGLE_ARB:
3815 *num_written = 1; 3816 *num_written = 1;
3816 if (params) { 3817 if (params) {
3817 TextureUnit& unit = state_.texture_units[state_.active_texture_unit]; 3818 TextureUnit& unit = state_.texture_units[state_.active_texture_unit];
3818 if (unit.bound_texture_rectangle_arb) { 3819 if (unit.bound_texture_rectangle_arb.get()) {
3819 GLuint client_id = 0; 3820 GLuint client_id = 0;
3820 texture_manager()->GetClientId( 3821 texture_manager()->GetClientId(
3821 unit.bound_texture_rectangle_arb->service_id(), &client_id); 3822 unit.bound_texture_rectangle_arb->service_id(), &client_id);
3822 *params = client_id; 3823 *params = client_id;
3823 } else { 3824 } else {
3824 *params = 0; 3825 *params = 0;
3825 } 3826 }
3826 } 3827 }
3827 return true; 3828 return true;
3828 case GL_UNPACK_FLIP_Y_CHROMIUM: 3829 case GL_UNPACK_FLIP_Y_CHROMIUM:
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
4224 } 4225 }
4225 service_id = info->service_id(); 4226 service_id = info->service_id();
4226 } 4227 }
4227 CopyRealGLErrorsToWrapper(); 4228 CopyRealGLErrorsToWrapper();
4228 glFramebufferRenderbufferEXT( 4229 glFramebufferRenderbufferEXT(
4229 target, attachment, renderbuffertarget, service_id); 4230 target, attachment, renderbuffertarget, service_id);
4230 GLenum error = PeekGLError(); 4231 GLenum error = PeekGLError();
4231 if (error == GL_NO_ERROR) { 4232 if (error == GL_NO_ERROR) {
4232 framebuffer_info->AttachRenderbuffer(attachment, info); 4233 framebuffer_info->AttachRenderbuffer(attachment, info);
4233 } 4234 }
4234 if (framebuffer_info == state_.bound_draw_framebuffer) { 4235 if (framebuffer_info == state_.bound_draw_framebuffer.get()) {
4235 clear_state_dirty_ = true; 4236 clear_state_dirty_ = true;
4236 } 4237 }
4237 } 4238 }
4238 4239
4239 void GLES2DecoderImpl::DoDisable(GLenum cap) { 4240 void GLES2DecoderImpl::DoDisable(GLenum cap) {
4240 if (SetCapabilityState(cap, false)) { 4241 if (SetCapabilityState(cap, false)) {
4241 glDisable(cap); 4242 glDisable(cap);
4242 } 4243 }
4243 } 4244 }
4244 4245
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
4379 "glFramebufferTexture2D", "level out of range"); 4380 "glFramebufferTexture2D", "level out of range");
4380 return; 4381 return;
4381 } 4382 }
4382 4383
4383 CopyRealGLErrorsToWrapper(); 4384 CopyRealGLErrorsToWrapper();
4384 glFramebufferTexture2DEXT(target, attachment, textarget, service_id, level); 4385 glFramebufferTexture2DEXT(target, attachment, textarget, service_id, level);
4385 GLenum error = PeekGLError(); 4386 GLenum error = PeekGLError();
4386 if (error == GL_NO_ERROR) { 4387 if (error == GL_NO_ERROR) {
4387 framebuffer_info->AttachTexture(attachment, info, textarget, level); 4388 framebuffer_info->AttachTexture(attachment, info, textarget, level);
4388 } 4389 }
4389 if (framebuffer_info == state_.bound_draw_framebuffer) { 4390 if (framebuffer_info == state_.bound_draw_framebuffer.get()) {
4390 clear_state_dirty_ = true; 4391 clear_state_dirty_ = true;
4391 } 4392 }
4392 } 4393 }
4393 4394
4394 void GLES2DecoderImpl::DoGetFramebufferAttachmentParameteriv( 4395 void GLES2DecoderImpl::DoGetFramebufferAttachmentParameteriv(
4395 GLenum target, GLenum attachment, GLenum pname, GLint* params) { 4396 GLenum target, GLenum attachment, GLenum pname, GLint* params) {
4396 FramebufferManager::FramebufferInfo* framebuffer_info = 4397 FramebufferManager::FramebufferInfo* framebuffer_info =
4397 GetFramebufferInfoForTarget(target); 4398 GetFramebufferInfoForTarget(target);
4398 if (!framebuffer_info) { 4399 if (!framebuffer_info) {
4399 SetGLError(GL_INVALID_OPERATION, 4400 SetGLError(GL_INVALID_OPERATION,
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
4578 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoLinkProgram"); 4579 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoLinkProgram");
4579 ProgramManager::ProgramInfo* info = GetProgramInfoNotShader( 4580 ProgramManager::ProgramInfo* info = GetProgramInfoNotShader(
4580 program, "glLinkProgram"); 4581 program, "glLinkProgram");
4581 if (!info) { 4582 if (!info) {
4582 return; 4583 return;
4583 } 4584 }
4584 4585
4585 ShaderTranslator* vertex_translator = NULL; 4586 ShaderTranslator* vertex_translator = NULL;
4586 ShaderTranslator* fragment_translator = NULL; 4587 ShaderTranslator* fragment_translator = NULL;
4587 if (use_shader_translator_) { 4588 if (use_shader_translator_) {
4588 vertex_translator = vertex_translator_; 4589 vertex_translator = vertex_translator_.get();
4589 fragment_translator = fragment_translator_; 4590 fragment_translator = fragment_translator_.get();
4590 } 4591 }
4591 if (info->Link(shader_manager(), 4592 if (info->Link(shader_manager(),
4592 vertex_translator, 4593 vertex_translator,
4593 fragment_translator, 4594 fragment_translator,
4594 feature_info_)) { 4595 feature_info_.get())) {
4595 if (info == state_.current_program.get()) { 4596 if (info == state_.current_program.get()) {
4596 if (workarounds().use_current_program_after_successful_link) { 4597 if (workarounds().use_current_program_after_successful_link) {
4597 glUseProgram(info->service_id()); 4598 glUseProgram(info->service_id());
4598 } 4599 }
4599 program_manager()->ClearUniforms(info); 4600 program_manager()->ClearUniforms(info);
4600 } 4601 }
4601 } 4602 }
4602 }; 4603 };
4603 4604
4604 void GLES2DecoderImpl::DoTexParameterf( 4605 void GLES2DecoderImpl::DoTexParameterf(
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
4657 } 4658 }
4658 4659
4659 if (!texture_manager()->SetParameter(info, pname, *params)) { 4660 if (!texture_manager()->SetParameter(info, pname, *params)) {
4660 SetGLErrorInvalidEnum("glTexParameteriv", pname, "pname"); 4661 SetGLErrorInvalidEnum("glTexParameteriv", pname, "pname");
4661 return; 4662 return;
4662 } 4663 }
4663 glTexParameteriv(target, pname, params); 4664 glTexParameteriv(target, pname, params);
4664 } 4665 }
4665 4666
4666 bool GLES2DecoderImpl::CheckCurrentProgram(const char* function_name) { 4667 bool GLES2DecoderImpl::CheckCurrentProgram(const char* function_name) {
4667 if (!state_.current_program) { 4668 if (!state_.current_program.get()) {
4668 // The program does not exist. 4669 // The program does not exist.
4669 SetGLError(GL_INVALID_OPERATION, function_name, "no program in use"); 4670 SetGLError(GL_INVALID_OPERATION, function_name, "no program in use");
4670 return false; 4671 return false;
4671 } 4672 }
4672 if (!state_.current_program->InUse()) { 4673 if (!state_.current_program->InUse()) {
4673 SetGLError(GL_INVALID_OPERATION, function_name, "program not linked"); 4674 SetGLError(GL_INVALID_OPERATION, function_name, "program not linked");
4674 return false; 4675 return false;
4675 } 4676 }
4676 return true; 4677 return true;
4677 } 4678 }
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
4905 if (!info) { 4906 if (!info) {
4906 return; 4907 return;
4907 } 4908 }
4908 if (!info->IsValid()) { 4909 if (!info->IsValid()) {
4909 // Program was not linked successfully. (ie, glLinkProgram) 4910 // Program was not linked successfully. (ie, glLinkProgram)
4910 SetGLError(GL_INVALID_OPERATION, "glUseProgram", "program not linked"); 4911 SetGLError(GL_INVALID_OPERATION, "glUseProgram", "program not linked");
4911 return; 4912 return;
4912 } 4913 }
4913 service_id = info->service_id(); 4914 service_id = info->service_id();
4914 } 4915 }
4915 if (state_.current_program) { 4916 if (state_.current_program.get()) {
4916 program_manager()->UnuseProgram(shader_manager(), state_.current_program); 4917 program_manager()->
4918 UnuseProgram(shader_manager(), state_.current_program.get());
4917 } 4919 }
4918 state_.current_program = info; 4920 state_.current_program = info;
4919 glUseProgram(service_id); 4921 glUseProgram(service_id);
4920 if (state_.current_program) { 4922 if (state_.current_program.get()) {
4921 program_manager()->UseProgram(state_.current_program); 4923 program_manager()->UseProgram(state_.current_program.get());
4922 } 4924 }
4923 } 4925 }
4924 4926
4925 uint32 GLES2DecoderImpl::GetGLError() { 4927 uint32 GLES2DecoderImpl::GetGLError() {
4926 // Check the GL error first, then our wrapped error. 4928 // Check the GL error first, then our wrapped error.
4927 GLenum error = glGetError(); 4929 GLenum error = glGetError();
4928 if (error == GL_NO_ERROR && error_bits_ != 0) { 4930 if (error == GL_NO_ERROR && error_bits_ != 0) {
4929 for (uint32 mask = 1; mask != 0; mask = mask << 1) { 4931 for (uint32 mask = 1; mask != 0; mask = mask << 1) {
4930 if ((error_bits_ & mask) != 0) { 4932 if ((error_bits_ & mask) != 0) {
4931 error = GLES2Util::GLErrorBitToGLError(mask); 4933 error = GLES2Util::GLErrorBitToGLError(mask);
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
5010 ShaderTranslator* translator = NULL; 5012 ShaderTranslator* translator = NULL;
5011 if (use_shader_translator_) { 5013 if (use_shader_translator_) {
5012 translator = info->shader_type() == GL_VERTEX_SHADER ? 5014 translator = info->shader_type() == GL_VERTEX_SHADER ?
5013 vertex_translator_.get() : fragment_translator_.get(); 5015 vertex_translator_.get() : fragment_translator_.get();
5014 } 5016 }
5015 // We know there will be no errors, because we only defer compilation on 5017 // We know there will be no errors, because we only defer compilation on
5016 // shaders that were previously compiled successfully. 5018 // shaders that were previously compiled successfully.
5017 program_manager()->ForceCompileShader(info->deferred_compilation_source(), 5019 program_manager()->ForceCompileShader(info->deferred_compilation_source(),
5018 info, 5020 info,
5019 translator, 5021 translator,
5020 feature_info_); 5022 feature_info_.get());
5021 } 5023 }
5022 } 5024 }
5023 5025
5024 void GLES2DecoderImpl::CopyRealGLErrorsToWrapper() { 5026 void GLES2DecoderImpl::CopyRealGLErrorsToWrapper() {
5025 GLenum error; 5027 GLenum error;
5026 while ((error = glGetError()) != GL_NO_ERROR) { 5028 while ((error = glGetError()) != GL_NO_ERROR) {
5027 SetGLError(error, "", NULL); 5029 SetGLError(error, "", NULL);
5028 } 5030 }
5029 } 5031 }
5030 5032
(...skipping 18 matching lines...) Expand all
5049 state_.current_program->sampler_indices(); 5051 state_.current_program->sampler_indices();
5050 for (size_t ii = 0; ii < sampler_indices.size(); ++ii) { 5052 for (size_t ii = 0; ii < sampler_indices.size(); ++ii) {
5051 const ProgramManager::ProgramInfo::UniformInfo* uniform_info = 5053 const ProgramManager::ProgramInfo::UniformInfo* uniform_info =
5052 state_.current_program->GetUniformInfo(sampler_indices[ii]); 5054 state_.current_program->GetUniformInfo(sampler_indices[ii]);
5053 DCHECK(uniform_info); 5055 DCHECK(uniform_info);
5054 for (size_t jj = 0; jj < uniform_info->texture_units.size(); ++jj) { 5056 for (size_t jj = 0; jj < uniform_info->texture_units.size(); ++jj) {
5055 GLuint texture_unit_index = uniform_info->texture_units[jj]; 5057 GLuint texture_unit_index = uniform_info->texture_units[jj];
5056 if (texture_unit_index < group_->max_texture_units()) { 5058 if (texture_unit_index < group_->max_texture_units()) {
5057 TextureUnit& texture_unit = state_.texture_units[texture_unit_index]; 5059 TextureUnit& texture_unit = state_.texture_units[texture_unit_index];
5058 TextureManager::TextureInfo* texture_info = 5060 TextureManager::TextureInfo* texture_info =
5059 texture_unit.GetInfoForSamplerType(uniform_info->type); 5061 texture_unit.GetInfoForSamplerType(uniform_info->type).get();
5060 if (!texture_info || !texture_manager()->CanRender(texture_info)) { 5062 if (!texture_info || !texture_manager()->CanRender(texture_info)) {
5061 textures_set = true; 5063 textures_set = true;
5062 glActiveTexture(GL_TEXTURE0 + texture_unit_index); 5064 glActiveTexture(GL_TEXTURE0 + texture_unit_index);
5063 glBindTexture( 5065 glBindTexture(
5064 GetBindTargetForSamplerType(uniform_info->type), 5066 GetBindTargetForSamplerType(uniform_info->type),
5065 texture_manager()->black_texture_id(uniform_info->type)); 5067 texture_manager()->black_texture_id(uniform_info->type));
5066 RenderWarning( 5068 RenderWarning(
5067 std::string("texture bound to texture unit ") + 5069 std::string("texture bound to texture unit ") +
5068 base::IntToString(texture_unit_index) + 5070 base::IntToString(texture_unit_index) +
5069 " is not renderable. It maybe non-power-of-2 and have " 5071 " is not renderable. It maybe non-power-of-2 and have "
(...skipping 14 matching lines...) Expand all
5084 for (size_t ii = 0; ii < sampler_indices.size(); ++ii) { 5086 for (size_t ii = 0; ii < sampler_indices.size(); ++ii) {
5085 const ProgramManager::ProgramInfo::UniformInfo* uniform_info = 5087 const ProgramManager::ProgramInfo::UniformInfo* uniform_info =
5086 state_.current_program->GetUniformInfo(sampler_indices[ii]); 5088 state_.current_program->GetUniformInfo(sampler_indices[ii]);
5087 DCHECK(uniform_info); 5089 DCHECK(uniform_info);
5088 for (size_t jj = 0; jj < uniform_info->texture_units.size(); ++jj) { 5090 for (size_t jj = 0; jj < uniform_info->texture_units.size(); ++jj) {
5089 GLuint texture_unit_index = uniform_info->texture_units[jj]; 5091 GLuint texture_unit_index = uniform_info->texture_units[jj];
5090 if (texture_unit_index < group_->max_texture_units()) { 5092 if (texture_unit_index < group_->max_texture_units()) {
5091 TextureUnit& texture_unit = state_.texture_units[texture_unit_index]; 5093 TextureUnit& texture_unit = state_.texture_units[texture_unit_index];
5092 TextureManager::TextureInfo* texture_info = 5094 TextureManager::TextureInfo* texture_info =
5093 uniform_info->type == GL_SAMPLER_2D ? 5095 uniform_info->type == GL_SAMPLER_2D ?
5094 texture_unit.bound_texture_2d : 5096 texture_unit.bound_texture_2d :
5095 texture_unit.bound_texture_cube_map; 5097 texture_unit.bound_texture_cube_map.get();
5096 if (!texture_info || !texture_manager()->CanRender(texture_info)) { 5098 if (!texture_info || !texture_manager()->CanRender(texture_info)) {
5097 glActiveTexture(GL_TEXTURE0 + texture_unit_index); 5099 glActiveTexture(GL_TEXTURE0 + texture_unit_index);
5098 // Get the texture info that was previously bound here. 5100 // Get the texture info that was previously bound here.
5099 texture_info = texture_unit.bind_target == GL_TEXTURE_2D ? 5101 texture_info = texture_unit.bind_target == GL_TEXTURE_2D ?
5100 texture_unit.bound_texture_2d : 5102 texture_unit.bound_texture_2d :
5101 texture_unit.bound_texture_cube_map; 5103 texture_unit.bound_texture_cube_map.get();
5102 glBindTexture(texture_unit.bind_target, 5104 glBindTexture(texture_unit.bind_target,
5103 texture_info ? texture_info->service_id() : 0); 5105 texture_info ? texture_info->service_id() : 0);
5104 } 5106 }
5105 } 5107 }
5106 } 5108 }
5107 } 5109 }
5108 // Set the active texture back to whatever the user had it as. 5110 // Set the active texture back to whatever the user had it as.
5109 glActiveTexture(GL_TEXTURE0 + state_.active_texture_unit); 5111 glActiveTexture(GL_TEXTURE0 + state_.active_texture_unit);
5110 } 5112 }
5111 5113
5112 bool GLES2DecoderImpl::ClearUnclearedTextures() { 5114 bool GLES2DecoderImpl::ClearUnclearedTextures() {
5113 // Only check if there are some uncleared textures. 5115 // Only check if there are some uncleared textures.
5114 if (!texture_manager()->HaveUnsafeTextures()) { 5116 if (!texture_manager()->HaveUnsafeTextures()) {
5115 return true; 5117 return true;
5116 } 5118 }
5117 5119
5118 // 1: Check all textures we are about to render with. 5120 // 1: Check all textures we are about to render with.
5119 if (state_.current_program) { 5121 if (state_.current_program.get()) {
5120 const ProgramManager::ProgramInfo::SamplerIndices& sampler_indices = 5122 const ProgramManager::ProgramInfo::SamplerIndices& sampler_indices =
5121 state_.current_program->sampler_indices(); 5123 state_.current_program->sampler_indices();
5122 for (size_t ii = 0; ii < sampler_indices.size(); ++ii) { 5124 for (size_t ii = 0; ii < sampler_indices.size(); ++ii) {
5123 const ProgramManager::ProgramInfo::UniformInfo* uniform_info = 5125 const ProgramManager::ProgramInfo::UniformInfo* uniform_info =
5124 state_.current_program->GetUniformInfo(sampler_indices[ii]); 5126 state_.current_program->GetUniformInfo(sampler_indices[ii]);
5125 DCHECK(uniform_info); 5127 DCHECK(uniform_info);
5126 for (size_t jj = 0; jj < uniform_info->texture_units.size(); ++jj) { 5128 for (size_t jj = 0; jj < uniform_info->texture_units.size(); ++jj) {
5127 GLuint texture_unit_index = uniform_info->texture_units[jj]; 5129 GLuint texture_unit_index = uniform_info->texture_units[jj];
5128 if (texture_unit_index < group_->max_texture_units()) { 5130 if (texture_unit_index < group_->max_texture_units()) {
5129 TextureUnit& texture_unit = state_.texture_units[texture_unit_index]; 5131 TextureUnit& texture_unit = state_.texture_units[texture_unit_index];
5130 TextureManager::TextureInfo* texture_info = 5132 TextureManager::TextureInfo* texture_info =
5131 texture_unit.GetInfoForSamplerType(uniform_info->type); 5133 texture_unit.GetInfoForSamplerType(uniform_info->type).get();
5132 if (texture_info && !texture_info->SafeToRenderFrom()) { 5134 if (texture_info && !texture_info->SafeToRenderFrom()) {
5133 if (!texture_manager()->ClearRenderableLevels(this, texture_info)) { 5135 if (!texture_manager()->ClearRenderableLevels(this, texture_info)) {
5134 return false; 5136 return false;
5135 } 5137 }
5136 } 5138 }
5137 } 5139 }
5138 } 5140 }
5139 } 5141 }
5140 } 5142 }
5141 return true; 5143 return true;
5142 } 5144 }
5143 5145
5144 bool GLES2DecoderImpl::IsDrawValid( 5146 bool GLES2DecoderImpl::IsDrawValid(
5145 const char* function_name, GLuint max_vertex_accessed, GLsizei primcount) { 5147 const char* function_name, GLuint max_vertex_accessed, GLsizei primcount) {
5146 // NOTE: We specifically do not check current_program->IsValid() because 5148 // NOTE: We specifically do not check current_program->IsValid() because
5147 // it could never be invalid since glUseProgram would have failed. While 5149 // it could never be invalid since glUseProgram would have failed. While
5148 // glLinkProgram could later mark the program as invalid the previous 5150 // glLinkProgram could later mark the program as invalid the previous
5149 // valid program will still function if it is still the current program. 5151 // valid program will still function if it is still the current program.
5150 if (!state_.current_program) { 5152 if (!state_.current_program.get()) {
5151 // The program does not exist. 5153 // The program does not exist.
5152 // But GL says no ERROR. 5154 // But GL says no ERROR.
5153 RenderWarning("Drawing with no current shader program."); 5155 RenderWarning("Drawing with no current shader program.");
5154 return false; 5156 return false;
5155 } 5157 }
5156 5158
5157 // true if any enabled, used divisor is zero 5159 // true if any enabled, used divisor is zero
5158 bool divisor0 = false; 5160 bool divisor0 = false;
5159 // Validate all attribs currently enabled. If they are used by the current 5161 // Validate all attribs currently enabled. If they are used by the current
5160 // program then check that they have enough elements to handle the draw call. 5162 // program then check that they have enough elements to handle the draw call.
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
5280 const void* ptr = reinterpret_cast<const void*>(info->offset()); 5282 const void* ptr = reinterpret_cast<const void*>(info->offset());
5281 BufferManager::BufferInfo* buffer_info = info->buffer(); 5283 BufferManager::BufferInfo* buffer_info = info->buffer();
5282 glBindBuffer(GL_ARRAY_BUFFER, buffer_info ? buffer_info->service_id() : 0); 5284 glBindBuffer(GL_ARRAY_BUFFER, buffer_info ? buffer_info->service_id() : 0);
5283 glVertexAttribPointer( 5285 glVertexAttribPointer(
5284 attrib, info->size(), info->type(), info->normalized(), info->gl_stride(), 5286 attrib, info->size(), info->type(), info->normalized(), info->gl_stride(),
5285 ptr); 5287 ptr);
5286 if (info->divisor()) 5288 if (info->divisor())
5287 glVertexAttribDivisorANGLE(attrib, info->divisor()); 5289 glVertexAttribDivisorANGLE(attrib, info->divisor());
5288 glBindBuffer( 5290 glBindBuffer(
5289 GL_ARRAY_BUFFER, 5291 GL_ARRAY_BUFFER,
5290 state_.bound_array_buffer ? state_.bound_array_buffer->service_id() : 0); 5292 state_.bound_array_buffer.get() ? state_.bound_array_buffer->
5293 service_id() : 0);
5291 5294
5292 // Never touch vertex attribute 0's state (in particular, never 5295 // Never touch vertex attribute 0's state (in particular, never
5293 // disable it) when running on desktop GL because it will never be 5296 // disable it) when running on desktop GL because it will never be
5294 // re-enabled. 5297 // re-enabled.
5295 if (attrib != 0 || 5298 if (attrib != 0 ||
5296 gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2) { 5299 gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2) {
5297 if (info->enabled()) { 5300 if (info->enabled()) {
5298 glEnableVertexAttribArray(attrib); 5301 glEnableVertexAttribArray(attrib);
5299 } else { 5302 } else {
5300 glDisableVertexAttribArray(attrib); 5303 glDisableVertexAttribArray(attrib);
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
5408 } 5411 }
5409 *simulated = true; 5412 *simulated = true;
5410 return true; 5413 return true;
5411 } 5414 }
5412 5415
5413 void GLES2DecoderImpl::RestoreStateForSimulatedFixedAttribs() { 5416 void GLES2DecoderImpl::RestoreStateForSimulatedFixedAttribs() {
5414 // There's no need to call glVertexAttribPointer because we shadow all the 5417 // There's no need to call glVertexAttribPointer because we shadow all the
5415 // settings and passing GL_FIXED to it will not work. 5418 // settings and passing GL_FIXED to it will not work.
5416 glBindBuffer( 5419 glBindBuffer(
5417 GL_ARRAY_BUFFER, 5420 GL_ARRAY_BUFFER,
5418 state_.bound_array_buffer ? state_.bound_array_buffer->service_id() : 0); 5421 state_.bound_array_buffer.get() ? state_.bound_array_buffer->
5422 service_id() : 0);
5419 } 5423 }
5420 5424
5421 error::Error GLES2DecoderImpl::DoDrawArrays( 5425 error::Error GLES2DecoderImpl::DoDrawArrays(
5422 const char* function_name, 5426 const char* function_name,
5423 bool instanced, 5427 bool instanced,
5424 GLenum mode, 5428 GLenum mode,
5425 GLint first, 5429 GLint first,
5426 GLsizei count, 5430 GLsizei count,
5427 GLsizei primcount) { 5431 GLsizei primcount) {
5428 if (ShouldDeferDraws()) 5432 if (ShouldDeferDraws())
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
5717 client_id, "glCompileShader"); 5721 client_id, "glCompileShader");
5718 if (!info) { 5722 if (!info) {
5719 return; 5723 return;
5720 } 5724 }
5721 ShaderTranslator* translator = NULL; 5725 ShaderTranslator* translator = NULL;
5722 if (use_shader_translator_) { 5726 if (use_shader_translator_) {
5723 translator = info->shader_type() == GL_VERTEX_SHADER ? 5727 translator = info->shader_type() == GL_VERTEX_SHADER ?
5724 vertex_translator_.get() : fragment_translator_.get(); 5728 vertex_translator_.get() : fragment_translator_.get();
5725 } 5729 }
5726 5730
5727 program_manager()->DoCompileShader(info, translator, feature_info_); 5731 program_manager()->DoCompileShader(info, translator, feature_info_.get());
5728 }; 5732 };
5729 5733
5730 void GLES2DecoderImpl::DoGetShaderiv( 5734 void GLES2DecoderImpl::DoGetShaderiv(
5731 GLuint shader, GLenum pname, GLint* params) { 5735 GLuint shader, GLenum pname, GLint* params) {
5732 ShaderManager::ShaderInfo* info = GetShaderInfoNotProgram( 5736 ShaderManager::ShaderInfo* info = GetShaderInfoNotProgram(
5733 shader, "glGetShaderiv"); 5737 shader, "glGetShaderiv");
5734 if (!info) { 5738 if (!info) {
5735 return; 5739 return;
5736 } 5740 }
5737 switch (pname) { 5741 switch (pname) {
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
6128 value.v[1] = v[1]; 6132 value.v[1] = v[1];
6129 value.v[2] = v[2]; 6133 value.v[2] = v[2];
6130 value.v[3] = v[3]; 6134 value.v[3] = v[3];
6131 info->set_value(value); 6135 info->set_value(value);
6132 glVertexAttrib4fv(index, v); 6136 glVertexAttrib4fv(index, v);
6133 } 6137 }
6134 6138
6135 error::Error GLES2DecoderImpl::HandleVertexAttribPointer( 6139 error::Error GLES2DecoderImpl::HandleVertexAttribPointer(
6136 uint32 immediate_data_size, const gles2::VertexAttribPointer& c) { 6140 uint32 immediate_data_size, const gles2::VertexAttribPointer& c) {
6137 6141
6138 if (!state_.bound_array_buffer || state_.bound_array_buffer->IsDeleted()) { 6142 if (
6139 if (state_.vertex_attrib_manager == default_vertex_attrib_manager_) { 6143 !state_.bound_array_buffer.get() || state_.bound_array_buffer->
6144 IsDeleted()) {
6145 if (
6146 state_.vertex_attrib_manager.get() ==
6147 default_vertex_attrib_manager_.get()) {
6140 SetGLError(GL_INVALID_VALUE, 6148 SetGLError(GL_INVALID_VALUE,
6141 "glVertexAttribPointer", "no array buffer bound"); 6149 "glVertexAttribPointer", "no array buffer bound");
6142 return error::kNoError; 6150 return error::kNoError;
6143 } else if (c.offset != 0) { 6151 } else if (c.offset != 0) {
6144 SetGLError(GL_INVALID_VALUE, 6152 SetGLError(GL_INVALID_VALUE,
6145 "glVertexAttribPointer", "client side arrays are not allowed"); 6153 "glVertexAttribPointer", "client side arrays are not allowed");
6146 return error::kNoError; 6154 return error::kNoError;
6147 } 6155 }
6148 } 6156 }
6149 6157
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
6189 "glVertexAttribPointer", "offset not valid for type"); 6197 "glVertexAttribPointer", "offset not valid for type");
6190 return error::kNoError; 6198 return error::kNoError;
6191 } 6199 }
6192 if (stride % component_size > 0) { 6200 if (stride % component_size > 0) {
6193 SetGLError(GL_INVALID_OPERATION, 6201 SetGLError(GL_INVALID_OPERATION,
6194 "glVertexAttribPointer", "stride not valid for type"); 6202 "glVertexAttribPointer", "stride not valid for type");
6195 return error::kNoError; 6203 return error::kNoError;
6196 } 6204 }
6197 state_.vertex_attrib_manager->SetAttribInfo( 6205 state_.vertex_attrib_manager->SetAttribInfo(
6198 indx, 6206 indx,
6199 state_.bound_array_buffer, 6207 state_.bound_array_buffer.get(),
6200 size, 6208 size,
6201 type, 6209 type,
6202 normalized, 6210 normalized,
6203 stride, 6211 stride,
6204 stride != 0 ? stride : component_size * size, 6212 stride != 0 ? stride : component_size * size,
6205 offset); 6213 offset);
6206 if (type != GL_FIXED) { 6214 if (type != GL_FIXED) {
6207 glVertexAttribPointer(indx, size, type, normalized, stride, ptr); 6215 glVertexAttribPointer(indx, size, type, normalized, stride, ptr);
6208 } 6216 }
6209 return error::kNoError; 6217 return error::kNoError;
(...skipping 2248 matching lines...) Expand 10 before | Expand all | Expand 10 after
8458 } 8466 }
8459 // NOTE: We don't generate Query objects here. Only in BeginQueryEXT 8467 // NOTE: We don't generate Query objects here. Only in BeginQueryEXT
8460 return true; 8468 return true;
8461 } 8469 }
8462 8470
8463 void GLES2DecoderImpl::DeleteQueriesEXTHelper( 8471 void GLES2DecoderImpl::DeleteQueriesEXTHelper(
8464 GLsizei n, const GLuint* client_ids) { 8472 GLsizei n, const GLuint* client_ids) {
8465 for (GLsizei ii = 0; ii < n; ++ii) { 8473 for (GLsizei ii = 0; ii < n; ++ii) {
8466 QueryManager::Query* query = query_manager_->GetQuery(client_ids[ii]); 8474 QueryManager::Query* query = query_manager_->GetQuery(client_ids[ii]);
8467 if (query && !query->IsDeleted()) { 8475 if (query && !query->IsDeleted()) {
8468 if (query == state_.current_query) { 8476 if (query == state_.current_query.get()) {
8469 state_.current_query = NULL; 8477 state_.current_query = NULL;
8470 } 8478 }
8471 query->Destroy(true); 8479 query->Destroy(true);
8472 query_manager_->RemoveQuery(client_ids[ii]); 8480 query_manager_->RemoveQuery(client_ids[ii]);
8473 } 8481 }
8474 } 8482 }
8475 } 8483 }
8476 8484
8477 bool GLES2DecoderImpl::ProcessPendingQueries() { 8485 bool GLES2DecoderImpl::ProcessPendingQueries() {
8478 if (query_manager_.get() == NULL) { 8486 if (query_manager_.get() == NULL) {
(...skipping 17 matching lines...) Expand all
8496 case GL_LATENCY_QUERY_CHROMIUM: 8504 case GL_LATENCY_QUERY_CHROMIUM:
8497 break; 8505 break;
8498 default: 8506 default:
8499 if (!features().occlusion_query_boolean) { 8507 if (!features().occlusion_query_boolean) {
8500 SetGLError(GL_INVALID_OPERATION, "glBeginQueryEXT", "not enabled"); 8508 SetGLError(GL_INVALID_OPERATION, "glBeginQueryEXT", "not enabled");
8501 return error::kNoError; 8509 return error::kNoError;
8502 } 8510 }
8503 break; 8511 break;
8504 } 8512 }
8505 8513
8506 if (state_.current_query) { 8514 if (state_.current_query.get()) {
8507 SetGLError( 8515 SetGLError(
8508 GL_INVALID_OPERATION, "glBeginQueryEXT", "query already in progress"); 8516 GL_INVALID_OPERATION, "glBeginQueryEXT", "query already in progress");
8509 return error::kNoError; 8517 return error::kNoError;
8510 } 8518 }
8511 8519
8512 if (client_id == 0) { 8520 if (client_id == 0) {
8513 SetGLError(GL_INVALID_OPERATION, "glBeginQueryEXT", "id is 0"); 8521 SetGLError(GL_INVALID_OPERATION, "glBeginQueryEXT", "id is 0");
8514 return error::kNoError; 8522 return error::kNoError;
8515 } 8523 }
8516 8524
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
8553 8561
8554 state_.current_query = query; 8562 state_.current_query = query;
8555 return error::kNoError; 8563 return error::kNoError;
8556 } 8564 }
8557 8565
8558 error::Error GLES2DecoderImpl::HandleEndQueryEXT( 8566 error::Error GLES2DecoderImpl::HandleEndQueryEXT(
8559 uint32 immediate_data_size, const gles2::EndQueryEXT& c) { 8567 uint32 immediate_data_size, const gles2::EndQueryEXT& c) {
8560 GLenum target = static_cast<GLenum>(c.target); 8568 GLenum target = static_cast<GLenum>(c.target);
8561 uint32 submit_count = static_cast<GLuint>(c.submit_count); 8569 uint32 submit_count = static_cast<GLuint>(c.submit_count);
8562 8570
8563 if (!state_.current_query) { 8571 if (!state_.current_query.get()) {
8564 SetGLError(GL_INVALID_OPERATION, "glEndQueryEXT", "No active query"); 8572 SetGLError(GL_INVALID_OPERATION, "glEndQueryEXT", "No active query");
8565 return error::kNoError; 8573 return error::kNoError;
8566 } 8574 }
8567 if (state_.current_query->target() != target) { 8575 if (state_.current_query->target() != target) {
8568 SetGLError(GL_INVALID_OPERATION, 8576 SetGLError(GL_INVALID_OPERATION,
8569 "glEndQueryEXT", "target does not match active query"); 8577 "glEndQueryEXT", "target does not match active query");
8570 return error::kNoError; 8578 return error::kNoError;
8571 } 8579 }
8572 8580
8573 if (!query_manager_->EndQuery(state_.current_query, submit_count)) { 8581 if (!query_manager_->EndQuery(state_.current_query.get(), submit_count)) {
8574 return error::kOutOfBounds; 8582 return error::kOutOfBounds;
8575 } 8583 }
8576 8584
8577 state_.current_query = NULL; 8585 state_.current_query = NULL;
8578 return error::kNoError; 8586 return error::kNoError;
8579 } 8587 }
8580 8588
8581 bool GLES2DecoderImpl::GenVertexArraysOESHelper( 8589 bool GLES2DecoderImpl::GenVertexArraysOESHelper(
8582 GLsizei n, const GLuint* client_ids) { 8590 GLsizei n, const GLuint* client_ids) {
8583 for (GLsizei ii = 0; ii < n; ++ii) { 8591 for (GLsizei ii = 0; ii < n; ++ii) {
(...skipping 18 matching lines...) Expand all
8602 8610
8603 return true; 8611 return true;
8604 } 8612 }
8605 8613
8606 void GLES2DecoderImpl::DeleteVertexArraysOESHelper( 8614 void GLES2DecoderImpl::DeleteVertexArraysOESHelper(
8607 GLsizei n, const GLuint* client_ids) { 8615 GLsizei n, const GLuint* client_ids) {
8608 for (GLsizei ii = 0; ii < n; ++ii) { 8616 for (GLsizei ii = 0; ii < n; ++ii) {
8609 VertexAttribManager* vao = 8617 VertexAttribManager* vao =
8610 GetVertexAttribManager(client_ids[ii]); 8618 GetVertexAttribManager(client_ids[ii]);
8611 if (vao && !vao->IsDeleted()) { 8619 if (vao && !vao->IsDeleted()) {
8612 if (state_.vertex_attrib_manager == vao) { 8620 if (state_.vertex_attrib_manager.get() == vao) {
8613 state_.vertex_attrib_manager = default_vertex_attrib_manager_; 8621 state_.vertex_attrib_manager = default_vertex_attrib_manager_;
8614 } 8622 }
8615 RemoveVertexAttribManager(client_ids[ii]); 8623 RemoveVertexAttribManager(client_ids[ii]);
8616 } 8624 }
8617 } 8625 }
8618 } 8626 }
8619 8627
8620 void GLES2DecoderImpl::DoBindVertexArrayOES(GLuint client_id) { 8628 void GLES2DecoderImpl::DoBindVertexArrayOES(GLuint client_id) {
8621 VertexAttribManager* vao = NULL; 8629 VertexAttribManager* vao = NULL;
8622 GLuint service_id = 0; 8630 GLuint service_id = 0;
8623 if (client_id != 0) { 8631 if (client_id != 0) {
8624 vao = GetVertexAttribManager(client_id); 8632 vao = GetVertexAttribManager(client_id);
8625 if (!vao) { 8633 if (!vao) {
8626 // Unlike most Bind* methods, the spec explicitly states that VertexArray 8634 // Unlike most Bind* methods, the spec explicitly states that VertexArray
8627 // only allows names that have been previously generated. As such, we do 8635 // only allows names that have been previously generated. As such, we do
8628 // not generate new names here. 8636 // not generate new names here.
8629 SetGLError(GL_INVALID_OPERATION, 8637 SetGLError(GL_INVALID_OPERATION,
8630 "glBindVertexArrayOES", "" 8638 "glBindVertexArrayOES", ""
8631 "bad vertex array id."); 8639 "bad vertex array id.");
8632 current_decoder_error_ = error::kNoError; 8640 current_decoder_error_ = error::kNoError;
8633 return; 8641 return;
8634 } else { 8642 } else {
8635 service_id = vao->service_id(); 8643 service_id = vao->service_id();
8636 } 8644 }
8637 } else { 8645 } else {
8638 vao = default_vertex_attrib_manager_; 8646 vao = default_vertex_attrib_manager_.get();
8639 } 8647 }
8640 8648
8641 // Only set the VAO state if it's changed 8649 // Only set the VAO state if it's changed
8642 if (state_.vertex_attrib_manager != vao) { 8650 if (state_.vertex_attrib_manager.get() != vao) {
8643 state_.vertex_attrib_manager = vao; 8651 state_.vertex_attrib_manager = vao;
8644 if (!features().native_vertex_array_object) { 8652 if (!features().native_vertex_array_object) {
8645 EmulateVertexArrayState(); 8653 EmulateVertexArrayState();
8646 } else { 8654 } else {
8647 glBindVertexArrayOES(service_id); 8655 glBindVertexArrayOES(service_id);
8648 } 8656 }
8649 } 8657 }
8650 } 8658 }
8651 8659
8652 // Used when OES_vertex_array_object isn't natively supported 8660 // Used when OES_vertex_array_object isn't natively supported
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
8992 copy_texture_CHROMIUM_->DoCopyTexture(target, source_info->service_id(), 9000 copy_texture_CHROMIUM_->DoCopyTexture(target, source_info->service_id(),
8993 dest_info->service_id(), level, 9001 dest_info->service_id(), level,
8994 unpack_flip_y_, 9002 unpack_flip_y_,
8995 unpack_premultiply_alpha_, 9003 unpack_premultiply_alpha_,
8996 unpack_unpremultiply_alpha_); 9004 unpack_unpremultiply_alpha_);
8997 glViewport( 9005 glViewport(
8998 state_.viewport_x, state_.viewport_y, 9006 state_.viewport_x, state_.viewport_y,
8999 state_.viewport_width, state_.viewport_height); 9007 state_.viewport_width, state_.viewport_height);
9000 9008
9001 // Restore all of the state touched by the extension. 9009 // Restore all of the state touched by the extension.
9002 if (state_.current_program) 9010 if (state_.current_program.get())
9003 glUseProgram(state_.current_program->service_id()); 9011 glUseProgram(state_.current_program->service_id());
9004 else 9012 else
9005 glUseProgram(0); 9013 glUseProgram(0);
9006 9014
9007 RestoreCurrentFramebufferBindings(); 9015 RestoreCurrentFramebufferBindings();
9008 RestoreCurrentTexture2DBindings(); 9016 RestoreCurrentTexture2DBindings();
9009 RestoreStateForAttrib( 9017 RestoreStateForAttrib(
9010 CopyTextureCHROMIUMResourceManager::kVertexPositionAttrib); 9018 CopyTextureCHROMIUMResourceManager::kVertexPositionAttrib);
9011 RestoreStateForAttrib( 9019 RestoreStateForAttrib(
9012 CopyTextureCHROMIUMResourceManager::kVertexTextureAttrib); 9020 CopyTextureCHROMIUMResourceManager::kVertexTextureAttrib);
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
9283 GL_RGBA, GL_UNSIGNED_BYTE, false); 9291 GL_RGBA, GL_UNSIGNED_BYTE, false);
9284 } 9292 }
9285 9293
9286 // Include the auto-generated part of this file. We split this because it means 9294 // Include the auto-generated part of this file. We split this because it means
9287 // we can easily edit the non-auto generated parts right here in this file 9295 // we can easily edit the non-auto generated parts right here in this file
9288 // instead of having to edit some template or the code generator. 9296 // instead of having to edit some template or the code generator.
9289 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 9297 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
9290 9298
9291 } // namespace gles2 9299 } // namespace gles2
9292 } // namespace gpu 9300 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/context_state.h ('k') | gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698