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

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

Issue 1747013: Changes the code to use separate ids namspaces... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 <vector> 10 #include <vector>
11 #include <string> 11 #include <string>
12 #include <map> 12 #include <map>
13 13
14 #include "app/gfx/gl/gl_context.h" 14 #include "app/gfx/gl/gl_context.h"
15 #include "base/callback.h" 15 #include "base/callback.h"
16 #include "base/linked_ptr.h" 16 #include "base/linked_ptr.h"
17 #include "base/scoped_ptr.h" 17 #include "base/scoped_ptr.h"
18 #include "base/weak_ptr.h" 18 #include "base/weak_ptr.h"
19 #include "build/build_config.h" 19 #include "build/build_config.h"
20 #define GLES2_GPU_SERVICE 1 20 #define GLES2_GPU_SERVICE 1
21 #include "gpu/command_buffer/common/gles2_cmd_format.h" 21 #include "gpu/command_buffer/common/gles2_cmd_format.h"
22 #include "gpu/command_buffer/common/gles2_cmd_utils.h" 22 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
23 #include "gpu/command_buffer/service/buffer_manager.h" 23 #include "gpu/command_buffer/service/buffer_manager.h"
24 #include "gpu/command_buffer/service/cmd_buffer_engine.h" 24 #include "gpu/command_buffer/service/cmd_buffer_engine.h"
25 #include "gpu/command_buffer/service/context_group.h" 25 #include "gpu/command_buffer/service/context_group.h"
26 #include "gpu/command_buffer/service/framebuffer_manager.h" 26 #include "gpu/command_buffer/service/framebuffer_manager.h"
27 #include "gpu/command_buffer/service/gl_utils.h" 27 #include "gpu/command_buffer/service/gl_utils.h"
28 #include "gpu/command_buffer/service/gles2_cmd_validation.h" 28 #include "gpu/command_buffer/service/gles2_cmd_validation.h"
29 #include "gpu/command_buffer/service/id_manager.h"
30 #include "gpu/command_buffer/service/program_manager.h" 29 #include "gpu/command_buffer/service/program_manager.h"
31 #include "gpu/command_buffer/service/renderbuffer_manager.h" 30 #include "gpu/command_buffer/service/renderbuffer_manager.h"
32 #include "gpu/command_buffer/service/shader_manager.h" 31 #include "gpu/command_buffer/service/shader_manager.h"
33 #include "gpu/command_buffer/service/texture_manager.h" 32 #include "gpu/command_buffer/service/texture_manager.h"
34 33
35 // TODO(alokp): Remove GLES2_GPU_SERVICE_TRANSLATE_SHADER guard 34 // TODO(alokp): Remove GLES2_GPU_SERVICE_TRANSLATE_SHADER guard
36 // as soon as translator is ready. 35 // as soon as translator is ready.
37 //#define GLES2_GPU_SERVICE_TRANSLATE_SHADER 36 //#define GLES2_GPU_SERVICE_TRANSLATE_SHADER
38 #if defined(GLES2_GPU_SERVICE_TRANSLATE_SHADER) 37 #if defined(GLES2_GPU_SERVICE_TRANSLATE_SHADER)
39 #include "third_party/angleproject/include/GLSLANG/ShaderLang.h" 38 #include "third_party/angleproject/include/GLSLANG/ShaderLang.h"
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 virtual const char* GetCommandName(unsigned int command_id) const; 375 virtual const char* GetCommandName(unsigned int command_id) const;
377 376
378 // Overridden from GLES2Decoder. 377 // Overridden from GLES2Decoder.
379 virtual bool Initialize(gfx::GLContext* context, 378 virtual bool Initialize(gfx::GLContext* context,
380 const gfx::Size& size, 379 const gfx::Size& size,
381 GLES2Decoder* parent, 380 GLES2Decoder* parent,
382 uint32 parent_client_texture_id); 381 uint32 parent_client_texture_id);
383 virtual void Destroy(); 382 virtual void Destroy();
384 virtual void ResizeOffscreenFrameBuffer(const gfx::Size& size); 383 virtual void ResizeOffscreenFrameBuffer(const gfx::Size& size);
385 virtual bool MakeCurrent(); 384 virtual bool MakeCurrent();
386 virtual uint32 GetServiceIdForTesting(uint32 client_id);
387 virtual GLES2Util* GetGLES2Util() { return &util_; } 385 virtual GLES2Util* GetGLES2Util() { return &util_; }
388 virtual gfx::GLContext* GetGLContext() { return context_; } 386 virtual gfx::GLContext* GetGLContext() { return context_; }
389 387
390 virtual void SetSwapBuffersCallback(Callback0::Type* callback); 388 virtual void SetSwapBuffersCallback(Callback0::Type* callback);
391 389
392 private: 390 private:
393 friend class ScopedGLErrorSuppressor; 391 friend class ScopedGLErrorSuppressor;
394 friend class ScopedTexture2DBinder; 392 friend class ScopedTexture2DBinder;
395 friend class ScopedFrameBufferBinder; 393 friend class ScopedFrameBufferBinder;
396 friend class ScopedRenderBufferBinder; 394 friend class ScopedRenderBufferBinder;
397 friend class ScopedDefaultGLContext; 395 friend class ScopedDefaultGLContext;
398 friend class RenderBuffer; 396 friend class RenderBuffer;
399 friend class FrameBuffer; 397 friend class FrameBuffer;
400 398
401 // State associated with each texture unit. 399 // State associated with each texture unit.
402 struct TextureUnit { 400 struct TextureUnit {
403 TextureUnit() : bind_target(GL_TEXTURE_2D) { } 401 TextureUnit() : bind_target(GL_TEXTURE_2D) { }
404 402
405 // The last target that was bound to this texture unit. 403 // The last target that was bound to this texture unit.
406 GLenum bind_target; 404 GLenum bind_target;
407 405
408 // texture currently bound to this unit's GL_TEXTURE_2D with glBindTexture 406 // texture currently bound to this unit's GL_TEXTURE_2D with glBindTexture
409 TextureManager::TextureInfo::Ref bound_texture_2d; 407 TextureManager::TextureInfo::Ref bound_texture_2d;
410 408
411 // texture currently bound to this unit's GL_TEXTURE_CUBE_MAP with 409 // texture currently bound to this unit's GL_TEXTURE_CUBE_MAP with
412 // glBindTexture 410 // glBindTexture
413 TextureManager::TextureInfo::Ref bound_texture_cube_map; 411 TextureManager::TextureInfo::Ref bound_texture_cube_map;
414 }; 412 };
415 413
416 friend void GLGenTexturesHelper( 414 // Helpers for the glGen and glDelete functions.
417 GLES2DecoderImpl* decoder, GLsizei n, GLuint* ids); 415 bool GenTexturesHelper(GLsizei n, const GLuint* client_ids);
418 friend void GLDeleteTexturesHelper( 416 void DeleteTexturesHelper(GLsizei n, const GLuint* client_ids);
419 GLES2DecoderImpl* decoder, GLsizei n, GLuint* ids); 417 bool GenBuffersHelper(GLsizei n, const GLuint* client_ids);
420 friend void GLGenBuffersHelper( 418 void DeleteBuffersHelper(GLsizei n, const GLuint* client_ids);
421 GLES2DecoderImpl* decoder, GLsizei n, GLuint* ids); 419 bool GenFramebuffersHelper(GLsizei n, const GLuint* client_ids);
422 friend void GLDeleteBuffersHelper( 420 void DeleteFramebuffersHelper(GLsizei n, const GLuint* client_ids);
423 GLES2DecoderImpl* decoder, GLsizei n, GLuint* ids); 421 bool GenRenderbuffersHelper(GLsizei n, const GLuint* client_ids);
424 friend void GLGenFramebuffersHelper( 422 void DeleteRenderbuffersHelper(GLsizei n, const GLuint* client_ids);
425 GLES2DecoderImpl* decoder, GLsizei n, GLuint* ids);
426 friend void GLDeleteFramebuffersHelper(
427 GLES2DecoderImpl* decoder, GLsizei n, GLuint* ids);
428 friend void GLGenRenderbuffersHelper(
429 GLES2DecoderImpl* decoder, GLsizei n, GLuint* ids);
430 friend void GLDeleteRenderbuffersHelper(
431 GLES2DecoderImpl* decoder, GLsizei n, GLuint* ids);
432 423
433 // TODO(gman): Cache these pointers? 424 // TODO(gman): Cache these pointers?
434 IdManager* id_manager() {
435 return group_->id_manager();
436 }
437
438 BufferManager* buffer_manager() { 425 BufferManager* buffer_manager() {
439 return group_->buffer_manager(); 426 return group_->buffer_manager();
440 } 427 }
441 428
442 RenderbufferManager* renderbuffer_manager() { 429 RenderbufferManager* renderbuffer_manager() {
443 return group_->renderbuffer_manager(); 430 return group_->renderbuffer_manager();
444 } 431 }
445 432
446 FramebufferManager* framebuffer_manager() { 433 FramebufferManager* framebuffer_manager() {
447 return group_->framebuffer_manager(); 434 return group_->framebuffer_manager();
448 } 435 }
449 436
450 ProgramManager* program_manager() { 437 ProgramManager* program_manager() {
451 return group_->program_manager(); 438 return group_->program_manager();
452 } 439 }
453 440
454 ShaderManager* shader_manager() { 441 ShaderManager* shader_manager() {
455 return group_->shader_manager(); 442 return group_->shader_manager();
456 } 443 }
457 444
458 TextureManager* texture_manager() { 445 TextureManager* texture_manager() {
459 return group_->texture_manager(); 446 return group_->texture_manager();
460 } 447 }
461 448
462 bool UpdateOffscreenFrameBufferSize(); 449 bool UpdateOffscreenFrameBufferSize();
463 450
464 // Template to help call glGenXXX functions.
465 template <void gl_gen_function(GLES2DecoderImpl*, GLsizei, GLuint*)>
466 bool GenGLObjects(GLsizei n, const GLuint* client_ids) {
467 DCHECK_GE(n, 0);
468 if (!ValidateIdsAreUnused(n, client_ids)) {
469 return false;
470 }
471 scoped_array<GLuint>temp(new GLuint[n]);
472 gl_gen_function(this, n, temp.get());
473 return RegisterObjects(n, client_ids, temp.get());
474 }
475
476 // Template to help call glDeleteXXX functions.
477 template <void gl_delete_function(GLES2DecoderImpl*, GLsizei, GLuint*)>
478 bool DeleteGLObjects(GLsizei n, const GLuint* client_ids) {
479 DCHECK_GE(n, 0);
480 scoped_array<GLuint>temp(new GLuint[n]);
481 UnregisterObjects(n, client_ids, temp.get());
482 gl_delete_function(this, n, temp.get());
483 return true;
484 }
485
486 // Check that the given ids are not used.
487 bool ValidateIdsAreUnused(GLsizei n, const GLuint* client_ids);
488
489 // Register client ids with generated service ids.
490 bool RegisterObjects(
491 GLsizei n, const GLuint* client_ids, const GLuint* service_ids);
492
493 // Unregisters client ids with service ids.
494 void UnregisterObjects(
495 GLsizei n, const GLuint* client_ids, GLuint* service_ids);
496
497 // Creates a TextureInfo for the given texture. 451 // Creates a TextureInfo for the given texture.
498 TextureManager::TextureInfo* CreateTextureInfo(GLuint texture) { 452 TextureManager::TextureInfo* CreateTextureInfo(
499 return texture_manager()->CreateTextureInfo(texture); 453 GLuint client_id, GLuint service_id) {
454 return texture_manager()->CreateTextureInfo(client_id, service_id);
500 } 455 }
501 456
502 // Gets the texture info for the given texture. Returns NULL if none exists. 457 // Gets the texture info for the given texture. Returns NULL if none exists.
503 TextureManager::TextureInfo* GetTextureInfo(GLuint texture) { 458 TextureManager::TextureInfo* GetTextureInfo(GLuint client_id) {
504 TextureManager::TextureInfo* info = 459 TextureManager::TextureInfo* info =
505 texture_manager()->GetTextureInfo(texture); 460 texture_manager()->GetTextureInfo(client_id);
506 return (info && !info->IsDeleted()) ? info : NULL; 461 return (info && !info->IsDeleted()) ? info : NULL;
507 } 462 }
508 463
509 // Deletes the texture info for the given texture. 464 // Deletes the texture info for the given texture.
510 void RemoveTextureInfo(GLuint texture) { 465 void RemoveTextureInfo(GLuint client_id) {
511 texture_manager()->RemoveTextureInfo(texture); 466 texture_manager()->RemoveTextureInfo(client_id);
512 } 467 }
513 468
514 // Get the size (in pixels) of the currently bound frame buffer (either FBO 469 // Get the size (in pixels) of the currently bound frame buffer (either FBO
515 // or regular back buffer). 470 // or regular back buffer).
516 gfx::Size GetBoundFrameBufferSize(); 471 gfx::Size GetBoundFrameBufferSize();
517 472
518 // Wrapper for CompressedTexImage2D commands. 473 // Wrapper for CompressedTexImage2D commands.
519 error::Error DoCompressedTexImage2D( 474 error::Error DoCompressedTexImage2D(
520 GLenum target, 475 GLenum target,
521 GLint level, 476 GLint level,
(...skipping 11 matching lines...) Expand all
533 GLenum internal_format, 488 GLenum internal_format,
534 GLsizei width, 489 GLsizei width,
535 GLsizei height, 490 GLsizei height,
536 GLint border, 491 GLint border,
537 GLenum format, 492 GLenum format,
538 GLenum type, 493 GLenum type,
539 const void* pixels, 494 const void* pixels,
540 uint32 pixels_size); 495 uint32 pixels_size);
541 496
542 // Creates a ProgramInfo for the given program. 497 // Creates a ProgramInfo for the given program.
543 void CreateProgramInfo(GLuint program) { 498 void CreateProgramInfo(GLuint client_id, GLuint service_id) {
544 program_manager()->CreateProgramInfo(program); 499 program_manager()->CreateProgramInfo(client_id, service_id);
545 } 500 }
546 501
547 // Gets the program info for the given program. Returns NULL if none exists. 502 // Gets the program info for the given program. Returns NULL if none exists.
548 // Programs that have no had glLinkProgram succesfully called on them will 503 ProgramManager::ProgramInfo* GetProgramInfo(GLuint client_id) {
549 // not exist.
550 ProgramManager::ProgramInfo* GetProgramInfo(GLuint program) {
551 ProgramManager::ProgramInfo* info = 504 ProgramManager::ProgramInfo* info =
552 program_manager()->GetProgramInfo(program); 505 program_manager()->GetProgramInfo(client_id);
553 return (info && !info->IsDeleted()) ? info : NULL; 506 return (info && !info->IsDeleted()) ? info : NULL;
554 } 507 }
555 508
556 // Deletes the program info for the given program. 509 // Deletes the program info for the given program.
557 void RemoveProgramInfo(GLuint program) { 510 void RemoveProgramInfo(GLuint client_id) {
558 program_manager()->RemoveProgramInfo(program); 511 program_manager()->RemoveProgramInfo(client_id);
559 } 512 }
560 513
561 // Creates a ShaderInfo for the given shader. 514 // Creates a ShaderInfo for the given shader.
562 void CreateShaderInfo(GLuint shader) { 515 void CreateShaderInfo(GLuint client_id, GLuint service_id) {
563 shader_manager()->CreateShaderInfo(shader); 516 shader_manager()->CreateShaderInfo(client_id, service_id);
564 } 517 }
565 518
566 // Gets the shader info for the given shader. Returns NULL if none exists. 519 // Gets the shader info for the given shader. Returns NULL if none exists.
567 ShaderManager::ShaderInfo* GetShaderInfo(GLuint shader) { 520 ShaderManager::ShaderInfo* GetShaderInfo(GLuint client_id) {
568 ShaderManager::ShaderInfo* info = shader_manager()->GetShaderInfo(shader); 521 ShaderManager::ShaderInfo* info =
522 shader_manager()->GetShaderInfo(client_id);
569 return (info && !info->IsDeleted()) ? info : NULL; 523 return (info && !info->IsDeleted()) ? info : NULL;
570 } 524 }
571 525
572 // Deletes the shader info for the given shader. 526 // Deletes the shader info for the given shader.
573 void RemoveShaderInfo(GLuint shader) { 527 void RemoveShaderInfo(GLuint client_id) {
574 shader_manager()->RemoveShaderInfo(shader); 528 shader_manager()->RemoveShaderInfo(client_id);
575 } 529 }
576 530
577 // Creates a buffer info for the given buffer. 531 // Creates a buffer info for the given buffer.
578 void CreateBufferInfo(GLuint buffer) { 532 void CreateBufferInfo(GLuint client_id, GLuint service_id) {
579 return buffer_manager()->CreateBufferInfo(buffer); 533 return buffer_manager()->CreateBufferInfo(client_id, service_id);
580 } 534 }
581 535
582 // Gets the buffer info for the given buffer. 536 // Gets the buffer info for the given buffer.
583 BufferManager::BufferInfo* GetBufferInfo(GLuint buffer) { 537 BufferManager::BufferInfo* GetBufferInfo(GLuint client_id) {
584 BufferManager::BufferInfo* info = buffer_manager()->GetBufferInfo(buffer); 538 BufferManager::BufferInfo* info =
539 buffer_manager()->GetBufferInfo(client_id);
585 return (info && !info->IsDeleted()) ? info : NULL; 540 return (info && !info->IsDeleted()) ? info : NULL;
586 } 541 }
587 542
588 // Removes any buffers in the VertexAtrribInfos and BufferInfos. This is used 543 // Removes any buffers in the VertexAtrribInfos and BufferInfos. This is used
589 // on glDeleteBuffers so we can make sure the user does not try to render 544 // on glDeleteBuffers so we can make sure the user does not try to render
590 // with deleted buffers. 545 // with deleted buffers.
591 void RemoveBufferInfo(GLuint buffer_id); 546 void RemoveBufferInfo(GLuint client_id);
592 547
593 // Creates a framebuffer info for the given framebuffer. 548 // Creates a framebuffer info for the given framebuffer.
594 void CreateFramebufferInfo(GLuint framebuffer) { 549 void CreateFramebufferInfo(GLuint client_id, GLuint service_id) {
595 return framebuffer_manager()->CreateFramebufferInfo(framebuffer); 550 return framebuffer_manager()->CreateFramebufferInfo(client_id, service_id);
596 } 551 }
597 552
598 // Gets the framebuffer info for the given framebuffer. 553 // Gets the framebuffer info for the given framebuffer.
599 FramebufferManager::FramebufferInfo* GetFramebufferInfo( 554 FramebufferManager::FramebufferInfo* GetFramebufferInfo(
600 GLuint framebuffer) { 555 GLuint client_id) {
601 FramebufferManager::FramebufferInfo* info = 556 FramebufferManager::FramebufferInfo* info =
602 framebuffer_manager()->GetFramebufferInfo(framebuffer); 557 framebuffer_manager()->GetFramebufferInfo(client_id);
603 return (info && !info->IsDeleted()) ? info : NULL; 558 return (info && !info->IsDeleted()) ? info : NULL;
604 } 559 }
605 560
606 // Removes the framebuffer info for the given framebuffer. 561 // Removes the framebuffer info for the given framebuffer.
607 void RemoveFramebufferInfo(GLuint framebuffer_id) { 562 void RemoveFramebufferInfo(GLuint client_id) {
608 framebuffer_manager()->RemoveFramebufferInfo(framebuffer_id); 563 framebuffer_manager()->RemoveFramebufferInfo(client_id);
609 } 564 }
610 565
611 // Creates a renderbuffer info for the given renderbuffer. 566 // Creates a renderbuffer info for the given renderbuffer.
612 void CreateRenderbufferInfo(GLuint renderbuffer) { 567 void CreateRenderbufferInfo(GLuint client_id, GLuint service_id) {
613 return renderbuffer_manager()->CreateRenderbufferInfo(renderbuffer); 568 return renderbuffer_manager()->CreateRenderbufferInfo(
569 client_id, service_id);
614 } 570 }
615 571
616 // Gets the renderbuffer info for the given renderbuffer. 572 // Gets the renderbuffer info for the given renderbuffer.
617 RenderbufferManager::RenderbufferInfo* GetRenderbufferInfo( 573 RenderbufferManager::RenderbufferInfo* GetRenderbufferInfo(
618 GLuint renderbuffer) { 574 GLuint client_id) {
619 RenderbufferManager::RenderbufferInfo* info = 575 RenderbufferManager::RenderbufferInfo* info =
620 renderbuffer_manager()->GetRenderbufferInfo(renderbuffer); 576 renderbuffer_manager()->GetRenderbufferInfo(client_id);
621 return (info && !info->IsDeleted()) ? info : NULL; 577 return (info && !info->IsDeleted()) ? info : NULL;
622 } 578 }
623 579
624 // Removes the renderbuffer info for the given renderbuffer. 580 // Removes the renderbuffer info for the given renderbuffer.
625 void RemoveRenderbufferInfo(GLuint renderbuffer_id) { 581 void RemoveRenderbufferInfo(GLuint client_id) {
626 renderbuffer_manager()->RemoveRenderbufferInfo(renderbuffer_id); 582 renderbuffer_manager()->RemoveRenderbufferInfo(client_id);
627 } 583 }
628 584
629 error::Error GetAttribLocationHelper( 585 error::Error GetAttribLocationHelper(
630 GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset, 586 GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset,
631 const std::string& name_str); 587 const std::string& name_str);
632 588
633 error::Error GetUniformLocationHelper( 589 error::Error GetUniformLocationHelper(
634 GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset, 590 GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset,
635 const std::string& name_str); 591 const std::string& name_str);
636 592
637 // Helper for glShaderSource. 593 // Helper for glShaderSource.
638 error::Error ShaderSourceHelper( 594 error::Error ShaderSourceHelper(
639 GLuint shader, const char* data, uint32 data_size); 595 GLuint client_id, const char* data, uint32 data_size);
640 596
641 // Helper for glGetBooleanv, glGetFloatv and glGetIntegerv 597 // Helper for glGetBooleanv, glGetFloatv and glGetIntegerv
642 bool GetHelper(GLenum pname, GLint* params, GLsizei* num_written); 598 bool GetHelper(GLenum pname, GLint* params, GLsizei* num_written);
643 599
644 // Wrapper for glCreateProgram 600 // Wrapper for glCreateProgram
645 void CreateProgramHelper(GLuint client_id); 601 bool CreateProgramHelper(GLuint client_id);
646 602
647 // Wrapper for glCreateShader 603 // Wrapper for glCreateShader
648 void CreateShaderHelper(GLenum type, GLuint client_id); 604 bool CreateShaderHelper(GLenum type, GLuint client_id);
649 605
650 // Wrapper for glActiveTexture 606 // Wrapper for glActiveTexture
651 void DoActiveTexture(GLenum texture_unit); 607 void DoActiveTexture(GLenum texture_unit);
652 608
609 // Wrapper for glAttachShader
610 void DoAttachShader(GLuint client_program_id, GLint client_shader_id);
611
653 // Wrapper for glBindBuffer since we need to track the current targets. 612 // Wrapper for glBindBuffer since we need to track the current targets.
654 void DoBindBuffer(GLenum target, GLuint buffer); 613 void DoBindBuffer(GLenum target, GLuint buffer);
655 614
656 // Wrapper for glBindFramebuffer since we need to track the current targets. 615 // Wrapper for glBindFramebuffer since we need to track the current targets.
657 void DoBindFramebuffer(GLenum target, GLuint framebuffer); 616 void DoBindFramebuffer(GLenum target, GLuint framebuffer);
658 617
659 // Wrapper for glBindRenderbuffer since we need to track the current targets. 618 // Wrapper for glBindRenderbuffer since we need to track the current targets.
660 void DoBindRenderbuffer(GLenum target, GLuint renderbuffer); 619 void DoBindRenderbuffer(GLenum target, GLuint renderbuffer);
661 620
662 // Wrapper for glBindTexture since we need to track the current targets. 621 // Wrapper for glBindTexture since we need to track the current targets.
663 void DoBindTexture(GLenum target, GLuint texture); 622 void DoBindTexture(GLenum target, GLuint texture);
664 623
665 // Wrapper for glBufferData. 624 // Wrapper for glBufferData.
666 void DoBufferData( 625 void DoBufferData(
667 GLenum target, GLsizeiptr size, const GLvoid * data, GLenum usage); 626 GLenum target, GLsizeiptr size, const GLvoid * data, GLenum usage);
668 627
669 // Wrapper for glBufferSubData. 628 // Wrapper for glBufferSubData.
670 void DoBufferSubData( 629 void DoBufferSubData(
671 GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid * data); 630 GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid * data);
672 631
673 // Wrapper for glCheckFramebufferStatus 632 // Wrapper for glCheckFramebufferStatus
674 GLenum DoCheckFramebufferStatus(GLenum target); 633 GLenum DoCheckFramebufferStatus(GLenum target);
675 634
676 // Wrapper for glCompileShader. 635 // Wrapper for glCompileShader.
677 void DoCompileShader(GLuint shader); 636 void DoCompileShader(GLuint shader);
678 637
638 // Wrapper for glDetachShader
639 void DoDetachShader(GLuint client_program_id, GLint client_shader_id);
640
679 // Wrapper for glDrawArrays. 641 // Wrapper for glDrawArrays.
680 void DoDrawArrays(GLenum mode, GLint first, GLsizei count); 642 void DoDrawArrays(GLenum mode, GLint first, GLsizei count);
681 643
682 // Wrapper for glDisableVertexAttribArray. 644 // Wrapper for glDisableVertexAttribArray.
683 void DoDisableVertexAttribArray(GLuint index); 645 void DoDisableVertexAttribArray(GLuint index);
684 646
685 // Wrapper for glEnableVertexAttribArray. 647 // Wrapper for glEnableVertexAttribArray.
686 void DoEnableVertexAttribArray(GLuint index); 648 void DoEnableVertexAttribArray(GLuint index);
687 649
688 // Wrapper for glFramebufferRenderbufffer. 650 // Wrapper for glFramebufferRenderbufffer.
(...skipping 30 matching lines...) Expand all
719 void DoGetProgramiv( 681 void DoGetProgramiv(
720 GLuint program_id, GLenum pname, GLint* params); 682 GLuint program_id, GLenum pname, GLint* params);
721 683
722 // Wrapper for glRenderbufferParameteriv. 684 // Wrapper for glRenderbufferParameteriv.
723 void DoGetRenderbufferParameteriv( 685 void DoGetRenderbufferParameteriv(
724 GLenum target, GLenum pname, GLint* params); 686 GLenum target, GLenum pname, GLint* params);
725 687
726 // Wrapper for glGetShaderiv 688 // Wrapper for glGetShaderiv
727 void DoGetShaderiv(GLuint shader, GLenum pname, GLint* params); 689 void DoGetShaderiv(GLuint shader, GLenum pname, GLint* params);
728 690
729 // Wrapper for glGetShaderSource.
730 void DoGetShaderSource(
731 GLuint shader, GLsizei bufsize, GLsizei* length, char* dst);
732
733 // Wrappers for glIsXXX functions. 691 // Wrappers for glIsXXX functions.
734 bool DoIsBuffer(GLuint client_id); 692 bool DoIsBuffer(GLuint client_id);
735 bool DoIsFramebuffer(GLuint client_id); 693 bool DoIsFramebuffer(GLuint client_id);
736 bool DoIsProgram(GLuint client_id); 694 bool DoIsProgram(GLuint client_id);
737 bool DoIsRenderbuffer(GLuint client_id); 695 bool DoIsRenderbuffer(GLuint client_id);
738 bool DoIsShader(GLuint client_id); 696 bool DoIsShader(GLuint client_id);
739 bool DoIsTexture(GLuint client_id); 697 bool DoIsTexture(GLuint client_id);
740 698
741 // Wrapper for glLinkProgram 699 // Wrapper for glLinkProgram
742 void DoLinkProgram(GLuint program); 700 void DoLinkProgram(GLuint program);
743 701
744 // Wrapper for glRenderbufferStorage. 702 // Wrapper for glRenderbufferStorage.
745 void DoRenderbufferStorage( 703 void DoRenderbufferStorage(
746 GLenum target, GLenum internalformat, GLsizei width, GLsizei height); 704 GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
747 705
748 // Wrapper for glReleaseShaderCompiler. 706 // Wrapper for glReleaseShaderCompiler.
749 void DoReleaseShaderCompiler() { } 707 void DoReleaseShaderCompiler() { }
750 708
751 // Wrappers for glTexParameter functions. 709 // Wrappers for glTexParameter functions.
752 void DoTexParameterf(GLenum target, GLenum pname, GLfloat param); 710 void DoTexParameterf(GLenum target, GLenum pname, GLfloat param);
753 void DoTexParameteri(GLenum target, GLenum pname, GLint param); 711 void DoTexParameteri(GLenum target, GLenum pname, GLint param);
754 void DoTexParameterfv(GLenum target, GLenum pname, const GLfloat* params); 712 void DoTexParameterfv(GLenum target, GLenum pname, const GLfloat* params);
755 void DoTexParameteriv(GLenum target, GLenum pname, const GLint* params); 713 void DoTexParameteriv(GLenum target, GLenum pname, const GLint* params);
756 714
757 // Wrappers for glUniform1i and glUniform1iv as according to the GLES2 715 // Wrappers for glUniform1i and glUniform1iv as according to the GLES2
758 // spec only these 2 functions can be used to set sampler uniforms. 716 // spec only these 2 functions can be used to set sampler uniforms.
759 void DoUniform1i(GLint location, GLint v0); 717 void DoUniform1i(GLint location, GLint v0);
760 void DoUniform1iv(GLint location, GLsizei count, const GLint *value); 718 void DoUniform1iv(GLint location, GLsizei count, const GLint *value);
761 719
762 // Wrapper for glUseProgram 720 // Wrapper for glUseProgram
763 void DoUseProgram(GLuint program); 721 void DoUseProgram(GLuint program);
764 722
723 // Wrapper for glValidateProgram.
724 void DoValidateProgram(GLuint program_client_id);
725
765 // Gets the GLError through our wrapper. 726 // Gets the GLError through our wrapper.
766 GLenum GetGLError(); 727 GLenum GetGLError();
767 728
768 // Sets our wrapper for the GLError. 729 // Sets our wrapper for the GLError.
769 void SetGLError(GLenum error); 730 void SetGLError(GLenum error);
770 731
771 // Copies the real GL errors to the wrapper. This is so we can 732 // Copies the real GL errors to the wrapper. This is so we can
772 // make sure there are no native GL errors before calling some GL function 733 // make sure there are no native GL errors before calling some GL function
773 // so that on return we know any error generated was for that specific 734 // so that on return we know any error generated was for that specific
774 // command. 735 // command.
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
940 // before binding a new texture. 901 // before binding a new texture.
941 glActiveTexture(GL_TEXTURE0); 902 glActiveTexture(GL_TEXTURE0);
942 glBindTexture(GL_TEXTURE_2D, id); 903 glBindTexture(GL_TEXTURE_2D, id);
943 } 904 }
944 905
945 ScopedTexture2DBinder::~ScopedTexture2DBinder() { 906 ScopedTexture2DBinder::~ScopedTexture2DBinder() {
946 ScopedGLErrorSuppressor suppressor(decoder_); 907 ScopedGLErrorSuppressor suppressor(decoder_);
947 GLES2DecoderImpl::TextureUnit& info = decoder_->texture_units_[0]; 908 GLES2DecoderImpl::TextureUnit& info = decoder_->texture_units_[0];
948 GLuint last_id; 909 GLuint last_id;
949 if (info.bound_texture_2d) 910 if (info.bound_texture_2d)
950 last_id = info.bound_texture_2d->texture_id(); 911 last_id = info.bound_texture_2d->service_id();
951 else 912 else
952 last_id = 0; 913 last_id = 0;
953 914
954 glBindTexture(GL_TEXTURE_2D, last_id); 915 glBindTexture(GL_TEXTURE_2D, last_id);
955 glActiveTexture(GL_TEXTURE0 + decoder_->active_texture_unit_); 916 glActiveTexture(GL_TEXTURE0 + decoder_->active_texture_unit_);
956 } 917 }
957 918
958 ScopedRenderBufferBinder::ScopedRenderBufferBinder(GLES2DecoderImpl* decoder, 919 ScopedRenderBufferBinder::ScopedRenderBufferBinder(GLES2DecoderImpl* decoder,
959 GLuint id) 920 GLuint id)
960 : decoder_(decoder) { 921 : decoder_(decoder) {
961 ScopedGLErrorSuppressor suppressor(decoder_); 922 ScopedGLErrorSuppressor suppressor(decoder_);
962 glBindRenderbufferEXT(GL_RENDERBUFFER, id); 923 glBindRenderbufferEXT(GL_RENDERBUFFER, id);
963 } 924 }
964 925
965 ScopedRenderBufferBinder::~ScopedRenderBufferBinder() { 926 ScopedRenderBufferBinder::~ScopedRenderBufferBinder() {
966 ScopedGLErrorSuppressor suppressor(decoder_); 927 ScopedGLErrorSuppressor suppressor(decoder_);
967 glBindRenderbufferEXT( 928 glBindRenderbufferEXT(
968 GL_RENDERBUFFER, 929 GL_RENDERBUFFER,
969 decoder_->bound_renderbuffer_ ? 930 decoder_->bound_renderbuffer_ ?
970 decoder_->bound_renderbuffer_->renderbuffer_id() : 0); 931 decoder_->bound_renderbuffer_->service_id() : 0);
971 } 932 }
972 933
973 ScopedFrameBufferBinder::ScopedFrameBufferBinder(GLES2DecoderImpl* decoder, 934 ScopedFrameBufferBinder::ScopedFrameBufferBinder(GLES2DecoderImpl* decoder,
974 GLuint id) 935 GLuint id)
975 : decoder_(decoder) { 936 : decoder_(decoder) {
976 ScopedGLErrorSuppressor suppressor(decoder_); 937 ScopedGLErrorSuppressor suppressor(decoder_);
977 glBindFramebufferEXT(GL_FRAMEBUFFER, id); 938 glBindFramebufferEXT(GL_FRAMEBUFFER, id);
978 } 939 }
979 940
980 ScopedFrameBufferBinder::~ScopedFrameBufferBinder() { 941 ScopedFrameBufferBinder::~ScopedFrameBufferBinder() {
981 ScopedGLErrorSuppressor suppressor(decoder_); 942 ScopedGLErrorSuppressor suppressor(decoder_);
982 FramebufferManager::FramebufferInfo* info = 943 FramebufferManager::FramebufferInfo* info =
983 decoder_->bound_framebuffer_.get(); 944 decoder_->bound_framebuffer_.get();
984 GLuint framebuffer_id = info ? info->framebuffer_id() : 0; 945 GLuint framebuffer_id = info ? info->service_id() : 0;
985 if (framebuffer_id == 0 && 946 if (framebuffer_id == 0 &&
986 decoder_->offscreen_target_frame_buffer_.get()) { 947 decoder_->offscreen_target_frame_buffer_.get()) {
987 glBindFramebufferEXT(GL_FRAMEBUFFER, 948 glBindFramebufferEXT(GL_FRAMEBUFFER,
988 decoder_->offscreen_target_frame_buffer_->id()); 949 decoder_->offscreen_target_frame_buffer_->id());
989 } else { 950 } else {
990 glBindFramebufferEXT(GL_FRAMEBUFFER, framebuffer_id); 951 glBindFramebufferEXT(GL_FRAMEBUFFER, framebuffer_id);
991 } 952 }
992 } 953 }
993 954
994 ScopedDefaultGLContext::ScopedDefaultGLContext(GLES2DecoderImpl* decoder) 955 ScopedDefaultGLContext::ScopedDefaultGLContext(GLES2DecoderImpl* decoder)
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
1260 1221
1261 // Create the saved offscreen texture. The target frame buffer is copied 1222 // Create the saved offscreen texture. The target frame buffer is copied
1262 // here when SwapBuffers is called. 1223 // here when SwapBuffers is called.
1263 offscreen_saved_color_texture_.reset(new Texture(this)); 1224 offscreen_saved_color_texture_.reset(new Texture(this));
1264 offscreen_saved_color_texture_->Create(); 1225 offscreen_saved_color_texture_->Create();
1265 1226
1266 // Map the ID of the saved offscreen texture into the parent so that 1227 // Map the ID of the saved offscreen texture into the parent so that
1267 // it can reference it. 1228 // it can reference it.
1268 if (parent_) { 1229 if (parent_) {
1269 GLuint service_id = offscreen_saved_color_texture_->id(); 1230 GLuint service_id = offscreen_saved_color_texture_->id();
1270 parent_->id_manager()->AddMapping(parent_client_texture_id,
1271 service_id);
1272 TextureManager::TextureInfo* info = 1231 TextureManager::TextureInfo* info =
1273 parent_->CreateTextureInfo(service_id); 1232 parent_->CreateTextureInfo(parent_client_texture_id, service_id);
1274 parent_->texture_manager()->SetInfoTarget(info, GL_TEXTURE_2D); 1233 parent_->texture_manager()->SetInfoTarget(info, GL_TEXTURE_2D);
1275 } 1234 }
1276 1235
1277 // Allocate the render buffers at their initial size and check the status 1236 // Allocate the render buffers at their initial size and check the status
1278 // of the frame buffers is okay. 1237 // of the frame buffers is okay.
1279 pending_offscreen_size_ = size; 1238 pending_offscreen_size_ = size;
1280 if (!UpdateOffscreenFrameBufferSize()) { 1239 if (!UpdateOffscreenFrameBufferSize()) {
1281 DLOG(ERROR) << "Could not allocate offscreen buffer storage."; 1240 DLOG(ERROR) << "Could not allocate offscreen buffer storage.";
1282 Destroy(); 1241 Destroy();
1283 return false; 1242 return false;
(...skipping 18 matching lines...) Expand all
1302 DLOG(ERROR) << "Could not initialize GLSL translator."; 1261 DLOG(ERROR) << "Could not initialize GLSL translator.";
1303 Destroy(); 1262 Destroy();
1304 return false; 1263 return false;
1305 } 1264 }
1306 #endif // GLES2_GPU_SERVICE_TRANSLATE_SHADER 1265 #endif // GLES2_GPU_SERVICE_TRANSLATE_SHADER
1307 #endif // GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2 1266 #endif // GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2
1308 1267
1309 return true; 1268 return true;
1310 } 1269 }
1311 1270
1312 // These commands convert from c calls to local os calls. 1271 bool GLES2DecoderImpl::GenBuffersHelper(GLsizei n, const GLuint* client_ids) {
1313 void GLGenBuffersHelper(
1314 GLES2DecoderImpl* decoder, GLsizei n, GLuint* ids) {
1315 glGenBuffersARB(n, ids);
1316 // TODO(gman): handle error
1317 for (GLsizei ii = 0; ii < n; ++ii) { 1272 for (GLsizei ii = 0; ii < n; ++ii) {
1318 decoder->CreateBufferInfo(ids[ii]); 1273 if (GetBufferInfo(client_ids[ii])) {
1274 return false;
1275 }
1276 }
1277 scoped_array<GLuint> service_ids(new GLuint[n]);
1278 glGenBuffersARB(n, service_ids.get());
1279 for (GLsizei ii = 0; ii < n; ++ii) {
1280 CreateBufferInfo(client_ids[ii], service_ids[ii]);
1281 }
1282 return true;
1283 }
1284
1285 bool GLES2DecoderImpl::GenFramebuffersHelper(
1286 GLsizei n, const GLuint* client_ids) {
1287 for (GLsizei ii = 0; ii < n; ++ii) {
1288 if (GetFramebufferInfo(client_ids[ii])) {
1289 return false;
1290 }
1291 }
1292 scoped_array<GLuint> service_ids(new GLuint[n]);
1293 glGenFramebuffersEXT(n, service_ids.get());
1294 for (GLsizei ii = 0; ii < n; ++ii) {
1295 CreateFramebufferInfo(client_ids[ii], service_ids[ii]);
1296 }
1297 return true;
1298 }
1299
1300 bool GLES2DecoderImpl::GenRenderbuffersHelper(
1301 GLsizei n, const GLuint* client_ids) {
1302 for (GLsizei ii = 0; ii < n; ++ii) {
1303 if (GetRenderbufferInfo(client_ids[ii])) {
1304 return false;
1305 }
1306 }
1307 scoped_array<GLuint> service_ids(new GLuint[n]);
1308 glGenRenderbuffersEXT(n, service_ids.get());
1309 for (GLsizei ii = 0; ii < n; ++ii) {
1310 CreateRenderbufferInfo(client_ids[ii], service_ids[ii]);
1311 }
1312 return true;
1313 }
1314
1315 bool GLES2DecoderImpl::GenTexturesHelper(GLsizei n, const GLuint* client_ids) {
1316 for (GLsizei ii = 0; ii < n; ++ii) {
1317 if (GetTextureInfo(client_ids[ii])) {
1318 return false;
1319 }
1320 }
1321 scoped_array<GLuint> service_ids(new GLuint[n]);
1322 glGenTextures(n, service_ids.get());
1323 for (GLsizei ii = 0; ii < n; ++ii) {
1324 CreateTextureInfo(client_ids[ii], service_ids[ii]);
1325 }
1326 return true;
1327 }
1328
1329 void GLES2DecoderImpl::DeleteBuffersHelper(
1330 GLsizei n, const GLuint* client_ids) {
1331 for (GLsizei ii = 0; ii < n; ++ii) {
1332 BufferManager::BufferInfo* info = GetBufferInfo(client_ids[ii]);
1333 if (info) {
1334 GLuint service_id = info->service_id();
1335 glDeleteBuffersARB(1, &service_id);
1336 RemoveBufferInfo(client_ids[ii]);
1337 }
1319 } 1338 }
1320 } 1339 }
1321 1340
1322 void GLGenFramebuffersHelper( 1341 void GLES2DecoderImpl::DeleteFramebuffersHelper(
1323 GLES2DecoderImpl* decoder, GLsizei n, GLuint* ids) { 1342 GLsizei n, const GLuint* client_ids) {
1324 glGenFramebuffersEXT(n, ids);
1325 // TODO(gman): handle error
1326 for (GLsizei ii = 0; ii < n; ++ii) { 1343 for (GLsizei ii = 0; ii < n; ++ii) {
1327 decoder->CreateFramebufferInfo(ids[ii]); 1344 FramebufferManager::FramebufferInfo* info =
1345 GetFramebufferInfo(client_ids[ii]);
1346 if (info) {
1347 GLuint service_id = info->service_id();
1348 glDeleteFramebuffersEXT(1, &service_id);
1349 RemoveFramebufferInfo(client_ids[ii]);
1350 }
1328 } 1351 }
1329 } 1352 }
1330 1353
1331 void GLGenRenderbuffersHelper( 1354 void GLES2DecoderImpl::DeleteRenderbuffersHelper(
1332 GLES2DecoderImpl* decoder, GLsizei n, GLuint* ids) { 1355 GLsizei n, const GLuint* client_ids) {
1333 glGenRenderbuffersEXT(n, ids);
1334 // TODO(gman): handle error
1335 for (GLsizei ii = 0; ii < n; ++ii) { 1356 for (GLsizei ii = 0; ii < n; ++ii) {
1336 decoder->CreateRenderbufferInfo(ids[ii]); 1357 RenderbufferManager::RenderbufferInfo* info =
1358 GetRenderbufferInfo(client_ids[ii]);
1359 if (info) {
1360 GLuint service_id = info->service_id();
1361 glDeleteRenderbuffersEXT(1, &service_id);
1362 RemoveRenderbufferInfo(client_ids[ii]);
1363 }
1337 } 1364 }
1338 } 1365 }
1339 1366
1340 void GLGenTexturesHelper( 1367 void GLES2DecoderImpl::DeleteTexturesHelper(
1341 GLES2DecoderImpl* decoder, GLsizei n, GLuint* ids) { 1368 GLsizei n, const GLuint* client_ids) {
1342 glGenTextures(n, ids);
1343 // TODO(gman): handle error
1344 for (GLsizei ii = 0; ii < n; ++ii) { 1369 for (GLsizei ii = 0; ii < n; ++ii) {
1345 decoder->CreateTextureInfo(ids[ii]); 1370 TextureManager::TextureInfo* info = GetTextureInfo(client_ids[ii]);
1346 } 1371 if (info) {
1347 } 1372 GLuint service_id = info->service_id();
1348 1373 glDeleteTextures(1, &service_id);
1349 void GLDeleteBuffersHelper( 1374 RemoveTextureInfo(client_ids[ii]);
1350 GLES2DecoderImpl* decoder, GLsizei n, GLuint* ids) { 1375 }
1351 glDeleteBuffersARB(n, ids);
1352 // TODO(gman): handle error
1353 for (GLsizei ii = 0; ii < n; ++ii) {
1354 decoder->RemoveBufferInfo(ids[ii]);
1355 }
1356 }
1357
1358 void GLDeleteFramebuffersHelper(
1359 GLES2DecoderImpl* decoder, GLsizei n, GLuint* ids) {
1360 glDeleteFramebuffersEXT(n, ids);
1361 // TODO(gman): handle error
1362 for (GLsizei ii = 0; ii < n; ++ii) {
1363 decoder->RemoveFramebufferInfo(ids[ii]);
1364 }
1365 }
1366
1367 void GLDeleteRenderbuffersHelper(
1368 GLES2DecoderImpl* decoder, GLsizei n, GLuint* ids) {
1369 glDeleteRenderbuffersEXT(n, ids);
1370 // TODO(gman): handle error
1371 for (GLsizei ii = 0; ii < n; ++ii) {
1372 decoder->RemoveRenderbufferInfo(ids[ii]);
1373 }
1374 }
1375
1376 void GLDeleteTexturesHelper(
1377 GLES2DecoderImpl* decoder, GLsizei n, GLuint* ids) {
1378 glDeleteTextures(n, ids);
1379 // TODO(gman): handle error
1380 for (GLsizei ii = 0; ii < n; ++ii) {
1381 decoder->RemoveTextureInfo(ids[ii]);
1382 } 1376 }
1383 } 1377 }
1384 1378
1385 // } // anonymous namespace 1379 // } // anonymous namespace
1386 1380
1387 bool GLES2DecoderImpl::MakeCurrent() { 1381 bool GLES2DecoderImpl::MakeCurrent() {
1388 #if defined(UNIT_TEST) 1382 #if defined(UNIT_TEST)
1389 return true; 1383 return true;
1390 #else 1384 #else
1391 return context_->MakeCurrent(); 1385 return context_->MakeCurrent();
1392 #endif 1386 #endif
1393 } 1387 }
1394 1388
1395 uint32 GLES2DecoderImpl::GetServiceIdForTesting(uint32 client_id) {
1396 #if defined(UNIT_TEST)
1397 GLuint service_id;
1398 bool result = id_manager()->GetServiceId(client_id, &service_id);
1399 return result ? service_id : 0u;
1400 #else
1401 DCHECK(false);
1402 return 0u;
1403 #endif
1404 }
1405
1406 bool GLES2DecoderImpl::ValidateIdsAreUnused(
1407 GLsizei n, const GLuint* client_ids) {
1408 for (GLsizei ii = 0; ii < n; ++ii) {
1409 GLuint service_id;
1410 if (id_manager()->GetServiceId(client_ids[ii], &service_id)) {
1411 return false;
1412 }
1413 }
1414 return true;
1415 }
1416
1417 bool GLES2DecoderImpl::RegisterObjects(
1418 GLsizei n, const GLuint* client_ids, const GLuint* service_ids) {
1419 for (GLsizei ii = 0; ii < n; ++ii) {
1420 if (!id_manager()->AddMapping(client_ids[ii], service_ids[ii])) {
1421 NOTREACHED();
1422 return false;
1423 }
1424 }
1425 return true;
1426 }
1427
1428 void GLES2DecoderImpl::UnregisterObjects(
1429 GLsizei n, const GLuint* client_ids, GLuint* service_ids) {
1430 for (GLsizei ii = 0; ii < n; ++ii) {
1431 if (id_manager()->GetServiceId(client_ids[ii], &service_ids[ii])) {
1432 id_manager()->RemoveMapping(client_ids[ii], service_ids[ii]);
1433 } else {
1434 service_ids[ii] = 0;
1435 }
1436 }
1437 }
1438
1439 gfx::Size GLES2DecoderImpl::GetBoundFrameBufferSize() { 1389 gfx::Size GLES2DecoderImpl::GetBoundFrameBufferSize() {
1440 if (bound_framebuffer_ != 0) { 1390 if (bound_framebuffer_ != 0) {
1441 int width = 0; 1391 int width = 0;
1442 int height = 0; 1392 int height = 0;
1443 1393
1444 // Assume we have to have COLOR_ATTACHMENT0. Should we check for depth and 1394 // Assume we have to have COLOR_ATTACHMENT0. Should we check for depth and
1445 // stencil. 1395 // stencil.
1446 GLint fb_type = 0; 1396 GLint fb_type = 0;
1447 glGetFramebufferAttachmentParameterivEXT( 1397 glGetFramebufferAttachmentParameterivEXT(
1448 GL_FRAMEBUFFER, 1398 GL_FRAMEBUFFER,
(...skipping 23 matching lines...) Expand all
1472 } 1422 }
1473 case GL_TEXTURE: 1423 case GL_TEXTURE:
1474 { 1424 {
1475 GLint texture_id = 0; 1425 GLint texture_id = 0;
1476 glGetFramebufferAttachmentParameterivEXT( 1426 glGetFramebufferAttachmentParameterivEXT(
1477 GL_FRAMEBUFFER, 1427 GL_FRAMEBUFFER,
1478 GL_COLOR_ATTACHMENT0, 1428 GL_COLOR_ATTACHMENT0,
1479 GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, 1429 GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME,
1480 &texture_id); 1430 &texture_id);
1481 if (texture_id != 0) { 1431 if (texture_id != 0) {
1482 TextureManager::TextureInfo* texture_info = 1432 GLuint client_id = 0;
1483 GetTextureInfo(texture_id); 1433 if (texture_manager()->GetClientId(texture_id, &client_id)) {
1484 if (texture_info) { 1434 TextureManager::TextureInfo* texture_info =
1485 GLint level = 0; 1435 GetTextureInfo(client_id);
1486 GLint face = 0; 1436 if (texture_info) {
1487 glGetFramebufferAttachmentParameterivEXT( 1437 GLint level = 0;
1488 GL_FRAMEBUFFER, 1438 GLint face = 0;
1489 GL_COLOR_ATTACHMENT0, 1439 glGetFramebufferAttachmentParameterivEXT(
1490 GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL, 1440 GL_FRAMEBUFFER,
1491 &level); 1441 GL_COLOR_ATTACHMENT0,
1492 glGetFramebufferAttachmentParameterivEXT( 1442 GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL,
1493 GL_FRAMEBUFFER, 1443 &level);
1494 GL_COLOR_ATTACHMENT0, 1444 glGetFramebufferAttachmentParameterivEXT(
1495 GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE, 1445 GL_FRAMEBUFFER,
1496 &face); 1446 GL_COLOR_ATTACHMENT0,
1497 texture_info->GetLevelSize( 1447 GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE,
1498 face ? face : GL_TEXTURE_2D, level, &width, &height); 1448 &face);
1449 texture_info->GetLevelSize(
1450 face ? face : GL_TEXTURE_2D, level, &width, &height);
1451 }
1499 } 1452 }
1500 } 1453 }
1501 break; 1454 break;
1502 } 1455 }
1503 default: 1456 default:
1504 // unknown so assume width and height are zero. 1457 // unknown so assume width and height are zero.
1505 break; 1458 break;
1506 } 1459 }
1507 1460
1508 return gfx::Size(width, height); 1461 return gfx::Size(width, height);
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
1621 if (context_) { 1574 if (context_) {
1622 MakeCurrent(); 1575 MakeCurrent();
1623 1576
1624 // Remove the saved frame buffer mapping from the parent decoder. The 1577 // Remove the saved frame buffer mapping from the parent decoder. The
1625 // parent pointer is a weak pointer so it will be null if the parent has 1578 // parent pointer is a weak pointer so it will be null if the parent has
1626 // already been destroyed. 1579 // already been destroyed.
1627 if (parent_) { 1580 if (parent_) {
1628 // First check the texture has been mapped into the parent. This might not 1581 // First check the texture has been mapped into the parent. This might not
1629 // be the case if initialization failed midway through. 1582 // be the case if initialization failed midway through.
1630 GLuint service_id = offscreen_saved_color_texture_->id(); 1583 GLuint service_id = offscreen_saved_color_texture_->id();
1631 GLuint client_id; 1584 GLuint client_id = 0;
1632 if (parent_->id_manager()->GetClientId(service_id, &client_id)) { 1585 if (parent_->texture_manager()->GetClientId(service_id, &client_id)) {
1633 parent_->texture_manager()->RemoveTextureInfo(service_id); 1586 parent_->texture_manager()->RemoveTextureInfo(client_id);
1634 parent_->id_manager()->RemoveMapping(client_id, service_id);
1635 } 1587 }
1636 } 1588 }
1637 1589
1638 if (offscreen_target_frame_buffer_.get()) { 1590 if (offscreen_target_frame_buffer_.get()) {
1639 offscreen_target_frame_buffer_->Destroy(); 1591 offscreen_target_frame_buffer_->Destroy();
1640 offscreen_target_frame_buffer_.reset(); 1592 offscreen_target_frame_buffer_.reset();
1641 } 1593 }
1642 1594
1643 if (offscreen_target_color_texture_.get()) { 1595 if (offscreen_target_color_texture_.get()) {
1644 offscreen_target_color_texture_->Destroy(); 1596 offscreen_target_color_texture_->Destroy();
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
1725 } 1677 }
1726 } else { 1678 } else {
1727 result = error::kInvalidArguments; 1679 result = error::kInvalidArguments;
1728 } 1680 }
1729 } else { 1681 } else {
1730 result = DoCommonCommand(command, arg_count, cmd_data); 1682 result = DoCommonCommand(command, arg_count, cmd_data);
1731 } 1683 }
1732 return result; 1684 return result;
1733 } 1685 }
1734 1686
1735 void GLES2DecoderImpl::RemoveBufferInfo(GLuint buffer_id) { 1687 void GLES2DecoderImpl::RemoveBufferInfo(GLuint client_id) {
1736 buffer_manager()->RemoveBufferInfo(buffer_id); 1688 buffer_manager()->RemoveBufferInfo(client_id);
1737 // TODO(gman): See if we can remove the rest of this function as
1738 // buffers are now reference counted and have a "IsDeleted" function.
1739 if (bound_array_buffer_ && bound_array_buffer_->buffer_id() == buffer_id) {
1740 bound_array_buffer_ = NULL;
1741 }
1742 if (bound_element_array_buffer_ &&
1743 bound_element_array_buffer_->buffer_id() == buffer_id) {
1744 bound_element_array_buffer_ = NULL;
1745 }
1746
1747 // go through VertexAttribInfo and update any info that references the buffer.
1748 for (GLuint ii = 0; ii < group_->max_vertex_attribs(); ++ii) {
1749 VertexAttribInfo& info = vertex_attrib_infos_[ii];
1750 if (info.buffer() && info.buffer()->buffer_id() == buffer_id) {
1751 info.ClearBuffer();
1752 }
1753 }
1754 } 1689 }
1755 1690
1756 void GLES2DecoderImpl::CreateProgramHelper(GLuint client_id) { 1691 bool GLES2DecoderImpl::CreateProgramHelper(GLuint client_id) {
1757 // TODO(gman): verify client_id is unused. 1692 if (GetProgramInfo(client_id)) {
1693 return false;
1694 }
1758 GLuint service_id = glCreateProgram(); 1695 GLuint service_id = glCreateProgram();
1759 if (service_id) { 1696 if (service_id != 0) {
1760 id_manager()->AddMapping(client_id, service_id); 1697 CreateProgramInfo(client_id, service_id);
1761 CreateProgramInfo(service_id);
1762 } 1698 }
1699 return true;
1763 } 1700 }
1764 1701
1765 void GLES2DecoderImpl::CreateShaderHelper(GLenum type, GLuint client_id) { 1702 bool GLES2DecoderImpl::CreateShaderHelper(GLenum type, GLuint client_id) {
1766 // TODO(gman): verify client_id is unused. 1703 if (GetShaderInfo(client_id)) {
1704 return false;
1705 }
1767 GLuint service_id = glCreateShader(type); 1706 GLuint service_id = glCreateShader(type);
1768 if (service_id) { 1707 if (service_id != 0) {
1769 id_manager()->AddMapping(client_id, service_id); 1708 CreateShaderInfo(client_id, service_id);
1770 CreateShaderInfo(service_id);
1771 } 1709 }
1710 return true;
1772 } 1711 }
1773 1712
1774 bool GLES2DecoderImpl::ValidateGLenumCompressedTextureInternalFormat(GLenum) { 1713 bool GLES2DecoderImpl::ValidateGLenumCompressedTextureInternalFormat(GLenum) {
1775 // TODO(gman): Add support for compressed texture formats. 1714 // TODO(gman): Add support for compressed texture formats.
1776 return false; 1715 return false;
1777 } 1716 }
1778 1717
1779 void GLES2DecoderImpl::DoActiveTexture(GLenum texture_unit) { 1718 void GLES2DecoderImpl::DoActiveTexture(GLenum texture_unit) {
1780 GLuint texture_index = texture_unit - GL_TEXTURE0; 1719 GLuint texture_index = texture_unit - GL_TEXTURE0;
1781 if (texture_index > group_->max_texture_units()) { 1720 if (texture_index > group_->max_texture_units()) {
1782 SetGLError(GL_INVALID_ENUM); 1721 SetGLError(GL_INVALID_ENUM);
1783 return; 1722 return;
1784 } 1723 }
1785 active_texture_unit_ = texture_index; 1724 active_texture_unit_ = texture_index;
1786 glActiveTexture(texture_unit); 1725 glActiveTexture(texture_unit);
1787 } 1726 }
1788 1727
1789 void GLES2DecoderImpl::DoBindBuffer(GLenum target, GLuint client_id) { 1728 void GLES2DecoderImpl::DoBindBuffer(GLenum target, GLuint client_id) {
1790 BufferManager::BufferInfo* info = NULL; 1729 BufferManager::BufferInfo* info = NULL;
1791 GLuint service_id = 0; 1730 GLuint service_id = 0;
1792 if (client_id != 0 && !id_manager()->GetServiceId(client_id, &service_id)) { 1731 if (client_id != 0) {
1793 // It's a new id so make a buffer info for it. 1732 info = GetBufferInfo(client_id);
1794 glGenBuffersARB(1, &service_id); 1733 if (!info) {
1795 RegisterObjects(1, &client_id, &service_id); 1734 // It's a new id so make a buffer info for it.
1796 CreateBufferInfo(service_id); 1735 glGenBuffersARB(1, &service_id);
1736 CreateBufferInfo(client_id, service_id);
1737 info = GetBufferInfo(client_id);
1738 }
1797 } 1739 }
1798 if (service_id) { 1740 if (info) {
1799 info = GetBufferInfo(service_id);
1800 // Check the buffer exists 1741 // Check the buffer exists
1801 // Check that we are not trying to bind it to a different target. 1742 // Check that we are not trying to bind it to a different target.
1802 if (!info || (info->target() != 0 && info->target() != target)) { 1743 if ((info->target() != 0 && info->target() != target)) {
1803 SetGLError(GL_INVALID_OPERATION); 1744 SetGLError(GL_INVALID_OPERATION);
1804 return; 1745 return;
1805 } 1746 }
1806 if (info->target() == 0) { 1747 if (info->target() == 0) {
1807 info->set_target(target); 1748 info->set_target(target);
1808 } 1749 }
1750 service_id = info->service_id();
1809 } 1751 }
1810 switch (target) { 1752 switch (target) {
1811 case GL_ARRAY_BUFFER: 1753 case GL_ARRAY_BUFFER:
1812 bound_array_buffer_ = info; 1754 bound_array_buffer_ = info;
1813 break; 1755 break;
1814 case GL_ELEMENT_ARRAY_BUFFER: 1756 case GL_ELEMENT_ARRAY_BUFFER:
1815 bound_element_array_buffer_ = info; 1757 bound_element_array_buffer_ = info;
1816 break; 1758 break;
1817 default: 1759 default:
1818 NOTREACHED(); // Validation should prevent us getting here. 1760 NOTREACHED(); // Validation should prevent us getting here.
1819 break; 1761 break;
1820 } 1762 }
1821 glBindBuffer(target, service_id); 1763 glBindBuffer(target, service_id);
1822 } 1764 }
1823 1765
1824 void GLES2DecoderImpl::DoBindFramebuffer(GLenum target, GLuint client_id) { 1766 void GLES2DecoderImpl::DoBindFramebuffer(GLenum target, GLuint client_id) {
1825 FramebufferManager::FramebufferInfo* info = NULL; 1767 FramebufferManager::FramebufferInfo* info = NULL;
1826 GLuint service_id = 0; 1768 GLuint service_id = 0;
1827 if (client_id != 0 && !id_manager()->GetServiceId(client_id, &service_id)) { 1769 if (client_id != 0) {
1828 // It's a new id so make a framebuffer info for it. 1770 info = GetFramebufferInfo(client_id);
1829 glGenFramebuffersEXT(1, &service_id);
1830 RegisterObjects(1, &client_id, &service_id);
1831 CreateFramebufferInfo(service_id);
1832 }
1833 if (service_id) {
1834 info = GetFramebufferInfo(service_id);
1835 // Check the framebuffer exists
1836 if (!info) { 1771 if (!info) {
1837 SetGLError(GL_INVALID_OPERATION); 1772 // It's a new id so make a framebuffer info for it.
1838 return; 1773 glGenFramebuffersEXT(1, &service_id);
1774 CreateFramebufferInfo(client_id, service_id);
1775 info = GetFramebufferInfo(client_id);
1776 } else {
1777 service_id = info->service_id();
1839 } 1778 }
1840 } 1779 }
1841 bound_framebuffer_ = info; 1780 bound_framebuffer_ = info;
1842 1781
1843 // When rendering to an offscreen frame buffer, instead of unbinding from 1782 // When rendering to an offscreen frame buffer, instead of unbinding from
1844 // the current frame buffer, bind to the offscreen target frame buffer. 1783 // the current frame buffer, bind to the offscreen target frame buffer.
1845 if (info == NULL && offscreen_target_frame_buffer_.get()) 1784 if (info == NULL && offscreen_target_frame_buffer_.get())
1846 service_id = offscreen_target_frame_buffer_->id(); 1785 service_id = offscreen_target_frame_buffer_->id();
1847 1786
1848 glBindFramebufferEXT(target, service_id); 1787 glBindFramebufferEXT(target, service_id);
1849 } 1788 }
1850 1789
1851 void GLES2DecoderImpl::DoBindRenderbuffer(GLenum target, GLuint client_id) { 1790 void GLES2DecoderImpl::DoBindRenderbuffer(GLenum target, GLuint client_id) {
1852 RenderbufferManager::RenderbufferInfo* info = NULL; 1791 RenderbufferManager::RenderbufferInfo* info = NULL;
1853 GLuint service_id = 0; 1792 GLuint service_id = 0;
1854 if (client_id != 0 && !id_manager()->GetServiceId(client_id, &service_id)) { 1793 if (client_id != 0) {
1855 // It's a new id so make a renderbuffer info for it. 1794 info = GetRenderbufferInfo(client_id);
1856 glGenRenderbuffersEXT(1, &service_id);
1857 RegisterObjects(1, &client_id, &service_id);
1858 CreateRenderbufferInfo(service_id);
1859 }
1860 if (service_id) {
1861 info = GetRenderbufferInfo(service_id);
1862 // Check the renderbuffer exists
1863 if (!info) { 1795 if (!info) {
1864 SetGLError(GL_INVALID_OPERATION); 1796 // It's a new id so make a renderbuffer info for it.
1865 return; 1797 glGenRenderbuffersEXT(1, &service_id);
1798 CreateRenderbufferInfo(client_id, service_id);
1799 } else {
1800 service_id = info->service_id();
1866 } 1801 }
1867 } 1802 }
1868 bound_renderbuffer_ = info; 1803 bound_renderbuffer_ = info;
1869 glBindRenderbufferEXT(target, service_id); 1804 glBindRenderbufferEXT(target, service_id);
1870 } 1805 }
1871 1806
1872 void GLES2DecoderImpl::DoBindTexture(GLenum target, GLuint client_id) { 1807 void GLES2DecoderImpl::DoBindTexture(GLenum target, GLuint client_id) {
1808 TextureManager::TextureInfo* info = NULL;
1873 GLuint service_id = 0; 1809 GLuint service_id = 0;
1874 if (client_id != 0 && !id_manager()->GetServiceId(client_id, &service_id)) { 1810 if (client_id != 0) {
1875 // It's a new id so make a texture info for it. 1811 info = GetTextureInfo(client_id);
1876 glGenTextures(1, &service_id); 1812 if (!info) {
1877 RegisterObjects(1, &client_id, &service_id); 1813 // It's a new id so make a texture info for it.
1878 CreateTextureInfo(service_id); 1814 glGenTextures(1, &service_id);
1815 CreateTextureInfo(client_id, service_id);
1816 info = GetTextureInfo(client_id);
1817 }
1818 } else {
1819 info = texture_manager()->GetDefaultTextureInfo(target);
1879 } 1820 }
1880 TextureManager::TextureInfo* info = 1821
1881 service_id ? GetTextureInfo(service_id) :
1882 texture_manager()->GetDefaultTextureInfo(target);
1883 // Check the texture exists 1822 // Check the texture exists
1884 // Check that we are not trying to bind it to a different target. 1823 // Check that we are not trying to bind it to a different target.
1885 if (!info || (info->target() != 0 && info->target() != target)) { 1824 if (info->target() != 0 && info->target() != target) {
1886 SetGLError(GL_INVALID_OPERATION); 1825 SetGLError(GL_INVALID_OPERATION);
1887 return; 1826 return;
1888 } 1827 }
1889 if (info->target() == 0) { 1828 if (info->target() == 0) {
1890 texture_manager()->SetInfoTarget(info, target); 1829 texture_manager()->SetInfoTarget(info, target);
1891 } 1830 }
1892 glBindTexture(target, service_id); 1831 glBindTexture(target, info->service_id());
1893 TextureUnit& unit = texture_units_[active_texture_unit_]; 1832 TextureUnit& unit = texture_units_[active_texture_unit_];
1894 unit.bind_target = target; 1833 unit.bind_target = target;
1895 switch (target) { 1834 switch (target) {
1896 case GL_TEXTURE_2D: 1835 case GL_TEXTURE_2D:
1897 unit.bound_texture_2d = info; 1836 unit.bound_texture_2d = info;
1898 break; 1837 break;
1899 case GL_TEXTURE_CUBE_MAP: 1838 case GL_TEXTURE_CUBE_MAP:
1900 unit.bound_texture_cube_map = info; 1839 unit.bound_texture_cube_map = info;
1901 break; 1840 break;
1902 default: 1841 default:
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
2023 ProgramManager::ProgramInfo* info = GetProgramInfo(program_id); 1962 ProgramManager::ProgramInfo* info = GetProgramInfo(program_id);
2024 if (!info) { 1963 if (!info) {
2025 SetGLError(GL_INVALID_OPERATION); 1964 SetGLError(GL_INVALID_OPERATION);
2026 return; 1965 return;
2027 } 1966 }
2028 info->GetProgramiv(pname, params); 1967 info->GetProgramiv(pname, params);
2029 } 1968 }
2030 1969
2031 error::Error GLES2DecoderImpl::HandleBindAttribLocation( 1970 error::Error GLES2DecoderImpl::HandleBindAttribLocation(
2032 uint32 immediate_data_size, const gles2::BindAttribLocation& c) { 1971 uint32 immediate_data_size, const gles2::BindAttribLocation& c) {
2033 GLuint program; 1972 ProgramManager::ProgramInfo* info = GetProgramInfo(c.program);
2034 if (!id_manager()->GetServiceId(c.program, &program)) { 1973 if (!info) {
2035 SetGLError(GL_INVALID_VALUE); 1974 SetGLError(GL_INVALID_VALUE);
2036 return error::kNoError; 1975 return error::kNoError;
2037 } 1976 }
2038 GLuint index = static_cast<GLuint>(c.index); 1977 GLuint index = static_cast<GLuint>(c.index);
2039 uint32 name_size = c.data_size; 1978 uint32 name_size = c.data_size;
2040 const char* name = GetSharedMemoryAs<const char*>( 1979 const char* name = GetSharedMemoryAs<const char*>(
2041 c.name_shm_id, c.name_shm_offset, name_size); 1980 c.name_shm_id, c.name_shm_offset, name_size);
2042 if (name == NULL) { 1981 if (name == NULL) {
2043 return error::kOutOfBounds; 1982 return error::kOutOfBounds;
2044 } 1983 }
2045 String name_str(name, name_size); 1984 String name_str(name, name_size);
2046 glBindAttribLocation(program, index, name_str.c_str()); 1985 glBindAttribLocation(info->service_id(), index, name_str.c_str());
2047 return error::kNoError; 1986 return error::kNoError;
2048 } 1987 }
2049 1988
2050 error::Error GLES2DecoderImpl::HandleBindAttribLocationImmediate( 1989 error::Error GLES2DecoderImpl::HandleBindAttribLocationImmediate(
2051 uint32 immediate_data_size, const gles2::BindAttribLocationImmediate& c) { 1990 uint32 immediate_data_size, const gles2::BindAttribLocationImmediate& c) {
2052 GLuint program; 1991 ProgramManager::ProgramInfo* info = GetProgramInfo(c.program);
2053 if (!id_manager()->GetServiceId(c.program, &program)) { 1992 if (!info) {
2054 SetGLError(GL_INVALID_VALUE); 1993 SetGLError(GL_INVALID_VALUE);
2055 return error::kNoError; 1994 return error::kNoError;
2056 } 1995 }
2057 GLuint index = static_cast<GLuint>(c.index); 1996 GLuint index = static_cast<GLuint>(c.index);
2058 uint32 name_size = c.data_size; 1997 uint32 name_size = c.data_size;
2059 const char* name = GetImmediateDataAs<const char*>( 1998 const char* name = GetImmediateDataAs<const char*>(
2060 c, name_size, immediate_data_size); 1999 c, name_size, immediate_data_size);
2061 if (name == NULL) { 2000 if (name == NULL) {
2062 return error::kOutOfBounds; 2001 return error::kOutOfBounds;
2063 } 2002 }
2064 String name_str(name, name_size); 2003 String name_str(name, name_size);
2065 glBindAttribLocation(program, index, name_str.c_str()); 2004 glBindAttribLocation(info->service_id(), index, name_str.c_str());
2066 return error::kNoError; 2005 return error::kNoError;
2067 } 2006 }
2068 2007
2069 error::Error GLES2DecoderImpl::HandleBindAttribLocationBucket( 2008 error::Error GLES2DecoderImpl::HandleBindAttribLocationBucket(
2070 uint32 immediate_data_size, const gles2::BindAttribLocationBucket& c) { 2009 uint32 immediate_data_size, const gles2::BindAttribLocationBucket& c) {
2071 GLuint program; 2010 ProgramManager::ProgramInfo* info = GetProgramInfo(c.program);
2072 if (!id_manager()->GetServiceId(c.program, &program)) { 2011 if (!info) {
2073 SetGLError(GL_INVALID_VALUE); 2012 SetGLError(GL_INVALID_VALUE);
2074 return error::kNoError; 2013 return error::kNoError;
2075 } 2014 }
2076 GLuint index = static_cast<GLuint>(c.index); 2015 GLuint index = static_cast<GLuint>(c.index);
2077 Bucket* bucket = GetBucket(c.name_bucket_id); 2016 Bucket* bucket = GetBucket(c.name_bucket_id);
2078 if (!bucket || bucket->size() == 0) { 2017 if (!bucket || bucket->size() == 0) {
2079 return error::kInvalidArguments; 2018 return error::kInvalidArguments;
2080 } 2019 }
2081 std::string name_str; 2020 std::string name_str;
2082 bucket->GetAsString(&name_str); 2021 bucket->GetAsString(&name_str);
2083 glBindAttribLocation(program, index, name_str.c_str()); 2022 glBindAttribLocation(info->service_id(), index, name_str.c_str());
2084 return error::kNoError; 2023 return error::kNoError;
2085 } 2024 }
2086 2025
2087 error::Error GLES2DecoderImpl::HandleDeleteShader( 2026 error::Error GLES2DecoderImpl::HandleDeleteShader(
2088 uint32 immediate_data_size, const gles2::DeleteShader& c) { 2027 uint32 immediate_data_size, const gles2::DeleteShader& c) {
2089 GLuint shader = c.shader; 2028 GLuint client_id = c.shader;
2090 GLuint service_id; 2029 if (client_id) {
2091 if (!id_manager()->GetServiceId(shader, &service_id)) { 2030 ShaderManager::ShaderInfo* info = GetShaderInfo(client_id);
2092 SetGLError(GL_INVALID_VALUE); 2031 if (info) {
2093 return error::kNoError; 2032 glDeleteShader(info->service_id());
2033 RemoveShaderInfo(client_id);
2034 } else {
2035 SetGLError(GL_INVALID_VALUE);
2036 }
2094 } 2037 }
2095 RemoveShaderInfo(service_id);
2096 glDeleteShader(service_id);
2097 id_manager()->RemoveMapping(shader, service_id);
2098 return error::kNoError; 2038 return error::kNoError;
2099 } 2039 }
2100 2040
2101 error::Error GLES2DecoderImpl::HandleDeleteProgram( 2041 error::Error GLES2DecoderImpl::HandleDeleteProgram(
2102 uint32 immediate_data_size, const gles2::DeleteProgram& c) { 2042 uint32 immediate_data_size, const gles2::DeleteProgram& c) {
2103 GLuint program = c.program; 2043 GLuint client_id = c.program;
2104 GLuint service_id; 2044 if (client_id) {
2105 if (!id_manager()->GetServiceId(program, &service_id)) { 2045 ProgramManager::ProgramInfo* info = GetProgramInfo(client_id);
2106 SetGLError(GL_INVALID_VALUE); 2046 if (info) {
2107 return error::kNoError; 2047 glDeleteProgram(info->service_id());
2048 RemoveProgramInfo(client_id);
2049 } else {
2050 SetGLError(GL_INVALID_VALUE);
2051 }
2108 } 2052 }
2109 RemoveProgramInfo(service_id);
2110 glDeleteProgram(service_id);
2111 id_manager()->RemoveMapping(program, service_id);
2112 return error::kNoError; 2053 return error::kNoError;
2113 } 2054 }
2114 2055
2115 void GLES2DecoderImpl::DoDrawArrays( 2056 void GLES2DecoderImpl::DoDrawArrays(
2116 GLenum mode, GLint first, GLsizei count) { 2057 GLenum mode, GLint first, GLsizei count) {
2117 if (IsDrawValid(first + count - 1)) { 2058 if (IsDrawValid(first + count - 1)) {
2118 bool has_non_renderable_textures; 2059 bool has_non_renderable_textures;
2119 SetBlackTextureForNonRenderableTextures(&has_non_renderable_textures); 2060 SetBlackTextureForNonRenderableTextures(&has_non_renderable_textures);
2120 glDrawArrays(mode, first, count); 2061 glDrawArrays(mode, first, count);
2121 if (has_non_renderable_textures) { 2062 if (has_non_renderable_textures) {
2122 RestoreStateForNonRenderableTextures(); 2063 RestoreStateForNonRenderableTextures();
2123 } 2064 }
2124 } 2065 }
2125 } 2066 }
2126 2067
2127 void GLES2DecoderImpl::DoFramebufferRenderbuffer( 2068 void GLES2DecoderImpl::DoFramebufferRenderbuffer(
2128 GLenum target, GLenum attachment, GLenum renderbuffertarget, 2069 GLenum target, GLenum attachment, GLenum renderbuffertarget,
2129 GLuint renderbuffer) { 2070 GLuint client_renderbuffer_id) {
2130 if (!bound_framebuffer_) { 2071 if (!bound_framebuffer_) {
2131 SetGLError(GL_INVALID_OPERATION); 2072 SetGLError(GL_INVALID_OPERATION);
2132 return; 2073 return;
2133 } 2074 }
2134 glFramebufferRenderbufferEXT(target, attachment, renderbuffertarget, 2075 GLuint service_id = 0;
2135 renderbuffer); 2076 if (client_renderbuffer_id) {
2077 RenderbufferManager::RenderbufferInfo* info =
2078 GetRenderbufferInfo(client_renderbuffer_id);
2079 if (!info) {
2080 SetGLError(GL_INVALID_OPERATION);
2081 return;
2082 }
2083 service_id = info->service_id();
2084 }
2085 glFramebufferRenderbufferEXT(
2086 target, attachment, renderbuffertarget, service_id);
2136 } 2087 }
2137 2088
2138 GLenum GLES2DecoderImpl::DoCheckFramebufferStatus(GLenum target) { 2089 GLenum GLES2DecoderImpl::DoCheckFramebufferStatus(GLenum target) {
2139 if (!bound_framebuffer_) { 2090 if (!bound_framebuffer_) {
2140 return GL_FRAMEBUFFER_COMPLETE; 2091 return GL_FRAMEBUFFER_COMPLETE;
2141 } 2092 }
2142 return glCheckFramebufferStatusEXT(target); 2093 return glCheckFramebufferStatusEXT(target);
2143 } 2094 }
2144 2095
2145 void GLES2DecoderImpl::DoFramebufferTexture2D( 2096 void GLES2DecoderImpl::DoFramebufferTexture2D(
2146 GLenum target, GLenum attachment, GLenum textarget, GLuint texture, 2097 GLenum target, GLenum attachment, GLenum textarget,
2147 GLint level) { 2098 GLuint client_texture_id, GLint level) {
2148 if (!bound_framebuffer_) { 2099 if (!bound_framebuffer_) {
2149 SetGLError(GL_INVALID_OPERATION); 2100 SetGLError(GL_INVALID_OPERATION);
2150 return; 2101 return;
2151 } 2102 }
2152 glFramebufferTexture2DEXT(target, attachment, textarget, texture, level); 2103 GLuint service_id = 0;
2104 if (client_texture_id) {
2105 TextureManager::TextureInfo* info = GetTextureInfo(client_texture_id);
2106 if (!info) {
2107 SetGLError(GL_INVALID_OPERATION);
2108 return;
2109 }
2110 service_id = info->service_id();
2111 }
2112 glFramebufferTexture2DEXT(target, attachment, textarget, service_id, level);
2153 } 2113 }
2154 2114
2155 void GLES2DecoderImpl::DoGetFramebufferAttachmentParameteriv( 2115 void GLES2DecoderImpl::DoGetFramebufferAttachmentParameteriv(
2156 GLenum target, GLenum attachment, GLenum pname, GLint* params) { 2116 GLenum target, GLenum attachment, GLenum pname, GLint* params) {
2157 if (!bound_framebuffer_) { 2117 if (!bound_framebuffer_) {
2158 SetGLError(GL_INVALID_OPERATION); 2118 SetGLError(GL_INVALID_OPERATION);
2159 return; 2119 return;
2160 } 2120 }
2161 glGetFramebufferAttachmentParameterivEXT(target, attachment, pname, params); 2121 glGetFramebufferAttachmentParameterivEXT(target, attachment, pname, params);
2162 } 2122 }
(...skipping 16 matching lines...) Expand all
2179 glRenderbufferStorageEXT(target, internalformat, width, height); 2139 glRenderbufferStorageEXT(target, internalformat, width, height);
2180 } 2140 }
2181 2141
2182 void GLES2DecoderImpl::DoLinkProgram(GLuint program) { 2142 void GLES2DecoderImpl::DoLinkProgram(GLuint program) {
2183 ProgramManager::ProgramInfo* info = GetProgramInfo(program); 2143 ProgramManager::ProgramInfo* info = GetProgramInfo(program);
2184 if (!info) { 2144 if (!info) {
2185 SetGLError(GL_INVALID_OPERATION); 2145 SetGLError(GL_INVALID_OPERATION);
2186 return; 2146 return;
2187 } 2147 }
2188 CopyRealGLErrorsToWrapper(); 2148 CopyRealGLErrorsToWrapper();
2189 glLinkProgram(program); 2149 glLinkProgram(info->service_id());
2190 GLenum error = glGetError(); 2150 GLenum error = glGetError();
2191 if (error != GL_NO_ERROR) { 2151 if (error != GL_NO_ERROR) {
2192 RemoveProgramInfo(program); 2152 info->Reset();
2193 SetGLError(error); 2153 SetGLError(error);
2194 } else { 2154 } else {
2195 info->Update(); 2155 info->Update();
2196 } 2156 }
2197 }; 2157 };
2198 2158
2199 void GLES2DecoderImpl::DoTexParameterf( 2159 void GLES2DecoderImpl::DoTexParameterf(
2200 GLenum target, GLenum pname, GLfloat param) { 2160 GLenum target, GLenum pname, GLfloat param) {
2201 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target); 2161 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target);
2202 if (!info) { 2162 if (!info) {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
2255 if (!current_program_ || current_program_->IsDeleted()) { 2215 if (!current_program_ || current_program_->IsDeleted()) {
2256 // The program does not exist. 2216 // The program does not exist.
2257 SetGLError(GL_INVALID_OPERATION); 2217 SetGLError(GL_INVALID_OPERATION);
2258 return; 2218 return;
2259 } 2219 }
2260 current_program_->SetSamplers(location, count, value); 2220 current_program_->SetSamplers(location, count, value);
2261 glUniform1iv(location, count, value); 2221 glUniform1iv(location, count, value);
2262 } 2222 }
2263 2223
2264 void GLES2DecoderImpl::DoUseProgram(GLuint program) { 2224 void GLES2DecoderImpl::DoUseProgram(GLuint program) {
2225 GLuint service_id = 0;
2265 ProgramManager::ProgramInfo* info = NULL; 2226 ProgramManager::ProgramInfo* info = NULL;
2266 if (program) { 2227 if (program) {
2267 info = GetProgramInfo(program); 2228 info = GetProgramInfo(program);
2268 if (!info) { 2229 if (!info) {
2230 SetGLError(GL_INVALID_VALUE);
2231 return;
2232 }
2233 if (!info->IsValid()) {
2269 // Program was not linked successfully. (ie, glLinkProgram) 2234 // Program was not linked successfully. (ie, glLinkProgram)
2270 SetGLError(GL_INVALID_OPERATION); 2235 SetGLError(GL_INVALID_OPERATION);
2271 return; 2236 return;
2272 } 2237 }
2238 service_id = info->service_id();
2273 } 2239 }
2274 current_program_ = info; 2240 current_program_ = info;
2275 glUseProgram(program); 2241 glUseProgram(service_id);
2276 } 2242 }
2277 2243
2278 GLenum GLES2DecoderImpl::GetGLError() { 2244 GLenum GLES2DecoderImpl::GetGLError() {
2279 // Check the GL error first, then our wrapped error. 2245 // Check the GL error first, then our wrapped error.
2280 GLenum error = glGetError(); 2246 GLenum error = glGetError();
2281 if (error == GL_NO_ERROR && error_bits_ != 0) { 2247 if (error == GL_NO_ERROR && error_bits_ != 0) {
2282 for (uint32 mask = 1; mask != 0; mask = mask << 1) { 2248 for (uint32 mask = 1; mask != 0; mask = mask << 1) {
2283 if ((error_bits_ & mask) != 0) { 2249 if ((error_bits_ & mask) != 0) {
2284 error = GLES2Util::GLErrorBitToGLError(mask); 2250 error = GLES2Util::GLErrorBitToGLError(mask);
2285 break; 2251 break;
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
2386 uniform_info->type == GL_SAMPLER_2D ? 2352 uniform_info->type == GL_SAMPLER_2D ?
2387 texture_unit.bound_texture_2d : 2353 texture_unit.bound_texture_2d :
2388 texture_unit.bound_texture_cube_map; 2354 texture_unit.bound_texture_cube_map;
2389 if (!texture_info || !texture_info->CanRender()) { 2355 if (!texture_info || !texture_info->CanRender()) {
2390 glActiveTexture(GL_TEXTURE0 + texture_unit_index); 2356 glActiveTexture(GL_TEXTURE0 + texture_unit_index);
2391 // Get the texture info that was previously bound here. 2357 // Get the texture info that was previously bound here.
2392 texture_info = texture_unit.bind_target == GL_TEXTURE_2D ? 2358 texture_info = texture_unit.bind_target == GL_TEXTURE_2D ?
2393 texture_unit.bound_texture_2d : 2359 texture_unit.bound_texture_2d :
2394 texture_unit.bound_texture_cube_map; 2360 texture_unit.bound_texture_cube_map;
2395 glBindTexture(texture_unit.bind_target, 2361 glBindTexture(texture_unit.bind_target,
2396 texture_info ? texture_info->texture_id() : 0); 2362 texture_info ? texture_info->service_id() : 0);
2397 } 2363 }
2398 } 2364 }
2399 } 2365 }
2400 } 2366 }
2401 // Set the active texture back to whatever the user had it as. 2367 // Set the active texture back to whatever the user had it as.
2402 glActiveTexture(GL_TEXTURE0 + active_texture_unit_); 2368 glActiveTexture(GL_TEXTURE0 + active_texture_unit_);
2403 } 2369 }
2404 2370
2405 bool GLES2DecoderImpl::IsDrawValid(GLuint max_vertex_accessed) { 2371 bool GLES2DecoderImpl::IsDrawValid(GLuint max_vertex_accessed) {
2406 if (!current_program_ || current_program_->IsDeleted()) { 2372 if (!current_program_ || current_program_->IsDeleted()) {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
2459 } 2425 }
2460 } 2426 }
2461 } 2427 }
2462 return error::kNoError; 2428 return error::kNoError;
2463 } 2429 }
2464 2430
2465 GLuint GLES2DecoderImpl::DoGetMaxValueInBuffer( 2431 GLuint GLES2DecoderImpl::DoGetMaxValueInBuffer(
2466 GLuint buffer_id, GLsizei count, GLenum type, GLuint offset) { 2432 GLuint buffer_id, GLsizei count, GLenum type, GLuint offset) {
2467 GLuint max_vertex_accessed = 0; 2433 GLuint max_vertex_accessed = 0;
2468 BufferManager::BufferInfo* info = GetBufferInfo(buffer_id); 2434 BufferManager::BufferInfo* info = GetBufferInfo(buffer_id);
2469 if (info->target() != GL_ELEMENT_ARRAY_BUFFER) { 2435 if (!info || info->target() != GL_ELEMENT_ARRAY_BUFFER) {
2436 // TODO(gman): Should this be a GL error or a command buffer error?
2470 SetGLError(GL_INVALID_OPERATION); 2437 SetGLError(GL_INVALID_OPERATION);
2471 } else { 2438 } else {
2472 if (!info->GetMaxValueForRange(offset, count, type, &max_vertex_accessed)) { 2439 if (!info->GetMaxValueForRange(offset, count, type, &max_vertex_accessed)) {
2440 // TODO(gman): Should this be a GL error or a command buffer error?
2473 SetGLError(GL_INVALID_OPERATION); 2441 SetGLError(GL_INVALID_OPERATION);
2474 } 2442 }
2475 } 2443 }
2476 return max_vertex_accessed; 2444 return max_vertex_accessed;
2477 } 2445 }
2478 2446
2479 // Calls glShaderSource for the various versions of the ShaderSource command. 2447 // Calls glShaderSource for the various versions of the ShaderSource command.
2480 // Assumes that data / data_size points to a piece of memory that is in range 2448 // Assumes that data / data_size points to a piece of memory that is in range
2481 // of whatever context it came from (shared memory, immediate memory, bucket 2449 // of whatever context it came from (shared memory, immediate memory, bucket
2482 // memory.) 2450 // memory.)
2483 error::Error GLES2DecoderImpl::ShaderSourceHelper( 2451 error::Error GLES2DecoderImpl::ShaderSourceHelper(
2484 GLuint shader, const char* data, uint32 data_size) { 2452 GLuint client_id, const char* data, uint32 data_size) {
2485 ShaderManager::ShaderInfo* info = GetShaderInfo(shader); 2453 ShaderManager::ShaderInfo* info = GetShaderInfo(client_id);
2486 if (!info) { 2454 if (!info) {
2487 SetGLError(GL_INVALID_OPERATION); 2455 SetGLError(GL_INVALID_VALUE);
2488 return error::kNoError; 2456 return error::kNoError;
2489 } 2457 }
2490 // Note: We don't actually call glShaderSource here. We wait until 2458 // Note: We don't actually call glShaderSource here. We wait until
2491 // the call to glCompileShader. 2459 // the call to glCompileShader.
2492 info->Update(std::string(data, data + data_size)); 2460 info->Update(std::string(data, data + data_size));
2493 return error::kNoError; 2461 return error::kNoError;
2494 } 2462 }
2495 2463
2496 error::Error GLES2DecoderImpl::HandleShaderSource( 2464 error::Error GLES2DecoderImpl::HandleShaderSource(
2497 uint32 immediate_data_size, const gles2::ShaderSource& c) { 2465 uint32 immediate_data_size, const gles2::ShaderSource& c) {
2498 GLuint shader;
2499 if (!id_manager()->GetServiceId(c.shader, &shader)) {
2500 SetGLError(GL_INVALID_VALUE);
2501 return error::kNoError;
2502 }
2503 uint32 data_size = c.data_size; 2466 uint32 data_size = c.data_size;
2504 const char* data = GetSharedMemoryAs<const char*>( 2467 const char* data = GetSharedMemoryAs<const char*>(
2505 c.data_shm_id, c.data_shm_offset, data_size); 2468 c.data_shm_id, c.data_shm_offset, data_size);
2506 if (!data) { 2469 if (!data) {
2507 return error::kOutOfBounds; 2470 return error::kOutOfBounds;
2508 } 2471 }
2509 return ShaderSourceHelper(shader, data, data_size); 2472 return ShaderSourceHelper(c.shader, data, data_size);
2510 } 2473 }
2511 2474
2512 error::Error GLES2DecoderImpl::HandleShaderSourceImmediate( 2475 error::Error GLES2DecoderImpl::HandleShaderSourceImmediate(
2513 uint32 immediate_data_size, const gles2::ShaderSourceImmediate& c) { 2476 uint32 immediate_data_size, const gles2::ShaderSourceImmediate& c) {
2514 GLuint shader;
2515 if (!id_manager()->GetServiceId(c.shader, &shader)) {
2516 SetGLError(GL_INVALID_VALUE);
2517 return error::kNoError;
2518 }
2519 uint32 data_size = c.data_size; 2477 uint32 data_size = c.data_size;
2520 const char* data = GetImmediateDataAs<const char*>( 2478 const char* data = GetImmediateDataAs<const char*>(
2521 c, data_size, immediate_data_size); 2479 c, data_size, immediate_data_size);
2522 if (!data) { 2480 if (!data) {
2523 return error::kOutOfBounds; 2481 return error::kOutOfBounds;
2524 } 2482 }
2525 return ShaderSourceHelper(shader, data, data_size); 2483 return ShaderSourceHelper(c.shader, data, data_size);
2526 } 2484 }
2527 2485
2528 error::Error GLES2DecoderImpl::HandleShaderSourceBucket( 2486 error::Error GLES2DecoderImpl::HandleShaderSourceBucket(
2529 uint32 immediate_data_size, const gles2::ShaderSourceBucket& c) { 2487 uint32 immediate_data_size, const gles2::ShaderSourceBucket& c) {
2530 GLuint shader;
2531 if (!id_manager()->GetServiceId(c.shader, &shader)) {
2532 SetGLError(GL_INVALID_VALUE);
2533 return error::kNoError;
2534 }
2535 Bucket* bucket = GetBucket(c.data_bucket_id); 2488 Bucket* bucket = GetBucket(c.data_bucket_id);
2536 if (!bucket || bucket->size() == 0) { 2489 if (!bucket || bucket->size() == 0) {
2537 return error::kInvalidArguments; 2490 return error::kInvalidArguments;
2538 } 2491 }
2539 return ShaderSourceHelper( 2492 return ShaderSourceHelper(
2540 shader, bucket->GetDataAs<const char*>(0, bucket->size() - 1), 2493 c.shader, bucket->GetDataAs<const char*>(0, bucket->size() - 1),
2541 bucket->size() - 1); 2494 bucket->size() - 1);
2542 } 2495 }
2543 2496
2544 void GLES2DecoderImpl::DoCompileShader(GLuint shader) { 2497 void GLES2DecoderImpl::DoCompileShader(GLuint client_id) {
2545 ShaderManager::ShaderInfo* info = GetShaderInfo(shader); 2498 ShaderManager::ShaderInfo* info = GetShaderInfo(client_id);
2546 if (!info) { 2499 if (!info) {
2547 SetGLError(GL_INVALID_OPERATION); 2500 SetGLError(GL_INVALID_VALUE);
2548 return; 2501 return;
2549 } 2502 }
2550
2551 // Translate GL ES 2.0 shader to Desktop GL shader and pass that to 2503 // Translate GL ES 2.0 shader to Desktop GL shader and pass that to
2552 // glShaderSource and then glCompileShader. 2504 // glShaderSource and then glCompileShader.
2553 const char* shader_src = info->source().c_str(); 2505 const char* shader_src = info->source().c_str();
2554 #if !defined(GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2) 2506 #if !defined(GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2)
2555 #if defined(GLES2_GPU_SERVICE_TRANSLATE_SHADER) 2507 #if defined(GLES2_GPU_SERVICE_TRANSLATE_SHADER)
2556 int dbg_options = 0; 2508 int dbg_options = 0;
2557 EShLanguage language = EShLangVertex; 2509 EShLanguage language = EShLangVertex;
2558 TBuiltInResource resources; 2510 TBuiltInResource resources;
2559 // TODO(alokp): Ask gman how to get appropriate values. 2511 // TODO(alokp): Ask gman how to get appropriate values.
2560 resources.maxVertexAttribs = 8; 2512 resources.maxVertexAttribs = 8;
(...skipping 10 matching lines...) Expand all
2571 // TODO(alokp): Ask gman where to set compile-status and info-log. 2523 // TODO(alokp): Ask gman where to set compile-status and info-log.
2572 // May be add member variables to ShaderManager::ShaderInfo? 2524 // May be add member variables to ShaderManager::ShaderInfo?
2573 const char* info_log = ShGetInfoLog(compiler); 2525 const char* info_log = ShGetInfoLog(compiler);
2574 ShDestruct(compiler); 2526 ShDestruct(compiler);
2575 return; 2527 return;
2576 } 2528 }
2577 shader_src = ShGetObjectCode(compiler); 2529 shader_src = ShGetObjectCode(compiler);
2578 #endif // GLES2_GPU_SERVICE_TRANSLATE_SHADER 2530 #endif // GLES2_GPU_SERVICE_TRANSLATE_SHADER
2579 #endif // GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2 2531 #endif // GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2
2580 2532
2581 glShaderSource(shader, 1, &shader_src, NULL); 2533 glShaderSource(info->service_id(), 1, &shader_src, NULL);
2582 glCompileShader(shader); 2534 glCompileShader(info->service_id());
2583 2535
2584 #if !defined(GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2) 2536 #if !defined(GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2)
2585 #ifdef GLES2_GPU_SERVICE_TRANSLATE_SHADER 2537 #ifdef GLES2_GPU_SERVICE_TRANSLATE_SHADER
2586 ShDestruct(compiler); 2538 ShDestruct(compiler);
2587 #endif // GLES2_GPU_SERVICE_TRANSLATE_SHADER 2539 #endif // GLES2_GPU_SERVICE_TRANSLATE_SHADER
2588 #endif // GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2 2540 #endif // GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2
2589 }; 2541 };
2590 2542
2591 void GLES2DecoderImpl::DoGetShaderiv( 2543 void GLES2DecoderImpl::DoGetShaderiv(
2592 GLuint shader, GLenum pname, GLint* params) { 2544 GLuint shader, GLenum pname, GLint* params) {
2593 ShaderManager::ShaderInfo* info = GetShaderInfo(shader); 2545 ShaderManager::ShaderInfo* info = GetShaderInfo(shader);
2594 if (!info) { 2546 if (!info) {
2595 SetGLError(GL_INVALID_OPERATION); 2547 SetGLError(GL_INVALID_OPERATION);
2596 return; 2548 return;
2597 } 2549 }
2598 if (pname == GL_SHADER_SOURCE_LENGTH) { 2550 if (pname == GL_SHADER_SOURCE_LENGTH) {
2599 *params = info->source().size(); 2551 *params = info->source().size();
2600 } else { 2552 } else {
2601 glGetShaderiv(shader, pname, params); 2553 glGetShaderiv(info->service_id(), pname, params);
2602 } 2554 }
2603 } 2555 }
2604 2556
2605 void GLES2DecoderImpl::DoGetShaderSource( 2557 error::Error GLES2DecoderImpl::HandleGetShaderSource(
2606 GLuint shader, GLsizei bufsize, GLsizei* length, char* dst) { 2558 uint32 immediate_data_size, const gles2::GetShaderSource& c) {
2559 GLuint shader = c.shader;
2607 ShaderManager::ShaderInfo* info = GetShaderInfo(shader); 2560 ShaderManager::ShaderInfo* info = GetShaderInfo(shader);
2608 if (!info) { 2561 if (!info) {
2609 SetGLError(GL_INVALID_OPERATION); 2562 SetGLError(GL_INVALID_VALUE);
2610 return; 2563 return error::kNoError;
2611 } 2564 }
2612 // bufsize is set by the service side code and should always be positive. 2565 uint32 bucket_id = static_cast<uint32>(c.bucket_id);
2613 DCHECK_GT(bufsize, 0); 2566 Bucket* bucket = CreateBucket(bucket_id);
2614 const std::string& source = info->source(); 2567 bucket->SetFromString(info->source());
2615 GLsizei size = std::min(bufsize - 1, static_cast<GLsizei>(source.size())); 2568 return error::kNoError;
2616 if (length) { 2569 }
2617 *length = size; 2570
2571 error::Error GLES2DecoderImpl::HandleGetProgramInfoLog(
2572 uint32 immediate_data_size, const gles2::GetProgramInfoLog& c) {
2573 GLuint program = c.program;
2574 ProgramManager::ProgramInfo* info = GetProgramInfo(program);
2575 if (!info) {
2576 SetGLError(GL_INVALID_VALUE);
2577 return error::kNoError;
2618 } 2578 }
2619 memcpy(dst, source.c_str(), size); 2579 uint32 bucket_id = static_cast<uint32>(c.bucket_id);
2620 dst[size] = '\0'; 2580 GLint len = 0;
2581 glGetProgramiv(info->service_id(), GL_INFO_LOG_LENGTH, &len);
2582 Bucket* bucket = CreateBucket(bucket_id);
2583 bucket->SetSize(len + 1);
2584 glGetProgramInfoLog(
2585 info->service_id(),
2586 len + 1, &len, bucket->GetDataAs<GLchar*>(0, len + 1));
2587 return error::kNoError;
2588 }
2589
2590 error::Error GLES2DecoderImpl::HandleGetShaderInfoLog(
2591 uint32 immediate_data_size, const gles2::GetShaderInfoLog& c) {
2592 GLuint shader = c.shader;
2593 ShaderManager::ShaderInfo* info = GetShaderInfo(shader);
2594 if (!info) {
2595 SetGLError(GL_INVALID_VALUE);
2596 return error::kNoError;
2597 }
2598 uint32 bucket_id = static_cast<uint32>(c.bucket_id);
2599 GLint len = 0;
2600 glGetShaderiv(info->service_id(), GL_INFO_LOG_LENGTH, &len);
2601 Bucket* bucket = CreateBucket(bucket_id);
2602 bucket->SetSize(len + 1);
2603 glGetShaderInfoLog(
2604 info->service_id(),
2605 len + 1, &len, bucket->GetDataAs<GLchar*>(0, len + 1));
2606 return error::kNoError;
2621 } 2607 }
2622 2608
2623 bool GLES2DecoderImpl::DoIsBuffer(GLuint client_id) { 2609 bool GLES2DecoderImpl::DoIsBuffer(GLuint client_id) {
2624 GLuint service_id = 0; 2610 return GetBufferInfo(client_id) != NULL;
2625 if (!id_manager()->GetServiceId(client_id, &service_id)) {
2626 return false;
2627 }
2628 return GetBufferInfo(service_id) != NULL;
2629 } 2611 }
2630 2612
2631 bool GLES2DecoderImpl::DoIsFramebuffer(GLuint client_id) { 2613 bool GLES2DecoderImpl::DoIsFramebuffer(GLuint client_id) {
2632 GLuint service_id = 0; 2614 return GetFramebufferInfo(client_id) != NULL;
2633 if (!id_manager()->GetServiceId(client_id, &service_id)) {
2634 return false;
2635 }
2636 return GetFramebufferInfo(service_id) != NULL;
2637 } 2615 }
2638 2616
2639 bool GLES2DecoderImpl::DoIsProgram(GLuint client_id) { 2617 bool GLES2DecoderImpl::DoIsProgram(GLuint client_id) {
2640 GLuint service_id = 0; 2618 return GetProgramInfo(client_id) != NULL;
2641 if (!id_manager()->GetServiceId(client_id, &service_id)) {
2642 return false;
2643 }
2644 return GetProgramInfo(service_id) != NULL;
2645 } 2619 }
2646 2620
2647 bool GLES2DecoderImpl::DoIsRenderbuffer(GLuint client_id) { 2621 bool GLES2DecoderImpl::DoIsRenderbuffer(GLuint client_id) {
2648 GLuint service_id = 0; 2622 return GetRenderbufferInfo(client_id) != NULL;
2649 if (!id_manager()->GetServiceId(client_id, &service_id)) {
2650 return false;
2651 }
2652 return GetRenderbufferInfo(service_id) != NULL;
2653 } 2623 }
2654 2624
2655 bool GLES2DecoderImpl::DoIsShader(GLuint client_id) { 2625 bool GLES2DecoderImpl::DoIsShader(GLuint client_id) {
2656 GLuint service_id = 0; 2626 return GetShaderInfo(client_id) != NULL;
2657 if (!id_manager()->GetServiceId(client_id, &service_id)) {
2658 return false;
2659 }
2660 return GetShaderInfo(service_id) != NULL;
2661 } 2627 }
2662 2628
2663 bool GLES2DecoderImpl::DoIsTexture(GLuint client_id) { 2629 bool GLES2DecoderImpl::DoIsTexture(GLuint client_id) {
2664 GLuint service_id = 0; 2630 return GetTextureInfo(client_id) != NULL;
2665 if (!id_manager()->GetServiceId(client_id, &service_id)) { 2631 }
2666 return false; 2632
2633 void GLES2DecoderImpl::DoAttachShader(
2634 GLuint program_client_id, GLint shader_client_id) {
2635 ProgramManager::ProgramInfo* program_info = GetProgramInfo(program_client_id);
2636 if (!program_info) {
2637 SetGLError(GL_INVALID_VALUE);
2638 return;
2667 } 2639 }
2668 return GetTextureInfo(service_id) != NULL; 2640 ShaderManager::ShaderInfo* shader_info = GetShaderInfo(shader_client_id);
2641 if (!shader_info) {
2642 SetGLError(GL_INVALID_VALUE);
2643 return;
2644 }
2645 glAttachShader(program_info->service_id(), shader_info->service_id());
2646 }
2647
2648 void GLES2DecoderImpl::DoDetachShader(
2649 GLuint program_client_id, GLint shader_client_id) {
2650 ProgramManager::ProgramInfo* program_info = GetProgramInfo(program_client_id);
2651 if (!program_info) {
2652 SetGLError(GL_INVALID_VALUE);
2653 return;
2654 }
2655 ShaderManager::ShaderInfo* shader_info = GetShaderInfo(shader_client_id);
2656 if (!shader_info) {
2657 SetGLError(GL_INVALID_VALUE);
2658 return;
2659 }
2660 glDetachShader(program_info->service_id(), shader_info->service_id());
2661 }
2662
2663 void GLES2DecoderImpl::DoValidateProgram(GLuint program_client_id) {
2664 ProgramManager::ProgramInfo* info = GetProgramInfo(program_client_id);
2665 if (!info) {
2666 SetGLError(GL_INVALID_VALUE);
2667 return;
2668 }
2669 glValidateProgram(info->service_id());
2669 } 2670 }
2670 2671
2671 error::Error GLES2DecoderImpl::HandleVertexAttribPointer( 2672 error::Error GLES2DecoderImpl::HandleVertexAttribPointer(
2672 uint32 immediate_data_size, const gles2::VertexAttribPointer& c) { 2673 uint32 immediate_data_size, const gles2::VertexAttribPointer& c) {
2673 if (bound_array_buffer_ && !bound_array_buffer_->IsDeleted()) { 2674 if (bound_array_buffer_ && !bound_array_buffer_->IsDeleted()) {
2674 GLuint indx = c.indx; 2675 GLuint indx = c.indx;
2675 GLint size = c.size; 2676 GLint size = c.size;
2676 GLenum type = c.type; 2677 GLenum type = c.type;
2677 GLboolean normalized = c.normalized; 2678 GLboolean normalized = c.normalized;
2678 GLsizei stride = c.stride; 2679 GLsizei stride = c.stride;
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
2839 // Validation should have prevented us from getting here. 2840 // Validation should have prevented us from getting here.
2840 DCHECK(false); 2841 DCHECK(false);
2841 break; 2842 break;
2842 } 2843 }
2843 return error::kNoError; 2844 return error::kNoError;
2844 } 2845 }
2845 2846
2846 error::Error GLES2DecoderImpl::GetAttribLocationHelper( 2847 error::Error GLES2DecoderImpl::GetAttribLocationHelper(
2847 GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset, 2848 GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset,
2848 const std::string& name_str) { 2849 const std::string& name_str) {
2849 GLuint program; 2850 ProgramManager::ProgramInfo* info = GetProgramInfo(client_id);
2850 if (!id_manager()->GetServiceId(client_id, &program)) { 2851 if (!info) {
2851 SetGLError(GL_INVALID_VALUE); 2852 SetGLError(GL_INVALID_VALUE);
2852 return error::kNoError; 2853 return error::kNoError;
2853 } 2854 }
2854 ProgramManager::ProgramInfo* info = GetProgramInfo(program); 2855 if (!info->IsValid()) {
2855 if (!info) {
2856 // Program was not linked successfully. (ie, glLinkProgram)
2857 SetGLError(GL_INVALID_OPERATION); 2856 SetGLError(GL_INVALID_OPERATION);
2858 return error::kNoError; 2857 return error::kNoError;
2859 } 2858 }
2860 GLint* location = GetSharedMemoryAs<GLint*>( 2859 GLint* location = GetSharedMemoryAs<GLint*>(
2861 location_shm_id, location_shm_offset, sizeof(GLint)); 2860 location_shm_id, location_shm_offset, sizeof(GLint));
2862 if (!location) { 2861 if (!location) {
2863 return error::kOutOfBounds; 2862 return error::kOutOfBounds;
2864 } 2863 }
2865 // Require the client to init this incase the context is lost and we are no 2864 // Require the client to init this incase the context is lost and we are no
2866 // longer executing commands. 2865 // longer executing commands.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
2905 } 2904 }
2906 std::string name_str; 2905 std::string name_str;
2907 bucket->GetAsString(&name_str); 2906 bucket->GetAsString(&name_str);
2908 return GetAttribLocationHelper( 2907 return GetAttribLocationHelper(
2909 c.program, c.location_shm_id, c.location_shm_offset, name_str); 2908 c.program, c.location_shm_id, c.location_shm_offset, name_str);
2910 } 2909 }
2911 2910
2912 error::Error GLES2DecoderImpl::GetUniformLocationHelper( 2911 error::Error GLES2DecoderImpl::GetUniformLocationHelper(
2913 GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset, 2912 GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset,
2914 const std::string& name_str) { 2913 const std::string& name_str) {
2915 GLuint program; 2914 ProgramManager::ProgramInfo* info = GetProgramInfo(client_id);
2916 if (!id_manager()->GetServiceId(client_id, &program)) { 2915 if (!info) {
2917 SetGLError(GL_INVALID_VALUE); 2916 SetGLError(GL_INVALID_VALUE);
2918 return error::kNoError; 2917 return error::kNoError;
2919 } 2918 }
2920 ProgramManager::ProgramInfo* info = GetProgramInfo(program); 2919 if (!info->IsValid()) {
2921 if (!info) {
2922 // Program was not linked successfully. (ie, glLinkProgram)
2923 SetGLError(GL_INVALID_OPERATION); 2920 SetGLError(GL_INVALID_OPERATION);
2924 return error::kNoError; 2921 return error::kNoError;
2925 } 2922 }
2926 GLint* location = GetSharedMemoryAs<GLint*>( 2923 GLint* location = GetSharedMemoryAs<GLint*>(
2927 location_shm_id, location_shm_offset, sizeof(GLint)); 2924 location_shm_id, location_shm_offset, sizeof(GLint));
2928 if (!location) { 2925 if (!location) {
2929 return error::kOutOfBounds; 2926 return error::kOutOfBounds;
2930 } 2927 }
2931 // Require the client to init this incase the context is lost an we are no 2928 // Require the client to init this incase the context is lost an we are no
2932 // longer executing commands. 2929 // longer executing commands.
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
3296 SizedResult<GLint>* result; 3293 SizedResult<GLint>* result;
3297 result = GetSharedMemoryAs<SizedResult<GLint>*>( 3294 result = GetSharedMemoryAs<SizedResult<GLint>*>(
3298 shm_id, shm_offset, SizedResult<GLint>::ComputeSize(0)); 3295 shm_id, shm_offset, SizedResult<GLint>::ComputeSize(0));
3299 if (!result) { 3296 if (!result) {
3300 *error = error::kOutOfBounds; 3297 *error = error::kOutOfBounds;
3301 return false; 3298 return false;
3302 } 3299 }
3303 *result_pointer = result; 3300 *result_pointer = result;
3304 // Set the result size to 0 so the client does not have to check for success. 3301 // Set the result size to 0 so the client does not have to check for success.
3305 result->SetNumResults(0); 3302 result->SetNumResults(0);
3306 if (!id_manager()->GetServiceId(program, service_id)) { 3303 ProgramManager::ProgramInfo* info = GetProgramInfo(program);
3304 if (!info) {
3307 SetGLError(GL_INVALID_VALUE); 3305 SetGLError(GL_INVALID_VALUE);
3308 return error::kNoError; 3306 return false;
3309 } 3307 }
3310 ProgramManager::ProgramInfo* info = GetProgramInfo(*service_id); 3308 if (!info->IsValid()) {
3311 if (!info) {
3312 // Program was not linked successfully. (ie, glLinkProgram) 3309 // Program was not linked successfully. (ie, glLinkProgram)
3313 SetGLError(GL_INVALID_OPERATION); 3310 SetGLError(GL_INVALID_OPERATION);
3314 return false; 3311 return false;
3315 } 3312 }
3313 *service_id = info->service_id();
3316 GLenum type; 3314 GLenum type;
3317 if (!info->GetUniformTypeByLocation(location, &type)) { 3315 if (!info->GetUniformTypeByLocation(location, &type)) {
3318 // No such location. 3316 // No such location.
3319 SetGLError(GL_INVALID_OPERATION); 3317 SetGLError(GL_INVALID_OPERATION);
3320 return false; 3318 return false;
3321 } 3319 }
3322 GLsizei size = GLES2Util::GetGLDataTypeSizeForUniforms(type); 3320 GLsizei size = GLES2Util::GetGLDataTypeSizeForUniforms(type);
3323 if (size == 0) { 3321 if (size == 0) {
3324 SetGLError(GL_INVALID_OPERATION); 3322 SetGLError(GL_INVALID_OPERATION);
3325 return false; 3323 return false;
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
3406 default: 3404 default:
3407 NOTREACHED(); 3405 NOTREACHED();
3408 break; 3406 break;
3409 } 3407 }
3410 } 3408 }
3411 return error::kNoError; 3409 return error::kNoError;
3412 } 3410 }
3413 3411
3414 error::Error GLES2DecoderImpl::HandleGetAttachedShaders( 3412 error::Error GLES2DecoderImpl::HandleGetAttachedShaders(
3415 uint32 immediate_data_size, const gles2::GetAttachedShaders& c) { 3413 uint32 immediate_data_size, const gles2::GetAttachedShaders& c) {
3416 GLuint service_id;
3417 uint32 result_size = c.result_size; 3414 uint32 result_size = c.result_size;
3418 if (!id_manager()->GetServiceId(c.program, &service_id)) { 3415 ProgramManager::ProgramInfo* info = GetProgramInfo(c.program);
3416 if (!info) {
3419 SetGLError(GL_INVALID_VALUE); 3417 SetGLError(GL_INVALID_VALUE);
3420 return error::kNoError; 3418 return error::kNoError;
3421 } 3419 }
3422 typedef gles2::GetAttachedShaders::Result Result; 3420 typedef gles2::GetAttachedShaders::Result Result;
3423 uint32 max_count = Result::ComputeMaxResults(result_size); 3421 uint32 max_count = Result::ComputeMaxResults(result_size);
3424 Result* result = GetSharedMemoryAs<Result*>( 3422 Result* result = GetSharedMemoryAs<Result*>(
3425 c.result_shm_id, c.result_shm_offset, Result::ComputeSize(max_count)); 3423 c.result_shm_id, c.result_shm_offset, Result::ComputeSize(max_count));
3426 if (!result) { 3424 if (!result) {
3427 return error::kOutOfBounds; 3425 return error::kOutOfBounds;
3428 } 3426 }
3429 // Check that the client initialized the result. 3427 // Check that the client initialized the result.
3430 if (result->size != 0) { 3428 if (result->size != 0) {
3431 return error::kInvalidArguments; 3429 return error::kInvalidArguments;
3432 } 3430 }
3433 GLsizei count = 0; 3431 GLsizei count = 0;
3434 glGetAttachedShaders(service_id, max_count, &count, result->GetData()); 3432 glGetAttachedShaders(
3433 info->service_id(), max_count, &count, result->GetData());
3435 for (GLsizei ii = 0; ii < count; ++ii) { 3434 for (GLsizei ii = 0; ii < count; ++ii) {
3436 if (!id_manager()->GetClientId(result->GetData()[ii], 3435 if (!shader_manager()->GetClientId(result->GetData()[ii],
3437 &result->GetData()[ii])) { 3436 &result->GetData()[ii])) {
3438 NOTREACHED(); 3437 NOTREACHED();
3439 return error::kGenericError; 3438 return error::kGenericError;
3440 } 3439 }
3441 } 3440 }
3442 result->SetNumResults(count); 3441 result->SetNumResults(count);
3443 return error::kNoError; 3442 return error::kNoError;
3444 } 3443 }
3445 3444
3446 error::Error GLES2DecoderImpl::HandleGetActiveUniform( 3445 error::Error GLES2DecoderImpl::HandleGetActiveUniform(
3447 uint32 immediate_data_size, const gles2::GetActiveUniform& c) { 3446 uint32 immediate_data_size, const gles2::GetActiveUniform& c) {
3448 GLuint program = c.program; 3447 GLuint program = c.program;
3449 GLuint index = c.index; 3448 GLuint index = c.index;
3450 uint32 name_bucket_id = c.name_bucket_id; 3449 uint32 name_bucket_id = c.name_bucket_id;
3451 GLuint service_id;
3452 typedef gles2::GetActiveUniform::Result Result; 3450 typedef gles2::GetActiveUniform::Result Result;
3453 Result* result = GetSharedMemoryAs<Result*>( 3451 Result* result = GetSharedMemoryAs<Result*>(
3454 c.result_shm_id, c.result_shm_offset, sizeof(*result)); 3452 c.result_shm_id, c.result_shm_offset, sizeof(*result));
3455 if (!result) { 3453 if (!result) {
3456 return error::kOutOfBounds; 3454 return error::kOutOfBounds;
3457 } 3455 }
3458 // Check that the client initialized the result. 3456 // Check that the client initialized the result.
3459 if (result->success != 0) { 3457 if (result->success != 0) {
3460 return error::kInvalidArguments; 3458 return error::kInvalidArguments;
3461 } 3459 }
3462 if (!id_manager()->GetServiceId(program, &service_id)) { 3460 ProgramManager::ProgramInfo* info = GetProgramInfo(program);
3461 if (!info) {
3463 SetGLError(GL_INVALID_VALUE); 3462 SetGLError(GL_INVALID_VALUE);
3464 return error::kNoError; 3463 return error::kNoError;
3465 } 3464 }
3466 ProgramManager::ProgramInfo* info = GetProgramInfo(service_id); 3465 if (!info->IsValid()) {
3467 if (!info) {
3468 // Program was not linked successfully. (ie, glLinkProgram) 3466 // Program was not linked successfully. (ie, glLinkProgram)
3469 SetGLError(GL_INVALID_OPERATION); 3467 SetGLError(GL_INVALID_VALUE);
3470 return error::kNoError; 3468 return error::kNoError;
3471 } 3469 }
3472 const ProgramManager::ProgramInfo::UniformInfo* uniform_info = 3470 const ProgramManager::ProgramInfo::UniformInfo* uniform_info =
3473 info->GetUniformInfo(index); 3471 info->GetUniformInfo(index);
3474 if (!uniform_info) { 3472 if (!uniform_info) {
3475 SetGLError(GL_INVALID_VALUE); 3473 SetGLError(GL_INVALID_VALUE);
3476 return error::kNoError; 3474 return error::kNoError;
3477 } 3475 }
3478 result->success = 1; // true. 3476 result->success = 1; // true.
3479 result->size = uniform_info->size; 3477 result->size = uniform_info->size;
3480 result->type = uniform_info->type; 3478 result->type = uniform_info->type;
3481 Bucket* bucket = CreateBucket(name_bucket_id); 3479 Bucket* bucket = CreateBucket(name_bucket_id);
3482 bucket->SetFromString(uniform_info->name); 3480 bucket->SetFromString(uniform_info->name);
3483 return error::kNoError; 3481 return error::kNoError;
3484 } 3482 }
3485 3483
3486 error::Error GLES2DecoderImpl::HandleGetActiveAttrib( 3484 error::Error GLES2DecoderImpl::HandleGetActiveAttrib(
3487 uint32 immediate_data_size, const gles2::GetActiveAttrib& c) { 3485 uint32 immediate_data_size, const gles2::GetActiveAttrib& c) {
3488 GLuint program = c.program; 3486 GLuint program = c.program;
3489 GLuint index = c.index; 3487 GLuint index = c.index;
3490 uint32 name_bucket_id = c.name_bucket_id; 3488 uint32 name_bucket_id = c.name_bucket_id;
3491 GLuint service_id;
3492 typedef gles2::GetActiveAttrib::Result Result; 3489 typedef gles2::GetActiveAttrib::Result Result;
3493 Result* result = GetSharedMemoryAs<Result*>( 3490 Result* result = GetSharedMemoryAs<Result*>(
3494 c.result_shm_id, c.result_shm_offset, sizeof(*result)); 3491 c.result_shm_id, c.result_shm_offset, sizeof(*result));
3495 if (!result) { 3492 if (!result) {
3496 return error::kOutOfBounds; 3493 return error::kOutOfBounds;
3497 } 3494 }
3498 // Check that the client initialized the result. 3495 // Check that the client initialized the result.
3499 if (result->success != 0) { 3496 if (result->success != 0) {
3500 return error::kInvalidArguments; 3497 return error::kInvalidArguments;
3501 } 3498 }
3502 if (!id_manager()->GetServiceId(program, &service_id)) { 3499 ProgramManager::ProgramInfo* info = GetProgramInfo(program);
3500 if (!info) {
3503 SetGLError(GL_INVALID_VALUE); 3501 SetGLError(GL_INVALID_VALUE);
3504 return error::kNoError; 3502 return error::kNoError;
3505 } 3503 }
3506 ProgramManager::ProgramInfo* info = GetProgramInfo(service_id); 3504 if (!info->IsValid()) {
3507 if (!info) {
3508 // Program was not linked successfully. (ie, glLinkProgram) 3505 // Program was not linked successfully. (ie, glLinkProgram)
3509 SetGLError(GL_INVALID_OPERATION); 3506 SetGLError(GL_INVALID_OPERATION);
3510 return error::kNoError; 3507 return error::kNoError;
3511 } 3508 }
3512 const ProgramManager::ProgramInfo::VertexAttribInfo* attrib_info = 3509 const ProgramManager::ProgramInfo::VertexAttribInfo* attrib_info =
3513 info->GetAttribInfo(index); 3510 info->GetAttribInfo(index);
3514 if (!attrib_info) { 3511 if (!attrib_info) {
3515 SetGLError(GL_INVALID_VALUE); 3512 SetGLError(GL_INVALID_VALUE);
3516 return error::kNoError; 3513 return error::kNoError;
3517 } 3514 }
(...skipping 28 matching lines...) Expand all
3546 const GLuint* shaders = GetSharedMemoryAs<const GLuint*>( 3543 const GLuint* shaders = GetSharedMemoryAs<const GLuint*>(
3547 c.shaders_shm_id, c.shaders_shm_offset, data_size); 3544 c.shaders_shm_id, c.shaders_shm_offset, data_size);
3548 GLenum binaryformat = static_cast<GLenum>(c.binaryformat); 3545 GLenum binaryformat = static_cast<GLenum>(c.binaryformat);
3549 const void* binary = GetSharedMemoryAs<const void*>( 3546 const void* binary = GetSharedMemoryAs<const void*>(
3550 c.binary_shm_id, c.binary_shm_offset, length); 3547 c.binary_shm_id, c.binary_shm_offset, length);
3551 if (shaders == NULL || binary == NULL) { 3548 if (shaders == NULL || binary == NULL) {
3552 return error::kOutOfBounds; 3549 return error::kOutOfBounds;
3553 } 3550 }
3554 scoped_array<GLuint> service_ids(new GLuint[n]); 3551 scoped_array<GLuint> service_ids(new GLuint[n]);
3555 for (GLsizei ii = 0; ii < n; ++ii) { 3552 for (GLsizei ii = 0; ii < n; ++ii) {
3556 if (!id_manager()->GetServiceId(shaders[ii], &service_ids[ii])) { 3553 ShaderManager::ShaderInfo* info = GetShaderInfo(shaders[ii]);
3554 if (!info) {
3557 SetGLError(GL_INVALID_VALUE); 3555 SetGLError(GL_INVALID_VALUE);
3558 return error::kNoError; 3556 return error::kNoError;
3559 } 3557 }
3560 // TODO(gman): Check that each shader exists. 3558 service_ids[ii] = info->service_id();
3561 } 3559 }
3562 // TODO(gman): call glShaderBinary 3560 // TODO(gman): call glShaderBinary
3563 return error::kNoError; 3561 return error::kNoError;
3564 #endif 3562 #endif
3565 } 3563 }
3566 3564
3567 error::Error GLES2DecoderImpl::HandleSwapBuffers( 3565 error::Error GLES2DecoderImpl::HandleSwapBuffers(
3568 uint32 immediate_data_size, const gles2::SwapBuffers& c) { 3566 uint32 immediate_data_size, const gles2::SwapBuffers& c) {
3569 // Check a client created frame buffer is not bound. TODO(apatrick): 3567 // Check a client created frame buffer is not bound. TODO(apatrick):
3570 // this error is overkill. It will require that the client recreate the 3568 // this error is overkill. It will require that the client recreate the
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
3606 return error::kNoError; 3604 return error::kNoError;
3607 } 3605 }
3608 3606
3609 // Include the auto-generated part of this file. We split this because it means 3607 // Include the auto-generated part of this file. We split this because it means
3610 // we can easily edit the non-auto generated parts right here in this file 3608 // we can easily edit the non-auto generated parts right here in this file
3611 // instead of having to edit some template or the code generator. 3609 // instead of having to edit some template or the code generator.
3612 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 3610 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
3613 3611
3614 } // namespace gles2 3612 } // namespace gles2
3615 } // namespace gpu 3613 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_decoder.h ('k') | gpu/command_buffer/service/gles2_cmd_decoder_autogen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698