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

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

Issue 12326146: Refactor/Rename a bunch of GPU stuff (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
6 6
7 #include <stdio.h> 7 #include <stdio.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <list> 10 #include <list>
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 } 137 }
138 138
139 // A struct to hold info about each command. 139 // A struct to hold info about each command.
140 struct CommandInfo { 140 struct CommandInfo {
141 int arg_flags; // How to handle the arguments for this command 141 int arg_flags; // How to handle the arguments for this command
142 int arg_count; // How many arguments are expected for this command. 142 int arg_count; // How many arguments are expected for this command.
143 }; 143 };
144 144
145 // A table of CommandInfo for all the commands. 145 // A table of CommandInfo for all the commands.
146 const CommandInfo g_command_info[] = { 146 const CommandInfo g_command_info[] = {
147 #define GLES2_CMD_OP(name) { \ 147 #define GLES2_CMD_OP(name) { \
148 name::kArgFlags, \ 148 cmds::name::kArgFlags, \
149 sizeof(name) / sizeof(CommandBufferEntry) - 1, }, /* NOLINT */ \ 149 sizeof(cmds::name) / sizeof(CommandBufferEntry) - 1, }, /* NOLINT */ \
150 150
151 GLES2_COMMAND_LIST(GLES2_CMD_OP) 151 GLES2_COMMAND_LIST(GLES2_CMD_OP)
152 152
153 #undef GLES2_CMD_OP 153 #undef GLES2_CMD_OP
154 }; 154 };
155 155
156 // Return true if a character belongs to the ASCII subset as defined in 156 // Return true if a character belongs to the ASCII subset as defined in
157 // GLSL ES 1.0 spec section 3.1. 157 // GLSL ES 1.0 spec section 3.1.
158 static bool CharacterIsValidForGLES(unsigned char c) { 158 static bool CharacterIsValidForGLES(unsigned char c) {
159 // Printing characters are valid except " $ ` @ \ ' DEL. 159 // Printing characters are valid except " $ ` @ \ ' DEL.
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 explicit ScopedTextureUploadTimer(GLES2DecoderImpl* decoder); 342 explicit ScopedTextureUploadTimer(GLES2DecoderImpl* decoder);
343 ~ScopedTextureUploadTimer(); 343 ~ScopedTextureUploadTimer();
344 344
345 private: 345 private:
346 GLES2DecoderImpl* decoder_; 346 GLES2DecoderImpl* decoder_;
347 base::TimeTicks begin_time_; 347 base::TimeTicks begin_time_;
348 DISALLOW_COPY_AND_ASSIGN(ScopedTextureUploadTimer); 348 DISALLOW_COPY_AND_ASSIGN(ScopedTextureUploadTimer);
349 }; 349 };
350 350
351 // Encapsulates an OpenGL texture. 351 // Encapsulates an OpenGL texture.
352 class Texture { 352 class BackTexture {
353 public: 353 public:
354 explicit Texture(GLES2DecoderImpl* decoder); 354 explicit BackTexture(GLES2DecoderImpl* decoder);
355 ~Texture(); 355 ~BackTexture();
356 356
357 // Create a new render texture. 357 // Create a new render texture.
358 void Create(); 358 void Create();
359 359
360 // Set the initial size and format of a render texture or resize it. 360 // Set the initial size and format of a render texture or resize it.
361 bool AllocateStorage(const gfx::Size& size, GLenum format, bool zero); 361 bool AllocateStorage(const gfx::Size& size, GLenum format, bool zero);
362 362
363 // Copy the contents of the currently bound frame buffer. 363 // Copy the contents of the currently bound frame buffer.
364 void Copy(const gfx::Size& size, GLenum format); 364 void Copy(const gfx::Size& size, GLenum format);
365 365
(...skipping 16 matching lines...) Expand all
382 size_t estimated_size() const { 382 size_t estimated_size() const {
383 return memory_tracker_.GetMemRepresented(); 383 return memory_tracker_.GetMemRepresented();
384 } 384 }
385 385
386 private: 386 private:
387 GLES2DecoderImpl* decoder_; 387 GLES2DecoderImpl* decoder_;
388 MemoryTypeTracker memory_tracker_; 388 MemoryTypeTracker memory_tracker_;
389 size_t bytes_allocated_; 389 size_t bytes_allocated_;
390 GLuint id_; 390 GLuint id_;
391 gfx::Size size_; 391 gfx::Size size_;
392 DISALLOW_COPY_AND_ASSIGN(Texture); 392 DISALLOW_COPY_AND_ASSIGN(BackTexture);
393 }; 393 };
394 394
395 // Encapsulates an OpenGL render buffer of any format. 395 // Encapsulates an OpenGL render buffer of any format.
396 class RenderBuffer { 396 class BackRenderbuffer {
397 public: 397 public:
398 explicit RenderBuffer(GLES2DecoderImpl* decoder); 398 explicit BackRenderbuffer(GLES2DecoderImpl* decoder);
399 ~RenderBuffer(); 399 ~BackRenderbuffer();
400 400
401 // Create a new render buffer. 401 // Create a new render buffer.
402 void Create(); 402 void Create();
403 403
404 // Set the initial size and format of a render buffer or resize it. 404 // Set the initial size and format of a render buffer or resize it.
405 bool AllocateStorage(const gfx::Size& size, GLenum format, GLsizei samples); 405 bool AllocateStorage(const gfx::Size& size, GLenum format, GLsizei samples);
406 406
407 // Destroy the render buffer. This must be explicitly called before destroying 407 // Destroy the render buffer. This must be explicitly called before destroying
408 // this object. 408 // this object.
409 void Destroy(); 409 void Destroy();
410 410
411 // Invalidate the render buffer. This can be used when a context is lost and 411 // Invalidate the render buffer. This can be used when a context is lost and
412 // it is not possible to make it current in order to free the resource. 412 // it is not possible to make it current in order to free the resource.
413 void Invalidate(); 413 void Invalidate();
414 414
415 GLuint id() const { 415 GLuint id() const {
416 return id_; 416 return id_;
417 } 417 }
418 418
419 size_t estimated_size() const { 419 size_t estimated_size() const {
420 return memory_tracker_.GetMemRepresented(); 420 return memory_tracker_.GetMemRepresented();
421 } 421 }
422 422
423 private: 423 private:
424 GLES2DecoderImpl* decoder_; 424 GLES2DecoderImpl* decoder_;
425 MemoryTypeTracker memory_tracker_; 425 MemoryTypeTracker memory_tracker_;
426 size_t bytes_allocated_; 426 size_t bytes_allocated_;
427 GLuint id_; 427 GLuint id_;
428 DISALLOW_COPY_AND_ASSIGN(RenderBuffer); 428 DISALLOW_COPY_AND_ASSIGN(BackRenderbuffer);
429 }; 429 };
430 430
431 // Encapsulates an OpenGL frame buffer. 431 // Encapsulates an OpenGL frame buffer.
432 class FrameBuffer { 432 class BackFramebuffer {
433 public: 433 public:
434 explicit FrameBuffer(GLES2DecoderImpl* decoder); 434 explicit BackFramebuffer(GLES2DecoderImpl* decoder);
435 ~FrameBuffer(); 435 ~BackFramebuffer();
436 436
437 // Create a new frame buffer. 437 // Create a new frame buffer.
438 void Create(); 438 void Create();
439 439
440 // Attach a color render buffer to a frame buffer. 440 // Attach a color render buffer to a frame buffer.
441 void AttachRenderTexture(Texture* texture); 441 void AttachRenderTexture(BackTexture* texture);
442 442
443 // Attach a render buffer to a frame buffer. Note that this unbinds any 443 // Attach a render buffer to a frame buffer. Note that this unbinds any
444 // currently bound frame buffer. 444 // currently bound frame buffer.
445 void AttachRenderBuffer(GLenum target, RenderBuffer* render_buffer); 445 void AttachRenderBuffer(GLenum target, BackRenderbuffer* render_buffer);
446 446
447 // Destroy the frame buffer. This must be explicitly called before destroying 447 // Destroy the frame buffer. This must be explicitly called before destroying
448 // this object. 448 // this object.
449 void Destroy(); 449 void Destroy();
450 450
451 // Invalidate the frame buffer. This can be used when a context is lost and it 451 // Invalidate the frame buffer. This can be used when a context is lost and it
452 // is not possible to make it current in order to free the resource. 452 // is not possible to make it current in order to free the resource.
453 void Invalidate(); 453 void Invalidate();
454 454
455 // See glCheckFramebufferStatusEXT. 455 // See glCheckFramebufferStatusEXT.
456 GLenum CheckStatus(); 456 GLenum CheckStatus();
457 457
458 GLuint id() const { 458 GLuint id() const {
459 return id_; 459 return id_;
460 } 460 }
461 461
462 private: 462 private:
463 GLES2DecoderImpl* decoder_; 463 GLES2DecoderImpl* decoder_;
464 GLuint id_; 464 GLuint id_;
465 DISALLOW_COPY_AND_ASSIGN(FrameBuffer); 465 DISALLOW_COPY_AND_ASSIGN(BackFramebuffer);
466 }; 466 };
467 467
468 // } // anonymous namespace. 468 // } // anonymous namespace.
469 469
470 bool GLES2Decoder::GetServiceTextureId(uint32 client_texture_id, 470 bool GLES2Decoder::GetServiceTextureId(uint32 client_texture_id,
471 uint32* service_texture_id) { 471 uint32* service_texture_id) {
472 return false; 472 return false;
473 } 473 }
474 474
475 GLES2Decoder::GLES2Decoder() 475 GLES2Decoder::GLES2Decoder()
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
617 bool BoundFramebufferHasDepthAttachment(); 617 bool BoundFramebufferHasDepthAttachment();
618 bool BoundFramebufferHasStencilAttachment(); 618 bool BoundFramebufferHasStencilAttachment();
619 619
620 virtual error::ContextLostReason GetContextLostReason() OVERRIDE; 620 virtual error::ContextLostReason GetContextLostReason() OVERRIDE;
621 621
622 private: 622 private:
623 friend class ScopedFrameBufferBinder; 623 friend class ScopedFrameBufferBinder;
624 friend class ScopedGLErrorSuppressor; 624 friend class ScopedGLErrorSuppressor;
625 friend class ScopedResolvedFrameBufferBinder; 625 friend class ScopedResolvedFrameBufferBinder;
626 friend class ScopedTextureUploadTimer; 626 friend class ScopedTextureUploadTimer;
627 friend class Texture; 627 friend class BackTexture;
628 friend class RenderBuffer; 628 friend class BackRenderbuffer;
629 friend class FrameBuffer; 629 friend class BackFramebuffer;
630 630
631 // Initialize or re-initialize the shader translator. 631 // Initialize or re-initialize the shader translator.
632 bool InitializeShaderTranslator(); 632 bool InitializeShaderTranslator();
633 633
634 void UpdateCapabilities(); 634 void UpdateCapabilities();
635 635
636 // Helpers for the glGen and glDelete functions. 636 // Helpers for the glGen and glDelete functions.
637 bool GenTexturesHelper(GLsizei n, const GLuint* client_ids); 637 bool GenTexturesHelper(GLsizei n, const GLuint* client_ids);
638 void DeleteTexturesHelper(GLsizei n, const GLuint* client_ids); 638 void DeleteTexturesHelper(GLsizei n, const GLuint* client_ids);
639 bool GenBuffersHelper(GLsizei n, const GLuint* client_ids); 639 bool GenBuffersHelper(GLsizei n, const GLuint* client_ids);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
700 if (tracker) { 700 if (tracker) {
701 return tracker->EnsureGPUMemoryAvailable(estimated_size); 701 return tracker->EnsureGPUMemoryAvailable(estimated_size);
702 } 702 }
703 return true; 703 return true;
704 } 704 }
705 705
706 bool IsOffscreenBufferMultisampled() const { 706 bool IsOffscreenBufferMultisampled() const {
707 return offscreen_target_samples_ > 1; 707 return offscreen_target_samples_ > 1;
708 } 708 }
709 709
710 // Creates a TextureInfo for the given texture. 710 // Creates a Texture for the given texture.
711 TextureManager::TextureInfo* CreateTextureInfo( 711 Texture* CreateTexture(
712 GLuint client_id, GLuint service_id) { 712 GLuint client_id, GLuint service_id) {
713 return texture_manager()->CreateTextureInfo(client_id, service_id); 713 return texture_manager()->CreateTexture(client_id, service_id);
714 } 714 }
715 715
716 // Gets the texture info for the given texture. Returns NULL if none exists. 716 // Gets the texture info for the given texture. Returns NULL if none exists.
717 TextureManager::TextureInfo* GetTextureInfo(GLuint client_id) const { 717 Texture* GetTexture(GLuint client_id) const {
718 TextureManager::TextureInfo* info = 718 Texture* info =
719 texture_manager()->GetTextureInfo(client_id); 719 texture_manager()->GetTexture(client_id);
720 return info; 720 return info;
721 } 721 }
722 722
723 // Deletes the texture info for the given texture. 723 // Deletes the texture info for the given texture.
724 void RemoveTextureInfo(GLuint client_id) { 724 void RemoveTexture(GLuint client_id) {
725 texture_manager()->RemoveTextureInfo(client_id); 725 texture_manager()->RemoveTexture(client_id);
726 } 726 }
727 727
728 // Get the size (in pixels) of the currently bound frame buffer (either FBO 728 // Get the size (in pixels) of the currently bound frame buffer (either FBO
729 // or regular back buffer). 729 // or regular back buffer).
730 gfx::Size GetBoundReadFrameBufferSize(); 730 gfx::Size GetBoundReadFrameBufferSize();
731 731
732 // Get the format of the currently bound frame buffer (either FBO or regular 732 // Get the format of the currently bound frame buffer (either FBO or regular
733 // back buffer) 733 // back buffer)
734 GLenum GetBoundReadFrameBufferInternalFormat(); 734 GLenum GetBoundReadFrameBufferInternalFormat();
735 GLenum GetBoundDrawFrameBufferInternalFormat(); 735 GLenum GetBoundDrawFrameBufferInternalFormat();
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
828 GLint yoffset, 828 GLint yoffset,
829 GLsizei width, 829 GLsizei width,
830 GLsizei height, 830 GLsizei height,
831 GLenum format, 831 GLenum format,
832 GLenum type, 832 GLenum type,
833 const void * data); 833 const void * data);
834 834
835 // Extra validation for async tex(Sub)Image2D. 835 // Extra validation for async tex(Sub)Image2D.
836 bool ValidateAsyncTransfer( 836 bool ValidateAsyncTransfer(
837 const char* function_name, 837 const char* function_name,
838 TextureManager::TextureInfo* info, 838 Texture* info,
839 GLenum target, 839 GLenum target,
840 GLint level, 840 GLint level,
841 const void * data); 841 const void * data);
842 842
843 // Wrapper for TexImageIOSurface2DCHROMIUM. 843 // Wrapper for TexImageIOSurface2DCHROMIUM.
844 void DoTexImageIOSurface2DCHROMIUM( 844 void DoTexImageIOSurface2DCHROMIUM(
845 GLenum target, 845 GLenum target,
846 GLsizei width, 846 GLsizei width,
847 GLsizei height, 847 GLsizei height,
848 GLuint io_surface_id, 848 GLuint io_surface_id,
(...skipping 19 matching lines...) Expand all
868 868
869 void DoBindTexImage2DCHROMIUM( 869 void DoBindTexImage2DCHROMIUM(
870 GLenum target, 870 GLenum target,
871 GLint image_id); 871 GLint image_id);
872 void DoReleaseTexImage2DCHROMIUM( 872 void DoReleaseTexImage2DCHROMIUM(
873 GLenum target, 873 GLenum target,
874 GLint image_id); 874 GLint image_id);
875 875
876 void DoTraceEndCHROMIUM(void); 876 void DoTraceEndCHROMIUM(void);
877 877
878 // Creates a ProgramInfo for the given program. 878 // Creates a Program for the given program.
879 ProgramManager::ProgramInfo* CreateProgramInfo( 879 Program* CreateProgram(
880 GLuint client_id, GLuint service_id) { 880 GLuint client_id, GLuint service_id) {
881 return program_manager()->CreateProgramInfo(client_id, service_id); 881 return program_manager()->CreateProgram(client_id, service_id);
882 } 882 }
883 883
884 // Gets the program info for the given program. Returns NULL if none exists. 884 // Gets the program info for the given program. Returns NULL if none exists.
885 ProgramManager::ProgramInfo* GetProgramInfo(GLuint client_id) { 885 Program* GetProgram(GLuint client_id) {
886 return program_manager()->GetProgramInfo(client_id); 886 return program_manager()->GetProgram(client_id);
887 } 887 }
888 888
889 #if defined(NDEBUG) 889 #if defined(NDEBUG)
890 void LogClientServiceMapping( 890 void LogClientServiceMapping(
891 const char* /* function_name */, 891 const char* /* function_name */,
892 GLuint /* client_id */, 892 GLuint /* client_id */,
893 GLuint /* service_id */) { 893 GLuint /* service_id */) {
894 } 894 }
895 template<typename T> 895 template<typename T>
896 void LogClientServiceForInfo( 896 void LogClientServiceForInfo(
(...skipping 12 matching lines...) Expand all
909 void LogClientServiceForInfo( 909 void LogClientServiceForInfo(
910 T* info, GLuint client_id, const char* function_name) { 910 T* info, GLuint client_id, const char* function_name) {
911 if (info) { 911 if (info) {
912 LogClientServiceMapping(function_name, client_id, info->service_id()); 912 LogClientServiceMapping(function_name, client_id, info->service_id());
913 } 913 }
914 } 914 }
915 #endif 915 #endif
916 916
917 // Gets the program info for the given program. If it's not a program 917 // Gets the program info for the given program. If it's not a program
918 // generates a GL error. Returns NULL if not program. 918 // generates a GL error. Returns NULL if not program.
919 ProgramManager::ProgramInfo* GetProgramInfoNotShader( 919 Program* GetProgramInfoNotShader(
920 GLuint client_id, const char* function_name) { 920 GLuint client_id, const char* function_name) {
921 ProgramManager::ProgramInfo* info = GetProgramInfo(client_id); 921 Program* info = GetProgram(client_id);
922 if (!info) { 922 if (!info) {
923 if (GetShaderInfo(client_id)) { 923 if (GetShader(client_id)) {
924 SetGLError( 924 SetGLError(
925 GL_INVALID_OPERATION, function_name, "shader passed for program"); 925 GL_INVALID_OPERATION, function_name, "shader passed for program");
926 } else { 926 } else {
927 SetGLError(GL_INVALID_VALUE, function_name, "unknown program"); 927 SetGLError(GL_INVALID_VALUE, function_name, "unknown program");
928 } 928 }
929 } 929 }
930 LogClientServiceForInfo(info, client_id, function_name); 930 LogClientServiceForInfo(info, client_id, function_name);
931 return info; 931 return info;
932 } 932 }
933 933
934 934
935 // Creates a ShaderInfo for the given shader. 935 // Creates a Shader for the given shader.
936 ShaderManager::ShaderInfo* CreateShaderInfo( 936 Shader* CreateShader(
937 GLuint client_id, 937 GLuint client_id,
938 GLuint service_id, 938 GLuint service_id,
939 GLenum shader_type) { 939 GLenum shader_type) {
940 return shader_manager()->CreateShaderInfo( 940 return shader_manager()->CreateShader(
941 client_id, service_id, shader_type); 941 client_id, service_id, shader_type);
942 } 942 }
943 943
944 // Gets the shader info for the given shader. Returns NULL if none exists. 944 // Gets the shader info for the given shader. Returns NULL if none exists.
945 ShaderManager::ShaderInfo* GetShaderInfo(GLuint client_id) { 945 Shader* GetShader(GLuint client_id) {
946 return shader_manager()->GetShaderInfo(client_id); 946 return shader_manager()->GetShader(client_id);
947 } 947 }
948 948
949 // Gets the shader info for the given shader. If it's not a shader generates a 949 // Gets the shader info for the given shader. If it's not a shader generates a
950 // GL error. Returns NULL if not shader. 950 // GL error. Returns NULL if not shader.
951 ShaderManager::ShaderInfo* GetShaderInfoNotProgram( 951 Shader* GetShaderInfoNotProgram(
952 GLuint client_id, const char* function_name) { 952 GLuint client_id, const char* function_name) {
953 ShaderManager::ShaderInfo* info = GetShaderInfo(client_id); 953 Shader* info = GetShader(client_id);
954 if (!info) { 954 if (!info) {
955 if (GetProgramInfo(client_id)) { 955 if (GetProgram(client_id)) {
956 SetGLError( 956 SetGLError(
957 GL_INVALID_OPERATION, function_name, "program passed for shader"); 957 GL_INVALID_OPERATION, function_name, "program passed for shader");
958 } else { 958 } else {
959 SetGLError( 959 SetGLError(
960 GL_INVALID_VALUE, function_name, "unknown shader"); 960 GL_INVALID_VALUE, function_name, "unknown shader");
961 } 961 }
962 } 962 }
963 LogClientServiceForInfo(info, client_id, function_name); 963 LogClientServiceForInfo(info, client_id, function_name);
964 return info; 964 return info;
965 } 965 }
966 966
967 // Creates a buffer info for the given buffer. 967 // Creates a buffer info for the given buffer.
968 void CreateBufferInfo(GLuint client_id, GLuint service_id) { 968 void CreateBuffer(GLuint client_id, GLuint service_id) {
969 return buffer_manager()->CreateBufferInfo(client_id, service_id); 969 return buffer_manager()->CreateBuffer(client_id, service_id);
970 } 970 }
971 971
972 // Gets the buffer info for the given buffer. 972 // Gets the buffer info for the given buffer.
973 BufferManager::BufferInfo* GetBufferInfo(GLuint client_id) { 973 BufferManager::Buffer* GetBuffer(GLuint client_id) {
974 BufferManager::BufferInfo* info = 974 BufferManager::Buffer* info =
975 buffer_manager()->GetBufferInfo(client_id); 975 buffer_manager()->GetBuffer(client_id);
976 return info; 976 return info;
977 } 977 }
978 978
979 // Removes any buffers in the VertexAtrribInfos and BufferInfos. This is used 979 // Removes any buffers in the VertexAtrribInfos and BufferInfos. This is used
980 // on glDeleteBuffers so we can make sure the user does not try to render 980 // on glDeleteBuffers so we can make sure the user does not try to render
981 // with deleted buffers. 981 // with deleted buffers.
982 void RemoveBufferInfo(GLuint client_id); 982 void RemoveBuffer(GLuint client_id);
983 983
984 // Creates a framebuffer info for the given framebuffer. 984 // Creates a framebuffer info for the given framebuffer.
985 void CreateFramebufferInfo(GLuint client_id, GLuint service_id) { 985 void CreateFramebuffer(GLuint client_id, GLuint service_id) {
986 return framebuffer_manager()->CreateFramebufferInfo(client_id, service_id); 986 return framebuffer_manager()->CreateFramebuffer(client_id, service_id);
987 } 987 }
988 988
989 // Gets the framebuffer info for the given framebuffer. 989 // Gets the framebuffer info for the given framebuffer.
990 FramebufferManager::FramebufferInfo* GetFramebufferInfo( 990 Framebuffer* GetFramebuffer(
991 GLuint client_id) { 991 GLuint client_id) {
992 FramebufferManager::FramebufferInfo* info = 992 Framebuffer* info =
993 framebuffer_manager()->GetFramebufferInfo(client_id); 993 framebuffer_manager()->GetFramebuffer(client_id);
994 return info; 994 return info;
995 } 995 }
996 996
997 // Removes the framebuffer info for the given framebuffer. 997 // Removes the framebuffer info for the given framebuffer.
998 void RemoveFramebufferInfo(GLuint client_id) { 998 void RemoveFramebuffer(GLuint client_id) {
999 framebuffer_manager()->RemoveFramebufferInfo(client_id); 999 framebuffer_manager()->RemoveFramebuffer(client_id);
1000 } 1000 }
1001 1001
1002 // Creates a renderbuffer info for the given renderbuffer. 1002 // Creates a renderbuffer info for the given renderbuffer.
1003 void CreateRenderbufferInfo(GLuint client_id, GLuint service_id) { 1003 void CreateRenderbuffer(GLuint client_id, GLuint service_id) {
1004 return renderbuffer_manager()->CreateRenderbufferInfo( 1004 return renderbuffer_manager()->CreateRenderbuffer(
1005 client_id, service_id); 1005 client_id, service_id);
1006 } 1006 }
1007 1007
1008 // Gets the renderbuffer info for the given renderbuffer. 1008 // Gets the renderbuffer info for the given renderbuffer.
1009 RenderbufferManager::RenderbufferInfo* GetRenderbufferInfo( 1009 Renderbuffer* GetRenderbuffer(
1010 GLuint client_id) { 1010 GLuint client_id) {
1011 RenderbufferManager::RenderbufferInfo* info = 1011 Renderbuffer* info =
1012 renderbuffer_manager()->GetRenderbufferInfo(client_id); 1012 renderbuffer_manager()->GetRenderbuffer(client_id);
1013 return info; 1013 return info;
1014 } 1014 }
1015 1015
1016 // Removes the renderbuffer info for the given renderbuffer. 1016 // Removes the renderbuffer info for the given renderbuffer.
1017 void RemoveRenderbufferInfo(GLuint client_id) { 1017 void RemoveRenderbuffer(GLuint client_id) {
1018 renderbuffer_manager()->RemoveRenderbufferInfo(client_id); 1018 renderbuffer_manager()->RemoveRenderbuffer(client_id);
1019 } 1019 }
1020 1020
1021 // Gets the vertex attrib manager for the given vertex array. 1021 // Gets the vertex attrib manager for the given vertex array.
1022 VertexAttribManager* GetVertexAttribManager(GLuint client_id) { 1022 VertexAttribManager* GetVertexAttribManager(GLuint client_id) {
1023 VertexAttribManager* info = 1023 VertexAttribManager* info =
1024 vertex_array_manager()->GetVertexAttribManager(client_id); 1024 vertex_array_manager()->GetVertexAttribManager(client_id);
1025 return info; 1025 return info;
1026 } 1026 }
1027 1027
1028 // Removes the vertex attrib manager for the given vertex array. 1028 // Removes the vertex attrib manager for the given vertex array.
(...skipping 21 matching lines...) Expand all
1050 1050
1051 // Helper for glShaderSource. 1051 // Helper for glShaderSource.
1052 error::Error ShaderSourceHelper( 1052 error::Error ShaderSourceHelper(
1053 GLuint client_id, const char* data, uint32 data_size); 1053 GLuint client_id, const char* data, uint32 data_size);
1054 1054
1055 // Clear any textures used by the current program. 1055 // Clear any textures used by the current program.
1056 bool ClearUnclearedTextures(); 1056 bool ClearUnclearedTextures();
1057 1057
1058 // Clear any uncleared level in texture. 1058 // Clear any uncleared level in texture.
1059 // Returns false if there was a generated GL error. 1059 // Returns false if there was a generated GL error.
1060 bool ClearTexture(TextureManager::TextureInfo* info); 1060 bool ClearTexture(Texture* info);
1061 1061
1062 // Clears any uncleared attachments attached to the given frame buffer. 1062 // Clears any uncleared attachments attached to the given frame buffer.
1063 // Returns false if there was a generated GL error. 1063 // Returns false if there was a generated GL error.
1064 void ClearUnclearedAttachments( 1064 void ClearUnclearedAttachments(
1065 GLenum target, FramebufferManager::FramebufferInfo* info); 1065 GLenum target, Framebuffer* info);
1066 1066
1067 // overridden from GLES2Decoder 1067 // overridden from GLES2Decoder
1068 virtual bool ClearLevel(unsigned service_id, 1068 virtual bool ClearLevel(unsigned service_id,
1069 unsigned bind_target, 1069 unsigned bind_target,
1070 unsigned target, 1070 unsigned target,
1071 int level, 1071 int level,
1072 unsigned format, 1072 unsigned format,
1073 unsigned type, 1073 unsigned type,
1074 int width, 1074 int width,
1075 int height, 1075 int height,
1076 bool is_texture_immutable) OVERRIDE; 1076 bool is_texture_immutable) OVERRIDE;
1077 1077
1078 // Restore all GL state that affects clearing. 1078 // Restore all GL state that affects clearing.
1079 void RestoreClearState(); 1079 void RestoreClearState();
1080 1080
1081 // Remembers the state of some capabilities. 1081 // Remembers the state of some capabilities.
1082 // Returns: true if glEnable/glDisable should actually be called. 1082 // Returns: true if glEnable/glDisable should actually be called.
1083 bool SetCapabilityState(GLenum cap, bool enabled); 1083 bool SetCapabilityState(GLenum cap, bool enabled);
1084 1084
1085 // Check that the currently bound framebuffers are valid. 1085 // Check that the currently bound framebuffers are valid.
1086 // Generates GL error if not. 1086 // Generates GL error if not.
1087 bool CheckBoundFramebuffersValid(const char* func_name); 1087 bool CheckBoundFramebuffersValid(const char* func_name);
1088 1088
1089 // Check if a framebuffer meets our requirements. 1089 // Check if a framebuffer meets our requirements.
1090 bool CheckFramebufferValid( 1090 bool CheckFramebufferValid(
1091 FramebufferManager::FramebufferInfo* framebuffer, 1091 Framebuffer* framebuffer,
1092 GLenum target, 1092 GLenum target,
1093 const char* func_name); 1093 const char* func_name);
1094 1094
1095 // Checks if the current program exists and is valid. If not generates the 1095 // Checks if the current program exists and is valid. If not generates the
1096 // appropriate GL error. Returns true if the current program is in a usable 1096 // appropriate GL error. Returns true if the current program is in a usable
1097 // state. 1097 // state.
1098 bool CheckCurrentProgram(const char* function_name); 1098 bool CheckCurrentProgram(const char* function_name);
1099 1099
1100 // Checks if the current program exists and is valid and that location is not 1100 // Checks if the current program exists and is valid and that location is not
1101 // -1. If the current program is not valid generates the appropriate GL 1101 // -1. If the current program is not valid generates the appropriate GL
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
1391 error::Error DoDrawArrays( 1391 error::Error DoDrawArrays(
1392 const char* function_name, 1392 const char* function_name,
1393 bool instanced, GLenum mode, GLint first, GLsizei count, 1393 bool instanced, GLenum mode, GLint first, GLsizei count,
1394 GLsizei primcount); 1394 GLsizei primcount);
1395 error::Error DoDrawElements( 1395 error::Error DoDrawElements(
1396 const char* function_name, 1396 const char* function_name,
1397 bool instanced, GLenum mode, GLsizei count, GLenum type, 1397 bool instanced, GLenum mode, GLsizei count, GLenum type,
1398 int32 offset, GLsizei primcount); 1398 int32 offset, GLsizei primcount);
1399 1399
1400 // Gets the buffer id for a given target. 1400 // Gets the buffer id for a given target.
1401 BufferManager::BufferInfo* GetBufferInfoForTarget(GLenum target) { 1401 BufferManager::Buffer* GetBufferInfoForTarget(GLenum target) {
1402 DCHECK(target == GL_ARRAY_BUFFER || target == GL_ELEMENT_ARRAY_BUFFER); 1402 DCHECK(target == GL_ARRAY_BUFFER || target == GL_ELEMENT_ARRAY_BUFFER);
1403 if (target == GL_ARRAY_BUFFER) { 1403 if (target == GL_ARRAY_BUFFER) {
1404 return state_.bound_array_buffer; 1404 return state_.bound_array_buffer;
1405 } else { 1405 } else {
1406 return state_.vertex_attrib_manager->element_array_buffer(); 1406 return state_.vertex_attrib_manager->element_array_buffer();
1407 } 1407 }
1408 } 1408 }
1409 1409
1410 // Gets the texture id for a given target. 1410 // Gets the texture id for a given target.
1411 TextureManager::TextureInfo* GetTextureInfoForTarget(GLenum target) { 1411 Texture* GetTextureInfoForTarget(GLenum target) {
1412 TextureUnit& unit = state_.texture_units[state_.active_texture_unit]; 1412 TextureUnit& unit = state_.texture_units[state_.active_texture_unit];
1413 TextureManager::TextureInfo* info = NULL; 1413 Texture* info = NULL;
1414 switch (target) { 1414 switch (target) {
1415 case GL_TEXTURE_2D: 1415 case GL_TEXTURE_2D:
1416 info = unit.bound_texture_2d; 1416 info = unit.bound_texture_2d;
1417 break; 1417 break;
1418 case GL_TEXTURE_CUBE_MAP: 1418 case GL_TEXTURE_CUBE_MAP:
1419 case GL_TEXTURE_CUBE_MAP_POSITIVE_X: 1419 case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
1420 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: 1420 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
1421 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: 1421 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
1422 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: 1422 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
1423 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: 1423 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
1424 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: 1424 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
1425 info = unit.bound_texture_cube_map; 1425 info = unit.bound_texture_cube_map;
1426 break; 1426 break;
1427 case GL_TEXTURE_EXTERNAL_OES: 1427 case GL_TEXTURE_EXTERNAL_OES:
1428 info = unit.bound_texture_external_oes; 1428 info = unit.bound_texture_external_oes;
1429 break; 1429 break;
1430 case GL_TEXTURE_RECTANGLE_ARB: 1430 case GL_TEXTURE_RECTANGLE_ARB:
1431 info = unit.bound_texture_rectangle_arb; 1431 info = unit.bound_texture_rectangle_arb;
1432 break; 1432 break;
1433 default: 1433 default:
1434 NOTREACHED(); 1434 NOTREACHED();
1435 return NULL; 1435 return NULL;
1436 } 1436 }
1437 return info; 1437 return info;
1438 } 1438 }
1439 1439
1440 TextureManager::TextureInfo* GetTextureInfoForTargetUnlessDefault( 1440 Texture* GetTextureInfoForTargetUnlessDefault(
1441 GLenum target) { 1441 GLenum target) {
1442 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target); 1442 Texture* info = GetTextureInfoForTarget(target);
1443 if (!info) 1443 if (!info)
1444 return NULL; 1444 return NULL;
1445 if (info == texture_manager()->GetDefaultTextureInfo(target)) 1445 if (info == texture_manager()->GetDefaultTextureInfo(target))
1446 return NULL; 1446 return NULL;
1447 return info; 1447 return info;
1448 } 1448 }
1449 1449
1450 GLenum GetBindTargetForSamplerType(GLenum type) { 1450 GLenum GetBindTargetForSamplerType(GLenum type) {
1451 DCHECK(type == GL_SAMPLER_2D || type == GL_SAMPLER_CUBE || 1451 DCHECK(type == GL_SAMPLER_2D || type == GL_SAMPLER_CUBE ||
1452 type == GL_SAMPLER_EXTERNAL_OES || type == GL_SAMPLER_2D_RECT_ARB); 1452 type == GL_SAMPLER_EXTERNAL_OES || type == GL_SAMPLER_2D_RECT_ARB);
1453 switch (type) { 1453 switch (type) {
1454 case GL_SAMPLER_2D: 1454 case GL_SAMPLER_2D:
1455 return GL_TEXTURE_2D; 1455 return GL_TEXTURE_2D;
1456 case GL_SAMPLER_CUBE: 1456 case GL_SAMPLER_CUBE:
1457 return GL_TEXTURE_CUBE_MAP; 1457 return GL_TEXTURE_CUBE_MAP;
1458 case GL_SAMPLER_EXTERNAL_OES: 1458 case GL_SAMPLER_EXTERNAL_OES:
1459 return GL_TEXTURE_EXTERNAL_OES; 1459 return GL_TEXTURE_EXTERNAL_OES;
1460 case GL_SAMPLER_2D_RECT_ARB: 1460 case GL_SAMPLER_2D_RECT_ARB:
1461 return GL_TEXTURE_RECTANGLE_ARB; 1461 return GL_TEXTURE_RECTANGLE_ARB;
1462 } 1462 }
1463 1463
1464 NOTREACHED(); 1464 NOTREACHED();
1465 return 0; 1465 return 0;
1466 } 1466 }
1467 1467
1468 // Gets the framebuffer info for a particular target. 1468 // Gets the framebuffer info for a particular target.
1469 FramebufferManager::FramebufferInfo* GetFramebufferInfoForTarget( 1469 Framebuffer* GetFramebufferInfoForTarget(
1470 GLenum target) { 1470 GLenum target) {
1471 FramebufferManager::FramebufferInfo* info = NULL; 1471 Framebuffer* info = NULL;
1472 switch (target) { 1472 switch (target) {
1473 case GL_FRAMEBUFFER: 1473 case GL_FRAMEBUFFER:
1474 case GL_DRAW_FRAMEBUFFER_EXT: 1474 case GL_DRAW_FRAMEBUFFER_EXT:
1475 info = state_.bound_draw_framebuffer; 1475 info = state_.bound_draw_framebuffer;
1476 break; 1476 break;
1477 case GL_READ_FRAMEBUFFER_EXT: 1477 case GL_READ_FRAMEBUFFER_EXT:
1478 info = state_.bound_read_framebuffer; 1478 info = state_.bound_read_framebuffer;
1479 break; 1479 break;
1480 default: 1480 default:
1481 NOTREACHED(); 1481 NOTREACHED();
1482 break; 1482 break;
1483 } 1483 }
1484 return info; 1484 return info;
1485 } 1485 }
1486 1486
1487 RenderbufferManager::RenderbufferInfo* GetRenderbufferInfoForTarget( 1487 Renderbuffer* GetRenderbufferInfoForTarget(
1488 GLenum target) { 1488 GLenum target) {
1489 RenderbufferManager::RenderbufferInfo* info = NULL; 1489 Renderbuffer* info = NULL;
1490 switch (target) { 1490 switch (target) {
1491 case GL_RENDERBUFFER: 1491 case GL_RENDERBUFFER:
1492 info = state_.bound_renderbuffer; 1492 info = state_.bound_renderbuffer;
1493 break; 1493 break;
1494 default: 1494 default:
1495 NOTREACHED(); 1495 NOTREACHED();
1496 break; 1496 break;
1497 } 1497 }
1498 return info; 1498 return info;
1499 } 1499 }
(...skipping 28 matching lines...) Expand all
1528 bool ValidateCompressedTexDimensions( 1528 bool ValidateCompressedTexDimensions(
1529 const char* function_name, 1529 const char* function_name,
1530 GLint level, GLsizei width, GLsizei height, GLenum format); 1530 GLint level, GLsizei width, GLsizei height, GLenum format);
1531 bool ValidateCompressedTexFuncData( 1531 bool ValidateCompressedTexFuncData(
1532 const char* function_name, 1532 const char* function_name,
1533 GLsizei width, GLsizei height, GLenum format, size_t size); 1533 GLsizei width, GLsizei height, GLenum format, size_t size);
1534 bool ValidateCompressedTexSubDimensions( 1534 bool ValidateCompressedTexSubDimensions(
1535 const char* function_name, 1535 const char* function_name,
1536 GLenum target, GLint level, GLint xoffset, GLint yoffset, 1536 GLenum target, GLint level, GLint xoffset, GLint yoffset,
1537 GLsizei width, GLsizei height, GLenum format, 1537 GLsizei width, GLsizei height, GLenum format,
1538 TextureManager::TextureInfo* texture); 1538 Texture* texture);
1539 1539
1540 void LogMessage(const std::string& msg); 1540 void LogMessage(const std::string& msg);
1541 void RenderWarning(const std::string& msg); 1541 void RenderWarning(const std::string& msg);
1542 void PerformanceWarning(const std::string& msg); 1542 void PerformanceWarning(const std::string& msg);
1543 const std::string& GetLogPrefix() const; 1543 const std::string& GetLogPrefix() const;
1544 1544
1545 const FeatureInfo::FeatureFlags& features() const { 1545 const FeatureInfo::FeatureFlags& features() const {
1546 return feature_info_->feature_flags(); 1546 return feature_info_->feature_flags();
1547 } 1547 }
1548 1548
1549 const FeatureInfo::Workarounds& workarounds() const { 1549 const FeatureInfo::Workarounds& workarounds() const {
1550 return feature_info_->workarounds(); 1550 return feature_info_->workarounds();
1551 } 1551 }
1552 1552
1553 bool ShouldDeferDraws() { 1553 bool ShouldDeferDraws() {
1554 return !offscreen_target_frame_buffer_.get() && 1554 return !offscreen_target_frame_buffer_.get() &&
1555 state_.bound_draw_framebuffer == NULL && 1555 state_.bound_draw_framebuffer == NULL &&
1556 surface_->DeferDraws(); 1556 surface_->DeferDraws();
1557 } 1557 }
1558 1558
1559 bool ShouldDeferReads() { 1559 bool ShouldDeferReads() {
1560 return !offscreen_target_frame_buffer_.get() && 1560 return !offscreen_target_frame_buffer_.get() &&
1561 state_.bound_read_framebuffer == NULL && 1561 state_.bound_read_framebuffer == NULL &&
1562 surface_->DeferDraws(); 1562 surface_->DeferDraws();
1563 } 1563 }
1564 1564
1565 void ForceCompileShaderIfPending(ShaderManager::ShaderInfo* info); 1565 void ForceCompileShaderIfPending(Shader* info);
1566 1566
1567 // Generate a member function prototype for each command in an automated and 1567 // Generate a member function prototype for each command in an automated and
1568 // typesafe way. 1568 // typesafe way.
1569 #define GLES2_CMD_OP(name) \ 1569 #define GLES2_CMD_OP(name) \
1570 Error Handle ## name( \ 1570 Error Handle ## name( \
1571 uint32 immediate_data_size, \ 1571 uint32 immediate_data_size, \
1572 const gles2::name& args); \ 1572 const cmds::name& args); \
1573 1573
1574 GLES2_COMMAND_LIST(GLES2_CMD_OP) 1574 GLES2_COMMAND_LIST(GLES2_CMD_OP)
1575 1575
1576 #undef GLES2_CMD_OP 1576 #undef GLES2_CMD_OP
1577 1577
1578 // The GL context this decoder renders to on behalf of the client. 1578 // The GL context this decoder renders to on behalf of the client.
1579 scoped_refptr<gfx::GLSurface> surface_; 1579 scoped_refptr<gfx::GLSurface> surface_;
1580 scoped_refptr<gfx::GLContext> context_; 1580 scoped_refptr<gfx::GLContext> context_;
1581 1581
1582 // The ContextGroup for this decoder uses to track resources. 1582 // The ContextGroup for this decoder uses to track resources.
1583 ContextGroup::Ref group_; 1583 scoped_refptr<ContextGroup> group_;
1584 1584
1585 // All the state for this context. 1585 // All the state for this context.
1586 ContextState state_; 1586 ContextState state_;
1587 1587
1588 // A parent decoder can access this decoders saved offscreen frame buffer. 1588 // A parent decoder can access this decoders saved offscreen frame buffer.
1589 // The parent pointer is reset if the parent is destroyed. 1589 // The parent pointer is reset if the parent is destroyed.
1590 base::WeakPtr<GLES2DecoderImpl> parent_; 1590 base::WeakPtr<GLES2DecoderImpl> parent_;
1591 1591
1592 // Current width and height of the offscreen frame buffer. 1592 // Current width and height of the offscreen frame buffer.
1593 gfx::Size offscreen_size_; 1593 gfx::Size offscreen_size_;
1594 1594
1595 // Current GL error bits. 1595 // Current GL error bits.
1596 uint32 error_bits_; 1596 uint32 error_bits_;
1597 1597
1598 // Util to help with GL. 1598 // Util to help with GL.
1599 GLES2Util util_; 1599 GLES2Util util_;
1600 1600
1601 // unpack flip y as last set by glPixelStorei 1601 // unpack flip y as last set by glPixelStorei
1602 bool unpack_flip_y_; 1602 bool unpack_flip_y_;
1603 1603
1604 // unpack (un)premultiply alpha as last set by glPixelStorei 1604 // unpack (un)premultiply alpha as last set by glPixelStorei
1605 bool unpack_premultiply_alpha_; 1605 bool unpack_premultiply_alpha_;
1606 bool unpack_unpremultiply_alpha_; 1606 bool unpack_unpremultiply_alpha_;
1607 1607
1608 // Default vertex attribs manager, used when no VAOs are bound. 1608 // Default vertex attribs manager, used when no VAOs are bound.
1609 VertexAttribManager::Ref default_vertex_attrib_manager_; 1609 scoped_refptr<VertexAttribManager> default_vertex_attrib_manager_;
1610 1610
1611 // The buffer we bind to attrib 0 since OpenGL requires it (ES does not). 1611 // The buffer we bind to attrib 0 since OpenGL requires it (ES does not).
1612 GLuint attrib_0_buffer_id_; 1612 GLuint attrib_0_buffer_id_;
1613 1613
1614 // The value currently in attrib_0. 1614 // The value currently in attrib_0.
1615 Vec4 attrib_0_value_; 1615 Vec4 attrib_0_value_;
1616 1616
1617 // Whether or not the attrib_0 buffer holds the attrib_0_value. 1617 // Whether or not the attrib_0 buffer holds the attrib_0_value.
1618 bool attrib_0_buffer_matches_value_; 1618 bool attrib_0_buffer_matches_value_;
1619 1619
1620 // The size of attrib 0. 1620 // The size of attrib 0.
1621 GLsizei attrib_0_size_; 1621 GLsizei attrib_0_size_;
1622 1622
1623 // The buffer used to simulate GL_FIXED attribs. 1623 // The buffer used to simulate GL_FIXED attribs.
1624 GLuint fixed_attrib_buffer_id_; 1624 GLuint fixed_attrib_buffer_id_;
1625 1625
1626 // The size of fiixed attrib buffer. 1626 // The size of fiixed attrib buffer.
1627 GLsizei fixed_attrib_buffer_size_; 1627 GLsizei fixed_attrib_buffer_size_;
1628 1628
1629 // state saved for clearing so we can clear render buffers and then 1629 // state saved for clearing so we can clear render buffers and then
1630 // restore to these values. 1630 // restore to these values.
1631 bool clear_state_dirty_; 1631 bool clear_state_dirty_;
1632 1632
1633 // The offscreen frame buffer that the client renders to. With EGL, the 1633 // The offscreen frame buffer that the client renders to. With EGL, the
1634 // depth and stencil buffers are separate. With regular GL there is a single 1634 // depth and stencil buffers are separate. With regular GL there is a single
1635 // packed depth stencil buffer in offscreen_target_depth_render_buffer_. 1635 // packed depth stencil buffer in offscreen_target_depth_render_buffer_.
1636 // offscreen_target_stencil_render_buffer_ is unused. 1636 // offscreen_target_stencil_render_buffer_ is unused.
1637 scoped_ptr<FrameBuffer> offscreen_target_frame_buffer_; 1637 scoped_ptr<BackFramebuffer> offscreen_target_frame_buffer_;
1638 scoped_ptr<Texture> offscreen_target_color_texture_; 1638 scoped_ptr<BackTexture> offscreen_target_color_texture_;
1639 scoped_ptr<RenderBuffer> offscreen_target_color_render_buffer_; 1639 scoped_ptr<BackRenderbuffer> offscreen_target_color_render_buffer_;
1640 scoped_ptr<RenderBuffer> offscreen_target_depth_render_buffer_; 1640 scoped_ptr<BackRenderbuffer> offscreen_target_depth_render_buffer_;
1641 scoped_ptr<RenderBuffer> offscreen_target_stencil_render_buffer_; 1641 scoped_ptr<BackRenderbuffer> offscreen_target_stencil_render_buffer_;
1642 GLenum offscreen_target_color_format_; 1642 GLenum offscreen_target_color_format_;
1643 GLenum offscreen_target_depth_format_; 1643 GLenum offscreen_target_depth_format_;
1644 GLenum offscreen_target_stencil_format_; 1644 GLenum offscreen_target_stencil_format_;
1645 GLsizei offscreen_target_samples_; 1645 GLsizei offscreen_target_samples_;
1646 GLboolean offscreen_target_buffer_preserved_; 1646 GLboolean offscreen_target_buffer_preserved_;
1647 1647
1648 // The copy that is saved when SwapBuffers is called. 1648 // The copy that is saved when SwapBuffers is called.
1649 scoped_ptr<FrameBuffer> offscreen_saved_frame_buffer_; 1649 scoped_ptr<BackFramebuffer> offscreen_saved_frame_buffer_;
1650 scoped_ptr<Texture> offscreen_saved_color_texture_; 1650 scoped_ptr<BackTexture> offscreen_saved_color_texture_;
1651 TextureManager::TextureInfo::Ref offscreen_saved_color_texture_info_; 1651 scoped_refptr<Texture>
1652 offscreen_saved_color_texture_info_;
1652 1653
1653 // The copy that is used as the destination for multi-sample resolves. 1654 // The copy that is used as the destination for multi-sample resolves.
1654 scoped_ptr<FrameBuffer> offscreen_resolved_frame_buffer_; 1655 scoped_ptr<BackFramebuffer> offscreen_resolved_frame_buffer_;
1655 scoped_ptr<Texture> offscreen_resolved_color_texture_; 1656 scoped_ptr<BackTexture> offscreen_resolved_color_texture_;
1656 GLenum offscreen_saved_color_format_; 1657 GLenum offscreen_saved_color_format_;
1657 1658
1658 scoped_ptr<QueryManager> query_manager_; 1659 scoped_ptr<QueryManager> query_manager_;
1659 1660
1660 scoped_ptr<VertexArrayManager> vertex_array_manager_; 1661 scoped_ptr<VertexArrayManager> vertex_array_manager_;
1661 1662
1662 base::Callback<void(gfx::Size)> resize_callback_; 1663 base::Callback<void(gfx::Size)> resize_callback_;
1663 1664
1664 MsgCallback msg_callback_; 1665 MsgCallback msg_callback_;
1665 WaitSyncPointCallback wait_sync_point_callback_; 1666 WaitSyncPointCallback wait_sync_point_callback_;
(...skipping 23 matching lines...) Expand all
1689 std::string this_in_hex_; 1690 std::string this_in_hex_;
1690 1691
1691 bool use_shader_translator_; 1692 bool use_shader_translator_;
1692 scoped_refptr<ShaderTranslator> vertex_translator_; 1693 scoped_refptr<ShaderTranslator> vertex_translator_;
1693 scoped_refptr<ShaderTranslator> fragment_translator_; 1694 scoped_refptr<ShaderTranslator> fragment_translator_;
1694 1695
1695 DisallowedFeatures disallowed_features_; 1696 DisallowedFeatures disallowed_features_;
1696 1697
1697 // Cached from ContextGroup 1698 // Cached from ContextGroup
1698 const Validators* validators_; 1699 const Validators* validators_;
1699 FeatureInfo::Ref feature_info_; 1700 scoped_refptr<FeatureInfo> feature_info_;
1700 1701
1701 // This indicates all the following texSubImage2D calls that are part of the 1702 // This indicates all the following texSubImage2D calls that are part of the
1702 // failed texImage2D call should be ignored. 1703 // failed texImage2D call should be ignored.
1703 bool tex_image_2d_failed_; 1704 bool tex_image_2d_failed_;
1704 1705
1705 int frame_number_; 1706 int frame_number_;
1706 1707
1707 bool has_robustness_extension_; 1708 bool has_robustness_extension_;
1708 GLenum reset_status_; 1709 GLenum reset_status_;
1709 1710
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
1804 if (!resolve_and_bind_) 1805 if (!resolve_and_bind_)
1805 return; 1806 return;
1806 1807
1807 ScopedGLErrorSuppressor suppressor(decoder_); 1808 ScopedGLErrorSuppressor suppressor(decoder_);
1808 glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, 1809 glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT,
1809 decoder_->offscreen_target_frame_buffer_->id()); 1810 decoder_->offscreen_target_frame_buffer_->id());
1810 GLuint targetid; 1811 GLuint targetid;
1811 if (internal) { 1812 if (internal) {
1812 if (!decoder_->offscreen_resolved_frame_buffer_.get()) { 1813 if (!decoder_->offscreen_resolved_frame_buffer_.get()) {
1813 decoder_->offscreen_resolved_frame_buffer_.reset( 1814 decoder_->offscreen_resolved_frame_buffer_.reset(
1814 new FrameBuffer(decoder_)); 1815 new BackFramebuffer(decoder_));
1815 decoder_->offscreen_resolved_frame_buffer_->Create(); 1816 decoder_->offscreen_resolved_frame_buffer_->Create();
1816 decoder_->offscreen_resolved_color_texture_.reset(new Texture(decoder_)); 1817 decoder_->offscreen_resolved_color_texture_.reset(
1818 new BackTexture(decoder_));
1817 decoder_->offscreen_resolved_color_texture_->Create(); 1819 decoder_->offscreen_resolved_color_texture_->Create();
1818 1820
1819 DCHECK(decoder_->offscreen_saved_color_format_); 1821 DCHECK(decoder_->offscreen_saved_color_format_);
1820 decoder_->offscreen_resolved_color_texture_->AllocateStorage( 1822 decoder_->offscreen_resolved_color_texture_->AllocateStorage(
1821 decoder_->offscreen_size_, decoder_->offscreen_saved_color_format_, 1823 decoder_->offscreen_size_, decoder_->offscreen_saved_color_format_,
1822 false); 1824 false);
1823 decoder_->offscreen_resolved_frame_buffer_->AttachRenderTexture( 1825 decoder_->offscreen_resolved_frame_buffer_->AttachRenderTexture(
1824 decoder_->offscreen_resolved_color_texture_.get()); 1826 decoder_->offscreen_resolved_color_texture_.get());
1825 if (decoder_->offscreen_resolved_frame_buffer_->CheckStatus() != 1827 if (decoder_->offscreen_resolved_frame_buffer_->CheckStatus() !=
1826 GL_FRAMEBUFFER_COMPLETE) { 1828 GL_FRAMEBUFFER_COMPLETE) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1862 : decoder_(decoder), 1864 : decoder_(decoder),
1863 begin_time_(base::TimeTicks::HighResNow()) { 1865 begin_time_(base::TimeTicks::HighResNow()) {
1864 } 1866 }
1865 1867
1866 ScopedTextureUploadTimer::~ScopedTextureUploadTimer() { 1868 ScopedTextureUploadTimer::~ScopedTextureUploadTimer() {
1867 decoder_->texture_upload_count_++; 1869 decoder_->texture_upload_count_++;
1868 decoder_->total_texture_upload_time_ += 1870 decoder_->total_texture_upload_time_ +=
1869 base::TimeTicks::HighResNow() - begin_time_; 1871 base::TimeTicks::HighResNow() - begin_time_;
1870 } 1872 }
1871 1873
1872 Texture::Texture(GLES2DecoderImpl* decoder) 1874 BackTexture::BackTexture(GLES2DecoderImpl* decoder)
1873 : decoder_(decoder), 1875 : decoder_(decoder),
1874 memory_tracker_(decoder->memory_tracker(), MemoryTracker::kUnmanaged), 1876 memory_tracker_(decoder->memory_tracker(), MemoryTracker::kUnmanaged),
1875 bytes_allocated_(0), 1877 bytes_allocated_(0),
1876 id_(0) { 1878 id_(0) {
1877 } 1879 }
1878 1880
1879 Texture::~Texture() { 1881 BackTexture::~BackTexture() {
1880 // This does not destroy the render texture because that would require that 1882 // This does not destroy the render texture because that would require that
1881 // the associated GL context was current. Just check that it was explicitly 1883 // the associated GL context was current. Just check that it was explicitly
1882 // destroyed. 1884 // destroyed.
1883 DCHECK_EQ(id_, 0u); 1885 DCHECK_EQ(id_, 0u);
1884 } 1886 }
1885 1887
1886 void Texture::Create() { 1888 void BackTexture::Create() {
1887 ScopedGLErrorSuppressor suppressor(decoder_); 1889 ScopedGLErrorSuppressor suppressor(decoder_);
1888 Destroy(); 1890 Destroy();
1889 glGenTextures(1, &id_); 1891 glGenTextures(1, &id_);
1890 ScopedTexture2DBinder binder(decoder_, id_); 1892 ScopedTexture2DBinder binder(decoder_, id_);
1891 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 1893 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1892 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 1894 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
1893 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 1895 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
1894 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 1896 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
1895 1897
1896 // TODO(apatrick): Attempt to diagnose crbug.com/97775. If SwapBuffers is 1898 // TODO(apatrick): Attempt to diagnose crbug.com/97775. If SwapBuffers is
1897 // never called on an offscreen context, no data will ever be uploaded to the 1899 // never called on an offscreen context, no data will ever be uploaded to the
1898 // saved offscreen color texture (it is deferred until to when SwapBuffers 1900 // saved offscreen color texture (it is deferred until to when SwapBuffers
1899 // is called). My idea is that some nvidia drivers might have a bug where 1901 // is called). My idea is that some nvidia drivers might have a bug where
1900 // deleting a texture that has never been populated might cause a 1902 // deleting a texture that has never been populated might cause a
1901 // crash. 1903 // crash.
1902 glTexImage2D( 1904 glTexImage2D(
1903 GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); 1905 GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
1904 1906
1905 bytes_allocated_ = 16u * 16u * 4u; 1907 bytes_allocated_ = 16u * 16u * 4u;
1906 memory_tracker_.TrackMemAlloc(bytes_allocated_); 1908 memory_tracker_.TrackMemAlloc(bytes_allocated_);
1907 } 1909 }
1908 1910
1909 bool Texture::AllocateStorage(const gfx::Size& size, GLenum format, bool zero) { 1911 bool BackTexture::AllocateStorage(
1912 const gfx::Size& size, GLenum format, bool zero) {
1910 DCHECK_NE(id_, 0u); 1913 DCHECK_NE(id_, 0u);
1911 ScopedGLErrorSuppressor suppressor(decoder_); 1914 ScopedGLErrorSuppressor suppressor(decoder_);
1912 ScopedTexture2DBinder binder(decoder_, id_); 1915 ScopedTexture2DBinder binder(decoder_, id_);
1913 uint32 image_size = 0; 1916 uint32 image_size = 0;
1914 GLES2Util::ComputeImageDataSizes( 1917 GLES2Util::ComputeImageDataSizes(
1915 size.width(), size.height(), format, GL_UNSIGNED_BYTE, 8, &image_size, 1918 size.width(), size.height(), format, GL_UNSIGNED_BYTE, 8, &image_size,
1916 NULL, NULL); 1919 NULL, NULL);
1917 1920
1918 if (!memory_tracker_.EnsureGPUMemoryAvailable(image_size)) { 1921 if (!memory_tracker_.EnsureGPUMemoryAvailable(image_size)) {
1919 return false; 1922 return false;
(...skipping 19 matching lines...) Expand all
1939 1942
1940 bool success = glGetError() == GL_NO_ERROR; 1943 bool success = glGetError() == GL_NO_ERROR;
1941 if (success) { 1944 if (success) {
1942 memory_tracker_.TrackMemFree(bytes_allocated_); 1945 memory_tracker_.TrackMemFree(bytes_allocated_);
1943 bytes_allocated_ = image_size; 1946 bytes_allocated_ = image_size;
1944 memory_tracker_.TrackMemAlloc(bytes_allocated_); 1947 memory_tracker_.TrackMemAlloc(bytes_allocated_);
1945 } 1948 }
1946 return success; 1949 return success;
1947 } 1950 }
1948 1951
1949 void Texture::Copy(const gfx::Size& size, GLenum format) { 1952 void BackTexture::Copy(const gfx::Size& size, GLenum format) {
1950 DCHECK_NE(id_, 0u); 1953 DCHECK_NE(id_, 0u);
1951 ScopedGLErrorSuppressor suppressor(decoder_); 1954 ScopedGLErrorSuppressor suppressor(decoder_);
1952 ScopedTexture2DBinder binder(decoder_, id_); 1955 ScopedTexture2DBinder binder(decoder_, id_);
1953 glCopyTexImage2D(GL_TEXTURE_2D, 1956 glCopyTexImage2D(GL_TEXTURE_2D,
1954 0, // level 1957 0, // level
1955 format, 1958 format,
1956 0, 0, 1959 0, 0,
1957 size.width(), 1960 size.width(),
1958 size.height(), 1961 size.height(),
1959 0); // border 1962 0); // border
1960 } 1963 }
1961 1964
1962 void Texture::Destroy() { 1965 void BackTexture::Destroy() {
1963 if (id_ != 0) { 1966 if (id_ != 0) {
1964 ScopedGLErrorSuppressor suppressor(decoder_); 1967 ScopedGLErrorSuppressor suppressor(decoder_);
1965 glDeleteTextures(1, &id_); 1968 glDeleteTextures(1, &id_);
1966 id_ = 0; 1969 id_ = 0;
1967 } 1970 }
1968 memory_tracker_.TrackMemFree(bytes_allocated_); 1971 memory_tracker_.TrackMemFree(bytes_allocated_);
1969 bytes_allocated_ = 0; 1972 bytes_allocated_ = 0;
1970 } 1973 }
1971 1974
1972 void Texture::Invalidate() { 1975 void BackTexture::Invalidate() {
1973 id_ = 0; 1976 id_ = 0;
1974 } 1977 }
1975 1978
1976 RenderBuffer::RenderBuffer(GLES2DecoderImpl* decoder) 1979 BackRenderbuffer::BackRenderbuffer(GLES2DecoderImpl* decoder)
1977 : decoder_(decoder), 1980 : decoder_(decoder),
1978 memory_tracker_(decoder->memory_tracker(), MemoryTracker::kUnmanaged), 1981 memory_tracker_(decoder->memory_tracker(), MemoryTracker::kUnmanaged),
1979 bytes_allocated_(0), 1982 bytes_allocated_(0),
1980 id_(0) { 1983 id_(0) {
1981 } 1984 }
1982 1985
1983 RenderBuffer::~RenderBuffer() { 1986 BackRenderbuffer::~BackRenderbuffer() {
1984 // This does not destroy the render buffer because that would require that 1987 // This does not destroy the render buffer because that would require that
1985 // the associated GL context was current. Just check that it was explicitly 1988 // the associated GL context was current. Just check that it was explicitly
1986 // destroyed. 1989 // destroyed.
1987 DCHECK_EQ(id_, 0u); 1990 DCHECK_EQ(id_, 0u);
1988 } 1991 }
1989 1992
1990 void RenderBuffer::Create() { 1993 void BackRenderbuffer::Create() {
1991 ScopedGLErrorSuppressor suppressor(decoder_); 1994 ScopedGLErrorSuppressor suppressor(decoder_);
1992 Destroy(); 1995 Destroy();
1993 glGenRenderbuffersEXT(1, &id_); 1996 glGenRenderbuffersEXT(1, &id_);
1994 } 1997 }
1995 1998
1996 bool RenderBuffer::AllocateStorage(const gfx::Size& size, GLenum format, 1999 bool BackRenderbuffer::AllocateStorage(const gfx::Size& size, GLenum format,
1997 GLsizei samples) { 2000 GLsizei samples) {
1998 ScopedGLErrorSuppressor suppressor(decoder_); 2001 ScopedGLErrorSuppressor suppressor(decoder_);
1999 ScopedRenderBufferBinder binder(decoder_, id_); 2002 ScopedRenderBufferBinder binder(decoder_, id_);
2000 2003
2001 uint32 estimated_size = 0; 2004 uint32 estimated_size = 0;
2002 if (!RenderbufferManager::ComputeEstimatedRenderbufferSize( 2005 if (!RenderbufferManager::ComputeEstimatedRenderbufferSize(
2003 size.width(), size.height(), samples, format, &estimated_size)) { 2006 size.width(), size.height(), samples, format, &estimated_size)) {
2004 return false; 2007 return false;
2005 } 2008 }
2006 2009
2007 if (!memory_tracker_.EnsureGPUMemoryAvailable(estimated_size)) { 2010 if (!memory_tracker_.EnsureGPUMemoryAvailable(estimated_size)) {
(...skipping 22 matching lines...) Expand all
2030 } 2033 }
2031 bool success = glGetError() == GL_NO_ERROR; 2034 bool success = glGetError() == GL_NO_ERROR;
2032 if (success) { 2035 if (success) {
2033 memory_tracker_.TrackMemFree(bytes_allocated_); 2036 memory_tracker_.TrackMemFree(bytes_allocated_);
2034 bytes_allocated_ = estimated_size; 2037 bytes_allocated_ = estimated_size;
2035 memory_tracker_.TrackMemAlloc(bytes_allocated_); 2038 memory_tracker_.TrackMemAlloc(bytes_allocated_);
2036 } 2039 }
2037 return success; 2040 return success;
2038 } 2041 }
2039 2042
2040 void RenderBuffer::Destroy() { 2043 void BackRenderbuffer::Destroy() {
2041 if (id_ != 0) { 2044 if (id_ != 0) {
2042 ScopedGLErrorSuppressor suppressor(decoder_); 2045 ScopedGLErrorSuppressor suppressor(decoder_);
2043 glDeleteRenderbuffersEXT(1, &id_); 2046 glDeleteRenderbuffersEXT(1, &id_);
2044 id_ = 0; 2047 id_ = 0;
2045 } 2048 }
2046 memory_tracker_.TrackMemFree(bytes_allocated_); 2049 memory_tracker_.TrackMemFree(bytes_allocated_);
2047 bytes_allocated_ = 0; 2050 bytes_allocated_ = 0;
2048 } 2051 }
2049 2052
2050 void RenderBuffer::Invalidate() { 2053 void BackRenderbuffer::Invalidate() {
2051 id_ = 0; 2054 id_ = 0;
2052 } 2055 }
2053 2056
2054 FrameBuffer::FrameBuffer(GLES2DecoderImpl* decoder) 2057 BackFramebuffer::BackFramebuffer(GLES2DecoderImpl* decoder)
2055 : decoder_(decoder), 2058 : decoder_(decoder),
2056 id_(0) { 2059 id_(0) {
2057 } 2060 }
2058 2061
2059 FrameBuffer::~FrameBuffer() { 2062 BackFramebuffer::~BackFramebuffer() {
2060 // This does not destroy the frame buffer because that would require that 2063 // This does not destroy the frame buffer because that would require that
2061 // the associated GL context was current. Just check that it was explicitly 2064 // the associated GL context was current. Just check that it was explicitly
2062 // destroyed. 2065 // destroyed.
2063 DCHECK_EQ(id_, 0u); 2066 DCHECK_EQ(id_, 0u);
2064 } 2067 }
2065 2068
2066 void FrameBuffer::Create() { 2069 void BackFramebuffer::Create() {
2067 ScopedGLErrorSuppressor suppressor(decoder_); 2070 ScopedGLErrorSuppressor suppressor(decoder_);
2068 Destroy(); 2071 Destroy();
2069 glGenFramebuffersEXT(1, &id_); 2072 glGenFramebuffersEXT(1, &id_);
2070 } 2073 }
2071 2074
2072 void FrameBuffer::AttachRenderTexture(Texture* texture) { 2075 void BackFramebuffer::AttachRenderTexture(BackTexture* texture) {
2073 DCHECK_NE(id_, 0u); 2076 DCHECK_NE(id_, 0u);
2074 ScopedGLErrorSuppressor suppressor(decoder_); 2077 ScopedGLErrorSuppressor suppressor(decoder_);
2075 ScopedFrameBufferBinder binder(decoder_, id_); 2078 ScopedFrameBufferBinder binder(decoder_, id_);
2076 GLuint attach_id = texture ? texture->id() : 0; 2079 GLuint attach_id = texture ? texture->id() : 0;
2077 glFramebufferTexture2DEXT(GL_FRAMEBUFFER, 2080 glFramebufferTexture2DEXT(GL_FRAMEBUFFER,
2078 GL_COLOR_ATTACHMENT0, 2081 GL_COLOR_ATTACHMENT0,
2079 GL_TEXTURE_2D, 2082 GL_TEXTURE_2D,
2080 attach_id, 2083 attach_id,
2081 0); 2084 0);
2082 } 2085 }
2083 2086
2084 void FrameBuffer::AttachRenderBuffer(GLenum target, 2087 void BackFramebuffer::AttachRenderBuffer(GLenum target,
2085 RenderBuffer* render_buffer) { 2088 BackRenderbuffer* render_buffer) {
2086 DCHECK_NE(id_, 0u); 2089 DCHECK_NE(id_, 0u);
2087 ScopedGLErrorSuppressor suppressor(decoder_); 2090 ScopedGLErrorSuppressor suppressor(decoder_);
2088 ScopedFrameBufferBinder binder(decoder_, id_); 2091 ScopedFrameBufferBinder binder(decoder_, id_);
2089 GLuint attach_id = render_buffer ? render_buffer->id() : 0; 2092 GLuint attach_id = render_buffer ? render_buffer->id() : 0;
2090 glFramebufferRenderbufferEXT(GL_FRAMEBUFFER, 2093 glFramebufferRenderbufferEXT(GL_FRAMEBUFFER,
2091 target, 2094 target,
2092 GL_RENDERBUFFER, 2095 GL_RENDERBUFFER,
2093 attach_id); 2096 attach_id);
2094 } 2097 }
2095 2098
2096 void FrameBuffer::Destroy() { 2099 void BackFramebuffer::Destroy() {
2097 if (id_ != 0) { 2100 if (id_ != 0) {
2098 ScopedGLErrorSuppressor suppressor(decoder_); 2101 ScopedGLErrorSuppressor suppressor(decoder_);
2099 glDeleteFramebuffersEXT(1, &id_); 2102 glDeleteFramebuffersEXT(1, &id_);
2100 id_ = 0; 2103 id_ = 0;
2101 } 2104 }
2102 } 2105 }
2103 2106
2104 void FrameBuffer::Invalidate() { 2107 void BackFramebuffer::Invalidate() {
2105 id_ = 0; 2108 id_ = 0;
2106 } 2109 }
2107 2110
2108 GLenum FrameBuffer::CheckStatus() { 2111 GLenum BackFramebuffer::CheckStatus() {
2109 DCHECK_NE(id_, 0u); 2112 DCHECK_NE(id_, 0u);
2110 ScopedGLErrorSuppressor suppressor(decoder_); 2113 ScopedGLErrorSuppressor suppressor(decoder_);
2111 ScopedFrameBufferBinder binder(decoder_, id_); 2114 ScopedFrameBufferBinder binder(decoder_, id_);
2112 return glCheckFramebufferStatusEXT(GL_FRAMEBUFFER); 2115 return glCheckFramebufferStatusEXT(GL_FRAMEBUFFER);
2113 } 2116 }
2114 2117
2115 GLES2Decoder* GLES2Decoder::Create(ContextGroup* group) { 2118 GLES2Decoder* GLES2Decoder::Create(ContextGroup* group) {
2116 return new GLES2DecoderImpl(group); 2119 return new GLES2DecoderImpl(group);
2117 } 2120 }
2118 2121
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
2254 glGenBuffersARB(1, &attrib_0_buffer_id_); 2257 glGenBuffersARB(1, &attrib_0_buffer_id_);
2255 glBindBuffer(GL_ARRAY_BUFFER, attrib_0_buffer_id_); 2258 glBindBuffer(GL_ARRAY_BUFFER, attrib_0_buffer_id_);
2256 glVertexAttribPointer(0, 1, GL_FLOAT, GL_FALSE, 0, NULL); 2259 glVertexAttribPointer(0, 1, GL_FLOAT, GL_FALSE, 0, NULL);
2257 glBindBuffer(GL_ARRAY_BUFFER, 0); 2260 glBindBuffer(GL_ARRAY_BUFFER, 0);
2258 glGenBuffersARB(1, &fixed_attrib_buffer_id_); 2261 glGenBuffersARB(1, &fixed_attrib_buffer_id_);
2259 2262
2260 state_.texture_units.resize(group_->max_texture_units()); 2263 state_.texture_units.resize(group_->max_texture_units());
2261 for (uint32 tt = 0; tt < state_.texture_units.size(); ++tt) { 2264 for (uint32 tt = 0; tt < state_.texture_units.size(); ++tt) {
2262 glActiveTexture(GL_TEXTURE0 + tt); 2265 glActiveTexture(GL_TEXTURE0 + tt);
2263 // We want the last bind to be 2D. 2266 // We want the last bind to be 2D.
2264 TextureManager::TextureInfo* info; 2267 Texture* info;
2265 if (features().oes_egl_image_external) { 2268 if (features().oes_egl_image_external) {
2266 info = texture_manager()->GetDefaultTextureInfo(GL_TEXTURE_EXTERNAL_OES); 2269 info = texture_manager()->GetDefaultTextureInfo(GL_TEXTURE_EXTERNAL_OES);
2267 state_.texture_units[tt].bound_texture_external_oes = info; 2270 state_.texture_units[tt].bound_texture_external_oes = info;
2268 glBindTexture(GL_TEXTURE_EXTERNAL_OES, info->service_id()); 2271 glBindTexture(GL_TEXTURE_EXTERNAL_OES, info->service_id());
2269 } 2272 }
2270 if (features().arb_texture_rectangle) { 2273 if (features().arb_texture_rectangle) {
2271 info = texture_manager()->GetDefaultTextureInfo(GL_TEXTURE_RECTANGLE_ARB); 2274 info = texture_manager()->GetDefaultTextureInfo(GL_TEXTURE_RECTANGLE_ARB);
2272 state_.texture_units[tt].bound_texture_rectangle_arb = info; 2275 state_.texture_units[tt].bound_texture_rectangle_arb = info;
2273 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, info->service_id()); 2276 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, info->service_id());
2274 } 2277 }
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
2375 offscreen_target_stencil_format_ = attrib_parser.stencil_size_ > 0 ? 2378 offscreen_target_stencil_format_ = attrib_parser.stencil_size_ > 0 ?
2376 GL_STENCIL_INDEX : 0; 2379 GL_STENCIL_INDEX : 0;
2377 } 2380 }
2378 } 2381 }
2379 2382
2380 offscreen_saved_color_format_ = attrib_parser.alpha_size_ > 0 ? 2383 offscreen_saved_color_format_ = attrib_parser.alpha_size_ > 0 ?
2381 GL_RGBA : GL_RGB; 2384 GL_RGBA : GL_RGB;
2382 2385
2383 // Create the target frame buffer. This is the one that the client renders 2386 // Create the target frame buffer. This is the one that the client renders
2384 // directly to. 2387 // directly to.
2385 offscreen_target_frame_buffer_.reset(new FrameBuffer(this)); 2388 offscreen_target_frame_buffer_.reset(new BackFramebuffer(this));
2386 offscreen_target_frame_buffer_->Create(); 2389 offscreen_target_frame_buffer_->Create();
2387 // Due to GLES2 format limitations, either the color texture (for 2390 // Due to GLES2 format limitations, either the color texture (for
2388 // non-multisampling) or the color render buffer (for multisampling) will be 2391 // non-multisampling) or the color render buffer (for multisampling) will be
2389 // attached to the offscreen frame buffer. The render buffer has more 2392 // attached to the offscreen frame buffer. The render buffer has more
2390 // limited formats available to it, but the texture can't do multisampling. 2393 // limited formats available to it, but the texture can't do multisampling.
2391 if (IsOffscreenBufferMultisampled()) { 2394 if (IsOffscreenBufferMultisampled()) {
2392 offscreen_target_color_render_buffer_.reset(new RenderBuffer(this)); 2395 offscreen_target_color_render_buffer_.reset(new BackRenderbuffer(this));
2393 offscreen_target_color_render_buffer_->Create(); 2396 offscreen_target_color_render_buffer_->Create();
2394 } else { 2397 } else {
2395 offscreen_target_color_texture_.reset(new Texture(this)); 2398 offscreen_target_color_texture_.reset(new BackTexture(this));
2396 offscreen_target_color_texture_->Create(); 2399 offscreen_target_color_texture_->Create();
2397 } 2400 }
2398 offscreen_target_depth_render_buffer_.reset(new RenderBuffer(this)); 2401 offscreen_target_depth_render_buffer_.reset(new BackRenderbuffer(this));
2399 offscreen_target_depth_render_buffer_->Create(); 2402 offscreen_target_depth_render_buffer_->Create();
2400 offscreen_target_stencil_render_buffer_.reset(new RenderBuffer(this)); 2403 offscreen_target_stencil_render_buffer_.reset(new BackRenderbuffer(this));
2401 offscreen_target_stencil_render_buffer_->Create(); 2404 offscreen_target_stencil_render_buffer_->Create();
2402 2405
2403 // Create the saved offscreen texture. The target frame buffer is copied 2406 // Create the saved offscreen texture. The target frame buffer is copied
2404 // here when SwapBuffers is called. 2407 // here when SwapBuffers is called.
2405 offscreen_saved_frame_buffer_.reset(new FrameBuffer(this)); 2408 offscreen_saved_frame_buffer_.reset(new BackFramebuffer(this));
2406 offscreen_saved_frame_buffer_->Create(); 2409 offscreen_saved_frame_buffer_->Create();
2407 // 2410 //
2408 offscreen_saved_color_texture_.reset(new Texture(this)); 2411 offscreen_saved_color_texture_.reset(new BackTexture(this));
2409 offscreen_saved_color_texture_->Create(); 2412 offscreen_saved_color_texture_->Create();
2410 2413
2411 // Allocate the render buffers at their initial size and check the status 2414 // Allocate the render buffers at their initial size and check the status
2412 // of the frame buffers is okay. 2415 // of the frame buffers is okay.
2413 if (!ResizeOffscreenFrameBuffer(size)) { 2416 if (!ResizeOffscreenFrameBuffer(size)) {
2414 LOG(ERROR) << "Could not allocate offscreen buffer storage."; 2417 LOG(ERROR) << "Could not allocate offscreen buffer storage.";
2415 Destroy(true); 2418 Destroy(true);
2416 return false; 2419 return false;
2417 } 2420 }
2418 2421
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
2567 if (!fragment_translator_.get()) { 2570 if (!fragment_translator_.get()) {
2568 LOG(ERROR) << "Could not initialize fragment shader translator."; 2571 LOG(ERROR) << "Could not initialize fragment shader translator.";
2569 Destroy(true); 2572 Destroy(true);
2570 return false; 2573 return false;
2571 } 2574 }
2572 return true; 2575 return true;
2573 } 2576 }
2574 2577
2575 bool GLES2DecoderImpl::GenBuffersHelper(GLsizei n, const GLuint* client_ids) { 2578 bool GLES2DecoderImpl::GenBuffersHelper(GLsizei n, const GLuint* client_ids) {
2576 for (GLsizei ii = 0; ii < n; ++ii) { 2579 for (GLsizei ii = 0; ii < n; ++ii) {
2577 if (GetBufferInfo(client_ids[ii])) { 2580 if (GetBuffer(client_ids[ii])) {
2578 return false; 2581 return false;
2579 } 2582 }
2580 } 2583 }
2581 scoped_array<GLuint> service_ids(new GLuint[n]); 2584 scoped_array<GLuint> service_ids(new GLuint[n]);
2582 glGenBuffersARB(n, service_ids.get()); 2585 glGenBuffersARB(n, service_ids.get());
2583 for (GLsizei ii = 0; ii < n; ++ii) { 2586 for (GLsizei ii = 0; ii < n; ++ii) {
2584 CreateBufferInfo(client_ids[ii], service_ids[ii]); 2587 CreateBuffer(client_ids[ii], service_ids[ii]);
2585 } 2588 }
2586 return true; 2589 return true;
2587 } 2590 }
2588 2591
2589 bool GLES2DecoderImpl::GenFramebuffersHelper( 2592 bool GLES2DecoderImpl::GenFramebuffersHelper(
2590 GLsizei n, const GLuint* client_ids) { 2593 GLsizei n, const GLuint* client_ids) {
2591 for (GLsizei ii = 0; ii < n; ++ii) { 2594 for (GLsizei ii = 0; ii < n; ++ii) {
2592 if (GetFramebufferInfo(client_ids[ii])) { 2595 if (GetFramebuffer(client_ids[ii])) {
2593 return false; 2596 return false;
2594 } 2597 }
2595 } 2598 }
2596 scoped_array<GLuint> service_ids(new GLuint[n]); 2599 scoped_array<GLuint> service_ids(new GLuint[n]);
2597 glGenFramebuffersEXT(n, service_ids.get()); 2600 glGenFramebuffersEXT(n, service_ids.get());
2598 for (GLsizei ii = 0; ii < n; ++ii) { 2601 for (GLsizei ii = 0; ii < n; ++ii) {
2599 CreateFramebufferInfo(client_ids[ii], service_ids[ii]); 2602 CreateFramebuffer(client_ids[ii], service_ids[ii]);
2600 } 2603 }
2601 return true; 2604 return true;
2602 } 2605 }
2603 2606
2604 bool GLES2DecoderImpl::GenRenderbuffersHelper( 2607 bool GLES2DecoderImpl::GenRenderbuffersHelper(
2605 GLsizei n, const GLuint* client_ids) { 2608 GLsizei n, const GLuint* client_ids) {
2606 for (GLsizei ii = 0; ii < n; ++ii) { 2609 for (GLsizei ii = 0; ii < n; ++ii) {
2607 if (GetRenderbufferInfo(client_ids[ii])) { 2610 if (GetRenderbuffer(client_ids[ii])) {
2608 return false; 2611 return false;
2609 } 2612 }
2610 } 2613 }
2611 scoped_array<GLuint> service_ids(new GLuint[n]); 2614 scoped_array<GLuint> service_ids(new GLuint[n]);
2612 glGenRenderbuffersEXT(n, service_ids.get()); 2615 glGenRenderbuffersEXT(n, service_ids.get());
2613 for (GLsizei ii = 0; ii < n; ++ii) { 2616 for (GLsizei ii = 0; ii < n; ++ii) {
2614 CreateRenderbufferInfo(client_ids[ii], service_ids[ii]); 2617 CreateRenderbuffer(client_ids[ii], service_ids[ii]);
2615 } 2618 }
2616 return true; 2619 return true;
2617 } 2620 }
2618 2621
2619 bool GLES2DecoderImpl::GenTexturesHelper(GLsizei n, const GLuint* client_ids) { 2622 bool GLES2DecoderImpl::GenTexturesHelper(GLsizei n, const GLuint* client_ids) {
2620 for (GLsizei ii = 0; ii < n; ++ii) { 2623 for (GLsizei ii = 0; ii < n; ++ii) {
2621 if (GetTextureInfo(client_ids[ii])) { 2624 if (GetTexture(client_ids[ii])) {
2622 return false; 2625 return false;
2623 } 2626 }
2624 } 2627 }
2625 scoped_array<GLuint> service_ids(new GLuint[n]); 2628 scoped_array<GLuint> service_ids(new GLuint[n]);
2626 glGenTextures(n, service_ids.get()); 2629 glGenTextures(n, service_ids.get());
2627 for (GLsizei ii = 0; ii < n; ++ii) { 2630 for (GLsizei ii = 0; ii < n; ++ii) {
2628 CreateTextureInfo(client_ids[ii], service_ids[ii]); 2631 CreateTexture(client_ids[ii], service_ids[ii]);
2629 } 2632 }
2630 return true; 2633 return true;
2631 } 2634 }
2632 2635
2633 void GLES2DecoderImpl::DeleteBuffersHelper( 2636 void GLES2DecoderImpl::DeleteBuffersHelper(
2634 GLsizei n, const GLuint* client_ids) { 2637 GLsizei n, const GLuint* client_ids) {
2635 for (GLsizei ii = 0; ii < n; ++ii) { 2638 for (GLsizei ii = 0; ii < n; ++ii) {
2636 BufferManager::BufferInfo* buffer = GetBufferInfo(client_ids[ii]); 2639 BufferManager::Buffer* buffer = GetBuffer(client_ids[ii]);
2637 if (buffer && !buffer->IsDeleted()) { 2640 if (buffer && !buffer->IsDeleted()) {
2638 state_.vertex_attrib_manager->Unbind(buffer); 2641 state_.vertex_attrib_manager->Unbind(buffer);
2639 if (state_.bound_array_buffer == buffer) { 2642 if (state_.bound_array_buffer == buffer) {
2640 state_.bound_array_buffer = NULL; 2643 state_.bound_array_buffer = NULL;
2641 } 2644 }
2642 RemoveBufferInfo(client_ids[ii]); 2645 RemoveBuffer(client_ids[ii]);
2643 } 2646 }
2644 } 2647 }
2645 } 2648 }
2646 2649
2647 void GLES2DecoderImpl::DeleteFramebuffersHelper( 2650 void GLES2DecoderImpl::DeleteFramebuffersHelper(
2648 GLsizei n, const GLuint* client_ids) { 2651 GLsizei n, const GLuint* client_ids) {
2649 bool supports_separate_framebuffer_binds = 2652 bool supports_separate_framebuffer_binds =
2650 features().chromium_framebuffer_multisample; 2653 features().chromium_framebuffer_multisample;
2651 2654
2652 for (GLsizei ii = 0; ii < n; ++ii) { 2655 for (GLsizei ii = 0; ii < n; ++ii) {
2653 FramebufferManager::FramebufferInfo* framebuffer = 2656 Framebuffer* framebuffer =
2654 GetFramebufferInfo(client_ids[ii]); 2657 GetFramebuffer(client_ids[ii]);
2655 if (framebuffer && !framebuffer->IsDeleted()) { 2658 if (framebuffer && !framebuffer->IsDeleted()) {
2656 if (framebuffer == state_.bound_draw_framebuffer) { 2659 if (framebuffer == state_.bound_draw_framebuffer) {
2657 state_.bound_draw_framebuffer = NULL; 2660 state_.bound_draw_framebuffer = NULL;
2658 clear_state_dirty_ = true; 2661 clear_state_dirty_ = true;
2659 GLenum target = supports_separate_framebuffer_binds ? 2662 GLenum target = supports_separate_framebuffer_binds ?
2660 GL_DRAW_FRAMEBUFFER_EXT : GL_FRAMEBUFFER; 2663 GL_DRAW_FRAMEBUFFER_EXT : GL_FRAMEBUFFER;
2661 glBindFramebufferEXT(target, GetBackbufferServiceId()); 2664 glBindFramebufferEXT(target, GetBackbufferServiceId());
2662 } 2665 }
2663 if (framebuffer == state_.bound_read_framebuffer) { 2666 if (framebuffer == state_.bound_read_framebuffer) {
2664 state_.bound_read_framebuffer = NULL; 2667 state_.bound_read_framebuffer = NULL;
2665 GLenum target = supports_separate_framebuffer_binds ? 2668 GLenum target = supports_separate_framebuffer_binds ?
2666 GL_READ_FRAMEBUFFER_EXT : GL_FRAMEBUFFER; 2669 GL_READ_FRAMEBUFFER_EXT : GL_FRAMEBUFFER;
2667 glBindFramebufferEXT(target, GetBackbufferServiceId()); 2670 glBindFramebufferEXT(target, GetBackbufferServiceId());
2668 } 2671 }
2669 OnFboChanged(); 2672 OnFboChanged();
2670 RemoveFramebufferInfo(client_ids[ii]); 2673 RemoveFramebuffer(client_ids[ii]);
2671 } 2674 }
2672 } 2675 }
2673 } 2676 }
2674 2677
2675 void GLES2DecoderImpl::DeleteRenderbuffersHelper( 2678 void GLES2DecoderImpl::DeleteRenderbuffersHelper(
2676 GLsizei n, const GLuint* client_ids) { 2679 GLsizei n, const GLuint* client_ids) {
2677 bool supports_separate_framebuffer_binds = 2680 bool supports_separate_framebuffer_binds =
2678 features().chromium_framebuffer_multisample; 2681 features().chromium_framebuffer_multisample;
2679 for (GLsizei ii = 0; ii < n; ++ii) { 2682 for (GLsizei ii = 0; ii < n; ++ii) {
2680 RenderbufferManager::RenderbufferInfo* renderbuffer = 2683 Renderbuffer* renderbuffer =
2681 GetRenderbufferInfo(client_ids[ii]); 2684 GetRenderbuffer(client_ids[ii]);
2682 if (renderbuffer && !renderbuffer->IsDeleted()) { 2685 if (renderbuffer && !renderbuffer->IsDeleted()) {
2683 if (state_.bound_renderbuffer == renderbuffer) { 2686 if (state_.bound_renderbuffer == renderbuffer) {
2684 state_.bound_renderbuffer = NULL; 2687 state_.bound_renderbuffer = NULL;
2685 } 2688 }
2686 // Unbind from current framebuffers. 2689 // Unbind from current framebuffers.
2687 if (supports_separate_framebuffer_binds) { 2690 if (supports_separate_framebuffer_binds) {
2688 if (state_.bound_read_framebuffer) { 2691 if (state_.bound_read_framebuffer) {
2689 state_.bound_read_framebuffer->UnbindRenderbuffer( 2692 state_.bound_read_framebuffer->UnbindRenderbuffer(
2690 GL_READ_FRAMEBUFFER_EXT, renderbuffer); 2693 GL_READ_FRAMEBUFFER_EXT, renderbuffer);
2691 } 2694 }
2692 if (state_.bound_draw_framebuffer) { 2695 if (state_.bound_draw_framebuffer) {
2693 state_.bound_draw_framebuffer->UnbindRenderbuffer( 2696 state_.bound_draw_framebuffer->UnbindRenderbuffer(
2694 GL_DRAW_FRAMEBUFFER_EXT, renderbuffer); 2697 GL_DRAW_FRAMEBUFFER_EXT, renderbuffer);
2695 } 2698 }
2696 } else { 2699 } else {
2697 if (state_.bound_draw_framebuffer) { 2700 if (state_.bound_draw_framebuffer) {
2698 state_.bound_draw_framebuffer->UnbindRenderbuffer( 2701 state_.bound_draw_framebuffer->UnbindRenderbuffer(
2699 GL_FRAMEBUFFER, renderbuffer); 2702 GL_FRAMEBUFFER, renderbuffer);
2700 } 2703 }
2701 } 2704 }
2702 clear_state_dirty_ = true; 2705 clear_state_dirty_ = true;
2703 RemoveRenderbufferInfo(client_ids[ii]); 2706 RemoveRenderbuffer(client_ids[ii]);
2704 } 2707 }
2705 } 2708 }
2706 } 2709 }
2707 2710
2708 void GLES2DecoderImpl::DeleteTexturesHelper( 2711 void GLES2DecoderImpl::DeleteTexturesHelper(
2709 GLsizei n, const GLuint* client_ids) { 2712 GLsizei n, const GLuint* client_ids) {
2710 bool supports_separate_framebuffer_binds = 2713 bool supports_separate_framebuffer_binds =
2711 features().chromium_framebuffer_multisample; 2714 features().chromium_framebuffer_multisample;
2712 for (GLsizei ii = 0; ii < n; ++ii) { 2715 for (GLsizei ii = 0; ii < n; ++ii) {
2713 TextureManager::TextureInfo* texture = GetTextureInfo(client_ids[ii]); 2716 Texture* texture = GetTexture(client_ids[ii]);
2714 if (texture && !texture->IsDeleted()) { 2717 if (texture && !texture->IsDeleted()) {
2715 if (texture->IsAttachedToFramebuffer()) { 2718 if (texture->IsAttachedToFramebuffer()) {
2716 clear_state_dirty_ = true; 2719 clear_state_dirty_ = true;
2717 } 2720 }
2718 // Unbind texture from texture units. 2721 // Unbind texture from texture units.
2719 for (size_t jj = 0; jj < state_.texture_units.size(); ++jj) { 2722 for (size_t jj = 0; jj < state_.texture_units.size(); ++jj) {
2720 state_.texture_units[jj].Unbind(texture); 2723 state_.texture_units[jj].Unbind(texture);
2721 } 2724 }
2722 // Unbind from current framebuffers. 2725 // Unbind from current framebuffers.
2723 if (supports_separate_framebuffer_binds) { 2726 if (supports_separate_framebuffer_binds) {
(...skipping 12 matching lines...) Expand all
2736 } 2739 }
2737 GLuint service_id = texture->service_id(); 2740 GLuint service_id = texture->service_id();
2738 if (texture->IsStreamTexture() && stream_texture_manager_) { 2741 if (texture->IsStreamTexture() && stream_texture_manager_) {
2739 stream_texture_manager_->DestroyStreamTexture(service_id); 2742 stream_texture_manager_->DestroyStreamTexture(service_id);
2740 } 2743 }
2741 #if defined(OS_MACOSX) 2744 #if defined(OS_MACOSX)
2742 if (texture->target() == GL_TEXTURE_RECTANGLE_ARB) { 2745 if (texture->target() == GL_TEXTURE_RECTANGLE_ARB) {
2743 ReleaseIOSurfaceForTexture(service_id); 2746 ReleaseIOSurfaceForTexture(service_id);
2744 } 2747 }
2745 #endif 2748 #endif
2746 RemoveTextureInfo(client_ids[ii]); 2749 RemoveTexture(client_ids[ii]);
2747 } 2750 }
2748 } 2751 }
2749 } 2752 }
2750 2753
2751 // } // anonymous namespace 2754 // } // anonymous namespace
2752 2755
2753 bool GLES2DecoderImpl::MakeCurrent() { 2756 bool GLES2DecoderImpl::MakeCurrent() {
2754 if (!context_.get() || !context_->MakeCurrent(surface_.get())) 2757 if (!context_.get() || !context_->MakeCurrent(surface_.get()))
2755 return false; 2758 return false;
2756 2759
(...skipping 28 matching lines...) Expand all
2785 2788
2786 return true; 2789 return true;
2787 } 2790 }
2788 2791
2789 void GLES2DecoderImpl::ReleaseCurrent() { 2792 void GLES2DecoderImpl::ReleaseCurrent() {
2790 if (context_.get()) 2793 if (context_.get())
2791 context_->ReleaseCurrent(surface_.get()); 2794 context_->ReleaseCurrent(surface_.get());
2792 } 2795 }
2793 2796
2794 void GLES2DecoderImpl::RestoreCurrentRenderbufferBindings() { 2797 void GLES2DecoderImpl::RestoreCurrentRenderbufferBindings() {
2795 RenderbufferManager::RenderbufferInfo* renderbuffer = 2798 Renderbuffer* renderbuffer =
2796 GetRenderbufferInfoForTarget(GL_RENDERBUFFER); 2799 GetRenderbufferInfoForTarget(GL_RENDERBUFFER);
2797 glBindRenderbufferEXT( 2800 glBindRenderbufferEXT(
2798 GL_RENDERBUFFER, renderbuffer ? renderbuffer->service_id() : 0); 2801 GL_RENDERBUFFER, renderbuffer ? renderbuffer->service_id() : 0);
2799 } 2802 }
2800 2803
2801 static void RebindCurrentFramebuffer( 2804 static void RebindCurrentFramebuffer(
2802 GLenum target, 2805 GLenum target,
2803 FramebufferManager::FramebufferInfo* info, 2806 Framebuffer* info,
2804 GLuint back_buffer_service_id) { 2807 GLuint back_buffer_service_id) {
2805 GLuint framebuffer_id = info ? info->service_id() : 0; 2808 GLuint framebuffer_id = info ? info->service_id() : 0;
2806 2809
2807 if (framebuffer_id == 0) { 2810 if (framebuffer_id == 0) {
2808 framebuffer_id = back_buffer_service_id; 2811 framebuffer_id = back_buffer_service_id;
2809 } 2812 }
2810 2813
2811 glBindFramebufferEXT(target, framebuffer_id); 2814 glBindFramebufferEXT(target, framebuffer_id);
2812 } 2815 }
2813 2816
(...skipping 25 matching lines...) Expand all
2839 last_id = info.bound_texture_2d->service_id(); 2842 last_id = info.bound_texture_2d->service_id();
2840 } else { 2843 } else {
2841 last_id = 0; 2844 last_id = 0;
2842 } 2845 }
2843 2846
2844 glBindTexture(GL_TEXTURE_2D, last_id); 2847 glBindTexture(GL_TEXTURE_2D, last_id);
2845 glActiveTexture(GL_TEXTURE0 + state_.active_texture_unit); 2848 glActiveTexture(GL_TEXTURE0 + state_.active_texture_unit);
2846 } 2849 }
2847 2850
2848 bool GLES2DecoderImpl::CheckFramebufferValid( 2851 bool GLES2DecoderImpl::CheckFramebufferValid(
2849 FramebufferManager::FramebufferInfo* framebuffer, 2852 Framebuffer* framebuffer,
2850 GLenum target, const char* func_name) { 2853 GLenum target, const char* func_name) {
2851 if (!framebuffer) { 2854 if (!framebuffer) {
2852 if (backbuffer_needs_clear_bits_) { 2855 if (backbuffer_needs_clear_bits_) {
2853 glClearColor(0, 0, 0, (GLES2Util::GetChannelsForFormat( 2856 glClearColor(0, 0, 0, (GLES2Util::GetChannelsForFormat(
2854 offscreen_target_color_format_) & 0x0008) != 0 ? 0 : 1); 2857 offscreen_target_color_format_) & 0x0008) != 0 ? 0 : 1);
2855 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 2858 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
2856 glClearStencil(0); 2859 glClearStencil(0);
2857 glStencilMask(-1); 2860 glStencilMask(-1);
2858 glClearDepth(1.0f); 2861 glClearDepth(1.0f);
2859 glDepthMask(true); 2862 glDepthMask(true);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
2915 } 2918 }
2916 return CheckFramebufferValid( 2919 return CheckFramebufferValid(
2917 state_.bound_draw_framebuffer, 2920 state_.bound_draw_framebuffer,
2918 GL_DRAW_FRAMEBUFFER_EXT, func_name) && 2921 GL_DRAW_FRAMEBUFFER_EXT, func_name) &&
2919 CheckFramebufferValid( 2922 CheckFramebufferValid(
2920 state_.bound_read_framebuffer, 2923 state_.bound_read_framebuffer,
2921 GL_READ_FRAMEBUFFER_EXT, func_name); 2924 GL_READ_FRAMEBUFFER_EXT, func_name);
2922 } 2925 }
2923 2926
2924 gfx::Size GLES2DecoderImpl::GetBoundReadFrameBufferSize() { 2927 gfx::Size GLES2DecoderImpl::GetBoundReadFrameBufferSize() {
2925 FramebufferManager::FramebufferInfo* framebuffer = 2928 Framebuffer* framebuffer =
2926 GetFramebufferInfoForTarget(GL_READ_FRAMEBUFFER_EXT); 2929 GetFramebufferInfoForTarget(GL_READ_FRAMEBUFFER_EXT);
2927 if (framebuffer != NULL) { 2930 if (framebuffer != NULL) {
2928 const FramebufferManager::FramebufferInfo::Attachment* attachment = 2931 const Framebuffer::Attachment* attachment =
2929 framebuffer->GetAttachment(GL_COLOR_ATTACHMENT0); 2932 framebuffer->GetAttachment(GL_COLOR_ATTACHMENT0);
2930 if (attachment) { 2933 if (attachment) {
2931 return gfx::Size(attachment->width(), attachment->height()); 2934 return gfx::Size(attachment->width(), attachment->height());
2932 } 2935 }
2933 return gfx::Size(0, 0); 2936 return gfx::Size(0, 0);
2934 } else if (offscreen_target_frame_buffer_.get()) { 2937 } else if (offscreen_target_frame_buffer_.get()) {
2935 return offscreen_size_; 2938 return offscreen_size_;
2936 } else { 2939 } else {
2937 return surface_->GetSize(); 2940 return surface_->GetSize();
2938 } 2941 }
2939 } 2942 }
2940 2943
2941 GLenum GLES2DecoderImpl::GetBoundReadFrameBufferInternalFormat() { 2944 GLenum GLES2DecoderImpl::GetBoundReadFrameBufferInternalFormat() {
2942 FramebufferManager::FramebufferInfo* framebuffer = 2945 Framebuffer* framebuffer =
2943 GetFramebufferInfoForTarget(GL_READ_FRAMEBUFFER_EXT); 2946 GetFramebufferInfoForTarget(GL_READ_FRAMEBUFFER_EXT);
2944 if (framebuffer != NULL) { 2947 if (framebuffer != NULL) {
2945 return framebuffer->GetColorAttachmentFormat(); 2948 return framebuffer->GetColorAttachmentFormat();
2946 } else if (offscreen_target_frame_buffer_.get()) { 2949 } else if (offscreen_target_frame_buffer_.get()) {
2947 return offscreen_target_color_format_; 2950 return offscreen_target_color_format_;
2948 } else { 2951 } else {
2949 return back_buffer_color_format_; 2952 return back_buffer_color_format_;
2950 } 2953 }
2951 } 2954 }
2952 2955
2953 GLenum GLES2DecoderImpl::GetBoundDrawFrameBufferInternalFormat() { 2956 GLenum GLES2DecoderImpl::GetBoundDrawFrameBufferInternalFormat() {
2954 FramebufferManager::FramebufferInfo* framebuffer = 2957 Framebuffer* framebuffer =
2955 GetFramebufferInfoForTarget(GL_DRAW_FRAMEBUFFER_EXT); 2958 GetFramebufferInfoForTarget(GL_DRAW_FRAMEBUFFER_EXT);
2956 if (framebuffer != NULL) { 2959 if (framebuffer != NULL) {
2957 return framebuffer->GetColorAttachmentFormat(); 2960 return framebuffer->GetColorAttachmentFormat();
2958 } else if (offscreen_target_frame_buffer_.get()) { 2961 } else if (offscreen_target_frame_buffer_.get()) {
2959 return offscreen_target_color_format_; 2962 return offscreen_target_color_format_;
2960 } else { 2963 } else {
2961 return back_buffer_color_format_; 2964 return back_buffer_color_format_;
2962 } 2965 }
2963 } 2966 }
2964 2967
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
3024 return async_pixel_transfer_delegate_.get(); 3027 return async_pixel_transfer_delegate_.get();
3025 } 3028 }
3026 3029
3027 void GLES2DecoderImpl::SetAsyncPixelTransferDelegate( 3030 void GLES2DecoderImpl::SetAsyncPixelTransferDelegate(
3028 gfx::AsyncPixelTransferDelegate* delegate) { 3031 gfx::AsyncPixelTransferDelegate* delegate) {
3029 async_pixel_transfer_delegate_ = make_scoped_ptr(delegate); 3032 async_pixel_transfer_delegate_ = make_scoped_ptr(delegate);
3030 } 3033 }
3031 3034
3032 bool GLES2DecoderImpl::GetServiceTextureId(uint32 client_texture_id, 3035 bool GLES2DecoderImpl::GetServiceTextureId(uint32 client_texture_id,
3033 uint32* service_texture_id) { 3036 uint32* service_texture_id) {
3034 TextureManager::TextureInfo* texture = 3037 Texture* texture =
3035 texture_manager()->GetTextureInfo(client_texture_id); 3038 texture_manager()->GetTexture(client_texture_id);
3036 if (texture) { 3039 if (texture) {
3037 *service_texture_id = texture->service_id(); 3040 *service_texture_id = texture->service_id();
3038 return true; 3041 return true;
3039 } 3042 }
3040 return false; 3043 return false;
3041 } 3044 }
3042 3045
3043 uint32 GLES2DecoderImpl::GetTextureUploadCount() { 3046 uint32 GLES2DecoderImpl::GetTextureUploadCount() {
3044 return texture_upload_count_ + 3047 return texture_upload_count_ +
3045 async_pixel_transfer_delegate_->GetTextureUploadCount(); 3048 async_pixel_transfer_delegate_->GetTextureUploadCount();
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
3196 parent_->children_.begin(), 3199 parent_->children_.begin(),
3197 parent_->children_.end(), 3200 parent_->children_.end(),
3198 this); 3201 this);
3199 DCHECK(it != parent_->children_.end()); 3202 DCHECK(it != parent_->children_.end());
3200 parent_->children_.erase(it); 3203 parent_->children_.erase(it);
3201 // First check the texture has been mapped into the parent. This might not 3204 // First check the texture has been mapped into the parent. This might not
3202 // be the case if initialization failed midway through. 3205 // be the case if initialization failed midway through.
3203 GLuint service_id = offscreen_saved_color_texture_->id(); 3206 GLuint service_id = offscreen_saved_color_texture_->id();
3204 GLuint client_id = 0; 3207 GLuint client_id = 0;
3205 if (parent_->texture_manager()->GetClientId(service_id, &client_id)) { 3208 if (parent_->texture_manager()->GetClientId(service_id, &client_id)) {
3206 parent_->texture_manager()->RemoveTextureInfo(client_id); 3209 parent_->texture_manager()->RemoveTexture(client_id);
3207 } 3210 }
3208 } 3211 }
3209 3212
3210 GLES2DecoderImpl* new_parent_impl = static_cast<GLES2DecoderImpl*>( 3213 GLES2DecoderImpl* new_parent_impl = static_cast<GLES2DecoderImpl*>(
3211 new_parent); 3214 new_parent);
3212 if (new_parent_impl) { 3215 if (new_parent_impl) {
3213 #ifndef NDEBUG 3216 #ifndef NDEBUG
3214 ChildList::iterator it = std::find( 3217 ChildList::iterator it = std::find(
3215 new_parent_impl->children_.begin(), 3218 new_parent_impl->children_.begin(),
3216 new_parent_impl->children_.end(), 3219 new_parent_impl->children_.end(),
3217 this); 3220 this);
3218 DCHECK(it == new_parent_impl->children_.end()); 3221 DCHECK(it == new_parent_impl->children_.end());
3219 #endif 3222 #endif
3220 new_parent_impl->children_.push_back(this); 3223 new_parent_impl->children_.push_back(this);
3221 // Map the ID of the saved offscreen texture into the parent so that 3224 // Map the ID of the saved offscreen texture into the parent so that
3222 // it can reference it. 3225 // it can reference it.
3223 GLuint service_id = offscreen_saved_color_texture_->id(); 3226 GLuint service_id = offscreen_saved_color_texture_->id();
3224 3227
3225 // Replace texture info when ID is already in use by parent. 3228 // Replace texture info when ID is already in use by parent.
3226 if (new_parent_impl->texture_manager()->GetTextureInfo( 3229 if (new_parent_impl->texture_manager()->GetTexture(
3227 new_parent_texture_id)) 3230 new_parent_texture_id))
3228 new_parent_impl->texture_manager()->RemoveTextureInfo( 3231 new_parent_impl->texture_manager()->RemoveTexture(
3229 new_parent_texture_id); 3232 new_parent_texture_id);
3230 3233
3231 offscreen_saved_color_texture_info_ = 3234 offscreen_saved_color_texture_info_ =
3232 new_parent_impl->CreateTextureInfo(new_parent_texture_id, service_id); 3235 new_parent_impl->CreateTexture(new_parent_texture_id, service_id);
3233 offscreen_saved_color_texture_info_->SetNotOwned(); 3236 offscreen_saved_color_texture_info_->SetNotOwned();
3234 new_parent_impl->texture_manager()-> 3237 new_parent_impl->texture_manager()->
3235 SetInfoTarget(offscreen_saved_color_texture_info_, GL_TEXTURE_2D); 3238 SetInfoTarget(offscreen_saved_color_texture_info_, GL_TEXTURE_2D);
3236 3239
3237 parent_ = base::AsWeakPtr<GLES2DecoderImpl>(new_parent_impl); 3240 parent_ = base::AsWeakPtr<GLES2DecoderImpl>(new_parent_impl);
3238 3241
3239 UpdateParentTextureInfo(); 3242 UpdateParentTextureInfo();
3240 } else { 3243 } else {
3241 parent_.reset(); 3244 parent_.reset();
3242 offscreen_saved_color_texture_info_ = NULL; 3245 offscreen_saved_color_texture_info_ = NULL;
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
3383 offscreen_resolved_frame_buffer_->Destroy(); 3386 offscreen_resolved_frame_buffer_->Destroy();
3384 if (offscreen_resolved_color_texture_.get()) 3387 if (offscreen_resolved_color_texture_.get())
3385 offscreen_resolved_color_texture_->Destroy(); 3388 offscreen_resolved_color_texture_->Destroy();
3386 offscreen_resolved_color_texture_.reset(); 3389 offscreen_resolved_color_texture_.reset();
3387 offscreen_resolved_frame_buffer_.reset(); 3390 offscreen_resolved_frame_buffer_.reset();
3388 3391
3389 return true; 3392 return true;
3390 } 3393 }
3391 3394
3392 error::Error GLES2DecoderImpl::HandleResizeCHROMIUM( 3395 error::Error GLES2DecoderImpl::HandleResizeCHROMIUM(
3393 uint32 immediate_data_size, const gles2::ResizeCHROMIUM& c) { 3396 uint32 immediate_data_size, const cmds::ResizeCHROMIUM& c) {
3394 if (!offscreen_target_frame_buffer_.get() && surface_->DeferDraws()) 3397 if (!offscreen_target_frame_buffer_.get() && surface_->DeferDraws())
3395 return error::kDeferCommandUntilLater; 3398 return error::kDeferCommandUntilLater;
3396 3399
3397 GLuint width = static_cast<GLuint>(c.width); 3400 GLuint width = static_cast<GLuint>(c.width);
3398 GLuint height = static_cast<GLuint>(c.height); 3401 GLuint height = static_cast<GLuint>(c.height);
3399 TRACE_EVENT2("gpu", "glResizeChromium", "width", width, "height", height); 3402 TRACE_EVENT2("gpu", "glResizeChromium", "width", width, "height", height);
3400 3403
3401 width = std::max(1U, width); 3404 width = std::max(1U, width);
3402 height = std::max(1U, height); 3405 height = std::max(1U, height);
3403 3406
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
3453 unsigned int command_index = command - kStartPoint - 1; 3456 unsigned int command_index = command - kStartPoint - 1;
3454 if (command_index < arraysize(g_command_info)) { 3457 if (command_index < arraysize(g_command_info)) {
3455 const CommandInfo& info = g_command_info[command_index]; 3458 const CommandInfo& info = g_command_info[command_index];
3456 unsigned int info_arg_count = static_cast<unsigned int>(info.arg_count); 3459 unsigned int info_arg_count = static_cast<unsigned int>(info.arg_count);
3457 if ((info.arg_flags == cmd::kFixed && arg_count == info_arg_count) || 3460 if ((info.arg_flags == cmd::kFixed && arg_count == info_arg_count) ||
3458 (info.arg_flags == cmd::kAtLeastN && arg_count >= info_arg_count)) { 3461 (info.arg_flags == cmd::kAtLeastN && arg_count >= info_arg_count)) {
3459 uint32 immediate_data_size = 3462 uint32 immediate_data_size =
3460 (arg_count - info_arg_count) * sizeof(CommandBufferEntry); // NOLINT 3463 (arg_count - info_arg_count) * sizeof(CommandBufferEntry); // NOLINT
3461 switch (command) { 3464 switch (command) {
3462 #define GLES2_CMD_OP(name) \ 3465 #define GLES2_CMD_OP(name) \
3463 case name::kCmdId: \ 3466 case cmds::name::kCmdId: \
3464 result = Handle ## name( \ 3467 result = Handle ## name( \
3465 immediate_data_size, \ 3468 immediate_data_size, \
3466 *static_cast<const name*>(cmd_data)); \ 3469 *static_cast<const gles2::cmds::name*>(cmd_data)); \
3467 break; \ 3470 break; \
3468 3471
3469 GLES2_COMMAND_LIST(GLES2_CMD_OP) 3472 GLES2_COMMAND_LIST(GLES2_CMD_OP)
3470 #undef GLES2_CMD_OP 3473 #undef GLES2_CMD_OP
3471 } 3474 }
3472 if (debug()) { 3475 if (debug()) {
3473 GLenum error; 3476 GLenum error;
3474 while ((error = glGetError()) != GL_NO_ERROR) { 3477 while ((error = glGetError()) != GL_NO_ERROR) {
3475 LOG(ERROR) << "[" << GetLogPrefix() << "] " 3478 LOG(ERROR) << "[" << GetLogPrefix() << "] "
3476 << "GL ERROR: " << GLES2Util::GetStringEnum(error) << " : " 3479 << "GL ERROR: " << GLES2Util::GetStringEnum(error) << " : "
3477 << GetCommandName(command); 3480 << GetCommandName(command);
3478 SetGLError(error, "DoCommand", "GL error from driver"); 3481 SetGLError(error, "DoCommand", "GL error from driver");
3479 } 3482 }
3480 } 3483 }
3481 } else { 3484 } else {
3482 result = error::kInvalidArguments; 3485 result = error::kInvalidArguments;
3483 } 3486 }
3484 } else { 3487 } else {
3485 result = DoCommonCommand(command, arg_count, cmd_data); 3488 result = DoCommonCommand(command, arg_count, cmd_data);
3486 } 3489 }
3487 if (result == error::kNoError && current_decoder_error_ != error::kNoError) { 3490 if (result == error::kNoError && current_decoder_error_ != error::kNoError) {
3488 result = current_decoder_error_; 3491 result = current_decoder_error_;
3489 current_decoder_error_ = error::kNoError; 3492 current_decoder_error_ = error::kNoError;
3490 } 3493 }
3491 return result; 3494 return result;
3492 } 3495 }
3493 3496
3494 void GLES2DecoderImpl::RemoveBufferInfo(GLuint client_id) { 3497 void GLES2DecoderImpl::RemoveBuffer(GLuint client_id) {
3495 buffer_manager()->RemoveBufferInfo(client_id); 3498 buffer_manager()->RemoveBuffer(client_id);
3496 } 3499 }
3497 3500
3498 bool GLES2DecoderImpl::CreateProgramHelper(GLuint client_id) { 3501 bool GLES2DecoderImpl::CreateProgramHelper(GLuint client_id) {
3499 if (GetProgramInfo(client_id)) { 3502 if (GetProgram(client_id)) {
3500 return false; 3503 return false;
3501 } 3504 }
3502 GLuint service_id = glCreateProgram(); 3505 GLuint service_id = glCreateProgram();
3503 if (service_id != 0) { 3506 if (service_id != 0) {
3504 CreateProgramInfo(client_id, service_id); 3507 CreateProgram(client_id, service_id);
3505 } 3508 }
3506 return true; 3509 return true;
3507 } 3510 }
3508 3511
3509 bool GLES2DecoderImpl::CreateShaderHelper(GLenum type, GLuint client_id) { 3512 bool GLES2DecoderImpl::CreateShaderHelper(GLenum type, GLuint client_id) {
3510 if (GetShaderInfo(client_id)) { 3513 if (GetShader(client_id)) {
3511 return false; 3514 return false;
3512 } 3515 }
3513 GLuint service_id = glCreateShader(type); 3516 GLuint service_id = glCreateShader(type);
3514 if (service_id != 0) { 3517 if (service_id != 0) {
3515 CreateShaderInfo(client_id, service_id, type); 3518 CreateShader(client_id, service_id, type);
3516 } 3519 }
3517 return true; 3520 return true;
3518 } 3521 }
3519 3522
3520 void GLES2DecoderImpl::DoFinish() { 3523 void GLES2DecoderImpl::DoFinish() {
3521 glFinish(); 3524 glFinish();
3522 ProcessPendingQueries(); 3525 ProcessPendingQueries();
3523 } 3526 }
3524 3527
3525 void GLES2DecoderImpl::DoFlush() { 3528 void GLES2DecoderImpl::DoFlush() {
3526 glFlush(); 3529 glFlush();
3527 ProcessPendingQueries(); 3530 ProcessPendingQueries();
3528 } 3531 }
3529 3532
3530 void GLES2DecoderImpl::DoActiveTexture(GLenum texture_unit) { 3533 void GLES2DecoderImpl::DoActiveTexture(GLenum texture_unit) {
3531 GLuint texture_index = texture_unit - GL_TEXTURE0; 3534 GLuint texture_index = texture_unit - GL_TEXTURE0;
3532 if (texture_index >= state_.texture_units.size()) { 3535 if (texture_index >= state_.texture_units.size()) {
3533 SetGLErrorInvalidEnum( 3536 SetGLErrorInvalidEnum(
3534 "glActiveTexture", texture_unit, "texture_unit"); 3537 "glActiveTexture", texture_unit, "texture_unit");
3535 return; 3538 return;
3536 } 3539 }
3537 state_.active_texture_unit = texture_index; 3540 state_.active_texture_unit = texture_index;
3538 glActiveTexture(texture_unit); 3541 glActiveTexture(texture_unit);
3539 } 3542 }
3540 3543
3541 void GLES2DecoderImpl::DoBindBuffer(GLenum target, GLuint client_id) { 3544 void GLES2DecoderImpl::DoBindBuffer(GLenum target, GLuint client_id) {
3542 BufferManager::BufferInfo* info = NULL; 3545 BufferManager::Buffer* info = NULL;
3543 GLuint service_id = 0; 3546 GLuint service_id = 0;
3544 if (client_id != 0) { 3547 if (client_id != 0) {
3545 info = GetBufferInfo(client_id); 3548 info = GetBuffer(client_id);
3546 if (!info) { 3549 if (!info) {
3547 if (!group_->bind_generates_resource()) { 3550 if (!group_->bind_generates_resource()) {
3548 LOG(ERROR) << "glBindBuffer: id not generated by glGenBuffers"; 3551 LOG(ERROR) << "glBindBuffer: id not generated by glGenBuffers";
3549 current_decoder_error_ = error::kGenericError; 3552 current_decoder_error_ = error::kGenericError;
3550 return; 3553 return;
3551 } 3554 }
3552 3555
3553 // It's a new id so make a buffer info for it. 3556 // It's a new id so make a buffer info for it.
3554 glGenBuffersARB(1, &service_id); 3557 glGenBuffersARB(1, &service_id);
3555 CreateBufferInfo(client_id, service_id); 3558 CreateBuffer(client_id, service_id);
3556 info = GetBufferInfo(client_id); 3559 info = GetBuffer(client_id);
3557 IdAllocatorInterface* id_allocator = 3560 IdAllocatorInterface* id_allocator =
3558 group_->GetIdAllocator(id_namespaces::kBuffers); 3561 group_->GetIdAllocator(id_namespaces::kBuffers);
3559 id_allocator->MarkAsUsed(client_id); 3562 id_allocator->MarkAsUsed(client_id);
3560 } 3563 }
3561 } 3564 }
3562 LogClientServiceForInfo(info, client_id, "glBindBuffer"); 3565 LogClientServiceForInfo(info, client_id, "glBindBuffer");
3563 if (info) { 3566 if (info) {
3564 if (!buffer_manager()->SetTarget(info, target)) { 3567 if (!buffer_manager()->SetTarget(info, target)) {
3565 SetGLError(GL_INVALID_OPERATION, 3568 SetGLError(GL_INVALID_OPERATION,
3566 "glBindBuffer", "buffer bound to more than 1 target"); 3569 "glBindBuffer", "buffer bound to more than 1 target");
(...skipping 14 matching lines...) Expand all
3581 } 3584 }
3582 glBindBuffer(target, service_id); 3585 glBindBuffer(target, service_id);
3583 } 3586 }
3584 3587
3585 bool GLES2DecoderImpl::BoundFramebufferHasColorAttachmentWithAlpha() { 3588 bool GLES2DecoderImpl::BoundFramebufferHasColorAttachmentWithAlpha() {
3586 return (GLES2Util::GetChannelsForFormat( 3589 return (GLES2Util::GetChannelsForFormat(
3587 GetBoundDrawFrameBufferInternalFormat()) & 0x0008) != 0; 3590 GetBoundDrawFrameBufferInternalFormat()) & 0x0008) != 0;
3588 } 3591 }
3589 3592
3590 bool GLES2DecoderImpl::BoundFramebufferHasDepthAttachment() { 3593 bool GLES2DecoderImpl::BoundFramebufferHasDepthAttachment() {
3591 FramebufferManager::FramebufferInfo* framebuffer = 3594 Framebuffer* framebuffer =
3592 GetFramebufferInfoForTarget(GL_DRAW_FRAMEBUFFER_EXT); 3595 GetFramebufferInfoForTarget(GL_DRAW_FRAMEBUFFER_EXT);
3593 if (framebuffer) { 3596 if (framebuffer) {
3594 return framebuffer->HasDepthAttachment(); 3597 return framebuffer->HasDepthAttachment();
3595 } 3598 }
3596 if (offscreen_target_frame_buffer_.get()) { 3599 if (offscreen_target_frame_buffer_.get()) {
3597 return offscreen_target_depth_format_ != 0; 3600 return offscreen_target_depth_format_ != 0;
3598 } 3601 }
3599 return back_buffer_has_depth_; 3602 return back_buffer_has_depth_;
3600 } 3603 }
3601 3604
3602 bool GLES2DecoderImpl::BoundFramebufferHasStencilAttachment() { 3605 bool GLES2DecoderImpl::BoundFramebufferHasStencilAttachment() {
3603 FramebufferManager::FramebufferInfo* framebuffer = 3606 Framebuffer* framebuffer =
3604 GetFramebufferInfoForTarget(GL_DRAW_FRAMEBUFFER_EXT); 3607 GetFramebufferInfoForTarget(GL_DRAW_FRAMEBUFFER_EXT);
3605 if (framebuffer) { 3608 if (framebuffer) {
3606 return framebuffer->HasStencilAttachment(); 3609 return framebuffer->HasStencilAttachment();
3607 } 3610 }
3608 if (offscreen_target_frame_buffer_.get()) { 3611 if (offscreen_target_frame_buffer_.get()) {
3609 return offscreen_target_stencil_format_ != 0 || 3612 return offscreen_target_stencil_format_ != 0 ||
3610 offscreen_target_depth_format_ == GL_DEPTH24_STENCIL8; 3613 offscreen_target_depth_format_ == GL_DEPTH24_STENCIL8;
3611 } 3614 }
3612 return back_buffer_has_stencil_; 3615 return back_buffer_has_stencil_;
3613 } 3616 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
3662 GetBackbufferServiceId(); 3665 GetBackbufferServiceId();
3663 glBindFramebufferEXT(GL_READ_FRAMEBUFFER, service_id); 3666 glBindFramebufferEXT(GL_READ_FRAMEBUFFER, service_id);
3664 } 3667 }
3665 OnFboChanged(); 3668 OnFboChanged();
3666 3669
3667 } 3670 }
3668 3671
3669 void GLES2DecoderImpl::RestoreTextureState(unsigned service_id) const { 3672 void GLES2DecoderImpl::RestoreTextureState(unsigned service_id) const {
3670 GLuint client_id = 0; 3673 GLuint client_id = 0;
3671 if (texture_manager()->GetClientId(service_id, &client_id)) { 3674 if (texture_manager()->GetClientId(service_id, &client_id)) {
3672 TextureManager::TextureInfo* texture = GetTextureInfo(client_id); 3675 Texture* texture = GetTexture(client_id);
3673 glBindTexture(GL_TEXTURE_2D, service_id); 3676 glBindTexture(GL_TEXTURE_2D, service_id);
3674 glTexParameteri( 3677 glTexParameteri(
3675 GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, texture->wrap_s()); 3678 GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, texture->wrap_s());
3676 glTexParameteri( 3679 glTexParameteri(
3677 GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, texture->wrap_t()); 3680 GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, texture->wrap_t());
3678 glTexParameteri( 3681 glTexParameteri(
3679 GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, texture->min_filter()); 3682 GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, texture->min_filter());
3680 glTexParameteri( 3683 glTexParameteri(
3681 GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, texture->mag_filter()); 3684 GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, texture->mag_filter());
3682 RestoreTextureUnitBindings(state_.active_texture_unit); 3685 RestoreTextureUnitBindings(state_.active_texture_unit);
3683 } 3686 }
3684 } 3687 }
3685 3688
3686 void GLES2DecoderImpl::OnFboChanged() const { 3689 void GLES2DecoderImpl::OnFboChanged() const {
3687 if (workarounds().restore_scissor_on_fbo_change) 3690 if (workarounds().restore_scissor_on_fbo_change)
3688 glScissor(state_.scissor_x, state_.scissor_y, 3691 glScissor(state_.scissor_x, state_.scissor_y,
3689 state_.scissor_width, state_.scissor_height); 3692 state_.scissor_width, state_.scissor_height);
3690 } 3693 }
3691 3694
3692 void GLES2DecoderImpl::DoBindFramebuffer(GLenum target, GLuint client_id) { 3695 void GLES2DecoderImpl::DoBindFramebuffer(GLenum target, GLuint client_id) {
3693 FramebufferManager::FramebufferInfo* info = NULL; 3696 Framebuffer* info = NULL;
3694 GLuint service_id = 0; 3697 GLuint service_id = 0;
3695 if (client_id != 0) { 3698 if (client_id != 0) {
3696 info = GetFramebufferInfo(client_id); 3699 info = GetFramebuffer(client_id);
3697 if (!info) { 3700 if (!info) {
3698 if (!group_->bind_generates_resource()) { 3701 if (!group_->bind_generates_resource()) {
3699 LOG(ERROR) 3702 LOG(ERROR)
3700 << "glBindFramebuffer: id not generated by glGenFramebuffers"; 3703 << "glBindFramebuffer: id not generated by glGenFramebuffers";
3701 current_decoder_error_ = error::kGenericError; 3704 current_decoder_error_ = error::kGenericError;
3702 return; 3705 return;
3703 } 3706 }
3704 3707
3705 // It's a new id so make a framebuffer info for it. 3708 // It's a new id so make a framebuffer info for it.
3706 glGenFramebuffersEXT(1, &service_id); 3709 glGenFramebuffersEXT(1, &service_id);
3707 CreateFramebufferInfo(client_id, service_id); 3710 CreateFramebuffer(client_id, service_id);
3708 info = GetFramebufferInfo(client_id); 3711 info = GetFramebuffer(client_id);
3709 IdAllocatorInterface* id_allocator = 3712 IdAllocatorInterface* id_allocator =
3710 group_->GetIdAllocator(id_namespaces::kFramebuffers); 3713 group_->GetIdAllocator(id_namespaces::kFramebuffers);
3711 id_allocator->MarkAsUsed(client_id); 3714 id_allocator->MarkAsUsed(client_id);
3712 } else { 3715 } else {
3713 service_id = info->service_id(); 3716 service_id = info->service_id();
3714 } 3717 }
3715 info->MarkAsValid(); 3718 info->MarkAsValid();
3716 } 3719 }
3717 LogClientServiceForInfo(info, client_id, "glBindFramebuffer"); 3720 LogClientServiceForInfo(info, client_id, "glBindFramebuffer");
3718 3721
(...skipping 10 matching lines...) Expand all
3729 // backbuffer. 3732 // backbuffer.
3730 if (info == NULL) { 3733 if (info == NULL) {
3731 service_id = GetBackbufferServiceId(); 3734 service_id = GetBackbufferServiceId();
3732 } 3735 }
3733 3736
3734 glBindFramebufferEXT(target, service_id); 3737 glBindFramebufferEXT(target, service_id);
3735 OnFboChanged(); 3738 OnFboChanged();
3736 } 3739 }
3737 3740
3738 void GLES2DecoderImpl::DoBindRenderbuffer(GLenum target, GLuint client_id) { 3741 void GLES2DecoderImpl::DoBindRenderbuffer(GLenum target, GLuint client_id) {
3739 RenderbufferManager::RenderbufferInfo* info = NULL; 3742 Renderbuffer* info = NULL;
3740 GLuint service_id = 0; 3743 GLuint service_id = 0;
3741 if (client_id != 0) { 3744 if (client_id != 0) {
3742 info = GetRenderbufferInfo(client_id); 3745 info = GetRenderbuffer(client_id);
3743 if (!info) { 3746 if (!info) {
3744 if (!group_->bind_generates_resource()) { 3747 if (!group_->bind_generates_resource()) {
3745 LOG(ERROR) 3748 LOG(ERROR)
3746 << "glBindRenderbuffer: id not generated by glGenRenderbuffers"; 3749 << "glBindRenderbuffer: id not generated by glGenRenderbuffers";
3747 current_decoder_error_ = error::kGenericError; 3750 current_decoder_error_ = error::kGenericError;
3748 return; 3751 return;
3749 } 3752 }
3750 3753
3751 // It's a new id so make a renderbuffer info for it. 3754 // It's a new id so make a renderbuffer info for it.
3752 glGenRenderbuffersEXT(1, &service_id); 3755 glGenRenderbuffersEXT(1, &service_id);
3753 CreateRenderbufferInfo(client_id, service_id); 3756 CreateRenderbuffer(client_id, service_id);
3754 info = GetRenderbufferInfo(client_id); 3757 info = GetRenderbuffer(client_id);
3755 IdAllocatorInterface* id_allocator = 3758 IdAllocatorInterface* id_allocator =
3756 group_->GetIdAllocator(id_namespaces::kRenderbuffers); 3759 group_->GetIdAllocator(id_namespaces::kRenderbuffers);
3757 id_allocator->MarkAsUsed(client_id); 3760 id_allocator->MarkAsUsed(client_id);
3758 } else { 3761 } else {
3759 service_id = info->service_id(); 3762 service_id = info->service_id();
3760 } 3763 }
3761 info->MarkAsValid(); 3764 info->MarkAsValid();
3762 } 3765 }
3763 LogClientServiceForInfo(info, client_id, "glBindRenerbuffer"); 3766 LogClientServiceForInfo(info, client_id, "glBindRenerbuffer");
3764 state_.bound_renderbuffer = info; 3767 state_.bound_renderbuffer = info;
3765 glBindRenderbufferEXT(target, service_id); 3768 glBindRenderbufferEXT(target, service_id);
3766 } 3769 }
3767 3770
3768 void GLES2DecoderImpl::DoBindTexture(GLenum target, GLuint client_id) { 3771 void GLES2DecoderImpl::DoBindTexture(GLenum target, GLuint client_id) {
3769 TextureManager::TextureInfo* info = NULL; 3772 Texture* info = NULL;
3770 GLuint service_id = 0; 3773 GLuint service_id = 0;
3771 if (client_id != 0) { 3774 if (client_id != 0) {
3772 info = GetTextureInfo(client_id); 3775 info = GetTexture(client_id);
3773 if (!info) { 3776 if (!info) {
3774 if (!group_->bind_generates_resource()) { 3777 if (!group_->bind_generates_resource()) {
3775 LOG(ERROR) << "glBindTexture: id not generated by glGenTextures"; 3778 LOG(ERROR) << "glBindTexture: id not generated by glGenTextures";
3776 current_decoder_error_ = error::kGenericError; 3779 current_decoder_error_ = error::kGenericError;
3777 return; 3780 return;
3778 } 3781 }
3779 3782
3780 // It's a new id so make a texture info for it. 3783 // It's a new id so make a texture info for it.
3781 glGenTextures(1, &service_id); 3784 glGenTextures(1, &service_id);
3782 DCHECK_NE(0u, service_id); 3785 DCHECK_NE(0u, service_id);
3783 CreateTextureInfo(client_id, service_id); 3786 CreateTexture(client_id, service_id);
3784 info = GetTextureInfo(client_id); 3787 info = GetTexture(client_id);
3785 IdAllocatorInterface* id_allocator = 3788 IdAllocatorInterface* id_allocator =
3786 group_->GetIdAllocator(id_namespaces::kTextures); 3789 group_->GetIdAllocator(id_namespaces::kTextures);
3787 id_allocator->MarkAsUsed(client_id); 3790 id_allocator->MarkAsUsed(client_id);
3788 } 3791 }
3789 } else { 3792 } else {
3790 info = texture_manager()->GetDefaultTextureInfo(target); 3793 info = texture_manager()->GetDefaultTextureInfo(target);
3791 } 3794 }
3792 3795
3793 // Check the texture exists 3796 // Check the texture exists
3794 // Check that we are not trying to bind it to a different target. 3797 // Check that we are not trying to bind it to a different target.
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
3844 } 3847 }
3845 } else { 3848 } else {
3846 SetGLError(GL_INVALID_VALUE, 3849 SetGLError(GL_INVALID_VALUE,
3847 "glDisableVertexAttribArray", "index out of range"); 3850 "glDisableVertexAttribArray", "index out of range");
3848 } 3851 }
3849 } 3852 }
3850 3853
3851 void GLES2DecoderImpl::DoDiscardFramebufferEXT(GLenum target, 3854 void GLES2DecoderImpl::DoDiscardFramebufferEXT(GLenum target,
3852 GLsizei numAttachments, 3855 GLsizei numAttachments,
3853 const GLenum* attachments) { 3856 const GLenum* attachments) {
3854 FramebufferManager::FramebufferInfo* framebuffer = 3857 Framebuffer* framebuffer =
3855 GetFramebufferInfoForTarget(GL_FRAMEBUFFER); 3858 GetFramebufferInfoForTarget(GL_FRAMEBUFFER);
3856 3859
3857 // Validates the attachments. If one of them fails 3860 // Validates the attachments. If one of them fails
3858 // the whole command fails. 3861 // the whole command fails.
3859 for (GLsizei i = 0; i < numAttachments; ++i) { 3862 for (GLsizei i = 0; i < numAttachments; ++i) {
3860 if ((framebuffer && 3863 if ((framebuffer &&
3861 !validators_->attachment.IsValid(attachments[i])) || 3864 !validators_->attachment.IsValid(attachments[i])) ||
3862 (!framebuffer && 3865 (!framebuffer &&
3863 !validators_->backbuffer_attachment.IsValid(attachments[i]))) { 3866 !validators_->backbuffer_attachment.IsValid(attachments[i]))) {
3864 SetGLErrorInvalidEnum("glDiscardFramebufferEXT", 3867 SetGLErrorInvalidEnum("glDiscardFramebufferEXT",
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
3898 void GLES2DecoderImpl::DoEnableVertexAttribArray(GLuint index) { 3901 void GLES2DecoderImpl::DoEnableVertexAttribArray(GLuint index) {
3899 if (state_.vertex_attrib_manager->Enable(index, true)) { 3902 if (state_.vertex_attrib_manager->Enable(index, true)) {
3900 glEnableVertexAttribArray(index); 3903 glEnableVertexAttribArray(index);
3901 } else { 3904 } else {
3902 SetGLError(GL_INVALID_VALUE, 3905 SetGLError(GL_INVALID_VALUE,
3903 "glEnableVertexAttribArray", "index out of range"); 3906 "glEnableVertexAttribArray", "index out of range");
3904 } 3907 }
3905 } 3908 }
3906 3909
3907 void GLES2DecoderImpl::DoGenerateMipmap(GLenum target) { 3910 void GLES2DecoderImpl::DoGenerateMipmap(GLenum target) {
3908 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target); 3911 Texture* info = GetTextureInfoForTarget(target);
3909 if (!info || 3912 if (!info ||
3910 !texture_manager()->CanGenerateMipmaps(info)) { 3913 !texture_manager()->CanGenerateMipmaps(info)) {
3911 SetGLError(GL_INVALID_OPERATION, 3914 SetGLError(GL_INVALID_OPERATION,
3912 "glGenerateMipmaps", "Can not generate mips"); 3915 "glGenerateMipmaps", "Can not generate mips");
3913 return; 3916 return;
3914 } 3917 }
3915 3918
3916 if (target == GL_TEXTURE_CUBE_MAP) { 3919 if (target == GL_TEXTURE_CUBE_MAP) {
3917 for (int i = 0; i < 6; ++i) { 3920 for (int i = 0; i < 6; ++i) {
3918 GLenum face = GL_TEXTURE_CUBE_MAP_POSITIVE_X + i; 3921 GLenum face = GL_TEXTURE_CUBE_MAP_POSITIVE_X + i;
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
4102 *params = client_id; 4105 *params = client_id;
4103 } else { 4106 } else {
4104 *params = 0; 4107 *params = 0;
4105 } 4108 }
4106 } 4109 }
4107 return true; 4110 return true;
4108 case GL_FRAMEBUFFER_BINDING: 4111 case GL_FRAMEBUFFER_BINDING:
4109 // case GL_DRAW_FRAMEBUFFER_BINDING_EXT: (same as GL_FRAMEBUFFER_BINDING) 4112 // case GL_DRAW_FRAMEBUFFER_BINDING_EXT: (same as GL_FRAMEBUFFER_BINDING)
4110 *num_written = 1; 4113 *num_written = 1;
4111 if (params) { 4114 if (params) {
4112 FramebufferManager::FramebufferInfo* framebuffer = 4115 Framebuffer* framebuffer =
4113 GetFramebufferInfoForTarget(GL_FRAMEBUFFER); 4116 GetFramebufferInfoForTarget(GL_FRAMEBUFFER);
4114 if (framebuffer) { 4117 if (framebuffer) {
4115 GLuint client_id = 0; 4118 GLuint client_id = 0;
4116 framebuffer_manager()->GetClientId( 4119 framebuffer_manager()->GetClientId(
4117 framebuffer->service_id(), &client_id); 4120 framebuffer->service_id(), &client_id);
4118 *params = client_id; 4121 *params = client_id;
4119 } else { 4122 } else {
4120 *params = 0; 4123 *params = 0;
4121 } 4124 }
4122 } 4125 }
4123 return true; 4126 return true;
4124 case GL_READ_FRAMEBUFFER_BINDING_EXT: 4127 case GL_READ_FRAMEBUFFER_BINDING_EXT:
4125 *num_written = 1; 4128 *num_written = 1;
4126 if (params) { 4129 if (params) {
4127 FramebufferManager::FramebufferInfo* framebuffer = 4130 Framebuffer* framebuffer =
4128 GetFramebufferInfoForTarget(GL_READ_FRAMEBUFFER_EXT); 4131 GetFramebufferInfoForTarget(GL_READ_FRAMEBUFFER_EXT);
4129 if (framebuffer) { 4132 if (framebuffer) {
4130 GLuint client_id = 0; 4133 GLuint client_id = 0;
4131 framebuffer_manager()->GetClientId( 4134 framebuffer_manager()->GetClientId(
4132 framebuffer->service_id(), &client_id); 4135 framebuffer->service_id(), &client_id);
4133 *params = client_id; 4136 *params = client_id;
4134 } else { 4137 } else {
4135 *params = 0; 4138 *params = 0;
4136 } 4139 }
4137 } 4140 }
4138 return true; 4141 return true;
4139 case GL_RENDERBUFFER_BINDING: 4142 case GL_RENDERBUFFER_BINDING:
4140 *num_written = 1; 4143 *num_written = 1;
4141 if (params) { 4144 if (params) {
4142 RenderbufferManager::RenderbufferInfo* renderbuffer = 4145 Renderbuffer* renderbuffer =
4143 GetRenderbufferInfoForTarget(GL_RENDERBUFFER); 4146 GetRenderbufferInfoForTarget(GL_RENDERBUFFER);
4144 if (renderbuffer) { 4147 if (renderbuffer) {
4145 GLuint client_id = 0; 4148 GLuint client_id = 0;
4146 renderbuffer_manager()->GetClientId( 4149 renderbuffer_manager()->GetClientId(
4147 renderbuffer->service_id(), &client_id); 4150 renderbuffer->service_id(), &client_id);
4148 *params = client_id; 4151 *params = client_id;
4149 } else { 4152 } else {
4150 *params = 0; 4153 *params = 0;
4151 } 4154 }
4152 } 4155 }
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
4301 DCHECK(params); 4304 DCHECK(params);
4302 GLsizei num_written; 4305 GLsizei num_written;
4303 if (!state_.GetStateAsGLint(pname, params, &num_written) && 4306 if (!state_.GetStateAsGLint(pname, params, &num_written) &&
4304 !GetHelper(pname, params, &num_written)) { 4307 !GetHelper(pname, params, &num_written)) {
4305 glGetIntegerv(pname, params); 4308 glGetIntegerv(pname, params);
4306 } 4309 }
4307 } 4310 }
4308 4311
4309 void GLES2DecoderImpl::DoGetProgramiv( 4312 void GLES2DecoderImpl::DoGetProgramiv(
4310 GLuint program_id, GLenum pname, GLint* params) { 4313 GLuint program_id, GLenum pname, GLint* params) {
4311 ProgramManager::ProgramInfo* info = GetProgramInfoNotShader( 4314 Program* info = GetProgramInfoNotShader(
4312 program_id, "glGetProgramiv"); 4315 program_id, "glGetProgramiv");
4313 if (!info) { 4316 if (!info) {
4314 return; 4317 return;
4315 } 4318 }
4316 info->GetProgramiv(pname, params); 4319 info->GetProgramiv(pname, params);
4317 } 4320 }
4318 4321
4319 void GLES2DecoderImpl::DoBindAttribLocation( 4322 void GLES2DecoderImpl::DoBindAttribLocation(
4320 GLuint program, GLuint index, const char* name) { 4323 GLuint program, GLuint index, const char* name) {
4321 if (!StringIsValidForGLES(name)) { 4324 if (!StringIsValidForGLES(name)) {
4322 SetGLError(GL_INVALID_VALUE, "glBindAttribLocation", "Invalid character"); 4325 SetGLError(GL_INVALID_VALUE, "glBindAttribLocation", "Invalid character");
4323 return; 4326 return;
4324 } 4327 }
4325 if (ProgramManager::IsInvalidPrefix(name, strlen(name))) { 4328 if (ProgramManager::IsInvalidPrefix(name, strlen(name))) {
4326 SetGLError(GL_INVALID_OPERATION, "glBindAttribLocation", "reserved prefix"); 4329 SetGLError(GL_INVALID_OPERATION, "glBindAttribLocation", "reserved prefix");
4327 return; 4330 return;
4328 } 4331 }
4329 if (index >= group_->max_vertex_attribs()) { 4332 if (index >= group_->max_vertex_attribs()) {
4330 SetGLError(GL_INVALID_VALUE, "glBindAttribLocation", "index out of range"); 4333 SetGLError(GL_INVALID_VALUE, "glBindAttribLocation", "index out of range");
4331 return; 4334 return;
4332 } 4335 }
4333 ProgramManager::ProgramInfo* info = GetProgramInfoNotShader( 4336 Program* info = GetProgramInfoNotShader(
4334 program, "glBindAttribLocation"); 4337 program, "glBindAttribLocation");
4335 if (!info) { 4338 if (!info) {
4336 return; 4339 return;
4337 } 4340 }
4338 info->SetAttribLocationBinding(name, static_cast<GLint>(index)); 4341 info->SetAttribLocationBinding(name, static_cast<GLint>(index));
4339 glBindAttribLocation(info->service_id(), index, name); 4342 glBindAttribLocation(info->service_id(), index, name);
4340 } 4343 }
4341 4344
4342 error::Error GLES2DecoderImpl::HandleBindAttribLocation( 4345 error::Error GLES2DecoderImpl::HandleBindAttribLocation(
4343 uint32 immediate_data_size, const gles2::BindAttribLocation& c) { 4346 uint32 immediate_data_size, const cmds::BindAttribLocation& c) {
4344 GLuint program = static_cast<GLuint>(c.program); 4347 GLuint program = static_cast<GLuint>(c.program);
4345 GLuint index = static_cast<GLuint>(c.index); 4348 GLuint index = static_cast<GLuint>(c.index);
4346 uint32 name_size = c.data_size; 4349 uint32 name_size = c.data_size;
4347 const char* name = GetSharedMemoryAs<const char*>( 4350 const char* name = GetSharedMemoryAs<const char*>(
4348 c.name_shm_id, c.name_shm_offset, name_size); 4351 c.name_shm_id, c.name_shm_offset, name_size);
4349 if (name == NULL) { 4352 if (name == NULL) {
4350 return error::kOutOfBounds; 4353 return error::kOutOfBounds;
4351 } 4354 }
4352 String name_str(name, name_size); 4355 String name_str(name, name_size);
4353 DoBindAttribLocation(program, index, name_str.c_str()); 4356 DoBindAttribLocation(program, index, name_str.c_str());
4354 return error::kNoError; 4357 return error::kNoError;
4355 } 4358 }
4356 4359
4357 error::Error GLES2DecoderImpl::HandleBindAttribLocationImmediate( 4360 error::Error GLES2DecoderImpl::HandleBindAttribLocationImmediate(
4358 uint32 immediate_data_size, const gles2::BindAttribLocationImmediate& c) { 4361 uint32 immediate_data_size, const cmds::BindAttribLocationImmediate& c) {
4359 GLuint program = static_cast<GLuint>(c.program); 4362 GLuint program = static_cast<GLuint>(c.program);
4360 GLuint index = static_cast<GLuint>(c.index); 4363 GLuint index = static_cast<GLuint>(c.index);
4361 uint32 name_size = c.data_size; 4364 uint32 name_size = c.data_size;
4362 const char* name = GetImmediateDataAs<const char*>( 4365 const char* name = GetImmediateDataAs<const char*>(
4363 c, name_size, immediate_data_size); 4366 c, name_size, immediate_data_size);
4364 if (name == NULL) { 4367 if (name == NULL) {
4365 return error::kOutOfBounds; 4368 return error::kOutOfBounds;
4366 } 4369 }
4367 String name_str(name, name_size); 4370 String name_str(name, name_size);
4368 DoBindAttribLocation(program, index, name_str.c_str()); 4371 DoBindAttribLocation(program, index, name_str.c_str());
4369 return error::kNoError; 4372 return error::kNoError;
4370 } 4373 }
4371 4374
4372 error::Error GLES2DecoderImpl::HandleBindAttribLocationBucket( 4375 error::Error GLES2DecoderImpl::HandleBindAttribLocationBucket(
4373 uint32 immediate_data_size, const gles2::BindAttribLocationBucket& c) { 4376 uint32 immediate_data_size, const cmds::BindAttribLocationBucket& c) {
4374 GLuint program = static_cast<GLuint>(c.program); 4377 GLuint program = static_cast<GLuint>(c.program);
4375 GLuint index = static_cast<GLuint>(c.index); 4378 GLuint index = static_cast<GLuint>(c.index);
4376 Bucket* bucket = GetBucket(c.name_bucket_id); 4379 Bucket* bucket = GetBucket(c.name_bucket_id);
4377 if (!bucket || bucket->size() == 0) { 4380 if (!bucket || bucket->size() == 0) {
4378 return error::kInvalidArguments; 4381 return error::kInvalidArguments;
4379 } 4382 }
4380 std::string name_str; 4383 std::string name_str;
4381 if (!bucket->GetAsString(&name_str)) { 4384 if (!bucket->GetAsString(&name_str)) {
4382 return error::kInvalidArguments; 4385 return error::kInvalidArguments;
4383 } 4386 }
(...skipping 13 matching lines...) Expand all
4397 "glBindUniformLocationCHROMIUM", "reserved prefix"); 4400 "glBindUniformLocationCHROMIUM", "reserved prefix");
4398 return; 4401 return;
4399 } 4402 }
4400 if (location < 0 || static_cast<uint32>(location) >= 4403 if (location < 0 || static_cast<uint32>(location) >=
4401 (group_->max_fragment_uniform_vectors() + 4404 (group_->max_fragment_uniform_vectors() +
4402 group_->max_vertex_uniform_vectors()) * 4) { 4405 group_->max_vertex_uniform_vectors()) * 4) {
4403 SetGLError(GL_INVALID_VALUE, 4406 SetGLError(GL_INVALID_VALUE,
4404 "glBindUniformLocationCHROMIUM", "location out of range"); 4407 "glBindUniformLocationCHROMIUM", "location out of range");
4405 return; 4408 return;
4406 } 4409 }
4407 ProgramManager::ProgramInfo* info = GetProgramInfoNotShader( 4410 Program* info = GetProgramInfoNotShader(
4408 program, "glBindUniformLocationCHROMIUM"); 4411 program, "glBindUniformLocationCHROMIUM");
4409 if (!info) { 4412 if (!info) {
4410 return; 4413 return;
4411 } 4414 }
4412 if (!info->SetUniformLocationBinding(name, location)) { 4415 if (!info->SetUniformLocationBinding(name, location)) {
4413 SetGLError(GL_INVALID_VALUE, 4416 SetGLError(GL_INVALID_VALUE,
4414 "glBindUniformLocationCHROMIUM", "location out of range"); 4417 "glBindUniformLocationCHROMIUM", "location out of range");
4415 } 4418 }
4416 } 4419 }
4417 4420
4418 error::Error GLES2DecoderImpl::HandleBindUniformLocationCHROMIUM( 4421 error::Error GLES2DecoderImpl::HandleBindUniformLocationCHROMIUM(
4419 uint32 immediate_data_size, const gles2::BindUniformLocationCHROMIUM& c) { 4422 uint32 immediate_data_size, const cmds::BindUniformLocationCHROMIUM& c) {
4420 GLuint program = static_cast<GLuint>(c.program); 4423 GLuint program = static_cast<GLuint>(c.program);
4421 GLint location = static_cast<GLint>(c.location); 4424 GLint location = static_cast<GLint>(c.location);
4422 uint32 name_size = c.data_size; 4425 uint32 name_size = c.data_size;
4423 const char* name = GetSharedMemoryAs<const char*>( 4426 const char* name = GetSharedMemoryAs<const char*>(
4424 c.name_shm_id, c.name_shm_offset, name_size); 4427 c.name_shm_id, c.name_shm_offset, name_size);
4425 if (name == NULL) { 4428 if (name == NULL) {
4426 return error::kOutOfBounds; 4429 return error::kOutOfBounds;
4427 } 4430 }
4428 String name_str(name, name_size); 4431 String name_str(name, name_size);
4429 DoBindUniformLocationCHROMIUM(program, location, name_str.c_str()); 4432 DoBindUniformLocationCHROMIUM(program, location, name_str.c_str());
4430 return error::kNoError; 4433 return error::kNoError;
4431 } 4434 }
4432 4435
4433 error::Error GLES2DecoderImpl::HandleBindUniformLocationCHROMIUMImmediate( 4436 error::Error GLES2DecoderImpl::HandleBindUniformLocationCHROMIUMImmediate(
4434 uint32 immediate_data_size, 4437 uint32 immediate_data_size,
4435 const gles2::BindUniformLocationCHROMIUMImmediate& c) { 4438 const cmds::BindUniformLocationCHROMIUMImmediate& c) {
4436 GLuint program = static_cast<GLuint>(c.program); 4439 GLuint program = static_cast<GLuint>(c.program);
4437 GLint location = static_cast<GLint>(c.location); 4440 GLint location = static_cast<GLint>(c.location);
4438 uint32 name_size = c.data_size; 4441 uint32 name_size = c.data_size;
4439 const char* name = GetImmediateDataAs<const char*>( 4442 const char* name = GetImmediateDataAs<const char*>(
4440 c, name_size, immediate_data_size); 4443 c, name_size, immediate_data_size);
4441 if (name == NULL) { 4444 if (name == NULL) {
4442 return error::kOutOfBounds; 4445 return error::kOutOfBounds;
4443 } 4446 }
4444 String name_str(name, name_size); 4447 String name_str(name, name_size);
4445 DoBindUniformLocationCHROMIUM(program, location, name_str.c_str()); 4448 DoBindUniformLocationCHROMIUM(program, location, name_str.c_str());
4446 return error::kNoError; 4449 return error::kNoError;
4447 } 4450 }
4448 4451
4449 error::Error GLES2DecoderImpl::HandleBindUniformLocationCHROMIUMBucket( 4452 error::Error GLES2DecoderImpl::HandleBindUniformLocationCHROMIUMBucket(
4450 uint32 immediate_data_size, 4453 uint32 immediate_data_size,
4451 const gles2::BindUniformLocationCHROMIUMBucket& c) { 4454 const cmds::BindUniformLocationCHROMIUMBucket& c) {
4452 GLuint program = static_cast<GLuint>(c.program); 4455 GLuint program = static_cast<GLuint>(c.program);
4453 GLint location = static_cast<GLint>(c.location); 4456 GLint location = static_cast<GLint>(c.location);
4454 Bucket* bucket = GetBucket(c.name_bucket_id); 4457 Bucket* bucket = GetBucket(c.name_bucket_id);
4455 if (!bucket || bucket->size() == 0) { 4458 if (!bucket || bucket->size() == 0) {
4456 return error::kInvalidArguments; 4459 return error::kInvalidArguments;
4457 } 4460 }
4458 std::string name_str; 4461 std::string name_str;
4459 if (!bucket->GetAsString(&name_str)) { 4462 if (!bucket->GetAsString(&name_str)) {
4460 return error::kInvalidArguments; 4463 return error::kInvalidArguments;
4461 } 4464 }
4462 DoBindUniformLocationCHROMIUM(program, location, name_str.c_str()); 4465 DoBindUniformLocationCHROMIUM(program, location, name_str.c_str());
4463 return error::kNoError; 4466 return error::kNoError;
4464 } 4467 }
4465 4468
4466 error::Error GLES2DecoderImpl::HandleDeleteShader( 4469 error::Error GLES2DecoderImpl::HandleDeleteShader(
4467 uint32 immediate_data_size, const gles2::DeleteShader& c) { 4470 uint32 immediate_data_size, const cmds::DeleteShader& c) {
4468 GLuint client_id = c.shader; 4471 GLuint client_id = c.shader;
4469 if (client_id) { 4472 if (client_id) {
4470 ShaderManager::ShaderInfo* info = GetShaderInfo(client_id); 4473 Shader* info = GetShader(client_id);
4471 if (info) { 4474 if (info) {
4472 if (!info->IsDeleted()) { 4475 if (!info->IsDeleted()) {
4473 glDeleteShader(info->service_id()); 4476 glDeleteShader(info->service_id());
4474 shader_manager()->MarkAsDeleted(info); 4477 shader_manager()->MarkAsDeleted(info);
4475 } 4478 }
4476 } else { 4479 } else {
4477 SetGLError(GL_INVALID_VALUE, "glDeleteShader", "unknown shader"); 4480 SetGLError(GL_INVALID_VALUE, "glDeleteShader", "unknown shader");
4478 } 4481 }
4479 } 4482 }
4480 return error::kNoError; 4483 return error::kNoError;
4481 } 4484 }
4482 4485
4483 error::Error GLES2DecoderImpl::HandleDeleteProgram( 4486 error::Error GLES2DecoderImpl::HandleDeleteProgram(
4484 uint32 immediate_data_size, const gles2::DeleteProgram& c) { 4487 uint32 immediate_data_size, const cmds::DeleteProgram& c) {
4485 GLuint client_id = c.program; 4488 GLuint client_id = c.program;
4486 if (client_id) { 4489 if (client_id) {
4487 ProgramManager::ProgramInfo* info = GetProgramInfo(client_id); 4490 Program* info = GetProgram(client_id);
4488 if (info) { 4491 if (info) {
4489 if (!info->IsDeleted()) { 4492 if (!info->IsDeleted()) {
4490 program_manager()->MarkAsDeleted(shader_manager(), info); 4493 program_manager()->MarkAsDeleted(shader_manager(), info);
4491 } 4494 }
4492 } else { 4495 } else {
4493 SetGLError(GL_INVALID_VALUE, "glDeleteProgram", "unknown program"); 4496 SetGLError(GL_INVALID_VALUE, "glDeleteProgram", "unknown program");
4494 } 4497 }
4495 } 4498 }
4496 return error::kNoError; 4499 return error::kNoError;
4497 } 4500 }
4498 4501
4499 void GLES2DecoderImpl::DoDeleteSharedIdsCHROMIUM( 4502 void GLES2DecoderImpl::DoDeleteSharedIdsCHROMIUM(
4500 GLuint namespace_id, GLsizei n, const GLuint* ids) { 4503 GLuint namespace_id, GLsizei n, const GLuint* ids) {
4501 IdAllocatorInterface* id_allocator = group_->GetIdAllocator(namespace_id); 4504 IdAllocatorInterface* id_allocator = group_->GetIdAllocator(namespace_id);
4502 for (GLsizei ii = 0; ii < n; ++ii) { 4505 for (GLsizei ii = 0; ii < n; ++ii) {
4503 id_allocator->FreeID(ids[ii]); 4506 id_allocator->FreeID(ids[ii]);
4504 } 4507 }
4505 } 4508 }
4506 4509
4507 error::Error GLES2DecoderImpl::HandleDeleteSharedIdsCHROMIUM( 4510 error::Error GLES2DecoderImpl::HandleDeleteSharedIdsCHROMIUM(
4508 uint32 immediate_data_size, const gles2::DeleteSharedIdsCHROMIUM& c) { 4511 uint32 immediate_data_size, const cmds::DeleteSharedIdsCHROMIUM& c) {
4509 GLuint namespace_id = static_cast<GLuint>(c.namespace_id); 4512 GLuint namespace_id = static_cast<GLuint>(c.namespace_id);
4510 GLsizei n = static_cast<GLsizei>(c.n); 4513 GLsizei n = static_cast<GLsizei>(c.n);
4511 uint32 data_size; 4514 uint32 data_size;
4512 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) { 4515 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
4513 return error::kOutOfBounds; 4516 return error::kOutOfBounds;
4514 } 4517 }
4515 const GLuint* ids = GetSharedMemoryAs<const GLuint*>( 4518 const GLuint* ids = GetSharedMemoryAs<const GLuint*>(
4516 c.ids_shm_id, c.ids_shm_offset, data_size); 4519 c.ids_shm_id, c.ids_shm_offset, data_size);
4517 if (n < 0) { 4520 if (n < 0) {
4518 SetGLError(GL_INVALID_VALUE, "DeleteSharedIdsCHROMIUM", "n < 0"); 4521 SetGLError(GL_INVALID_VALUE, "DeleteSharedIdsCHROMIUM", "n < 0");
(...skipping 15 matching lines...) Expand all
4534 } 4537 }
4535 } else { 4538 } else {
4536 for (GLsizei ii = 0; ii < n; ++ii) { 4539 for (GLsizei ii = 0; ii < n; ++ii) {
4537 ids[ii] = id_allocator->AllocateIDAtOrAbove(id_offset); 4540 ids[ii] = id_allocator->AllocateIDAtOrAbove(id_offset);
4538 id_offset = ids[ii] + 1; 4541 id_offset = ids[ii] + 1;
4539 } 4542 }
4540 } 4543 }
4541 } 4544 }
4542 4545
4543 error::Error GLES2DecoderImpl::HandleGenSharedIdsCHROMIUM( 4546 error::Error GLES2DecoderImpl::HandleGenSharedIdsCHROMIUM(
4544 uint32 immediate_data_size, const gles2::GenSharedIdsCHROMIUM& c) { 4547 uint32 immediate_data_size, const cmds::GenSharedIdsCHROMIUM& c) {
4545 GLuint namespace_id = static_cast<GLuint>(c.namespace_id); 4548 GLuint namespace_id = static_cast<GLuint>(c.namespace_id);
4546 GLuint id_offset = static_cast<GLuint>(c.id_offset); 4549 GLuint id_offset = static_cast<GLuint>(c.id_offset);
4547 GLsizei n = static_cast<GLsizei>(c.n); 4550 GLsizei n = static_cast<GLsizei>(c.n);
4548 uint32 data_size; 4551 uint32 data_size;
4549 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) { 4552 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
4550 return error::kOutOfBounds; 4553 return error::kOutOfBounds;
4551 } 4554 }
4552 GLuint* ids = GetSharedMemoryAs<GLuint*>( 4555 GLuint* ids = GetSharedMemoryAs<GLuint*>(
4553 c.ids_shm_id, c.ids_shm_offset, data_size); 4556 c.ids_shm_id, c.ids_shm_offset, data_size);
4554 if (n < 0) { 4557 if (n < 0) {
(...skipping 17 matching lines...) Expand all
4572 } 4575 }
4573 SetGLError( 4576 SetGLError(
4574 GL_INVALID_VALUE, "RegisterSharedIdsCHROMIUM", 4577 GL_INVALID_VALUE, "RegisterSharedIdsCHROMIUM",
4575 "attempt to register id that already exists"); 4578 "attempt to register id that already exists");
4576 return; 4579 return;
4577 } 4580 }
4578 } 4581 }
4579 } 4582 }
4580 4583
4581 error::Error GLES2DecoderImpl::HandleRegisterSharedIdsCHROMIUM( 4584 error::Error GLES2DecoderImpl::HandleRegisterSharedIdsCHROMIUM(
4582 uint32 immediate_data_size, const gles2::RegisterSharedIdsCHROMIUM& c) { 4585 uint32 immediate_data_size, const cmds::RegisterSharedIdsCHROMIUM& c) {
4583 GLuint namespace_id = static_cast<GLuint>(c.namespace_id); 4586 GLuint namespace_id = static_cast<GLuint>(c.namespace_id);
4584 GLsizei n = static_cast<GLsizei>(c.n); 4587 GLsizei n = static_cast<GLsizei>(c.n);
4585 uint32 data_size; 4588 uint32 data_size;
4586 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) { 4589 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
4587 return error::kOutOfBounds; 4590 return error::kOutOfBounds;
4588 } 4591 }
4589 GLuint* ids = GetSharedMemoryAs<GLuint*>( 4592 GLuint* ids = GetSharedMemoryAs<GLuint*>(
4590 c.ids_shm_id, c.ids_shm_offset, data_size); 4593 c.ids_shm_id, c.ids_shm_offset, data_size);
4591 if (n < 0) { 4594 if (n < 0) {
4592 SetGLError(GL_INVALID_VALUE, "RegisterSharedIdsCHROMIUM", "n < 0"); 4595 SetGLError(GL_INVALID_VALUE, "RegisterSharedIdsCHROMIUM", "n < 0");
(...skipping 15 matching lines...) Expand all
4608 "green", state_.color_clear_green); 4611 "green", state_.color_clear_green);
4609 ApplyDirtyState(); 4612 ApplyDirtyState();
4610 glClear(mask); 4613 glClear(mask);
4611 } 4614 }
4612 return error::kNoError; 4615 return error::kNoError;
4613 } 4616 }
4614 4617
4615 void GLES2DecoderImpl::DoFramebufferRenderbuffer( 4618 void GLES2DecoderImpl::DoFramebufferRenderbuffer(
4616 GLenum target, GLenum attachment, GLenum renderbuffertarget, 4619 GLenum target, GLenum attachment, GLenum renderbuffertarget,
4617 GLuint client_renderbuffer_id) { 4620 GLuint client_renderbuffer_id) {
4618 FramebufferManager::FramebufferInfo* framebuffer_info = 4621 Framebuffer* framebuffer_info =
4619 GetFramebufferInfoForTarget(target); 4622 GetFramebufferInfoForTarget(target);
4620 if (!framebuffer_info) { 4623 if (!framebuffer_info) {
4621 SetGLError(GL_INVALID_OPERATION, 4624 SetGLError(GL_INVALID_OPERATION,
4622 "glFramebufferRenderbuffer", "no framebuffer bound"); 4625 "glFramebufferRenderbuffer", "no framebuffer bound");
4623 return; 4626 return;
4624 } 4627 }
4625 GLuint service_id = 0; 4628 GLuint service_id = 0;
4626 RenderbufferManager::RenderbufferInfo* info = NULL; 4629 Renderbuffer* info = NULL;
4627 if (client_renderbuffer_id) { 4630 if (client_renderbuffer_id) {
4628 info = GetRenderbufferInfo(client_renderbuffer_id); 4631 info = GetRenderbuffer(client_renderbuffer_id);
4629 if (!info) { 4632 if (!info) {
4630 SetGLError(GL_INVALID_OPERATION, 4633 SetGLError(GL_INVALID_OPERATION,
4631 "glFramebufferRenderbuffer", "unknown renderbuffer"); 4634 "glFramebufferRenderbuffer", "unknown renderbuffer");
4632 return; 4635 return;
4633 } 4636 }
4634 service_id = info->service_id(); 4637 service_id = info->service_id();
4635 } 4638 }
4636 CopyRealGLErrorsToWrapper(); 4639 CopyRealGLErrorsToWrapper();
4637 glFramebufferRenderbufferEXT( 4640 glFramebufferRenderbufferEXT(
4638 target, attachment, renderbuffertarget, service_id); 4641 target, attachment, renderbuffertarget, service_id);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
4678 } 4681 }
4679 4682
4680 void GLES2DecoderImpl::DoSampleCoverage(GLclampf value, GLboolean invert) { 4683 void GLES2DecoderImpl::DoSampleCoverage(GLclampf value, GLboolean invert) {
4681 state_.sample_coverage_value = std::min(1.0f, std::max(0.0f, value)); 4684 state_.sample_coverage_value = std::min(1.0f, std::max(0.0f, value));
4682 state_.sample_coverage_invert = (invert != 0); 4685 state_.sample_coverage_invert = (invert != 0);
4683 glSampleCoverage(state_.sample_coverage_value, invert); 4686 glSampleCoverage(state_.sample_coverage_value, invert);
4684 } 4687 }
4685 4688
4686 // Assumes framebuffer is complete. 4689 // Assumes framebuffer is complete.
4687 void GLES2DecoderImpl::ClearUnclearedAttachments( 4690 void GLES2DecoderImpl::ClearUnclearedAttachments(
4688 GLenum target, FramebufferManager::FramebufferInfo* info) { 4691 GLenum target, Framebuffer* info) {
4689 if (target == GL_READ_FRAMEBUFFER_EXT) { 4692 if (target == GL_READ_FRAMEBUFFER_EXT) {
4690 // bind this to the DRAW point, clear then bind back to READ 4693 // bind this to the DRAW point, clear then bind back to READ
4691 // TODO(gman): I don't think there is any guarantee that an FBO that 4694 // TODO(gman): I don't think there is any guarantee that an FBO that
4692 // is complete on the READ attachment will be complete as a DRAW 4695 // is complete on the READ attachment will be complete as a DRAW
4693 // attachment. 4696 // attachment.
4694 glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, 0); 4697 glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, 0);
4695 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, info->service_id()); 4698 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, info->service_id());
4696 } 4699 }
4697 GLbitfield clear_bits = 0; 4700 GLbitfield clear_bits = 0;
4698 if (info->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0)) { 4701 if (info->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0)) {
(...skipping 22 matching lines...) Expand all
4721 glDisable(GL_SCISSOR_TEST); 4724 glDisable(GL_SCISSOR_TEST);
4722 glClear(clear_bits); 4725 glClear(clear_bits);
4723 4726
4724 framebuffer_manager()->MarkAttachmentsAsCleared( 4727 framebuffer_manager()->MarkAttachmentsAsCleared(
4725 info, renderbuffer_manager(), texture_manager()); 4728 info, renderbuffer_manager(), texture_manager());
4726 4729
4727 RestoreClearState(); 4730 RestoreClearState();
4728 4731
4729 if (target == GL_READ_FRAMEBUFFER_EXT) { 4732 if (target == GL_READ_FRAMEBUFFER_EXT) {
4730 glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, info->service_id()); 4733 glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, info->service_id());
4731 FramebufferManager::FramebufferInfo* framebuffer = 4734 Framebuffer* framebuffer =
4732 GetFramebufferInfoForTarget(GL_DRAW_FRAMEBUFFER_EXT); 4735 GetFramebufferInfoForTarget(GL_DRAW_FRAMEBUFFER_EXT);
4733 GLuint service_id = 4736 GLuint service_id =
4734 framebuffer ? framebuffer->service_id() : GetBackbufferServiceId(); 4737 framebuffer ? framebuffer->service_id() : GetBackbufferServiceId();
4735 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, service_id); 4738 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, service_id);
4736 } 4739 }
4737 } 4740 }
4738 4741
4739 void GLES2DecoderImpl::RestoreClearState() { 4742 void GLES2DecoderImpl::RestoreClearState() {
4740 clear_state_dirty_ = true; 4743 clear_state_dirty_ = true;
4741 glClearColor( 4744 glClearColor(
4742 state_.color_clear_red, state_.color_clear_green, state_.color_clear_blue, 4745 state_.color_clear_red, state_.color_clear_green, state_.color_clear_blue,
4743 state_.color_clear_alpha); 4746 state_.color_clear_alpha);
4744 glClearStencil(state_.stencil_clear); 4747 glClearStencil(state_.stencil_clear);
4745 glClearDepth(state_.depth_clear); 4748 glClearDepth(state_.depth_clear);
4746 if (state_.enable_flags.scissor_test) { 4749 if (state_.enable_flags.scissor_test) {
4747 glEnable(GL_SCISSOR_TEST); 4750 glEnable(GL_SCISSOR_TEST);
4748 } 4751 }
4749 } 4752 }
4750 4753
4751 GLenum GLES2DecoderImpl::DoCheckFramebufferStatus(GLenum target) { 4754 GLenum GLES2DecoderImpl::DoCheckFramebufferStatus(GLenum target) {
4752 FramebufferManager::FramebufferInfo* framebuffer = 4755 Framebuffer* framebuffer =
4753 GetFramebufferInfoForTarget(target); 4756 GetFramebufferInfoForTarget(target);
4754 if (!framebuffer) { 4757 if (!framebuffer) {
4755 return GL_FRAMEBUFFER_COMPLETE; 4758 return GL_FRAMEBUFFER_COMPLETE;
4756 } 4759 }
4757 GLenum completeness = framebuffer->IsPossiblyComplete(); 4760 GLenum completeness = framebuffer->IsPossiblyComplete();
4758 if (completeness != GL_FRAMEBUFFER_COMPLETE) { 4761 if (completeness != GL_FRAMEBUFFER_COMPLETE) {
4759 return completeness; 4762 return completeness;
4760 } 4763 }
4761 return framebuffer->GetStatus(texture_manager(), target); 4764 return framebuffer->GetStatus(texture_manager(), target);
4762 } 4765 }
4763 4766
4764 void GLES2DecoderImpl::DoFramebufferTexture2D( 4767 void GLES2DecoderImpl::DoFramebufferTexture2D(
4765 GLenum target, GLenum attachment, GLenum textarget, 4768 GLenum target, GLenum attachment, GLenum textarget,
4766 GLuint client_texture_id, GLint level) { 4769 GLuint client_texture_id, GLint level) {
4767 FramebufferManager::FramebufferInfo* framebuffer_info = 4770 Framebuffer* framebuffer_info =
4768 GetFramebufferInfoForTarget(target); 4771 GetFramebufferInfoForTarget(target);
4769 if (!framebuffer_info) { 4772 if (!framebuffer_info) {
4770 SetGLError(GL_INVALID_OPERATION, 4773 SetGLError(GL_INVALID_OPERATION,
4771 "glFramebufferTexture2D", "no framebuffer bound."); 4774 "glFramebufferTexture2D", "no framebuffer bound.");
4772 return; 4775 return;
4773 } 4776 }
4774 GLuint service_id = 0; 4777 GLuint service_id = 0;
4775 TextureManager::TextureInfo* info = NULL; 4778 Texture* info = NULL;
4776 if (client_texture_id) { 4779 if (client_texture_id) {
4777 info = GetTextureInfo(client_texture_id); 4780 info = GetTexture(client_texture_id);
4778 if (!info) { 4781 if (!info) {
4779 SetGLError(GL_INVALID_OPERATION, 4782 SetGLError(GL_INVALID_OPERATION,
4780 "glFramebufferTexture2D", "unknown texture"); 4783 "glFramebufferTexture2D", "unknown texture");
4781 return; 4784 return;
4782 } 4785 }
4783 service_id = info->service_id(); 4786 service_id = info->service_id();
4784 } 4787 }
4785 4788
4786 if (!texture_manager()->ValidForTarget(textarget, level, 0, 0, 1)) { 4789 if (!texture_manager()->ValidForTarget(textarget, level, 0, 0, 1)) {
4787 SetGLError(GL_INVALID_VALUE, 4790 SetGLError(GL_INVALID_VALUE,
4788 "glFramebufferTexture2D", "level out of range"); 4791 "glFramebufferTexture2D", "level out of range");
4789 return; 4792 return;
4790 } 4793 }
4791 4794
4792 CopyRealGLErrorsToWrapper(); 4795 CopyRealGLErrorsToWrapper();
4793 glFramebufferTexture2DEXT(target, attachment, textarget, service_id, level); 4796 glFramebufferTexture2DEXT(target, attachment, textarget, service_id, level);
4794 GLenum error = PeekGLError(); 4797 GLenum error = PeekGLError();
4795 if (error == GL_NO_ERROR) { 4798 if (error == GL_NO_ERROR) {
4796 framebuffer_info->AttachTexture(attachment, info, textarget, level); 4799 framebuffer_info->AttachTexture(attachment, info, textarget, level);
4797 } 4800 }
4798 if (framebuffer_info == state_.bound_draw_framebuffer) { 4801 if (framebuffer_info == state_.bound_draw_framebuffer) {
4799 clear_state_dirty_ = true; 4802 clear_state_dirty_ = true;
4800 } 4803 }
4801 } 4804 }
4802 4805
4803 void GLES2DecoderImpl::DoGetFramebufferAttachmentParameteriv( 4806 void GLES2DecoderImpl::DoGetFramebufferAttachmentParameteriv(
4804 GLenum target, GLenum attachment, GLenum pname, GLint* params) { 4807 GLenum target, GLenum attachment, GLenum pname, GLint* params) {
4805 FramebufferManager::FramebufferInfo* framebuffer_info = 4808 Framebuffer* framebuffer_info =
4806 GetFramebufferInfoForTarget(target); 4809 GetFramebufferInfoForTarget(target);
4807 if (!framebuffer_info) { 4810 if (!framebuffer_info) {
4808 SetGLError(GL_INVALID_OPERATION, 4811 SetGLError(GL_INVALID_OPERATION,
4809 "glFramebufferAttachmentParameteriv", "no framebuffer bound"); 4812 "glFramebufferAttachmentParameteriv", "no framebuffer bound");
4810 return; 4813 return;
4811 } 4814 }
4812 glGetFramebufferAttachmentParameterivEXT(target, attachment, pname, params); 4815 glGetFramebufferAttachmentParameterivEXT(target, attachment, pname, params);
4813 if (pname == GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME) { 4816 if (pname == GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME) {
4814 GLint type = 0; 4817 GLint type = 0;
4815 GLuint client_id = 0; 4818 GLuint client_id = 0;
(...skipping 10 matching lines...) Expand all
4826 } 4829 }
4827 default: 4830 default:
4828 break; 4831 break;
4829 } 4832 }
4830 *params = client_id; 4833 *params = client_id;
4831 } 4834 }
4832 } 4835 }
4833 4836
4834 void GLES2DecoderImpl::DoGetRenderbufferParameteriv( 4837 void GLES2DecoderImpl::DoGetRenderbufferParameteriv(
4835 GLenum target, GLenum pname, GLint* params) { 4838 GLenum target, GLenum pname, GLint* params) {
4836 RenderbufferManager::RenderbufferInfo* renderbuffer = 4839 Renderbuffer* renderbuffer =
4837 GetRenderbufferInfoForTarget(GL_RENDERBUFFER); 4840 GetRenderbufferInfoForTarget(GL_RENDERBUFFER);
4838 if (!renderbuffer) { 4841 if (!renderbuffer) {
4839 SetGLError(GL_INVALID_OPERATION, 4842 SetGLError(GL_INVALID_OPERATION,
4840 "glGetRenderbufferParameteriv", "no renderbuffer bound"); 4843 "glGetRenderbufferParameteriv", "no renderbuffer bound");
4841 return; 4844 return;
4842 } 4845 }
4843 switch (pname) { 4846 switch (pname) {
4844 case GL_RENDERBUFFER_INTERNAL_FORMAT: 4847 case GL_RENDERBUFFER_INTERNAL_FORMAT:
4845 *params = renderbuffer->internal_format(); 4848 *params = renderbuffer->internal_format();
4846 break; 4849 break;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
4879 4882
4880 void GLES2DecoderImpl::DoRenderbufferStorageMultisample( 4883 void GLES2DecoderImpl::DoRenderbufferStorageMultisample(
4881 GLenum target, GLsizei samples, GLenum internalformat, 4884 GLenum target, GLsizei samples, GLenum internalformat,
4882 GLsizei width, GLsizei height) { 4885 GLsizei width, GLsizei height) {
4883 if (!features().chromium_framebuffer_multisample) { 4886 if (!features().chromium_framebuffer_multisample) {
4884 SetGLError(GL_INVALID_OPERATION, 4887 SetGLError(GL_INVALID_OPERATION,
4885 "glRenderbufferStorageMultisampleEXT", "function not available"); 4888 "glRenderbufferStorageMultisampleEXT", "function not available");
4886 return; 4889 return;
4887 } 4890 }
4888 4891
4889 RenderbufferManager::RenderbufferInfo* renderbuffer = 4892 Renderbuffer* renderbuffer =
4890 GetRenderbufferInfoForTarget(GL_RENDERBUFFER); 4893 GetRenderbufferInfoForTarget(GL_RENDERBUFFER);
4891 if (!renderbuffer) { 4894 if (!renderbuffer) {
4892 SetGLError(GL_INVALID_OPERATION, 4895 SetGLError(GL_INVALID_OPERATION,
4893 "glRenderbufferStorageMultisampleEXT", "no renderbuffer bound"); 4896 "glRenderbufferStorageMultisampleEXT", "no renderbuffer bound");
4894 return; 4897 return;
4895 } 4898 }
4896 4899
4897 if (samples > renderbuffer_manager()->max_samples()) { 4900 if (samples > renderbuffer_manager()->max_samples()) {
4898 SetGLError(GL_INVALID_VALUE, 4901 SetGLError(GL_INVALID_VALUE,
4899 "glRenderbufferStorageMultisampleEXT", "samples too large"); 4902 "glRenderbufferStorageMultisampleEXT", "samples too large");
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
4936 // TODO(gman): If renderbuffers tracked which framebuffers they were 4939 // TODO(gman): If renderbuffers tracked which framebuffers they were
4937 // attached to we could just mark those framebuffers as not complete. 4940 // attached to we could just mark those framebuffers as not complete.
4938 framebuffer_manager()->IncFramebufferStateChangeCount(); 4941 framebuffer_manager()->IncFramebufferStateChangeCount();
4939 renderbuffer_manager()->SetInfo( 4942 renderbuffer_manager()->SetInfo(
4940 renderbuffer, samples, internalformat, width, height); 4943 renderbuffer, samples, internalformat, width, height);
4941 } 4944 }
4942 } 4945 }
4943 4946
4944 void GLES2DecoderImpl::DoRenderbufferStorage( 4947 void GLES2DecoderImpl::DoRenderbufferStorage(
4945 GLenum target, GLenum internalformat, GLsizei width, GLsizei height) { 4948 GLenum target, GLenum internalformat, GLsizei width, GLsizei height) {
4946 RenderbufferManager::RenderbufferInfo* renderbuffer = 4949 Renderbuffer* renderbuffer =
4947 GetRenderbufferInfoForTarget(GL_RENDERBUFFER); 4950 GetRenderbufferInfoForTarget(GL_RENDERBUFFER);
4948 if (!renderbuffer) { 4951 if (!renderbuffer) {
4949 SetGLError(GL_INVALID_OPERATION, 4952 SetGLError(GL_INVALID_OPERATION,
4950 "glRenderbufferStorage", "no renderbuffer bound"); 4953 "glRenderbufferStorage", "no renderbuffer bound");
4951 return; 4954 return;
4952 } 4955 }
4953 4956
4954 if (width > renderbuffer_manager()->max_renderbuffer_size() || 4957 if (width > renderbuffer_manager()->max_renderbuffer_size() ||
4955 height > renderbuffer_manager()->max_renderbuffer_size()) { 4958 height > renderbuffer_manager()->max_renderbuffer_size()) {
4956 SetGLError(GL_INVALID_VALUE, 4959 SetGLError(GL_INVALID_VALUE,
(...skipping 24 matching lines...) Expand all
4981 // TODO(gman): If tetxures tracked which framebuffers they were attached to 4984 // TODO(gman): If tetxures tracked which framebuffers they were attached to
4982 // we could just mark those framebuffers as not complete. 4985 // we could just mark those framebuffers as not complete.
4983 framebuffer_manager()->IncFramebufferStateChangeCount(); 4986 framebuffer_manager()->IncFramebufferStateChangeCount();
4984 renderbuffer_manager()->SetInfo( 4987 renderbuffer_manager()->SetInfo(
4985 renderbuffer, 1, internalformat, width, height); 4988 renderbuffer, 1, internalformat, width, height);
4986 } 4989 }
4987 } 4990 }
4988 4991
4989 void GLES2DecoderImpl::DoLinkProgram(GLuint program) { 4992 void GLES2DecoderImpl::DoLinkProgram(GLuint program) {
4990 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoLinkProgram"); 4993 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoLinkProgram");
4991 ProgramManager::ProgramInfo* info = GetProgramInfoNotShader( 4994 Program* info = GetProgramInfoNotShader(
4992 program, "glLinkProgram"); 4995 program, "glLinkProgram");
4993 if (!info) { 4996 if (!info) {
4994 return; 4997 return;
4995 } 4998 }
4996 4999
4997 LogClientServiceForInfo(info, program, "glLinkProgram"); 5000 LogClientServiceForInfo(info, program, "glLinkProgram");
4998 ShaderTranslator* vertex_translator = NULL; 5001 ShaderTranslator* vertex_translator = NULL;
4999 ShaderTranslator* fragment_translator = NULL; 5002 ShaderTranslator* fragment_translator = NULL;
5000 if (use_shader_translator_) { 5003 if (use_shader_translator_) {
5001 vertex_translator = vertex_translator_; 5004 vertex_translator = vertex_translator_;
5002 fragment_translator = fragment_translator_; 5005 fragment_translator = fragment_translator_;
5003 } 5006 }
5004 if (info->Link(shader_manager(), 5007 if (info->Link(shader_manager(),
5005 vertex_translator, 5008 vertex_translator,
5006 fragment_translator, 5009 fragment_translator,
5007 feature_info_)) { 5010 feature_info_)) {
5008 if (info == state_.current_program.get()) { 5011 if (info == state_.current_program.get()) {
5009 if (workarounds().use_current_program_after_successful_link) { 5012 if (workarounds().use_current_program_after_successful_link) {
5010 glUseProgram(info->service_id()); 5013 glUseProgram(info->service_id());
5011 } 5014 }
5012 program_manager()->ClearUniforms(info); 5015 program_manager()->ClearUniforms(info);
5013 } 5016 }
5014 } 5017 }
5015 }; 5018 };
5016 5019
5017 void GLES2DecoderImpl::DoTexParameterf( 5020 void GLES2DecoderImpl::DoTexParameterf(
5018 GLenum target, GLenum pname, GLfloat param) { 5021 GLenum target, GLenum pname, GLfloat param) {
5019 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target); 5022 Texture* info = GetTextureInfoForTarget(target);
5020 if (!info) { 5023 if (!info) {
5021 SetGLError(GL_INVALID_VALUE, "glTexParameterf", "unknown texture"); 5024 SetGLError(GL_INVALID_VALUE, "glTexParameterf", "unknown texture");
5022 return; 5025 return;
5023 } 5026 }
5024 5027
5025 GLenum error = texture_manager()->SetParameter( 5028 GLenum error = texture_manager()->SetParameter(
5026 info, pname, static_cast<GLint>(param)); 5029 info, pname, static_cast<GLint>(param));
5027 if (error != GL_NO_ERROR) { 5030 if (error != GL_NO_ERROR) {
5028 SetGLErrorInvalidParam( 5031 SetGLErrorInvalidParam(
5029 error, "glTexParameterf", pname, static_cast<GLint>(param)); 5032 error, "glTexParameterf", pname, static_cast<GLint>(param));
5030 return; 5033 return;
5031 } 5034 }
5032 glTexParameterf(target, pname, param); 5035 glTexParameterf(target, pname, param);
5033 } 5036 }
5034 5037
5035 void GLES2DecoderImpl::DoTexParameteri( 5038 void GLES2DecoderImpl::DoTexParameteri(
5036 GLenum target, GLenum pname, GLint param) { 5039 GLenum target, GLenum pname, GLint param) {
5037 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target); 5040 Texture* info = GetTextureInfoForTarget(target);
5038 if (!info) { 5041 if (!info) {
5039 SetGLError(GL_INVALID_VALUE, "glTexParameteri", "unknown texture"); 5042 SetGLError(GL_INVALID_VALUE, "glTexParameteri", "unknown texture");
5040 return; 5043 return;
5041 } 5044 }
5042 5045
5043 GLenum error = texture_manager()->SetParameter(info, pname, param); 5046 GLenum error = texture_manager()->SetParameter(info, pname, param);
5044 if (error != GL_NO_ERROR) { 5047 if (error != GL_NO_ERROR) {
5045 SetGLErrorInvalidParam(error, "glTexParameteri", pname, param); 5048 SetGLErrorInvalidParam(error, "glTexParameteri", pname, param);
5046 return; 5049 return;
5047 } 5050 }
5048 // Texture tracking pools exist only for the command decoder, so 5051 // Texture tracking pools exist only for the command decoder, so
5049 // do not pass them on to the native GL implementation. 5052 // do not pass them on to the native GL implementation.
5050 if (pname == GL_TEXTURE_POOL_CHROMIUM) { 5053 if (pname == GL_TEXTURE_POOL_CHROMIUM) {
5051 return; 5054 return;
5052 } 5055 }
5053 glTexParameteri(target, pname, param); 5056 glTexParameteri(target, pname, param);
5054 } 5057 }
5055 5058
5056 void GLES2DecoderImpl::DoTexParameterfv( 5059 void GLES2DecoderImpl::DoTexParameterfv(
5057 GLenum target, GLenum pname, const GLfloat* params) { 5060 GLenum target, GLenum pname, const GLfloat* params) {
5058 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target); 5061 Texture* info = GetTextureInfoForTarget(target);
5059 if (!info) { 5062 if (!info) {
5060 SetGLError(GL_INVALID_VALUE, "glTexParameterfv", "unknown texture"); 5063 SetGLError(GL_INVALID_VALUE, "glTexParameterfv", "unknown texture");
5061 return; 5064 return;
5062 } 5065 }
5063 5066
5064 GLenum error =texture_manager()->SetParameter( 5067 GLenum error =texture_manager()->SetParameter(
5065 info, pname, static_cast<GLint>(params[0])); 5068 info, pname, static_cast<GLint>(params[0]));
5066 if (error != GL_NO_ERROR) { 5069 if (error != GL_NO_ERROR) {
5067 SetGLErrorInvalidParam( 5070 SetGLErrorInvalidParam(
5068 error, "glTexParameterfv", pname, static_cast<GLint>(params[0])); 5071 error, "glTexParameterfv", pname, static_cast<GLint>(params[0]));
5069 return; 5072 return;
5070 } 5073 }
5071 glTexParameterfv(target, pname, params); 5074 glTexParameterfv(target, pname, params);
5072 } 5075 }
5073 5076
5074 void GLES2DecoderImpl::DoTexParameteriv( 5077 void GLES2DecoderImpl::DoTexParameteriv(
5075 GLenum target, GLenum pname, const GLint* params) { 5078 GLenum target, GLenum pname, const GLint* params) {
5076 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target); 5079 Texture* info = GetTextureInfoForTarget(target);
5077 if (!info) { 5080 if (!info) {
5078 SetGLError(GL_INVALID_VALUE, "glTexParameteriv", "unknown texture"); 5081 SetGLError(GL_INVALID_VALUE, "glTexParameteriv", "unknown texture");
5079 return; 5082 return;
5080 } 5083 }
5081 5084
5082 GLenum error = texture_manager()->SetParameter(info, pname, *params); 5085 GLenum error = texture_manager()->SetParameter(info, pname, *params);
5083 if (error != GL_NO_ERROR) { 5086 if (error != GL_NO_ERROR) {
5084 SetGLErrorInvalidParam(error, "glTexParameteriv", pname, *params); 5087 SetGLErrorInvalidParam(error, "glTexParameteriv", pname, *params);
5085 return; 5088 return;
5086 } 5089 }
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
5228 const GLES2DecoderImpl::BaseUniformInfo& base_info, 5231 const GLES2DecoderImpl::BaseUniformInfo& base_info,
5229 GLint* real_location, GLenum* type, GLsizei* count) { 5232 GLint* real_location, GLenum* type, GLsizei* count) {
5230 DCHECK(type); 5233 DCHECK(type);
5231 DCHECK(count); 5234 DCHECK(count);
5232 DCHECK(real_location); 5235 DCHECK(real_location);
5233 5236
5234 if (!CheckCurrentProgramForUniform(fake_location, function_name)) { 5237 if (!CheckCurrentProgramForUniform(fake_location, function_name)) {
5235 return false; 5238 return false;
5236 } 5239 }
5237 GLint array_index = -1; 5240 GLint array_index = -1;
5238 const ProgramManager::ProgramInfo::UniformInfo* info = 5241 const Program::UniformInfo* info =
5239 state_.current_program->GetUniformInfoByFakeLocation( 5242 state_.current_program->GetUniformInfoByFakeLocation(
5240 fake_location, real_location, &array_index); 5243 fake_location, real_location, &array_index);
5241 if (!info) { 5244 if (!info) {
5242 SetGLError(GL_INVALID_OPERATION, function_name, "unknown location"); 5245 SetGLError(GL_INVALID_OPERATION, function_name, "unknown location");
5243 return false; 5246 return false;
5244 } 5247 }
5245 bool okay = false; 5248 bool okay = false;
5246 for (size_t ii = 0; ii < base_info.num_valid_types; ++ii) { 5249 for (size_t ii = 0; ii < base_info.num_valid_types; ++ii) {
5247 if (base_info.valid_types[ii] == info->type) { 5250 if (base_info.valid_types[ii] == info->type) {
5248 okay = true; 5251 okay = true;
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
5457 if (!PrepForSetUniformByLocation( 5460 if (!PrepForSetUniformByLocation(
5458 fake_location, "glUniformMatrix4fv", valid_float_mat4_base_info, 5461 fake_location, "glUniformMatrix4fv", valid_float_mat4_base_info,
5459 &real_location, &type, &count)) { 5462 &real_location, &type, &count)) {
5460 return; 5463 return;
5461 } 5464 }
5462 glUniformMatrix4fv(real_location, count, transpose, value); 5465 glUniformMatrix4fv(real_location, count, transpose, value);
5463 } 5466 }
5464 5467
5465 void GLES2DecoderImpl::DoUseProgram(GLuint program) { 5468 void GLES2DecoderImpl::DoUseProgram(GLuint program) {
5466 GLuint service_id = 0; 5469 GLuint service_id = 0;
5467 ProgramManager::ProgramInfo* info = NULL; 5470 Program* info = NULL;
5468 if (program) { 5471 if (program) {
5469 info = GetProgramInfoNotShader(program, "glUseProgram"); 5472 info = GetProgramInfoNotShader(program, "glUseProgram");
5470 if (!info) { 5473 if (!info) {
5471 return; 5474 return;
5472 } 5475 }
5473 if (!info->IsValid()) { 5476 if (!info->IsValid()) {
5474 // Program was not linked successfully. (ie, glLinkProgram) 5477 // Program was not linked successfully. (ie, glLinkProgram)
5475 SetGLError(GL_INVALID_OPERATION, "glUseProgram", "program not linked"); 5478 SetGLError(GL_INVALID_OPERATION, "glUseProgram", "program not linked");
5476 return; 5479 return;
5477 } 5480 }
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
5583 5586
5584 void GLES2DecoderImpl::RenderWarning(const std::string& msg) { 5587 void GLES2DecoderImpl::RenderWarning(const std::string& msg) {
5585 LogMessage(std::string("RENDER WARNING: ") + msg); 5588 LogMessage(std::string("RENDER WARNING: ") + msg);
5586 } 5589 }
5587 5590
5588 void GLES2DecoderImpl::PerformanceWarning(const std::string& msg) { 5591 void GLES2DecoderImpl::PerformanceWarning(const std::string& msg) {
5589 LogMessage(std::string("PERFORMANCE WARNING: ") + msg); 5592 LogMessage(std::string("PERFORMANCE WARNING: ") + msg);
5590 } 5593 }
5591 5594
5592 void GLES2DecoderImpl::ForceCompileShaderIfPending( 5595 void GLES2DecoderImpl::ForceCompileShaderIfPending(
5593 ShaderManager::ShaderInfo* info) { 5596 Shader* info) {
5594 if (info->compilation_status() == 5597 if (info->compilation_status() ==
5595 ShaderManager::ShaderInfo::PENDING_DEFERRED_COMPILE) { 5598 Shader::PENDING_DEFERRED_COMPILE) {
5596 ShaderTranslator* translator = NULL; 5599 ShaderTranslator* translator = NULL;
5597 if (use_shader_translator_) { 5600 if (use_shader_translator_) {
5598 translator = info->shader_type() == GL_VERTEX_SHADER ? 5601 translator = info->shader_type() == GL_VERTEX_SHADER ?
5599 vertex_translator_.get() : fragment_translator_.get(); 5602 vertex_translator_.get() : fragment_translator_.get();
5600 } 5603 }
5601 // We know there will be no errors, because we only defer compilation on 5604 // We know there will be no errors, because we only defer compilation on
5602 // shaders that were previously compiled successfully. 5605 // shaders that were previously compiled successfully.
5603 program_manager()->ForceCompileShader(info->deferred_compilation_source(), 5606 program_manager()->ForceCompileShader(info->deferred_compilation_source(),
5604 info, 5607 info,
5605 translator, 5608 translator,
(...skipping 18 matching lines...) Expand all
5624 } 5627 }
5625 } 5628 }
5626 5629
5627 bool GLES2DecoderImpl::SetBlackTextureForNonRenderableTextures() { 5630 bool GLES2DecoderImpl::SetBlackTextureForNonRenderableTextures() {
5628 DCHECK(state_.current_program); 5631 DCHECK(state_.current_program);
5629 // Only check if there are some unrenderable textures. 5632 // Only check if there are some unrenderable textures.
5630 if (!texture_manager()->HaveUnrenderableTextures()) { 5633 if (!texture_manager()->HaveUnrenderableTextures()) {
5631 return false; 5634 return false;
5632 } 5635 }
5633 bool textures_set = false; 5636 bool textures_set = false;
5634 const ProgramManager::ProgramInfo::SamplerIndices& sampler_indices = 5637 const Program::SamplerIndices& sampler_indices =
5635 state_.current_program->sampler_indices(); 5638 state_.current_program->sampler_indices();
5636 for (size_t ii = 0; ii < sampler_indices.size(); ++ii) { 5639 for (size_t ii = 0; ii < sampler_indices.size(); ++ii) {
5637 const ProgramManager::ProgramInfo::UniformInfo* uniform_info = 5640 const Program::UniformInfo* uniform_info =
5638 state_.current_program->GetUniformInfo(sampler_indices[ii]); 5641 state_.current_program->GetUniformInfo(sampler_indices[ii]);
5639 DCHECK(uniform_info); 5642 DCHECK(uniform_info);
5640 for (size_t jj = 0; jj < uniform_info->texture_units.size(); ++jj) { 5643 for (size_t jj = 0; jj < uniform_info->texture_units.size(); ++jj) {
5641 GLuint texture_unit_index = uniform_info->texture_units[jj]; 5644 GLuint texture_unit_index = uniform_info->texture_units[jj];
5642 if (texture_unit_index < state_.texture_units.size()) { 5645 if (texture_unit_index < state_.texture_units.size()) {
5643 TextureUnit& texture_unit = state_.texture_units[texture_unit_index]; 5646 TextureUnit& texture_unit = state_.texture_units[texture_unit_index];
5644 TextureManager::TextureInfo* texture_info = 5647 Texture* texture_info =
5645 texture_unit.GetInfoForSamplerType(uniform_info->type); 5648 texture_unit.GetInfoForSamplerType(uniform_info->type);
5646 if (!texture_info || !texture_manager()->CanRender(texture_info)) { 5649 if (!texture_info || !texture_manager()->CanRender(texture_info)) {
5647 textures_set = true; 5650 textures_set = true;
5648 glActiveTexture(GL_TEXTURE0 + texture_unit_index); 5651 glActiveTexture(GL_TEXTURE0 + texture_unit_index);
5649 glBindTexture( 5652 glBindTexture(
5650 GetBindTargetForSamplerType(uniform_info->type), 5653 GetBindTargetForSamplerType(uniform_info->type),
5651 texture_manager()->black_texture_id(uniform_info->type)); 5654 texture_manager()->black_texture_id(uniform_info->type));
5652 RenderWarning( 5655 RenderWarning(
5653 std::string("texture bound to texture unit ") + 5656 std::string("texture bound to texture unit ") +
5654 base::IntToString(texture_unit_index) + 5657 base::IntToString(texture_unit_index) +
5655 " is not renderable. It maybe non-power-of-2 and have " 5658 " is not renderable. It maybe non-power-of-2 and have "
5656 " incompatible texture filtering or is not " 5659 " incompatible texture filtering or is not "
5657 "'texture complete'"); 5660 "'texture complete'");
5658 } 5661 }
5659 } 5662 }
5660 // else: should this be an error? 5663 // else: should this be an error?
5661 } 5664 }
5662 } 5665 }
5663 return textures_set; 5666 return textures_set;
5664 } 5667 }
5665 5668
5666 void GLES2DecoderImpl::RestoreStateForNonRenderableTextures() { 5669 void GLES2DecoderImpl::RestoreStateForNonRenderableTextures() {
5667 DCHECK(state_.current_program); 5670 DCHECK(state_.current_program);
5668 const ProgramManager::ProgramInfo::SamplerIndices& sampler_indices = 5671 const Program::SamplerIndices& sampler_indices =
5669 state_.current_program->sampler_indices(); 5672 state_.current_program->sampler_indices();
5670 for (size_t ii = 0; ii < sampler_indices.size(); ++ii) { 5673 for (size_t ii = 0; ii < sampler_indices.size(); ++ii) {
5671 const ProgramManager::ProgramInfo::UniformInfo* uniform_info = 5674 const Program::UniformInfo* uniform_info =
5672 state_.current_program->GetUniformInfo(sampler_indices[ii]); 5675 state_.current_program->GetUniformInfo(sampler_indices[ii]);
5673 DCHECK(uniform_info); 5676 DCHECK(uniform_info);
5674 for (size_t jj = 0; jj < uniform_info->texture_units.size(); ++jj) { 5677 for (size_t jj = 0; jj < uniform_info->texture_units.size(); ++jj) {
5675 GLuint texture_unit_index = uniform_info->texture_units[jj]; 5678 GLuint texture_unit_index = uniform_info->texture_units[jj];
5676 if (texture_unit_index < state_.texture_units.size()) { 5679 if (texture_unit_index < state_.texture_units.size()) {
5677 TextureUnit& texture_unit = state_.texture_units[texture_unit_index]; 5680 TextureUnit& texture_unit = state_.texture_units[texture_unit_index];
5678 TextureManager::TextureInfo* texture_info = 5681 Texture* texture_info =
5679 uniform_info->type == GL_SAMPLER_2D ? 5682 uniform_info->type == GL_SAMPLER_2D ?
5680 texture_unit.bound_texture_2d : 5683 texture_unit.bound_texture_2d :
5681 texture_unit.bound_texture_cube_map; 5684 texture_unit.bound_texture_cube_map;
5682 if (!texture_info || !texture_manager()->CanRender(texture_info)) { 5685 if (!texture_info || !texture_manager()->CanRender(texture_info)) {
5683 glActiveTexture(GL_TEXTURE0 + texture_unit_index); 5686 glActiveTexture(GL_TEXTURE0 + texture_unit_index);
5684 // Get the texture info that was previously bound here. 5687 // Get the texture info that was previously bound here.
5685 texture_info = texture_unit.bind_target == GL_TEXTURE_2D ? 5688 texture_info = texture_unit.bind_target == GL_TEXTURE_2D ?
5686 texture_unit.bound_texture_2d : 5689 texture_unit.bound_texture_2d :
5687 texture_unit.bound_texture_cube_map; 5690 texture_unit.bound_texture_cube_map;
5688 glBindTexture(texture_unit.bind_target, 5691 glBindTexture(texture_unit.bind_target,
5689 texture_info ? texture_info->service_id() : 0); 5692 texture_info ? texture_info->service_id() : 0);
5690 } 5693 }
5691 } 5694 }
5692 } 5695 }
5693 } 5696 }
5694 // Set the active texture back to whatever the user had it as. 5697 // Set the active texture back to whatever the user had it as.
5695 glActiveTexture(GL_TEXTURE0 + state_.active_texture_unit); 5698 glActiveTexture(GL_TEXTURE0 + state_.active_texture_unit);
5696 } 5699 }
5697 5700
5698 bool GLES2DecoderImpl::ClearUnclearedTextures() { 5701 bool GLES2DecoderImpl::ClearUnclearedTextures() {
5699 // Only check if there are some uncleared textures. 5702 // Only check if there are some uncleared textures.
5700 if (!texture_manager()->HaveUnsafeTextures()) { 5703 if (!texture_manager()->HaveUnsafeTextures()) {
5701 return true; 5704 return true;
5702 } 5705 }
5703 5706
5704 // 1: Check all textures we are about to render with. 5707 // 1: Check all textures we are about to render with.
5705 if (state_.current_program) { 5708 if (state_.current_program) {
5706 const ProgramManager::ProgramInfo::SamplerIndices& sampler_indices = 5709 const Program::SamplerIndices& sampler_indices =
5707 state_.current_program->sampler_indices(); 5710 state_.current_program->sampler_indices();
5708 for (size_t ii = 0; ii < sampler_indices.size(); ++ii) { 5711 for (size_t ii = 0; ii < sampler_indices.size(); ++ii) {
5709 const ProgramManager::ProgramInfo::UniformInfo* uniform_info = 5712 const Program::UniformInfo* uniform_info =
5710 state_.current_program->GetUniformInfo(sampler_indices[ii]); 5713 state_.current_program->GetUniformInfo(sampler_indices[ii]);
5711 DCHECK(uniform_info); 5714 DCHECK(uniform_info);
5712 for (size_t jj = 0; jj < uniform_info->texture_units.size(); ++jj) { 5715 for (size_t jj = 0; jj < uniform_info->texture_units.size(); ++jj) {
5713 GLuint texture_unit_index = uniform_info->texture_units[jj]; 5716 GLuint texture_unit_index = uniform_info->texture_units[jj];
5714 if (texture_unit_index < state_.texture_units.size()) { 5717 if (texture_unit_index < state_.texture_units.size()) {
5715 TextureUnit& texture_unit = state_.texture_units[texture_unit_index]; 5718 TextureUnit& texture_unit = state_.texture_units[texture_unit_index];
5716 TextureManager::TextureInfo* texture_info = 5719 Texture* texture_info =
5717 texture_unit.GetInfoForSamplerType(uniform_info->type); 5720 texture_unit.GetInfoForSamplerType(uniform_info->type);
5718 if (texture_info && !texture_info->SafeToRenderFrom()) { 5721 if (texture_info && !texture_info->SafeToRenderFrom()) {
5719 if (!texture_manager()->ClearRenderableLevels(this, texture_info)) { 5722 if (!texture_manager()->ClearRenderableLevels(this, texture_info)) {
5720 return false; 5723 return false;
5721 } 5724 }
5722 } 5725 }
5723 } 5726 }
5724 } 5727 }
5725 } 5728 }
5726 } 5729 }
(...skipping 16 matching lines...) Expand all
5743 // true if any enabled, used divisor is zero 5746 // true if any enabled, used divisor is zero
5744 bool divisor0 = false; 5747 bool divisor0 = false;
5745 // Validate all attribs currently enabled. If they are used by the current 5748 // Validate all attribs currently enabled. If they are used by the current
5746 // program then check that they have enough elements to handle the draw call. 5749 // program then check that they have enough elements to handle the draw call.
5747 // If they are not used by the current program check that they have a buffer 5750 // If they are not used by the current program check that they have a buffer
5748 // assigned. 5751 // assigned.
5749 const VertexAttribManager::VertexAttribInfoList& infos = 5752 const VertexAttribManager::VertexAttribInfoList& infos =
5750 state_.vertex_attrib_manager->GetEnabledVertexAttribInfos(); 5753 state_.vertex_attrib_manager->GetEnabledVertexAttribInfos();
5751 for (VertexAttribManager::VertexAttribInfoList::const_iterator it = 5754 for (VertexAttribManager::VertexAttribInfoList::const_iterator it =
5752 infos.begin(); it != infos.end(); ++it) { 5755 infos.begin(); it != infos.end(); ++it) {
5753 const VertexAttribManager::VertexAttribInfo* info = *it; 5756 const VertexAttrib* info = *it;
5754 const ProgramManager::ProgramInfo::VertexAttribInfo* attrib_info = 5757 const Program::VertexAttrib* attrib_info =
5755 state_.current_program->GetAttribInfoByLocation(info->index()); 5758 state_.current_program->GetAttribInfoByLocation(info->index());
5756 if (attrib_info) { 5759 if (attrib_info) {
5757 divisor0 |= (info->divisor() == 0); 5760 divisor0 |= (info->divisor() == 0);
5758 GLuint count = info->MaxVertexAccessed(primcount, max_vertex_accessed); 5761 GLuint count = info->MaxVertexAccessed(primcount, max_vertex_accessed);
5759 // This attrib is used in the current program. 5762 // This attrib is used in the current program.
5760 if (!info->CanAccess(count)) { 5763 if (!info->CanAccess(count)) {
5761 SetGLError( 5764 SetGLError(
5762 GL_INVALID_OPERATION, function_name, 5765 GL_INVALID_OPERATION, function_name,
5763 (std::string( 5766 (std::string(
5764 "attempt to access out of range vertices in attribute ") + 5767 "attempt to access out of range vertices in attribute ") +
(...skipping 26 matching lines...) Expand all
5791 } 5794 }
5792 5795
5793 bool GLES2DecoderImpl::SimulateAttrib0( 5796 bool GLES2DecoderImpl::SimulateAttrib0(
5794 const char* function_name, GLuint max_vertex_accessed, bool* simulated) { 5797 const char* function_name, GLuint max_vertex_accessed, bool* simulated) {
5795 DCHECK(simulated); 5798 DCHECK(simulated);
5796 *simulated = false; 5799 *simulated = false;
5797 5800
5798 if (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2) 5801 if (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2)
5799 return true; 5802 return true;
5800 5803
5801 const VertexAttribManager::VertexAttribInfo* info = 5804 const VertexAttrib* info =
5802 state_.vertex_attrib_manager->GetVertexAttribInfo(0); 5805 state_.vertex_attrib_manager->GetVertexAttrib(0);
5803 // If it's enabled or it's not used then we don't need to do anything. 5806 // If it's enabled or it's not used then we don't need to do anything.
5804 bool attrib_0_used = 5807 bool attrib_0_used =
5805 state_.current_program->GetAttribInfoByLocation(0) != NULL; 5808 state_.current_program->GetAttribInfoByLocation(0) != NULL;
5806 if (info->enabled() && attrib_0_used) { 5809 if (info->enabled() && attrib_0_used) {
5807 return true; 5810 return true;
5808 } 5811 }
5809 5812
5810 // Make a buffer with a single repeated vec4 value enough to 5813 // Make a buffer with a single repeated vec4 value enough to
5811 // simulate the constant value that is supposed to be here. 5814 // simulate the constant value that is supposed to be here.
5812 // This is required to emulate GLES2 on GL. 5815 // This is required to emulate GLES2 on GL.
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
5854 glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, NULL); 5857 glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, NULL);
5855 5858
5856 if (info->divisor()) 5859 if (info->divisor())
5857 glVertexAttribDivisorANGLE(0, 0); 5860 glVertexAttribDivisorANGLE(0, 0);
5858 5861
5859 *simulated = true; 5862 *simulated = true;
5860 return true; 5863 return true;
5861 } 5864 }
5862 5865
5863 void GLES2DecoderImpl::RestoreStateForAttrib(GLuint attrib) { 5866 void GLES2DecoderImpl::RestoreStateForAttrib(GLuint attrib) {
5864 const VertexAttribManager::VertexAttribInfo* info = 5867 const VertexAttrib* info =
5865 state_.vertex_attrib_manager->GetVertexAttribInfo(attrib); 5868 state_.vertex_attrib_manager->GetVertexAttrib(attrib);
5866 const void* ptr = reinterpret_cast<const void*>(info->offset()); 5869 const void* ptr = reinterpret_cast<const void*>(info->offset());
5867 BufferManager::BufferInfo* buffer_info = info->buffer(); 5870 BufferManager::Buffer* buffer_info = info->buffer();
5868 glBindBuffer(GL_ARRAY_BUFFER, buffer_info ? buffer_info->service_id() : 0); 5871 glBindBuffer(GL_ARRAY_BUFFER, buffer_info ? buffer_info->service_id() : 0);
5869 glVertexAttribPointer( 5872 glVertexAttribPointer(
5870 attrib, info->size(), info->type(), info->normalized(), info->gl_stride(), 5873 attrib, info->size(), info->type(), info->normalized(), info->gl_stride(),
5871 ptr); 5874 ptr);
5872 if (info->divisor()) 5875 if (info->divisor())
5873 glVertexAttribDivisorANGLE(attrib, info->divisor()); 5876 glVertexAttribDivisorANGLE(attrib, info->divisor());
5874 glBindBuffer( 5877 glBindBuffer(
5875 GL_ARRAY_BUFFER, 5878 GL_ARRAY_BUFFER,
5876 state_.bound_array_buffer ? state_.bound_array_buffer->service_id() : 0); 5879 state_.bound_array_buffer ? state_.bound_array_buffer->service_id() : 0);
5877 5880
(...skipping 29 matching lines...) Expand all
5907 // twice in 2 different attribs, find the overlapping parts and therefore 5910 // twice in 2 different attribs, find the overlapping parts and therefore
5908 // duplicate the minimum amount of data but this whole code path is not meant 5911 // duplicate the minimum amount of data but this whole code path is not meant
5909 // to be used normally. It's just here to pass that OpenGL ES 2.0 conformance 5912 // to be used normally. It's just here to pass that OpenGL ES 2.0 conformance
5910 // tests so we just add to the buffer attrib used. 5913 // tests so we just add to the buffer attrib used.
5911 5914
5912 GLuint elements_needed = 0; 5915 GLuint elements_needed = 0;
5913 const VertexAttribManager::VertexAttribInfoList& infos = 5916 const VertexAttribManager::VertexAttribInfoList& infos =
5914 state_.vertex_attrib_manager->GetEnabledVertexAttribInfos(); 5917 state_.vertex_attrib_manager->GetEnabledVertexAttribInfos();
5915 for (VertexAttribManager::VertexAttribInfoList::const_iterator it = 5918 for (VertexAttribManager::VertexAttribInfoList::const_iterator it =
5916 infos.begin(); it != infos.end(); ++it) { 5919 infos.begin(); it != infos.end(); ++it) {
5917 const VertexAttribManager::VertexAttribInfo* info = *it; 5920 const VertexAttrib* info = *it;
5918 const ProgramManager::ProgramInfo::VertexAttribInfo* attrib_info = 5921 const Program::VertexAttrib* attrib_info =
5919 state_.current_program->GetAttribInfoByLocation(info->index()); 5922 state_.current_program->GetAttribInfoByLocation(info->index());
5920 GLuint max_accessed = info->MaxVertexAccessed(primcount, 5923 GLuint max_accessed = info->MaxVertexAccessed(primcount,
5921 max_vertex_accessed); 5924 max_vertex_accessed);
5922 GLuint num_vertices = max_accessed + 1; 5925 GLuint num_vertices = max_accessed + 1;
5923 if (num_vertices == 0) { 5926 if (num_vertices == 0) {
5924 SetGLError(GL_OUT_OF_MEMORY, function_name, "Simulating attrib 0"); 5927 SetGLError(GL_OUT_OF_MEMORY, function_name, "Simulating attrib 0");
5925 return false; 5928 return false;
5926 } 5929 }
5927 if (attrib_info && 5930 if (attrib_info &&
5928 info->CanAccess(max_accessed) && 5931 info->CanAccess(max_accessed) &&
(...skipping 26 matching lines...) Expand all
5955 SetGLError( 5958 SetGLError(
5956 GL_OUT_OF_MEMORY, function_name, "simulating GL_FIXED attribs"); 5959 GL_OUT_OF_MEMORY, function_name, "simulating GL_FIXED attribs");
5957 return false; 5960 return false;
5958 } 5961 }
5959 } 5962 }
5960 5963
5961 // Copy the elements and convert to float 5964 // Copy the elements and convert to float
5962 GLintptr offset = 0; 5965 GLintptr offset = 0;
5963 for (VertexAttribManager::VertexAttribInfoList::const_iterator it = 5966 for (VertexAttribManager::VertexAttribInfoList::const_iterator it =
5964 infos.begin(); it != infos.end(); ++it) { 5967 infos.begin(); it != infos.end(); ++it) {
5965 const VertexAttribManager::VertexAttribInfo* info = *it; 5968 const VertexAttrib* info = *it;
5966 const ProgramManager::ProgramInfo::VertexAttribInfo* attrib_info = 5969 const Program::VertexAttrib* attrib_info =
5967 state_.current_program->GetAttribInfoByLocation(info->index()); 5970 state_.current_program->GetAttribInfoByLocation(info->index());
5968 GLuint max_accessed = info->MaxVertexAccessed(primcount, 5971 GLuint max_accessed = info->MaxVertexAccessed(primcount,
5969 max_vertex_accessed); 5972 max_vertex_accessed);
5970 GLuint num_vertices = max_accessed + 1; 5973 GLuint num_vertices = max_accessed + 1;
5971 if (num_vertices == 0) { 5974 if (num_vertices == 0) {
5972 SetGLError(GL_OUT_OF_MEMORY, function_name, "Simulating attrib 0"); 5975 SetGLError(GL_OUT_OF_MEMORY, function_name, "Simulating attrib 0");
5973 return false; 5976 return false;
5974 } 5977 }
5975 if (attrib_info && 5978 if (attrib_info &&
5976 info->CanAccess(max_accessed) && 5979 info->CanAccess(max_accessed) &&
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
6071 } 6074 }
6072 } 6075 }
6073 if (simulated_attrib_0) { 6076 if (simulated_attrib_0) {
6074 RestoreStateForAttrib(0); 6077 RestoreStateForAttrib(0);
6075 } 6078 }
6076 } 6079 }
6077 return error::kNoError; 6080 return error::kNoError;
6078 } 6081 }
6079 6082
6080 error::Error GLES2DecoderImpl::HandleDrawArrays( 6083 error::Error GLES2DecoderImpl::HandleDrawArrays(
6081 uint32 immediate_data_size, const gles2::DrawArrays& c) { 6084 uint32 immediate_data_size, const cmds::DrawArrays& c) {
6082 return DoDrawArrays("glDrawArrays", 6085 return DoDrawArrays("glDrawArrays",
6083 false, 6086 false,
6084 static_cast<GLenum>(c.mode), 6087 static_cast<GLenum>(c.mode),
6085 static_cast<GLint>(c.first), 6088 static_cast<GLint>(c.first),
6086 static_cast<GLsizei>(c.count), 6089 static_cast<GLsizei>(c.count),
6087 0); 6090 0);
6088 } 6091 }
6089 6092
6090 error::Error GLES2DecoderImpl::HandleDrawArraysInstancedANGLE( 6093 error::Error GLES2DecoderImpl::HandleDrawArraysInstancedANGLE(
6091 uint32 immediate_data_size, const gles2::DrawArraysInstancedANGLE& c) { 6094 uint32 immediate_data_size, const cmds::DrawArraysInstancedANGLE& c) {
6092 if (!features().angle_instanced_arrays) { 6095 if (!features().angle_instanced_arrays) {
6093 SetGLError(GL_INVALID_OPERATION, 6096 SetGLError(GL_INVALID_OPERATION,
6094 "glDrawArraysInstancedANGLE", "function not available"); 6097 "glDrawArraysInstancedANGLE", "function not available");
6095 return error::kNoError; 6098 return error::kNoError;
6096 } 6099 }
6097 return DoDrawArrays("glDrawArraysIntancedANGLE", 6100 return DoDrawArrays("glDrawArraysIntancedANGLE",
6098 true, 6101 true,
6099 static_cast<GLenum>(c.mode), 6102 static_cast<GLenum>(c.mode),
6100 static_cast<GLint>(c.first), 6103 static_cast<GLint>(c.first),
6101 static_cast<GLsizei>(c.count), 6104 static_cast<GLsizei>(c.count),
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
6186 } 6189 }
6187 } 6190 }
6188 if (simulated_attrib_0) { 6191 if (simulated_attrib_0) {
6189 RestoreStateForAttrib(0); 6192 RestoreStateForAttrib(0);
6190 } 6193 }
6191 } 6194 }
6192 return error::kNoError; 6195 return error::kNoError;
6193 } 6196 }
6194 6197
6195 error::Error GLES2DecoderImpl::HandleDrawElements( 6198 error::Error GLES2DecoderImpl::HandleDrawElements(
6196 uint32 immediate_data_size, const gles2::DrawElements& c) { 6199 uint32 immediate_data_size, const cmds::DrawElements& c) {
6197 return DoDrawElements("glDrawElements", 6200 return DoDrawElements("glDrawElements",
6198 false, 6201 false,
6199 static_cast<GLenum>(c.mode), 6202 static_cast<GLenum>(c.mode),
6200 static_cast<GLsizei>(c.count), 6203 static_cast<GLsizei>(c.count),
6201 static_cast<GLenum>(c.type), 6204 static_cast<GLenum>(c.type),
6202 static_cast<int32>(c.index_offset), 6205 static_cast<int32>(c.index_offset),
6203 0); 6206 0);
6204 } 6207 }
6205 6208
6206 error::Error GLES2DecoderImpl::HandleDrawElementsInstancedANGLE( 6209 error::Error GLES2DecoderImpl::HandleDrawElementsInstancedANGLE(
6207 uint32 immediate_data_size, const gles2::DrawElementsInstancedANGLE& c) { 6210 uint32 immediate_data_size, const cmds::DrawElementsInstancedANGLE& c) {
6208 if (!features().angle_instanced_arrays) { 6211 if (!features().angle_instanced_arrays) {
6209 SetGLError(GL_INVALID_OPERATION, 6212 SetGLError(GL_INVALID_OPERATION,
6210 "glDrawElementsInstancedANGLE", "function not available"); 6213 "glDrawElementsInstancedANGLE", "function not available");
6211 return error::kNoError; 6214 return error::kNoError;
6212 } 6215 }
6213 return DoDrawElements("glDrawElementsInstancedANGLE", 6216 return DoDrawElements("glDrawElementsInstancedANGLE",
6214 true, 6217 true,
6215 static_cast<GLenum>(c.mode), 6218 static_cast<GLenum>(c.mode),
6216 static_cast<GLsizei>(c.count), 6219 static_cast<GLsizei>(c.count),
6217 static_cast<GLenum>(c.type), 6220 static_cast<GLenum>(c.type),
6218 static_cast<int32>(c.index_offset), 6221 static_cast<int32>(c.index_offset),
6219 static_cast<GLsizei>(c.primcount)); 6222 static_cast<GLsizei>(c.primcount));
6220 } 6223 }
6221 6224
6222 GLuint GLES2DecoderImpl::DoGetMaxValueInBufferCHROMIUM( 6225 GLuint GLES2DecoderImpl::DoGetMaxValueInBufferCHROMIUM(
6223 GLuint buffer_id, GLsizei count, GLenum type, GLuint offset) { 6226 GLuint buffer_id, GLsizei count, GLenum type, GLuint offset) {
6224 GLuint max_vertex_accessed = 0; 6227 GLuint max_vertex_accessed = 0;
6225 BufferManager::BufferInfo* info = GetBufferInfo(buffer_id); 6228 BufferManager::Buffer* info = GetBuffer(buffer_id);
6226 if (!info) { 6229 if (!info) {
6227 // TODO(gman): Should this be a GL error or a command buffer error? 6230 // TODO(gman): Should this be a GL error or a command buffer error?
6228 SetGLError(GL_INVALID_VALUE, 6231 SetGLError(GL_INVALID_VALUE,
6229 "GetMaxValueInBufferCHROMIUM", "unknown buffer"); 6232 "GetMaxValueInBufferCHROMIUM", "unknown buffer");
6230 } else { 6233 } else {
6231 if (!info->GetMaxValueForRange(offset, count, type, &max_vertex_accessed)) { 6234 if (!info->GetMaxValueForRange(offset, count, type, &max_vertex_accessed)) {
6232 // TODO(gman): Should this be a GL error or a command buffer error? 6235 // TODO(gman): Should this be a GL error or a command buffer error?
6233 SetGLError( 6236 SetGLError(
6234 GL_INVALID_OPERATION, 6237 GL_INVALID_OPERATION,
6235 "GetMaxValueInBufferCHROMIUM", "range out of bounds for buffer"); 6238 "GetMaxValueInBufferCHROMIUM", "range out of bounds for buffer");
6236 } 6239 }
6237 } 6240 }
6238 return max_vertex_accessed; 6241 return max_vertex_accessed;
6239 } 6242 }
6240 6243
6241 // Calls glShaderSource for the various versions of the ShaderSource command. 6244 // Calls glShaderSource for the various versions of the ShaderSource command.
6242 // Assumes that data / data_size points to a piece of memory that is in range 6245 // Assumes that data / data_size points to a piece of memory that is in range
6243 // of whatever context it came from (shared memory, immediate memory, bucket 6246 // of whatever context it came from (shared memory, immediate memory, bucket
6244 // memory.) 6247 // memory.)
6245 error::Error GLES2DecoderImpl::ShaderSourceHelper( 6248 error::Error GLES2DecoderImpl::ShaderSourceHelper(
6246 GLuint client_id, const char* data, uint32 data_size) { 6249 GLuint client_id, const char* data, uint32 data_size) {
6247 std::string str(data, data + data_size); 6250 std::string str(data, data + data_size);
6248 ShaderManager::ShaderInfo* info = GetShaderInfoNotProgram( 6251 Shader* info = GetShaderInfoNotProgram(
6249 client_id, "glShaderSource"); 6252 client_id, "glShaderSource");
6250 if (!info) { 6253 if (!info) {
6251 return error::kNoError; 6254 return error::kNoError;
6252 } 6255 }
6253 // Note: We don't actually call glShaderSource here. We wait until 6256 // Note: We don't actually call glShaderSource here. We wait until
6254 // the call to glCompileShader. 6257 // the call to glCompileShader.
6255 info->UpdateSource(str.c_str()); 6258 info->UpdateSource(str.c_str());
6256 return error::kNoError; 6259 return error::kNoError;
6257 } 6260 }
6258 6261
6259 error::Error GLES2DecoderImpl::HandleShaderSource( 6262 error::Error GLES2DecoderImpl::HandleShaderSource(
6260 uint32 immediate_data_size, const gles2::ShaderSource& c) { 6263 uint32 immediate_data_size, const cmds::ShaderSource& c) {
6261 uint32 data_size = c.data_size; 6264 uint32 data_size = c.data_size;
6262 const char* data = GetSharedMemoryAs<const char*>( 6265 const char* data = GetSharedMemoryAs<const char*>(
6263 c.data_shm_id, c.data_shm_offset, data_size); 6266 c.data_shm_id, c.data_shm_offset, data_size);
6264 if (!data) { 6267 if (!data) {
6265 return error::kOutOfBounds; 6268 return error::kOutOfBounds;
6266 } 6269 }
6267 return ShaderSourceHelper(c.shader, data, data_size); 6270 return ShaderSourceHelper(c.shader, data, data_size);
6268 } 6271 }
6269 6272
6270 error::Error GLES2DecoderImpl::HandleShaderSourceImmediate( 6273 error::Error GLES2DecoderImpl::HandleShaderSourceImmediate(
6271 uint32 immediate_data_size, const gles2::ShaderSourceImmediate& c) { 6274 uint32 immediate_data_size, const cmds::ShaderSourceImmediate& c) {
6272 uint32 data_size = c.data_size; 6275 uint32 data_size = c.data_size;
6273 const char* data = GetImmediateDataAs<const char*>( 6276 const char* data = GetImmediateDataAs<const char*>(
6274 c, data_size, immediate_data_size); 6277 c, data_size, immediate_data_size);
6275 if (!data) { 6278 if (!data) {
6276 return error::kOutOfBounds; 6279 return error::kOutOfBounds;
6277 } 6280 }
6278 return ShaderSourceHelper(c.shader, data, data_size); 6281 return ShaderSourceHelper(c.shader, data, data_size);
6279 } 6282 }
6280 6283
6281 error::Error GLES2DecoderImpl::HandleShaderSourceBucket( 6284 error::Error GLES2DecoderImpl::HandleShaderSourceBucket(
6282 uint32 immediate_data_size, const gles2::ShaderSourceBucket& c) { 6285 uint32 immediate_data_size, const cmds::ShaderSourceBucket& c) {
6283 Bucket* bucket = GetBucket(c.data_bucket_id); 6286 Bucket* bucket = GetBucket(c.data_bucket_id);
6284 if (!bucket || bucket->size() == 0) { 6287 if (!bucket || bucket->size() == 0) {
6285 return error::kInvalidArguments; 6288 return error::kInvalidArguments;
6286 } 6289 }
6287 return ShaderSourceHelper( 6290 return ShaderSourceHelper(
6288 c.shader, bucket->GetDataAs<const char*>(0, bucket->size() - 1), 6291 c.shader, bucket->GetDataAs<const char*>(0, bucket->size() - 1),
6289 bucket->size() - 1); 6292 bucket->size() - 1);
6290 } 6293 }
6291 6294
6292 void GLES2DecoderImpl::DoCompileShader(GLuint client_id) { 6295 void GLES2DecoderImpl::DoCompileShader(GLuint client_id) {
6293 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCompileShader"); 6296 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCompileShader");
6294 ShaderManager::ShaderInfo* info = GetShaderInfoNotProgram( 6297 Shader* info = GetShaderInfoNotProgram(
6295 client_id, "glCompileShader"); 6298 client_id, "glCompileShader");
6296 if (!info) { 6299 if (!info) {
6297 return; 6300 return;
6298 } 6301 }
6299 ShaderTranslator* translator = NULL; 6302 ShaderTranslator* translator = NULL;
6300 if (use_shader_translator_) { 6303 if (use_shader_translator_) {
6301 translator = info->shader_type() == GL_VERTEX_SHADER ? 6304 translator = info->shader_type() == GL_VERTEX_SHADER ?
6302 vertex_translator_.get() : fragment_translator_.get(); 6305 vertex_translator_.get() : fragment_translator_.get();
6303 } 6306 }
6304 6307
6305 program_manager()->DoCompileShader(info, translator, feature_info_); 6308 program_manager()->DoCompileShader(info, translator, feature_info_);
6306 }; 6309 };
6307 6310
6308 void GLES2DecoderImpl::DoGetShaderiv( 6311 void GLES2DecoderImpl::DoGetShaderiv(
6309 GLuint shader, GLenum pname, GLint* params) { 6312 GLuint shader, GLenum pname, GLint* params) {
6310 ShaderManager::ShaderInfo* info = GetShaderInfoNotProgram( 6313 Shader* info = GetShaderInfoNotProgram(
6311 shader, "glGetShaderiv"); 6314 shader, "glGetShaderiv");
6312 if (!info) { 6315 if (!info) {
6313 return; 6316 return;
6314 } 6317 }
6315 switch (pname) { 6318 switch (pname) {
6316 case GL_SHADER_SOURCE_LENGTH: 6319 case GL_SHADER_SOURCE_LENGTH:
6317 *params = info->source() ? info->source()->size() + 1 : 0; 6320 *params = info->source() ? info->source()->size() + 1 : 0;
6318 return; 6321 return;
6319 case GL_COMPILE_STATUS: 6322 case GL_COMPILE_STATUS:
6320 *params = compile_shader_always_succeeds_ ? true : info->IsValid(); 6323 *params = compile_shader_always_succeeds_ ? true : info->IsValid();
6321 return; 6324 return;
6322 case GL_INFO_LOG_LENGTH: 6325 case GL_INFO_LOG_LENGTH:
6323 *params = info->log_info() ? info->log_info()->size() + 1 : 0; 6326 *params = info->log_info() ? info->log_info()->size() + 1 : 0;
6324 return; 6327 return;
6325 case GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE: 6328 case GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE:
6326 ForceCompileShaderIfPending(info); 6329 ForceCompileShaderIfPending(info);
6327 *params = info->translated_source() ? 6330 *params = info->translated_source() ?
6328 info->translated_source()->size() + 1 : 0; 6331 info->translated_source()->size() + 1 : 0;
6329 return; 6332 return;
6330 default: 6333 default:
6331 break; 6334 break;
6332 } 6335 }
6333 glGetShaderiv(info->service_id(), pname, params); 6336 glGetShaderiv(info->service_id(), pname, params);
6334 } 6337 }
6335 6338
6336 error::Error GLES2DecoderImpl::HandleGetShaderSource( 6339 error::Error GLES2DecoderImpl::HandleGetShaderSource(
6337 uint32 immediate_data_size, const gles2::GetShaderSource& c) { 6340 uint32 immediate_data_size, const cmds::GetShaderSource& c) {
6338 GLuint shader = c.shader; 6341 GLuint shader = c.shader;
6339 uint32 bucket_id = static_cast<uint32>(c.bucket_id); 6342 uint32 bucket_id = static_cast<uint32>(c.bucket_id);
6340 Bucket* bucket = CreateBucket(bucket_id); 6343 Bucket* bucket = CreateBucket(bucket_id);
6341 ShaderManager::ShaderInfo* info = GetShaderInfoNotProgram( 6344 Shader* info = GetShaderInfoNotProgram(
6342 shader, "glGetShaderSource"); 6345 shader, "glGetShaderSource");
6343 if (!info || !info->source()) { 6346 if (!info || !info->source()) {
6344 bucket->SetSize(0); 6347 bucket->SetSize(0);
6345 return error::kNoError; 6348 return error::kNoError;
6346 } 6349 }
6347 bucket->SetFromString(info->source()->c_str()); 6350 bucket->SetFromString(info->source()->c_str());
6348 return error::kNoError; 6351 return error::kNoError;
6349 } 6352 }
6350 6353
6351 error::Error GLES2DecoderImpl::HandleGetTranslatedShaderSourceANGLE( 6354 error::Error GLES2DecoderImpl::HandleGetTranslatedShaderSourceANGLE(
6352 uint32 immediate_data_size, 6355 uint32 immediate_data_size,
6353 const gles2::GetTranslatedShaderSourceANGLE& c) { 6356 const cmds::GetTranslatedShaderSourceANGLE& c) {
6354 GLuint shader = c.shader; 6357 GLuint shader = c.shader;
6355 6358
6356 uint32 bucket_id = static_cast<uint32>(c.bucket_id); 6359 uint32 bucket_id = static_cast<uint32>(c.bucket_id);
6357 Bucket* bucket = CreateBucket(bucket_id); 6360 Bucket* bucket = CreateBucket(bucket_id);
6358 ShaderManager::ShaderInfo* info = GetShaderInfoNotProgram( 6361 Shader* info = GetShaderInfoNotProgram(
6359 shader, "glTranslatedGetShaderSourceANGLE"); 6362 shader, "glTranslatedGetShaderSourceANGLE");
6360 if (!info) { 6363 if (!info) {
6361 bucket->SetSize(0); 6364 bucket->SetSize(0);
6362 return error::kNoError; 6365 return error::kNoError;
6363 } 6366 }
6364 ForceCompileShaderIfPending(info); 6367 ForceCompileShaderIfPending(info);
6365 6368
6366 bucket->SetFromString(info->translated_source() ? 6369 bucket->SetFromString(info->translated_source() ?
6367 info->translated_source()->c_str() : NULL); 6370 info->translated_source()->c_str() : NULL);
6368 return error::kNoError; 6371 return error::kNoError;
6369 } 6372 }
6370 6373
6371 error::Error GLES2DecoderImpl::HandleGetProgramInfoLog( 6374 error::Error GLES2DecoderImpl::HandleGetProgramInfoLog(
6372 uint32 immediate_data_size, const gles2::GetProgramInfoLog& c) { 6375 uint32 immediate_data_size, const cmds::GetProgramInfoLog& c) {
6373 GLuint program = c.program; 6376 GLuint program = c.program;
6374 uint32 bucket_id = static_cast<uint32>(c.bucket_id); 6377 uint32 bucket_id = static_cast<uint32>(c.bucket_id);
6375 Bucket* bucket = CreateBucket(bucket_id); 6378 Bucket* bucket = CreateBucket(bucket_id);
6376 ProgramManager::ProgramInfo* info = GetProgramInfoNotShader( 6379 Program* info = GetProgramInfoNotShader(
6377 program, "glGetProgramInfoLog"); 6380 program, "glGetProgramInfoLog");
6378 if (!info || !info->log_info()) { 6381 if (!info || !info->log_info()) {
6379 bucket->SetFromString(""); 6382 bucket->SetFromString("");
6380 return error::kNoError; 6383 return error::kNoError;
6381 } 6384 }
6382 bucket->SetFromString(info->log_info()->c_str()); 6385 bucket->SetFromString(info->log_info()->c_str());
6383 return error::kNoError; 6386 return error::kNoError;
6384 } 6387 }
6385 6388
6386 error::Error GLES2DecoderImpl::HandleGetShaderInfoLog( 6389 error::Error GLES2DecoderImpl::HandleGetShaderInfoLog(
6387 uint32 immediate_data_size, const gles2::GetShaderInfoLog& c) { 6390 uint32 immediate_data_size, const cmds::GetShaderInfoLog& c) {
6388 GLuint shader = c.shader; 6391 GLuint shader = c.shader;
6389 uint32 bucket_id = static_cast<uint32>(c.bucket_id); 6392 uint32 bucket_id = static_cast<uint32>(c.bucket_id);
6390 Bucket* bucket = CreateBucket(bucket_id); 6393 Bucket* bucket = CreateBucket(bucket_id);
6391 ShaderManager::ShaderInfo* info = GetShaderInfoNotProgram( 6394 Shader* info = GetShaderInfoNotProgram(
6392 shader, "glGetShaderInfoLog"); 6395 shader, "glGetShaderInfoLog");
6393 if (!info || !info->log_info()) { 6396 if (!info || !info->log_info()) {
6394 bucket->SetFromString(""); 6397 bucket->SetFromString("");
6395 return error::kNoError; 6398 return error::kNoError;
6396 } 6399 }
6397 bucket->SetFromString(info->log_info()->c_str()); 6400 bucket->SetFromString(info->log_info()->c_str());
6398 return error::kNoError; 6401 return error::kNoError;
6399 } 6402 }
6400 6403
6401 bool GLES2DecoderImpl::DoIsEnabled(GLenum cap) { 6404 bool GLES2DecoderImpl::DoIsEnabled(GLenum cap) {
6402 return state_.GetEnabled(cap); 6405 return state_.GetEnabled(cap);
6403 } 6406 }
6404 6407
6405 bool GLES2DecoderImpl::DoIsBuffer(GLuint client_id) { 6408 bool GLES2DecoderImpl::DoIsBuffer(GLuint client_id) {
6406 const BufferManager::BufferInfo* buffer = GetBufferInfo(client_id); 6409 const BufferManager::Buffer* buffer = GetBuffer(client_id);
6407 return buffer && buffer->IsValid() && !buffer->IsDeleted(); 6410 return buffer && buffer->IsValid() && !buffer->IsDeleted();
6408 } 6411 }
6409 6412
6410 bool GLES2DecoderImpl::DoIsFramebuffer(GLuint client_id) { 6413 bool GLES2DecoderImpl::DoIsFramebuffer(GLuint client_id) {
6411 const FramebufferManager::FramebufferInfo* framebuffer = 6414 const Framebuffer* framebuffer =
6412 GetFramebufferInfo(client_id); 6415 GetFramebuffer(client_id);
6413 return framebuffer && framebuffer->IsValid() && !framebuffer->IsDeleted(); 6416 return framebuffer && framebuffer->IsValid() && !framebuffer->IsDeleted();
6414 } 6417 }
6415 6418
6416 bool GLES2DecoderImpl::DoIsProgram(GLuint client_id) { 6419 bool GLES2DecoderImpl::DoIsProgram(GLuint client_id) {
6417 // IsProgram is true for programs as soon as they are created, until they are 6420 // IsProgram is true for programs as soon as they are created, until they are
6418 // deleted and no longer in use. 6421 // deleted and no longer in use.
6419 const ProgramManager::ProgramInfo* program = GetProgramInfo(client_id); 6422 const Program* program = GetProgram(client_id);
6420 return program != NULL && !program->IsDeleted(); 6423 return program != NULL && !program->IsDeleted();
6421 } 6424 }
6422 6425
6423 bool GLES2DecoderImpl::DoIsRenderbuffer(GLuint client_id) { 6426 bool GLES2DecoderImpl::DoIsRenderbuffer(GLuint client_id) {
6424 const RenderbufferManager::RenderbufferInfo* renderbuffer = 6427 const Renderbuffer* renderbuffer =
6425 GetRenderbufferInfo(client_id); 6428 GetRenderbuffer(client_id);
6426 return renderbuffer && renderbuffer->IsValid() && !renderbuffer->IsDeleted(); 6429 return renderbuffer && renderbuffer->IsValid() && !renderbuffer->IsDeleted();
6427 } 6430 }
6428 6431
6429 bool GLES2DecoderImpl::DoIsShader(GLuint client_id) { 6432 bool GLES2DecoderImpl::DoIsShader(GLuint client_id) {
6430 // IsShader is true for shaders as soon as they are created, until they 6433 // IsShader is true for shaders as soon as they are created, until they
6431 // are deleted and not attached to any programs. 6434 // are deleted and not attached to any programs.
6432 const ShaderManager::ShaderInfo* shader = GetShaderInfo(client_id); 6435 const Shader* shader = GetShader(client_id);
6433 return shader != NULL && !shader->IsDeleted(); 6436 return shader != NULL && !shader->IsDeleted();
6434 } 6437 }
6435 6438
6436 bool GLES2DecoderImpl::DoIsTexture(GLuint client_id) { 6439 bool GLES2DecoderImpl::DoIsTexture(GLuint client_id) {
6437 const TextureManager::TextureInfo* texture = GetTextureInfo(client_id); 6440 const Texture* texture = GetTexture(client_id);
6438 return texture && texture->IsValid() && !texture->IsDeleted(); 6441 return texture && texture->IsValid() && !texture->IsDeleted();
6439 } 6442 }
6440 6443
6441 void GLES2DecoderImpl::DoAttachShader( 6444 void GLES2DecoderImpl::DoAttachShader(
6442 GLuint program_client_id, GLint shader_client_id) { 6445 GLuint program_client_id, GLint shader_client_id) {
6443 ProgramManager::ProgramInfo* program_info = GetProgramInfoNotShader( 6446 Program* program_info = GetProgramInfoNotShader(
6444 program_client_id, "glAttachShader"); 6447 program_client_id, "glAttachShader");
6445 if (!program_info) { 6448 if (!program_info) {
6446 return; 6449 return;
6447 } 6450 }
6448 ShaderManager::ShaderInfo* shader_info = GetShaderInfoNotProgram( 6451 Shader* shader_info = GetShaderInfoNotProgram(
6449 shader_client_id, "glAttachShader"); 6452 shader_client_id, "glAttachShader");
6450 if (!shader_info) { 6453 if (!shader_info) {
6451 return; 6454 return;
6452 } 6455 }
6453 if (!program_info->AttachShader(shader_manager(), shader_info)) { 6456 if (!program_info->AttachShader(shader_manager(), shader_info)) {
6454 SetGLError(GL_INVALID_OPERATION, 6457 SetGLError(GL_INVALID_OPERATION,
6455 "glAttachShader", "can not attach more than" 6458 "glAttachShader", "can not attach more than"
6456 " one shader of the same type."); 6459 " one shader of the same type.");
6457 return; 6460 return;
6458 } 6461 }
6459 glAttachShader(program_info->service_id(), shader_info->service_id()); 6462 glAttachShader(program_info->service_id(), shader_info->service_id());
6460 } 6463 }
6461 6464
6462 void GLES2DecoderImpl::DoDetachShader( 6465 void GLES2DecoderImpl::DoDetachShader(
6463 GLuint program_client_id, GLint shader_client_id) { 6466 GLuint program_client_id, GLint shader_client_id) {
6464 ProgramManager::ProgramInfo* program_info = GetProgramInfoNotShader( 6467 Program* program_info = GetProgramInfoNotShader(
6465 program_client_id, "glDetachShader"); 6468 program_client_id, "glDetachShader");
6466 if (!program_info) { 6469 if (!program_info) {
6467 return; 6470 return;
6468 } 6471 }
6469 ShaderManager::ShaderInfo* shader_info = GetShaderInfoNotProgram( 6472 Shader* shader_info = GetShaderInfoNotProgram(
6470 shader_client_id, "glDetachShader"); 6473 shader_client_id, "glDetachShader");
6471 if (!shader_info) { 6474 if (!shader_info) {
6472 return; 6475 return;
6473 } 6476 }
6474 if (!program_info->DetachShader(shader_manager(), shader_info)) { 6477 if (!program_info->DetachShader(shader_manager(), shader_info)) {
6475 SetGLError(GL_INVALID_OPERATION, 6478 SetGLError(GL_INVALID_OPERATION,
6476 "glDetachShader", "shader not attached to program"); 6479 "glDetachShader", "shader not attached to program");
6477 return; 6480 return;
6478 } 6481 }
6479 glDetachShader(program_info->service_id(), shader_info->service_id()); 6482 glDetachShader(program_info->service_id(), shader_info->service_id());
6480 } 6483 }
6481 6484
6482 void GLES2DecoderImpl::DoValidateProgram(GLuint program_client_id) { 6485 void GLES2DecoderImpl::DoValidateProgram(GLuint program_client_id) {
6483 ProgramManager::ProgramInfo* info = GetProgramInfoNotShader( 6486 Program* info = GetProgramInfoNotShader(
6484 program_client_id, "glValidateProgram"); 6487 program_client_id, "glValidateProgram");
6485 if (!info) { 6488 if (!info) {
6486 return; 6489 return;
6487 } 6490 }
6488 info->Validate(); 6491 info->Validate();
6489 } 6492 }
6490 6493
6491 void GLES2DecoderImpl::DoGetVertexAttribfv( 6494 void GLES2DecoderImpl::DoGetVertexAttribfv(
6492 GLuint index, GLenum pname, GLfloat* params) { 6495 GLuint index, GLenum pname, GLfloat* params) {
6493 VertexAttribManager::VertexAttribInfo* info = 6496 VertexAttrib* info =
6494 state_.vertex_attrib_manager->GetVertexAttribInfo(index); 6497 state_.vertex_attrib_manager->GetVertexAttrib(index);
6495 if (!info) { 6498 if (!info) {
6496 SetGLError(GL_INVALID_VALUE, "glGetVertexAttribfv", "index out of range"); 6499 SetGLError(GL_INVALID_VALUE, "glGetVertexAttribfv", "index out of range");
6497 return; 6500 return;
6498 } 6501 }
6499 switch (pname) { 6502 switch (pname) {
6500 case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: { 6503 case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: {
6501 BufferManager::BufferInfo* buffer = info->buffer(); 6504 BufferManager::Buffer* buffer = info->buffer();
6502 if (buffer && !buffer->IsDeleted()) { 6505 if (buffer && !buffer->IsDeleted()) {
6503 GLuint client_id; 6506 GLuint client_id;
6504 buffer_manager()->GetClientId(buffer->service_id(), &client_id); 6507 buffer_manager()->GetClientId(buffer->service_id(), &client_id);
6505 *params = static_cast<GLfloat>(client_id); 6508 *params = static_cast<GLfloat>(client_id);
6506 } 6509 }
6507 break; 6510 break;
6508 } 6511 }
6509 case GL_VERTEX_ATTRIB_ARRAY_ENABLED: 6512 case GL_VERTEX_ATTRIB_ARRAY_ENABLED:
6510 *params = static_cast<GLfloat>(info->enabled()); 6513 *params = static_cast<GLfloat>(info->enabled());
6511 break; 6514 break;
(...skipping 21 matching lines...) Expand all
6533 *params = static_cast<GLfloat>(info->divisor()); 6536 *params = static_cast<GLfloat>(info->divisor());
6534 break; 6537 break;
6535 default: 6538 default:
6536 NOTREACHED(); 6539 NOTREACHED();
6537 break; 6540 break;
6538 } 6541 }
6539 } 6542 }
6540 6543
6541 void GLES2DecoderImpl::DoGetVertexAttribiv( 6544 void GLES2DecoderImpl::DoGetVertexAttribiv(
6542 GLuint index, GLenum pname, GLint* params) { 6545 GLuint index, GLenum pname, GLint* params) {
6543 VertexAttribManager::VertexAttribInfo* info = 6546 VertexAttrib* info =
6544 state_.vertex_attrib_manager->GetVertexAttribInfo(index); 6547 state_.vertex_attrib_manager->GetVertexAttrib(index);
6545 if (!info) { 6548 if (!info) {
6546 SetGLError(GL_INVALID_VALUE, "glGetVertexAttribiv", "index out of range"); 6549 SetGLError(GL_INVALID_VALUE, "glGetVertexAttribiv", "index out of range");
6547 return; 6550 return;
6548 } 6551 }
6549 switch (pname) { 6552 switch (pname) {
6550 case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: { 6553 case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: {
6551 BufferManager::BufferInfo* buffer = info->buffer(); 6554 BufferManager::Buffer* buffer = info->buffer();
6552 if (buffer && !buffer->IsDeleted()) { 6555 if (buffer && !buffer->IsDeleted()) {
6553 GLuint client_id; 6556 GLuint client_id;
6554 buffer_manager()->GetClientId(buffer->service_id(), &client_id); 6557 buffer_manager()->GetClientId(buffer->service_id(), &client_id);
6555 *params = client_id; 6558 *params = client_id;
6556 } 6559 }
6557 break; 6560 break;
6558 } 6561 }
6559 case GL_VERTEX_ATTRIB_ARRAY_ENABLED: 6562 case GL_VERTEX_ATTRIB_ARRAY_ENABLED:
6560 *params = info->enabled(); 6563 *params = info->enabled();
6561 break; 6564 break;
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
6653 } 6656 }
6654 } 6657 }
6655 6658
6656 void GLES2DecoderImpl::DoVertexAttrib4fv(GLuint index, const GLfloat* v) { 6659 void GLES2DecoderImpl::DoVertexAttrib4fv(GLuint index, const GLfloat* v) {
6657 if (SetVertexAttribValue("glVertexAttrib4fv", index, v)) { 6660 if (SetVertexAttribValue("glVertexAttrib4fv", index, v)) {
6658 glVertexAttrib4fv(index, v); 6661 glVertexAttrib4fv(index, v);
6659 } 6662 }
6660 } 6663 }
6661 6664
6662 error::Error GLES2DecoderImpl::HandleVertexAttribPointer( 6665 error::Error GLES2DecoderImpl::HandleVertexAttribPointer(
6663 uint32 immediate_data_size, const gles2::VertexAttribPointer& c) { 6666 uint32 immediate_data_size, const cmds::VertexAttribPointer& c) {
6664 6667
6665 if (!state_.bound_array_buffer || state_.bound_array_buffer->IsDeleted()) { 6668 if (!state_.bound_array_buffer || state_.bound_array_buffer->IsDeleted()) {
6666 if (state_.vertex_attrib_manager == default_vertex_attrib_manager_) { 6669 if (state_.vertex_attrib_manager == default_vertex_attrib_manager_) {
6667 SetGLError(GL_INVALID_VALUE, 6670 SetGLError(GL_INVALID_VALUE,
6668 "glVertexAttribPointer", "no array buffer bound"); 6671 "glVertexAttribPointer", "no array buffer bound");
6669 return error::kNoError; 6672 return error::kNoError;
6670 } else if (c.offset != 0) { 6673 } else if (c.offset != 0) {
6671 SetGLError(GL_INVALID_VALUE, 6674 SetGLError(GL_INVALID_VALUE,
6672 "glVertexAttribPointer", "client side arrays are not allowed"); 6675 "glVertexAttribPointer", "client side arrays are not allowed");
6673 return error::kNoError; 6676 return error::kNoError;
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
6739 void GLES2DecoderImpl::DoViewport(GLint x, GLint y, GLsizei width, 6742 void GLES2DecoderImpl::DoViewport(GLint x, GLint y, GLsizei width,
6740 GLsizei height) { 6743 GLsizei height) {
6741 state_.viewport_x = x; 6744 state_.viewport_x = x;
6742 state_.viewport_y = y; 6745 state_.viewport_y = y;
6743 state_.viewport_width = std::min(width, viewport_max_width_); 6746 state_.viewport_width = std::min(width, viewport_max_width_);
6744 state_.viewport_height = std::min(height, viewport_max_height_); 6747 state_.viewport_height = std::min(height, viewport_max_height_);
6745 glViewport(x, y, width, height); 6748 glViewport(x, y, width, height);
6746 } 6749 }
6747 6750
6748 error::Error GLES2DecoderImpl::HandleVertexAttribDivisorANGLE( 6751 error::Error GLES2DecoderImpl::HandleVertexAttribDivisorANGLE(
6749 uint32 immediate_data_size, const gles2::VertexAttribDivisorANGLE& c) { 6752 uint32 immediate_data_size, const cmds::VertexAttribDivisorANGLE& c) {
6750 if (!features().angle_instanced_arrays) { 6753 if (!features().angle_instanced_arrays) {
6751 SetGLError(GL_INVALID_OPERATION, 6754 SetGLError(GL_INVALID_OPERATION,
6752 "glVertexAttribDivisorANGLE", "function not available"); 6755 "glVertexAttribDivisorANGLE", "function not available");
6753 } 6756 }
6754 GLuint index = c.index; 6757 GLuint index = c.index;
6755 GLuint divisor = c.divisor; 6758 GLuint divisor = c.divisor;
6756 if (index >= group_->max_vertex_attribs()) { 6759 if (index >= group_->max_vertex_attribs()) {
6757 SetGLError(GL_INVALID_VALUE, 6760 SetGLError(GL_INVALID_VALUE,
6758 "glVertexAttribDivisorANGLE", "index out of range"); 6761 "glVertexAttribDivisorANGLE", "index out of range");
6759 return error::kNoError; 6762 return error::kNoError;
6760 } 6763 }
6761 6764
6762 state_.vertex_attrib_manager->SetDivisor( 6765 state_.vertex_attrib_manager->SetDivisor(
6763 index, 6766 index,
6764 divisor); 6767 divisor);
6765 glVertexAttribDivisorANGLE(index, divisor); 6768 glVertexAttribDivisorANGLE(index, divisor);
6766 return error::kNoError; 6769 return error::kNoError;
6767 } 6770 }
6768 6771
6769 error::Error GLES2DecoderImpl::HandleReadPixels( 6772 error::Error GLES2DecoderImpl::HandleReadPixels(
6770 uint32 immediate_data_size, const gles2::ReadPixels& c) { 6773 uint32 immediate_data_size, const cmds::ReadPixels& c) {
6771 if (ShouldDeferReads()) 6774 if (ShouldDeferReads())
6772 return error::kDeferCommandUntilLater; 6775 return error::kDeferCommandUntilLater;
6773 GLint x = c.x; 6776 GLint x = c.x;
6774 GLint y = c.y; 6777 GLint y = c.y;
6775 GLsizei width = c.width; 6778 GLsizei width = c.width;
6776 GLsizei height = c.height; 6779 GLsizei height = c.height;
6777 GLenum format = c.format; 6780 GLenum format = c.format;
6778 GLenum type = c.type; 6781 GLenum type = c.type;
6779 if (width < 0 || height < 0) { 6782 if (width < 0 || height < 0) {
6780 SetGLError(GL_INVALID_VALUE, "glReadPixels", "dimensions < 0"); 6783 SetGLError(GL_INVALID_VALUE, "glReadPixels", "dimensions < 0");
6781 return error::kNoError; 6784 return error::kNoError;
6782 } 6785 }
6783 typedef gles2::ReadPixels::Result Result; 6786 typedef cmds::ReadPixels::Result Result;
6784 uint32 pixels_size; 6787 uint32 pixels_size;
6785 if (!GLES2Util::ComputeImageDataSizes( 6788 if (!GLES2Util::ComputeImageDataSizes(
6786 width, height, format, type, state_.pack_alignment, &pixels_size, 6789 width, height, format, type, state_.pack_alignment, &pixels_size,
6787 NULL, NULL)) { 6790 NULL, NULL)) {
6788 return error::kOutOfBounds; 6791 return error::kOutOfBounds;
6789 } 6792 }
6790 void* pixels = GetSharedMemoryAs<void*>( 6793 void* pixels = GetSharedMemoryAs<void*>(
6791 c.pixels_shm_id, c.pixels_shm_offset, pixels_size); 6794 c.pixels_shm_id, c.pixels_shm_offset, pixels_size);
6792 Result* result = GetSharedMemoryAs<Result*>( 6795 Result* result = GetSharedMemoryAs<Result*>(
6793 c.result_shm_id, c.result_shm_offset, sizeof(*result)); 6796 c.result_shm_id, c.result_shm_offset, sizeof(*result));
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
6914 default: 6917 default:
6915 break; 6918 break;
6916 } 6919 }
6917 } 6920 }
6918 } 6921 }
6919 6922
6920 return error::kNoError; 6923 return error::kNoError;
6921 } 6924 }
6922 6925
6923 error::Error GLES2DecoderImpl::HandlePixelStorei( 6926 error::Error GLES2DecoderImpl::HandlePixelStorei(
6924 uint32 immediate_data_size, const gles2::PixelStorei& c) { 6927 uint32 immediate_data_size, const cmds::PixelStorei& c) {
6925 GLenum pname = c.pname; 6928 GLenum pname = c.pname;
6926 GLenum param = c.param; 6929 GLenum param = c.param;
6927 if (!validators_->pixel_store.IsValid(pname)) { 6930 if (!validators_->pixel_store.IsValid(pname)) {
6928 SetGLErrorInvalidEnum("glPixelStorei", pname, "pname"); 6931 SetGLErrorInvalidEnum("glPixelStorei", pname, "pname");
6929 return error::kNoError; 6932 return error::kNoError;
6930 } 6933 }
6931 switch (pname) { 6934 switch (pname) {
6932 case GL_PACK_ALIGNMENT: 6935 case GL_PACK_ALIGNMENT:
6933 case GL_UNPACK_ALIGNMENT: 6936 case GL_UNPACK_ALIGNMENT:
6934 if (!validators_->pixel_store_alignment.IsValid(param)) { 6937 if (!validators_->pixel_store_alignment.IsValid(param)) {
(...skipping 27 matching lines...) Expand all
6962 break; 6965 break;
6963 default: 6966 default:
6964 // Validation should have prevented us from getting here. 6967 // Validation should have prevented us from getting here.
6965 NOTREACHED(); 6968 NOTREACHED();
6966 break; 6969 break;
6967 } 6970 }
6968 return error::kNoError; 6971 return error::kNoError;
6969 } 6972 }
6970 6973
6971 error::Error GLES2DecoderImpl::HandlePostSubBufferCHROMIUM( 6974 error::Error GLES2DecoderImpl::HandlePostSubBufferCHROMIUM(
6972 uint32 immediate_data_size, const gles2::PostSubBufferCHROMIUM& c) { 6975 uint32 immediate_data_size, const cmds::PostSubBufferCHROMIUM& c) {
6973 TRACE_EVENT0("gpu", "GLES2DecoderImpl::HandlePostSubBufferCHROMIUM"); 6976 TRACE_EVENT0("gpu", "GLES2DecoderImpl::HandlePostSubBufferCHROMIUM");
6974 if (!surface_->HasExtension("GL_CHROMIUM_post_sub_buffer")) { 6977 if (!surface_->HasExtension("GL_CHROMIUM_post_sub_buffer")) {
6975 SetGLError(GL_INVALID_OPERATION, 6978 SetGLError(GL_INVALID_OPERATION,
6976 "glPostSubBufferCHROMIUM", "command not supported by surface"); 6979 "glPostSubBufferCHROMIUM", "command not supported by surface");
6977 return error::kNoError; 6980 return error::kNoError;
6978 } 6981 }
6979 if (surface_->PostSubBuffer(c.x, c.y, c.width, c.height)) { 6982 if (surface_->PostSubBuffer(c.x, c.y, c.width, c.height)) {
6980 return error::kNoError; 6983 return error::kNoError;
6981 } else { 6984 } else {
6982 LOG(ERROR) << "Context lost because PostSubBuffer failed."; 6985 LOG(ERROR) << "Context lost because PostSubBuffer failed.";
6983 return error::kLostContext; 6986 return error::kLostContext;
6984 } 6987 }
6985 } 6988 }
6986 6989
6987 error::Error GLES2DecoderImpl::GetAttribLocationHelper( 6990 error::Error GLES2DecoderImpl::GetAttribLocationHelper(
6988 GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset, 6991 GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset,
6989 const std::string& name_str) { 6992 const std::string& name_str) {
6990 if (!StringIsValidForGLES(name_str.c_str())) { 6993 if (!StringIsValidForGLES(name_str.c_str())) {
6991 SetGLError(GL_INVALID_VALUE, "glGetAttribLocation", "Invalid character"); 6994 SetGLError(GL_INVALID_VALUE, "glGetAttribLocation", "Invalid character");
6992 return error::kNoError; 6995 return error::kNoError;
6993 } 6996 }
6994 ProgramManager::ProgramInfo* info = GetProgramInfoNotShader( 6997 Program* info = GetProgramInfoNotShader(
6995 client_id, "glGetAttribLocation"); 6998 client_id, "glGetAttribLocation");
6996 if (!info) { 6999 if (!info) {
6997 return error::kNoError; 7000 return error::kNoError;
6998 } 7001 }
6999 if (!info->IsValid()) { 7002 if (!info->IsValid()) {
7000 SetGLError( 7003 SetGLError(
7001 GL_INVALID_OPERATION, "glGetAttribLocation", "program not linked"); 7004 GL_INVALID_OPERATION, "glGetAttribLocation", "program not linked");
7002 return error::kNoError; 7005 return error::kNoError;
7003 } 7006 }
7004 GLint* location = GetSharedMemoryAs<GLint*>( 7007 GLint* location = GetSharedMemoryAs<GLint*>(
7005 location_shm_id, location_shm_offset, sizeof(GLint)); 7008 location_shm_id, location_shm_offset, sizeof(GLint));
7006 if (!location) { 7009 if (!location) {
7007 return error::kOutOfBounds; 7010 return error::kOutOfBounds;
7008 } 7011 }
7009 // Require the client to init this incase the context is lost and we are no 7012 // Require the client to init this incase the context is lost and we are no
7010 // longer executing commands. 7013 // longer executing commands.
7011 if (*location != -1) { 7014 if (*location != -1) {
7012 return error::kGenericError; 7015 return error::kGenericError;
7013 } 7016 }
7014 *location = info->GetAttribLocation(name_str); 7017 *location = info->GetAttribLocation(name_str);
7015 return error::kNoError; 7018 return error::kNoError;
7016 } 7019 }
7017 7020
7018 error::Error GLES2DecoderImpl::HandleGetAttribLocation( 7021 error::Error GLES2DecoderImpl::HandleGetAttribLocation(
7019 uint32 immediate_data_size, const gles2::GetAttribLocation& c) { 7022 uint32 immediate_data_size, const cmds::GetAttribLocation& c) {
7020 uint32 name_size = c.data_size; 7023 uint32 name_size = c.data_size;
7021 const char* name = GetSharedMemoryAs<const char*>( 7024 const char* name = GetSharedMemoryAs<const char*>(
7022 c.name_shm_id, c.name_shm_offset, name_size); 7025 c.name_shm_id, c.name_shm_offset, name_size);
7023 if (!name) { 7026 if (!name) {
7024 return error::kOutOfBounds; 7027 return error::kOutOfBounds;
7025 } 7028 }
7026 String name_str(name, name_size); 7029 String name_str(name, name_size);
7027 return GetAttribLocationHelper( 7030 return GetAttribLocationHelper(
7028 c.program, c.location_shm_id, c.location_shm_offset, name_str); 7031 c.program, c.location_shm_id, c.location_shm_offset, name_str);
7029 } 7032 }
7030 7033
7031 error::Error GLES2DecoderImpl::HandleGetAttribLocationImmediate( 7034 error::Error GLES2DecoderImpl::HandleGetAttribLocationImmediate(
7032 uint32 immediate_data_size, const gles2::GetAttribLocationImmediate& c) { 7035 uint32 immediate_data_size, const cmds::GetAttribLocationImmediate& c) {
7033 uint32 name_size = c.data_size; 7036 uint32 name_size = c.data_size;
7034 const char* name = GetImmediateDataAs<const char*>( 7037 const char* name = GetImmediateDataAs<const char*>(
7035 c, name_size, immediate_data_size); 7038 c, name_size, immediate_data_size);
7036 if (!name) { 7039 if (!name) {
7037 return error::kOutOfBounds; 7040 return error::kOutOfBounds;
7038 } 7041 }
7039 String name_str(name, name_size); 7042 String name_str(name, name_size);
7040 return GetAttribLocationHelper( 7043 return GetAttribLocationHelper(
7041 c.program, c.location_shm_id, c.location_shm_offset, name_str); 7044 c.program, c.location_shm_id, c.location_shm_offset, name_str);
7042 } 7045 }
7043 7046
7044 error::Error GLES2DecoderImpl::HandleGetAttribLocationBucket( 7047 error::Error GLES2DecoderImpl::HandleGetAttribLocationBucket(
7045 uint32 immediate_data_size, const gles2::GetAttribLocationBucket& c) { 7048 uint32 immediate_data_size, const cmds::GetAttribLocationBucket& c) {
7046 Bucket* bucket = GetBucket(c.name_bucket_id); 7049 Bucket* bucket = GetBucket(c.name_bucket_id);
7047 if (!bucket) { 7050 if (!bucket) {
7048 return error::kInvalidArguments; 7051 return error::kInvalidArguments;
7049 } 7052 }
7050 std::string name_str; 7053 std::string name_str;
7051 if (!bucket->GetAsString(&name_str)) { 7054 if (!bucket->GetAsString(&name_str)) {
7052 return error::kInvalidArguments; 7055 return error::kInvalidArguments;
7053 } 7056 }
7054 return GetAttribLocationHelper( 7057 return GetAttribLocationHelper(
7055 c.program, c.location_shm_id, c.location_shm_offset, name_str); 7058 c.program, c.location_shm_id, c.location_shm_offset, name_str);
7056 } 7059 }
7057 7060
7058 error::Error GLES2DecoderImpl::GetUniformLocationHelper( 7061 error::Error GLES2DecoderImpl::GetUniformLocationHelper(
7059 GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset, 7062 GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset,
7060 const std::string& name_str) { 7063 const std::string& name_str) {
7061 if (!StringIsValidForGLES(name_str.c_str())) { 7064 if (!StringIsValidForGLES(name_str.c_str())) {
7062 SetGLError(GL_INVALID_VALUE, "glGetUniformLocation", "Invalid character"); 7065 SetGLError(GL_INVALID_VALUE, "glGetUniformLocation", "Invalid character");
7063 return error::kNoError; 7066 return error::kNoError;
7064 } 7067 }
7065 ProgramManager::ProgramInfo* info = GetProgramInfoNotShader( 7068 Program* info = GetProgramInfoNotShader(
7066 client_id, "glUniformLocation"); 7069 client_id, "glUniformLocation");
7067 if (!info) { 7070 if (!info) {
7068 return error::kNoError; 7071 return error::kNoError;
7069 } 7072 }
7070 if (!info->IsValid()) { 7073 if (!info->IsValid()) {
7071 SetGLError( 7074 SetGLError(
7072 GL_INVALID_OPERATION, "glGetUniformLocation", "program not linked"); 7075 GL_INVALID_OPERATION, "glGetUniformLocation", "program not linked");
7073 return error::kNoError; 7076 return error::kNoError;
7074 } 7077 }
7075 GLint* location = GetSharedMemoryAs<GLint*>( 7078 GLint* location = GetSharedMemoryAs<GLint*>(
7076 location_shm_id, location_shm_offset, sizeof(GLint)); 7079 location_shm_id, location_shm_offset, sizeof(GLint));
7077 if (!location) { 7080 if (!location) {
7078 return error::kOutOfBounds; 7081 return error::kOutOfBounds;
7079 } 7082 }
7080 // Require the client to init this incase the context is lost an we are no 7083 // Require the client to init this incase the context is lost an we are no
7081 // longer executing commands. 7084 // longer executing commands.
7082 if (*location != -1) { 7085 if (*location != -1) {
7083 return error::kGenericError; 7086 return error::kGenericError;
7084 } 7087 }
7085 *location = info->GetUniformFakeLocation(name_str); 7088 *location = info->GetUniformFakeLocation(name_str);
7086 return error::kNoError; 7089 return error::kNoError;
7087 } 7090 }
7088 7091
7089 error::Error GLES2DecoderImpl::HandleGetUniformLocation( 7092 error::Error GLES2DecoderImpl::HandleGetUniformLocation(
7090 uint32 immediate_data_size, const gles2::GetUniformLocation& c) { 7093 uint32 immediate_data_size, const cmds::GetUniformLocation& c) {
7091 uint32 name_size = c.data_size; 7094 uint32 name_size = c.data_size;
7092 const char* name = GetSharedMemoryAs<const char*>( 7095 const char* name = GetSharedMemoryAs<const char*>(
7093 c.name_shm_id, c.name_shm_offset, name_size); 7096 c.name_shm_id, c.name_shm_offset, name_size);
7094 if (!name) { 7097 if (!name) {
7095 return error::kOutOfBounds; 7098 return error::kOutOfBounds;
7096 } 7099 }
7097 String name_str(name, name_size); 7100 String name_str(name, name_size);
7098 return GetUniformLocationHelper( 7101 return GetUniformLocationHelper(
7099 c.program, c.location_shm_id, c.location_shm_offset, name_str); 7102 c.program, c.location_shm_id, c.location_shm_offset, name_str);
7100 } 7103 }
7101 7104
7102 error::Error GLES2DecoderImpl::HandleGetUniformLocationImmediate( 7105 error::Error GLES2DecoderImpl::HandleGetUniformLocationImmediate(
7103 uint32 immediate_data_size, const gles2::GetUniformLocationImmediate& c) { 7106 uint32 immediate_data_size, const cmds::GetUniformLocationImmediate& c) {
7104 uint32 name_size = c.data_size; 7107 uint32 name_size = c.data_size;
7105 const char* name = GetImmediateDataAs<const char*>( 7108 const char* name = GetImmediateDataAs<const char*>(
7106 c, name_size, immediate_data_size); 7109 c, name_size, immediate_data_size);
7107 if (!name) { 7110 if (!name) {
7108 return error::kOutOfBounds; 7111 return error::kOutOfBounds;
7109 } 7112 }
7110 String name_str(name, name_size); 7113 String name_str(name, name_size);
7111 return GetUniformLocationHelper( 7114 return GetUniformLocationHelper(
7112 c.program, c.location_shm_id, c.location_shm_offset, name_str); 7115 c.program, c.location_shm_id, c.location_shm_offset, name_str);
7113 } 7116 }
7114 7117
7115 error::Error GLES2DecoderImpl::HandleGetUniformLocationBucket( 7118 error::Error GLES2DecoderImpl::HandleGetUniformLocationBucket(
7116 uint32 immediate_data_size, const gles2::GetUniformLocationBucket& c) { 7119 uint32 immediate_data_size, const cmds::GetUniformLocationBucket& c) {
7117 Bucket* bucket = GetBucket(c.name_bucket_id); 7120 Bucket* bucket = GetBucket(c.name_bucket_id);
7118 if (!bucket) { 7121 if (!bucket) {
7119 return error::kInvalidArguments; 7122 return error::kInvalidArguments;
7120 } 7123 }
7121 std::string name_str; 7124 std::string name_str;
7122 if (!bucket->GetAsString(&name_str)) { 7125 if (!bucket->GetAsString(&name_str)) {
7123 return error::kInvalidArguments; 7126 return error::kInvalidArguments;
7124 } 7127 }
7125 return GetUniformLocationHelper( 7128 return GetUniformLocationHelper(
7126 c.program, c.location_shm_id, c.location_shm_offset, name_str); 7129 c.program, c.location_shm_id, c.location_shm_offset, name_str);
7127 } 7130 }
7128 7131
7129 error::Error GLES2DecoderImpl::HandleGetString( 7132 error::Error GLES2DecoderImpl::HandleGetString(
7130 uint32 immediate_data_size, const gles2::GetString& c) { 7133 uint32 immediate_data_size, const cmds::GetString& c) {
7131 GLenum name = static_cast<GLenum>(c.name); 7134 GLenum name = static_cast<GLenum>(c.name);
7132 if (!validators_->string_type.IsValid(name)) { 7135 if (!validators_->string_type.IsValid(name)) {
7133 SetGLErrorInvalidEnum("glGetString", name, "name"); 7136 SetGLErrorInvalidEnum("glGetString", name, "name");
7134 return error::kNoError; 7137 return error::kNoError;
7135 } 7138 }
7136 const char* gl_str = reinterpret_cast<const char*>(glGetString(name)); 7139 const char* gl_str = reinterpret_cast<const char*>(glGetString(name));
7137 const char* str = NULL; 7140 const char* str = NULL;
7138 std::string extensions; 7141 std::string extensions;
7139 switch (name) { 7142 switch (name) {
7140 case GL_VERSION: 7143 case GL_VERSION:
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
7187 return; 7190 return;
7188 } 7191 }
7189 if (!validators_->buffer_usage.IsValid(usage)) { 7192 if (!validators_->buffer_usage.IsValid(usage)) {
7190 SetGLErrorInvalidEnum("glBufferData", usage, "usage"); 7193 SetGLErrorInvalidEnum("glBufferData", usage, "usage");
7191 return; 7194 return;
7192 } 7195 }
7193 if (size < 0) { 7196 if (size < 0) {
7194 SetGLError(GL_INVALID_VALUE, "glBufferData", "size < 0"); 7197 SetGLError(GL_INVALID_VALUE, "glBufferData", "size < 0");
7195 return; 7198 return;
7196 } 7199 }
7197 BufferManager::BufferInfo* info = GetBufferInfoForTarget(target); 7200 BufferManager::Buffer* info = GetBufferInfoForTarget(target);
7198 if (!info) { 7201 if (!info) {
7199 SetGLError(GL_INVALID_VALUE, "glBufferData", "unknown buffer"); 7202 SetGLError(GL_INVALID_VALUE, "glBufferData", "unknown buffer");
7200 return; 7203 return;
7201 } 7204 }
7202 7205
7203 if (!EnsureGPUMemoryAvailable(size)) { 7206 if (!EnsureGPUMemoryAvailable(size)) {
7204 SetGLError(GL_OUT_OF_MEMORY, "glBufferData", "out of memory"); 7207 SetGLError(GL_OUT_OF_MEMORY, "glBufferData", "out of memory");
7205 return; 7208 return;
7206 } 7209 }
7207 7210
(...skipping 10 matching lines...) Expand all
7218 GLenum error = PeekGLError(); 7221 GLenum error = PeekGLError();
7219 if (error == GL_NO_ERROR) { 7222 if (error == GL_NO_ERROR) {
7220 buffer_manager()->SetInfo(info, size, usage); 7223 buffer_manager()->SetInfo(info, size, usage);
7221 info->SetRange(0, size, data); 7224 info->SetRange(0, size, data);
7222 } else { 7225 } else {
7223 buffer_manager()->SetInfo(info, 0, usage); 7226 buffer_manager()->SetInfo(info, 0, usage);
7224 } 7227 }
7225 } 7228 }
7226 7229
7227 error::Error GLES2DecoderImpl::HandleBufferData( 7230 error::Error GLES2DecoderImpl::HandleBufferData(
7228 uint32 immediate_data_size, const gles2::BufferData& c) { 7231 uint32 immediate_data_size, const cmds::BufferData& c) {
7229 GLenum target = static_cast<GLenum>(c.target); 7232 GLenum target = static_cast<GLenum>(c.target);
7230 GLsizeiptr size = static_cast<GLsizeiptr>(c.size); 7233 GLsizeiptr size = static_cast<GLsizeiptr>(c.size);
7231 uint32 data_shm_id = static_cast<uint32>(c.data_shm_id); 7234 uint32 data_shm_id = static_cast<uint32>(c.data_shm_id);
7232 uint32 data_shm_offset = static_cast<uint32>(c.data_shm_offset); 7235 uint32 data_shm_offset = static_cast<uint32>(c.data_shm_offset);
7233 GLenum usage = static_cast<GLenum>(c.usage); 7236 GLenum usage = static_cast<GLenum>(c.usage);
7234 const void* data = NULL; 7237 const void* data = NULL;
7235 if (data_shm_id != 0 || data_shm_offset != 0) { 7238 if (data_shm_id != 0 || data_shm_offset != 0) {
7236 data = GetSharedMemoryAs<const void*>(data_shm_id, data_shm_offset, size); 7239 data = GetSharedMemoryAs<const void*>(data_shm_id, data_shm_offset, size);
7237 if (!data) { 7240 if (!data) {
7238 return error::kOutOfBounds; 7241 return error::kOutOfBounds;
7239 } 7242 }
7240 } 7243 }
7241 DoBufferData(target, size, data, usage); 7244 DoBufferData(target, size, data, usage);
7242 return error::kNoError; 7245 return error::kNoError;
7243 } 7246 }
7244 7247
7245 error::Error GLES2DecoderImpl::HandleBufferDataImmediate( 7248 error::Error GLES2DecoderImpl::HandleBufferDataImmediate(
7246 uint32 immediate_data_size, const gles2::BufferDataImmediate& c) { 7249 uint32 immediate_data_size, const cmds::BufferDataImmediate& c) {
7247 GLenum target = static_cast<GLenum>(c.target); 7250 GLenum target = static_cast<GLenum>(c.target);
7248 GLsizeiptr size = static_cast<GLsizeiptr>(c.size); 7251 GLsizeiptr size = static_cast<GLsizeiptr>(c.size);
7249 const void* data = GetImmediateDataAs<const void*>( 7252 const void* data = GetImmediateDataAs<const void*>(
7250 c, size, immediate_data_size); 7253 c, size, immediate_data_size);
7251 if (!data) { 7254 if (!data) {
7252 return error::kOutOfBounds; 7255 return error::kOutOfBounds;
7253 } 7256 }
7254 GLenum usage = static_cast<GLenum>(c.usage); 7257 GLenum usage = static_cast<GLenum>(c.usage);
7255 DoBufferData(target, size, data, usage); 7258 DoBufferData(target, size, data, usage);
7256 return error::kNoError; 7259 return error::kNoError;
7257 } 7260 }
7258 7261
7259 void GLES2DecoderImpl::DoBufferSubData( 7262 void GLES2DecoderImpl::DoBufferSubData(
7260 GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid * data) { 7263 GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid * data) {
7261 BufferManager::BufferInfo* info = GetBufferInfoForTarget(target); 7264 BufferManager::Buffer* info = GetBufferInfoForTarget(target);
7262 if (!info) { 7265 if (!info) {
7263 SetGLError(GL_INVALID_VALUE, "glBufferSubData", "unknown buffer"); 7266 SetGLError(GL_INVALID_VALUE, "glBufferSubData", "unknown buffer");
7264 return; 7267 return;
7265 } 7268 }
7266 if (!info->SetRange(offset, size, data)) { 7269 if (!info->SetRange(offset, size, data)) {
7267 SetGLError(GL_INVALID_VALUE, "glBufferSubData", "out of range"); 7270 SetGLError(GL_INVALID_VALUE, "glBufferSubData", "out of range");
7268 return; 7271 return;
7269 } 7272 }
7270 glBufferSubData(target, offset, size, data); 7273 glBufferSubData(target, offset, size, data);
7271 } 7274 }
(...skipping 30 matching lines...) Expand all
7302 glClearStencil(0); 7305 glClearStencil(0);
7303 glStencilMask(-1); 7306 glStencilMask(-1);
7304 glClearDepth(1.0f); 7307 glClearDepth(1.0f);
7305 glDepthMask(true); 7308 glDepthMask(true);
7306 glDisable(GL_SCISSOR_TEST); 7309 glDisable(GL_SCISSOR_TEST);
7307 glClear(GL_DEPTH_BUFFER_BIT | (have_stencil ? GL_STENCIL_BUFFER_BIT : 0)); 7310 glClear(GL_DEPTH_BUFFER_BIT | (have_stencil ? GL_STENCIL_BUFFER_BIT : 0));
7308 7311
7309 RestoreClearState(); 7312 RestoreClearState();
7310 7313
7311 glDeleteFramebuffersEXT(1, &fb); 7314 glDeleteFramebuffersEXT(1, &fb);
7312 FramebufferManager::FramebufferInfo* framebuffer = 7315 Framebuffer* framebuffer =
7313 GetFramebufferInfoForTarget(GL_DRAW_FRAMEBUFFER_EXT); 7316 GetFramebufferInfoForTarget(GL_DRAW_FRAMEBUFFER_EXT);
7314 GLuint fb_service_id = 7317 GLuint fb_service_id =
7315 framebuffer ? framebuffer->service_id() : GetBackbufferServiceId(); 7318 framebuffer ? framebuffer->service_id() : GetBackbufferServiceId();
7316 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, fb_service_id); 7319 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, fb_service_id);
7317 return true; 7320 return true;
7318 } 7321 }
7319 7322
7320 static const uint32 kMaxZeroSize = 1024 * 1024 * 4; 7323 static const uint32 kMaxZeroSize = 1024 * 1024 * 4;
7321 7324
7322 uint32 size; 7325 uint32 size;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
7357 while (y < height) { 7360 while (y < height) {
7358 GLint h = y + tile_height > height ? height - y : tile_height; 7361 GLint h = y + tile_height > height ? height - y : tile_height;
7359 if (is_texture_immutable || h != height) { 7362 if (is_texture_immutable || h != height) {
7360 glTexSubImage2D(target, level, 0, y, width, h, format, type, zero.get()); 7363 glTexSubImage2D(target, level, 0, y, width, h, format, type, zero.get());
7361 } else { 7364 } else {
7362 WrappedTexImage2D( 7365 WrappedTexImage2D(
7363 target, level, format, width, h, 0, format, type, zero.get()); 7366 target, level, format, width, h, 0, format, type, zero.get());
7364 } 7367 }
7365 y += tile_height; 7368 y += tile_height;
7366 } 7369 }
7367 TextureManager::TextureInfo* info = GetTextureInfoForTarget(bind_target); 7370 Texture* info = GetTextureInfoForTarget(bind_target);
7368 glBindTexture(bind_target, info ? info->service_id() : 0); 7371 glBindTexture(bind_target, info ? info->service_id() : 0);
7369 return true; 7372 return true;
7370 } 7373 }
7371 7374
7372 namespace { 7375 namespace {
7373 7376
7374 const int kS3TCBlockWidth = 4; 7377 const int kS3TCBlockWidth = 4;
7375 const int kS3TCBlockHeight = 4; 7378 const int kS3TCBlockHeight = 4;
7376 const int kS3TCDXT1BlockSize = 8; 7379 const int kS3TCDXT1BlockSize = 8;
7377 const int kS3TCDXT3AndDXT5BlockSize = 16; 7380 const int kS3TCDXT3AndDXT5BlockSize = 16;
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
7461 return true; 7464 return true;
7462 default: 7465 default:
7463 return false; 7466 return false;
7464 } 7467 }
7465 } 7468 }
7466 7469
7467 bool GLES2DecoderImpl::ValidateCompressedTexSubDimensions( 7470 bool GLES2DecoderImpl::ValidateCompressedTexSubDimensions(
7468 const char* function_name, 7471 const char* function_name,
7469 GLenum target, GLint level, GLint xoffset, GLint yoffset, 7472 GLenum target, GLint level, GLint xoffset, GLint yoffset,
7470 GLsizei width, GLsizei height, GLenum format, 7473 GLsizei width, GLsizei height, GLenum format,
7471 TextureManager::TextureInfo* texture) { 7474 Texture* texture) {
7472 if (xoffset < 0 || yoffset < 0) { 7475 if (xoffset < 0 || yoffset < 0) {
7473 SetGLError( 7476 SetGLError(
7474 GL_INVALID_VALUE, function_name, "xoffset or yoffset < 0"); 7477 GL_INVALID_VALUE, function_name, "xoffset or yoffset < 0");
7475 return false; 7478 return false;
7476 } 7479 }
7477 7480
7478 switch (format) { 7481 switch (format) {
7479 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: 7482 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
7480 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: 7483 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
7481 case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: 7484 case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
7530 SetGLErrorInvalidEnum( 7533 SetGLErrorInvalidEnum(
7531 "glCompressedTexImage2D", internal_format, "internal_format"); 7534 "glCompressedTexImage2D", internal_format, "internal_format");
7532 return error::kNoError; 7535 return error::kNoError;
7533 } 7536 }
7534 if (!texture_manager()->ValidForTarget(target, level, width, height, 1) || 7537 if (!texture_manager()->ValidForTarget(target, level, width, height, 1) ||
7535 border != 0) { 7538 border != 0) {
7536 SetGLError(GL_INVALID_VALUE, 7539 SetGLError(GL_INVALID_VALUE,
7537 "glCompressedTexImage2D", "dimensions out of range"); 7540 "glCompressedTexImage2D", "dimensions out of range");
7538 return error::kNoError; 7541 return error::kNoError;
7539 } 7542 }
7540 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target); 7543 Texture* info = GetTextureInfoForTarget(target);
7541 if (!info) { 7544 if (!info) {
7542 SetGLError(GL_INVALID_VALUE, 7545 SetGLError(GL_INVALID_VALUE,
7543 "glCompressedTexImage2D", "unknown texture target"); 7546 "glCompressedTexImage2D", "unknown texture target");
7544 return error::kNoError; 7547 return error::kNoError;
7545 } 7548 }
7546 if (info->IsImmutable()) { 7549 if (info->IsImmutable()) {
7547 SetGLError(GL_INVALID_OPERATION, 7550 SetGLError(GL_INVALID_OPERATION,
7548 "glCompressedTexImage2D", "texture is immutable"); 7551 "glCompressedTexImage2D", "texture is immutable");
7549 return error::kNoError; 7552 return error::kNoError;
7550 } 7553 }
(...skipping 29 matching lines...) Expand all
7580 GLenum error = PeekGLError(); 7583 GLenum error = PeekGLError();
7581 if (error == GL_NO_ERROR) { 7584 if (error == GL_NO_ERROR) {
7582 texture_manager()->SetLevelInfo( 7585 texture_manager()->SetLevelInfo(
7583 info, target, level, internal_format, width, height, 1, border, 0, 0, 7586 info, target, level, internal_format, width, height, 1, border, 0, 0,
7584 true); 7587 true);
7585 } 7588 }
7586 return error::kNoError; 7589 return error::kNoError;
7587 } 7590 }
7588 7591
7589 error::Error GLES2DecoderImpl::HandleCompressedTexImage2D( 7592 error::Error GLES2DecoderImpl::HandleCompressedTexImage2D(
7590 uint32 immediate_data_size, const gles2::CompressedTexImage2D& c) { 7593 uint32 immediate_data_size, const cmds::CompressedTexImage2D& c) {
7591 GLenum target = static_cast<GLenum>(c.target); 7594 GLenum target = static_cast<GLenum>(c.target);
7592 GLint level = static_cast<GLint>(c.level); 7595 GLint level = static_cast<GLint>(c.level);
7593 GLenum internal_format = static_cast<GLenum>(c.internalformat); 7596 GLenum internal_format = static_cast<GLenum>(c.internalformat);
7594 GLsizei width = static_cast<GLsizei>(c.width); 7597 GLsizei width = static_cast<GLsizei>(c.width);
7595 GLsizei height = static_cast<GLsizei>(c.height); 7598 GLsizei height = static_cast<GLsizei>(c.height);
7596 GLint border = static_cast<GLint>(c.border); 7599 GLint border = static_cast<GLint>(c.border);
7597 GLsizei image_size = static_cast<GLsizei>(c.imageSize); 7600 GLsizei image_size = static_cast<GLsizei>(c.imageSize);
7598 uint32 data_shm_id = static_cast<uint32>(c.data_shm_id); 7601 uint32 data_shm_id = static_cast<uint32>(c.data_shm_id);
7599 uint32 data_shm_offset = static_cast<uint32>(c.data_shm_offset); 7602 uint32 data_shm_offset = static_cast<uint32>(c.data_shm_offset);
7600 const void* data = NULL; 7603 const void* data = NULL;
7601 if (data_shm_id != 0 || data_shm_offset != 0) { 7604 if (data_shm_id != 0 || data_shm_offset != 0) {
7602 data = GetSharedMemoryAs<const void*>( 7605 data = GetSharedMemoryAs<const void*>(
7603 data_shm_id, data_shm_offset, image_size); 7606 data_shm_id, data_shm_offset, image_size);
7604 if (!data) { 7607 if (!data) {
7605 return error::kOutOfBounds; 7608 return error::kOutOfBounds;
7606 } 7609 }
7607 } 7610 }
7608 return DoCompressedTexImage2D( 7611 return DoCompressedTexImage2D(
7609 target, level, internal_format, width, height, border, image_size, data); 7612 target, level, internal_format, width, height, border, image_size, data);
7610 } 7613 }
7611 7614
7612 error::Error GLES2DecoderImpl::HandleCompressedTexImage2DImmediate( 7615 error::Error GLES2DecoderImpl::HandleCompressedTexImage2DImmediate(
7613 uint32 immediate_data_size, const gles2::CompressedTexImage2DImmediate& c) { 7616 uint32 immediate_data_size, const cmds::CompressedTexImage2DImmediate& c) {
7614 GLenum target = static_cast<GLenum>(c.target); 7617 GLenum target = static_cast<GLenum>(c.target);
7615 GLint level = static_cast<GLint>(c.level); 7618 GLint level = static_cast<GLint>(c.level);
7616 GLenum internal_format = static_cast<GLenum>(c.internalformat); 7619 GLenum internal_format = static_cast<GLenum>(c.internalformat);
7617 GLsizei width = static_cast<GLsizei>(c.width); 7620 GLsizei width = static_cast<GLsizei>(c.width);
7618 GLsizei height = static_cast<GLsizei>(c.height); 7621 GLsizei height = static_cast<GLsizei>(c.height);
7619 GLint border = static_cast<GLint>(c.border); 7622 GLint border = static_cast<GLint>(c.border);
7620 GLsizei image_size = static_cast<GLsizei>(c.imageSize); 7623 GLsizei image_size = static_cast<GLsizei>(c.imageSize);
7621 const void* data = GetImmediateDataAs<const void*>( 7624 const void* data = GetImmediateDataAs<const void*>(
7622 c, image_size, immediate_data_size); 7625 c, image_size, immediate_data_size);
7623 if (!data) { 7626 if (!data) {
7624 return error::kOutOfBounds; 7627 return error::kOutOfBounds;
7625 } 7628 }
7626 return DoCompressedTexImage2D( 7629 return DoCompressedTexImage2D(
7627 target, level, internal_format, width, height, border, image_size, data); 7630 target, level, internal_format, width, height, border, image_size, data);
7628 } 7631 }
7629 7632
7630 error::Error GLES2DecoderImpl::HandleCompressedTexImage2DBucket( 7633 error::Error GLES2DecoderImpl::HandleCompressedTexImage2DBucket(
7631 uint32 immediate_data_size, const gles2::CompressedTexImage2DBucket& c) { 7634 uint32 immediate_data_size, const cmds::CompressedTexImage2DBucket& c) {
7632 GLenum target = static_cast<GLenum>(c.target); 7635 GLenum target = static_cast<GLenum>(c.target);
7633 GLint level = static_cast<GLint>(c.level); 7636 GLint level = static_cast<GLint>(c.level);
7634 GLenum internal_format = static_cast<GLenum>(c.internalformat); 7637 GLenum internal_format = static_cast<GLenum>(c.internalformat);
7635 GLsizei width = static_cast<GLsizei>(c.width); 7638 GLsizei width = static_cast<GLsizei>(c.width);
7636 GLsizei height = static_cast<GLsizei>(c.height); 7639 GLsizei height = static_cast<GLsizei>(c.height);
7637 GLint border = static_cast<GLint>(c.border); 7640 GLint border = static_cast<GLint>(c.border);
7638 Bucket* bucket = GetBucket(c.bucket_id); 7641 Bucket* bucket = GetBucket(c.bucket_id);
7639 if (!bucket) { 7642 if (!bucket) {
7640 return error::kInvalidArguments; 7643 return error::kInvalidArguments;
7641 } 7644 }
7642 uint32 data_size = bucket->size(); 7645 uint32 data_size = bucket->size();
7643 GLsizei imageSize = data_size; 7646 GLsizei imageSize = data_size;
7644 const void* data = bucket->GetData(0, data_size); 7647 const void* data = bucket->GetData(0, data_size);
7645 if (!data) { 7648 if (!data) {
7646 return error::kInvalidArguments; 7649 return error::kInvalidArguments;
7647 } 7650 }
7648 return DoCompressedTexImage2D( 7651 return DoCompressedTexImage2D(
7649 target, level, internal_format, width, height, border, 7652 target, level, internal_format, width, height, border,
7650 imageSize, data); 7653 imageSize, data);
7651 } 7654 }
7652 7655
7653 error::Error GLES2DecoderImpl::HandleCompressedTexSubImage2DBucket( 7656 error::Error GLES2DecoderImpl::HandleCompressedTexSubImage2DBucket(
7654 uint32 immediate_data_size, 7657 uint32 immediate_data_size,
7655 const gles2::CompressedTexSubImage2DBucket& c) { 7658 const cmds::CompressedTexSubImage2DBucket& c) {
7656 GLenum target = static_cast<GLenum>(c.target); 7659 GLenum target = static_cast<GLenum>(c.target);
7657 GLint level = static_cast<GLint>(c.level); 7660 GLint level = static_cast<GLint>(c.level);
7658 GLint xoffset = static_cast<GLint>(c.xoffset); 7661 GLint xoffset = static_cast<GLint>(c.xoffset);
7659 GLint yoffset = static_cast<GLint>(c.yoffset); 7662 GLint yoffset = static_cast<GLint>(c.yoffset);
7660 GLsizei width = static_cast<GLsizei>(c.width); 7663 GLsizei width = static_cast<GLsizei>(c.width);
7661 GLsizei height = static_cast<GLsizei>(c.height); 7664 GLsizei height = static_cast<GLsizei>(c.height);
7662 GLenum format = static_cast<GLenum>(c.format); 7665 GLenum format = static_cast<GLenum>(c.format);
7663 Bucket* bucket = GetBucket(c.bucket_id); 7666 Bucket* bucket = GetBucket(c.bucket_id);
7664 if (!bucket) { 7667 if (!bucket) {
7665 return error::kInvalidArguments; 7668 return error::kInvalidArguments;
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
7759 SetGLError(GL_INVALID_VALUE, function_name, "dimensions out of range"); 7762 SetGLError(GL_INVALID_VALUE, function_name, "dimensions out of range");
7760 return false; 7763 return false;
7761 } 7764 }
7762 if ((GLES2Util::GetChannelsForFormat(format) & 7765 if ((GLES2Util::GetChannelsForFormat(format) &
7763 (GLES2Util::kDepth | GLES2Util::kStencil)) != 0 && pixels) { 7766 (GLES2Util::kDepth | GLES2Util::kStencil)) != 0 && pixels) {
7764 SetGLError( 7767 SetGLError(
7765 GL_INVALID_OPERATION, 7768 GL_INVALID_OPERATION,
7766 function_name, "can not supply data for depth or stencil textures"); 7769 function_name, "can not supply data for depth or stencil textures");
7767 return false; 7770 return false;
7768 } 7771 }
7769 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target); 7772 Texture* info = GetTextureInfoForTarget(target);
7770 if (!info) { 7773 if (!info) {
7771 SetGLError(GL_INVALID_OPERATION, 7774 SetGLError(GL_INVALID_OPERATION,
7772 function_name, "unknown texture for target"); 7775 function_name, "unknown texture for target");
7773 return false; 7776 return false;
7774 } 7777 }
7775 if (info->IsImmutable()) { 7778 if (info->IsImmutable()) {
7776 SetGLError(GL_INVALID_OPERATION, 7779 SetGLError(GL_INVALID_OPERATION,
7777 function_name, "texture is immutable"); 7780 function_name, "texture is immutable");
7778 return false; 7781 return false;
7779 } 7782 }
(...skipping 14 matching lines...) Expand all
7794 if (!ValidateTexImage2D("glTexImage2D", target, level, internal_format, 7797 if (!ValidateTexImage2D("glTexImage2D", target, level, internal_format,
7795 width, height, border, format, type, pixels, pixels_size)) { 7798 width, height, border, format, type, pixels, pixels_size)) {
7796 return; 7799 return;
7797 } 7800 }
7798 7801
7799 if (!EnsureGPUMemoryAvailable(pixels_size)) { 7802 if (!EnsureGPUMemoryAvailable(pixels_size)) {
7800 SetGLError(GL_OUT_OF_MEMORY, "glTexImage2D", "out of memory"); 7803 SetGLError(GL_OUT_OF_MEMORY, "glTexImage2D", "out of memory");
7801 return; 7804 return;
7802 } 7805 }
7803 7806
7804 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target); 7807 Texture* info = GetTextureInfoForTarget(target);
7805 GLsizei tex_width = 0; 7808 GLsizei tex_width = 0;
7806 GLsizei tex_height = 0; 7809 GLsizei tex_height = 0;
7807 GLenum tex_type = 0; 7810 GLenum tex_type = 0;
7808 GLenum tex_format = 0; 7811 GLenum tex_format = 0;
7809 bool level_is_same = 7812 bool level_is_same =
7810 info->GetLevelSize(target, level, &tex_width, &tex_height) && 7813 info->GetLevelSize(target, level, &tex_width, &tex_height) &&
7811 info->GetLevelType(target, level, &tex_type, &tex_format) && 7814 info->GetLevelType(target, level, &tex_type, &tex_format) &&
7812 width == tex_width && height == tex_height && 7815 width == tex_width && height == tex_height &&
7813 type == tex_type && format == tex_format; 7816 type == tex_type && format == tex_format;
7814 7817
(...skipping 30 matching lines...) Expand all
7845 texture_manager()->SetLevelInfo( 7848 texture_manager()->SetLevelInfo(
7846 info, 7849 info,
7847 target, level, internal_format, width, height, 1, border, format, type, 7850 target, level, internal_format, width, height, 1, border, format, type,
7848 pixels != NULL); 7851 pixels != NULL);
7849 tex_image_2d_failed_ = false; 7852 tex_image_2d_failed_ = false;
7850 } 7853 }
7851 return; 7854 return;
7852 } 7855 }
7853 7856
7854 error::Error GLES2DecoderImpl::HandleTexImage2D( 7857 error::Error GLES2DecoderImpl::HandleTexImage2D(
7855 uint32 immediate_data_size, const gles2::TexImage2D& c) { 7858 uint32 immediate_data_size, const cmds::TexImage2D& c) {
7856 TRACE_EVENT0("gpu", "GLES2DecoderImpl::HandleTexImage2D"); 7859 TRACE_EVENT0("gpu", "GLES2DecoderImpl::HandleTexImage2D");
7857 tex_image_2d_failed_ = true; 7860 tex_image_2d_failed_ = true;
7858 GLenum target = static_cast<GLenum>(c.target); 7861 GLenum target = static_cast<GLenum>(c.target);
7859 GLint level = static_cast<GLint>(c.level); 7862 GLint level = static_cast<GLint>(c.level);
7860 GLint internal_format = static_cast<GLint>(c.internalformat); 7863 GLint internal_format = static_cast<GLint>(c.internalformat);
7861 GLsizei width = static_cast<GLsizei>(c.width); 7864 GLsizei width = static_cast<GLsizei>(c.width);
7862 GLsizei height = static_cast<GLsizei>(c.height); 7865 GLsizei height = static_cast<GLsizei>(c.height);
7863 GLint border = static_cast<GLint>(c.border); 7866 GLint border = static_cast<GLint>(c.border);
7864 GLenum format = static_cast<GLenum>(c.format); 7867 GLenum format = static_cast<GLenum>(c.format);
7865 GLenum type = static_cast<GLenum>(c.type); 7868 GLenum type = static_cast<GLenum>(c.type);
(...skipping 14 matching lines...) Expand all
7880 } 7883 }
7881 } 7884 }
7882 7885
7883 DoTexImage2D( 7886 DoTexImage2D(
7884 target, level, internal_format, width, height, border, format, type, 7887 target, level, internal_format, width, height, border, format, type,
7885 pixels, pixels_size); 7888 pixels, pixels_size);
7886 return error::kNoError; 7889 return error::kNoError;
7887 } 7890 }
7888 7891
7889 error::Error GLES2DecoderImpl::HandleTexImage2DImmediate( 7892 error::Error GLES2DecoderImpl::HandleTexImage2DImmediate(
7890 uint32 immediate_data_size, const gles2::TexImage2DImmediate& c) { 7893 uint32 immediate_data_size, const cmds::TexImage2DImmediate& c) {
7891 GLenum target = static_cast<GLenum>(c.target); 7894 GLenum target = static_cast<GLenum>(c.target);
7892 GLint level = static_cast<GLint>(c.level); 7895 GLint level = static_cast<GLint>(c.level);
7893 GLint internal_format = static_cast<GLint>(c.internalformat); 7896 GLint internal_format = static_cast<GLint>(c.internalformat);
7894 GLsizei width = static_cast<GLsizei>(c.width); 7897 GLsizei width = static_cast<GLsizei>(c.width);
7895 GLsizei height = static_cast<GLsizei>(c.height); 7898 GLsizei height = static_cast<GLsizei>(c.height);
7896 GLint border = static_cast<GLint>(c.border); 7899 GLint border = static_cast<GLint>(c.border);
7897 GLenum format = static_cast<GLenum>(c.format); 7900 GLenum format = static_cast<GLenum>(c.format);
7898 GLenum type = static_cast<GLenum>(c.type); 7901 GLenum type = static_cast<GLenum>(c.type);
7899 uint32 size; 7902 uint32 size;
7900 if (!GLES2Util::ComputeImageDataSizes( 7903 if (!GLES2Util::ComputeImageDataSizes(
(...skipping 15 matching lines...) Expand all
7916 void GLES2DecoderImpl::DoCompressedTexSubImage2D( 7919 void GLES2DecoderImpl::DoCompressedTexSubImage2D(
7917 GLenum target, 7920 GLenum target,
7918 GLint level, 7921 GLint level,
7919 GLint xoffset, 7922 GLint xoffset,
7920 GLint yoffset, 7923 GLint yoffset,
7921 GLsizei width, 7924 GLsizei width,
7922 GLsizei height, 7925 GLsizei height,
7923 GLenum format, 7926 GLenum format,
7924 GLsizei image_size, 7927 GLsizei image_size,
7925 const void * data) { 7928 const void * data) {
7926 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target); 7929 Texture* info = GetTextureInfoForTarget(target);
7927 if (!info) { 7930 if (!info) {
7928 SetGLError(GL_INVALID_OPERATION, 7931 SetGLError(GL_INVALID_OPERATION,
7929 "glCompressedTexSubImage2D", "unknown texture for target"); 7932 "glCompressedTexSubImage2D", "unknown texture for target");
7930 return; 7933 return;
7931 } 7934 }
7932 GLenum type = 0; 7935 GLenum type = 0;
7933 GLenum internal_format = 0; 7936 GLenum internal_format = 0;
7934 if (!info->GetLevelType(target, level, &type, &internal_format)) { 7937 if (!info->GetLevelType(target, level, &type, &internal_format)) {
7935 SetGLError( 7938 SetGLError(
7936 GL_INVALID_OPERATION, 7939 GL_INVALID_OPERATION,
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
7987 void GLES2DecoderImpl::DoCopyTexImage2D( 7990 void GLES2DecoderImpl::DoCopyTexImage2D(
7988 GLenum target, 7991 GLenum target,
7989 GLint level, 7992 GLint level,
7990 GLenum internal_format, 7993 GLenum internal_format,
7991 GLint x, 7994 GLint x,
7992 GLint y, 7995 GLint y,
7993 GLsizei width, 7996 GLsizei width,
7994 GLsizei height, 7997 GLsizei height,
7995 GLint border) { 7998 GLint border) {
7996 DCHECK(!ShouldDeferReads()); 7999 DCHECK(!ShouldDeferReads());
7997 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target); 8000 Texture* info = GetTextureInfoForTarget(target);
7998 if (!info) { 8001 if (!info) {
7999 SetGLError(GL_INVALID_OPERATION, 8002 SetGLError(GL_INVALID_OPERATION,
8000 "glCopyTexImage2D", "unknown texture for target"); 8003 "glCopyTexImage2D", "unknown texture for target");
8001 return; 8004 return;
8002 } 8005 }
8003 if (info->IsImmutable()) { 8006 if (info->IsImmutable()) {
8004 SetGLError(GL_INVALID_OPERATION, 8007 SetGLError(GL_INVALID_OPERATION,
8005 "glCopyTexImage2D", "texture is immutable"); 8008 "glCopyTexImage2D", "texture is immutable");
8006 } 8009 }
8007 if (!texture_manager()->ValidForTarget(target, level, width, height, 1) || 8010 if (!texture_manager()->ValidForTarget(target, level, width, height, 1) ||
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
8103 void GLES2DecoderImpl::DoCopyTexSubImage2D( 8106 void GLES2DecoderImpl::DoCopyTexSubImage2D(
8104 GLenum target, 8107 GLenum target,
8105 GLint level, 8108 GLint level,
8106 GLint xoffset, 8109 GLint xoffset,
8107 GLint yoffset, 8110 GLint yoffset,
8108 GLint x, 8111 GLint x,
8109 GLint y, 8112 GLint y,
8110 GLsizei width, 8113 GLsizei width,
8111 GLsizei height) { 8114 GLsizei height) {
8112 DCHECK(!ShouldDeferReads()); 8115 DCHECK(!ShouldDeferReads());
8113 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target); 8116 Texture* info = GetTextureInfoForTarget(target);
8114 if (!info) { 8117 if (!info) {
8115 SetGLError(GL_INVALID_OPERATION, 8118 SetGLError(GL_INVALID_OPERATION,
8116 "glCopyTexSubImage2D", "unknown texture for target"); 8119 "glCopyTexSubImage2D", "unknown texture for target");
8117 return; 8120 return;
8118 } 8121 }
8119 GLenum type = 0; 8122 GLenum type = 0;
8120 GLenum format = 0; 8123 GLenum format = 0;
8121 if (!info->GetLevelType(target, level, &type, &format) || 8124 if (!info->GetLevelType(target, level, &type, &format) ||
8122 !info->ValidForTexture( 8125 !info->ValidForTexture(
8123 target, level, xoffset, yoffset, width, height, format, type)) { 8126 target, level, xoffset, yoffset, width, height, format, type)) {
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
8225 return false; 8228 return false;
8226 } 8229 }
8227 if (!validators_->texture_format.IsValid(format)) { 8230 if (!validators_->texture_format.IsValid(format)) {
8228 SetGLErrorInvalidEnum(function_name, format, "format"); 8231 SetGLErrorInvalidEnum(function_name, format, "format");
8229 return false; 8232 return false;
8230 } 8233 }
8231 if (!validators_->pixel_type.IsValid(type)) { 8234 if (!validators_->pixel_type.IsValid(type)) {
8232 SetGLErrorInvalidEnum(function_name, type, "type"); 8235 SetGLErrorInvalidEnum(function_name, type, "type");
8233 return false; 8236 return false;
8234 } 8237 }
8235 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target); 8238 Texture* info = GetTextureInfoForTarget(target);
8236 if (!info) { 8239 if (!info) {
8237 SetGLError(GL_INVALID_OPERATION, 8240 SetGLError(GL_INVALID_OPERATION,
8238 function_name, "unknown texture for target"); 8241 function_name, "unknown texture for target");
8239 return false; 8242 return false;
8240 } 8243 }
8241 GLenum current_type = 0; 8244 GLenum current_type = 0;
8242 GLenum internal_format = 0; 8245 GLenum internal_format = 0;
8243 if (!info->GetLevelType(target, level, &current_type, &internal_format)) { 8246 if (!info->GetLevelType(target, level, &current_type, &internal_format)) {
8244 SetGLError( 8247 SetGLError(
8245 GL_INVALID_OPERATION, function_name, "level does not exist."); 8248 GL_INVALID_OPERATION, function_name, "level does not exist.");
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
8287 GLsizei width, 8290 GLsizei width,
8288 GLsizei height, 8291 GLsizei height,
8289 GLenum format, 8292 GLenum format,
8290 GLenum type, 8293 GLenum type,
8291 const void * data) { 8294 const void * data) {
8292 error::Error error = error::kNoError; 8295 error::Error error = error::kNoError;
8293 if (!ValidateTexSubImage2D(&error, "glTexSubImage2D", target, level, 8296 if (!ValidateTexSubImage2D(&error, "glTexSubImage2D", target, level,
8294 xoffset, yoffset, width, height, format, type, data)) { 8297 xoffset, yoffset, width, height, format, type, data)) {
8295 return error; 8298 return error;
8296 } 8299 }
8297 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target); 8300 Texture* info = GetTextureInfoForTarget(target);
8298 GLsizei tex_width = 0; 8301 GLsizei tex_width = 0;
8299 GLsizei tex_height = 0; 8302 GLsizei tex_height = 0;
8300 bool ok = info->GetLevelSize(target, level, &tex_width, &tex_height); 8303 bool ok = info->GetLevelSize(target, level, &tex_width, &tex_height);
8301 DCHECK(ok); 8304 DCHECK(ok);
8302 if (xoffset != 0 || yoffset != 0 || 8305 if (xoffset != 0 || yoffset != 0 ||
8303 width != tex_width || height != tex_height) { 8306 width != tex_width || height != tex_height) {
8304 if (!texture_manager()->ClearTextureLevel(this, info, target, level)) { 8307 if (!texture_manager()->ClearTextureLevel(this, info, target, level)) {
8305 SetGLError(GL_OUT_OF_MEMORY, "glTexSubImage2D", "dimensions too big"); 8308 SetGLError(GL_OUT_OF_MEMORY, "glTexSubImage2D", "dimensions too big");
8306 return error::kNoError; 8309 return error::kNoError;
8307 } 8310 }
(...skipping 12 matching lines...) Expand all
8320 } else { 8323 } else {
8321 ScopedTextureUploadTimer timer(this); 8324 ScopedTextureUploadTimer timer(this);
8322 glTexSubImage2D( 8325 glTexSubImage2D(
8323 target, level, xoffset, yoffset, width, height, format, type, data); 8326 target, level, xoffset, yoffset, width, height, format, type, data);
8324 } 8327 }
8325 texture_manager()->SetLevelCleared(info, target, level, true); 8328 texture_manager()->SetLevelCleared(info, target, level, true);
8326 return error::kNoError; 8329 return error::kNoError;
8327 } 8330 }
8328 8331
8329 error::Error GLES2DecoderImpl::HandleTexSubImage2D( 8332 error::Error GLES2DecoderImpl::HandleTexSubImage2D(
8330 uint32 immediate_data_size, const gles2::TexSubImage2D& c) { 8333 uint32 immediate_data_size, const cmds::TexSubImage2D& c) {
8331 TRACE_EVENT0("gpu", "GLES2DecoderImpl::HandleTexSubImage2D"); 8334 TRACE_EVENT0("gpu", "GLES2DecoderImpl::HandleTexSubImage2D");
8332 GLboolean internal = static_cast<GLboolean>(c.internal); 8335 GLboolean internal = static_cast<GLboolean>(c.internal);
8333 if (internal == GL_TRUE && tex_image_2d_failed_) 8336 if (internal == GL_TRUE && tex_image_2d_failed_)
8334 return error::kNoError; 8337 return error::kNoError;
8335 8338
8336 GLenum target = static_cast<GLenum>(c.target); 8339 GLenum target = static_cast<GLenum>(c.target);
8337 GLint level = static_cast<GLint>(c.level); 8340 GLint level = static_cast<GLint>(c.level);
8338 GLint xoffset = static_cast<GLint>(c.xoffset); 8341 GLint xoffset = static_cast<GLint>(c.xoffset);
8339 GLint yoffset = static_cast<GLint>(c.yoffset); 8342 GLint yoffset = static_cast<GLint>(c.yoffset);
8340 GLsizei width = static_cast<GLsizei>(c.width); 8343 GLsizei width = static_cast<GLsizei>(c.width);
8341 GLsizei height = static_cast<GLsizei>(c.height); 8344 GLsizei height = static_cast<GLsizei>(c.height);
8342 GLenum format = static_cast<GLenum>(c.format); 8345 GLenum format = static_cast<GLenum>(c.format);
8343 GLenum type = static_cast<GLenum>(c.type); 8346 GLenum type = static_cast<GLenum>(c.type);
8344 uint32 data_size; 8347 uint32 data_size;
8345 if (!GLES2Util::ComputeImageDataSizes( 8348 if (!GLES2Util::ComputeImageDataSizes(
8346 width, height, format, type, state_.unpack_alignment, &data_size, 8349 width, height, format, type, state_.unpack_alignment, &data_size,
8347 NULL, NULL)) { 8350 NULL, NULL)) {
8348 return error::kOutOfBounds; 8351 return error::kOutOfBounds;
8349 } 8352 }
8350 const void* pixels = GetSharedMemoryAs<const void*>( 8353 const void* pixels = GetSharedMemoryAs<const void*>(
8351 c.pixels_shm_id, c.pixels_shm_offset, data_size); 8354 c.pixels_shm_id, c.pixels_shm_offset, data_size);
8352 return DoTexSubImage2D( 8355 return DoTexSubImage2D(
8353 target, level, xoffset, yoffset, width, height, format, type, pixels); 8356 target, level, xoffset, yoffset, width, height, format, type, pixels);
8354 } 8357 }
8355 8358
8356 error::Error GLES2DecoderImpl::HandleTexSubImage2DImmediate( 8359 error::Error GLES2DecoderImpl::HandleTexSubImage2DImmediate(
8357 uint32 immediate_data_size, const gles2::TexSubImage2DImmediate& c) { 8360 uint32 immediate_data_size, const cmds::TexSubImage2DImmediate& c) {
8358 GLboolean internal = static_cast<GLboolean>(c.internal); 8361 GLboolean internal = static_cast<GLboolean>(c.internal);
8359 if (internal == GL_TRUE && tex_image_2d_failed_) 8362 if (internal == GL_TRUE && tex_image_2d_failed_)
8360 return error::kNoError; 8363 return error::kNoError;
8361 8364
8362 GLenum target = static_cast<GLenum>(c.target); 8365 GLenum target = static_cast<GLenum>(c.target);
8363 GLint level = static_cast<GLint>(c.level); 8366 GLint level = static_cast<GLint>(c.level);
8364 GLint xoffset = static_cast<GLint>(c.xoffset); 8367 GLint xoffset = static_cast<GLint>(c.xoffset);
8365 GLint yoffset = static_cast<GLint>(c.yoffset); 8368 GLint yoffset = static_cast<GLint>(c.yoffset);
8366 GLsizei width = static_cast<GLsizei>(c.width); 8369 GLsizei width = static_cast<GLsizei>(c.width);
8367 GLsizei height = static_cast<GLsizei>(c.height); 8370 GLsizei height = static_cast<GLsizei>(c.height);
8368 GLenum format = static_cast<GLenum>(c.format); 8371 GLenum format = static_cast<GLenum>(c.format);
8369 GLenum type = static_cast<GLenum>(c.type); 8372 GLenum type = static_cast<GLenum>(c.type);
8370 uint32 data_size; 8373 uint32 data_size;
8371 if (!GLES2Util::ComputeImageDataSizes( 8374 if (!GLES2Util::ComputeImageDataSizes(
8372 width, height, format, type, state_.unpack_alignment, &data_size, 8375 width, height, format, type, state_.unpack_alignment, &data_size,
8373 NULL, NULL)) { 8376 NULL, NULL)) {
8374 return error::kOutOfBounds; 8377 return error::kOutOfBounds;
8375 } 8378 }
8376 const void* pixels = GetImmediateDataAs<const void*>( 8379 const void* pixels = GetImmediateDataAs<const void*>(
8377 c, data_size, immediate_data_size); 8380 c, data_size, immediate_data_size);
8378 return DoTexSubImage2D( 8381 return DoTexSubImage2D(
8379 target, level, xoffset, yoffset, width, height, format, type, pixels); 8382 target, level, xoffset, yoffset, width, height, format, type, pixels);
8380 } 8383 }
8381 8384
8382 error::Error GLES2DecoderImpl::HandleGetVertexAttribPointerv( 8385 error::Error GLES2DecoderImpl::HandleGetVertexAttribPointerv(
8383 uint32 immediate_data_size, const gles2::GetVertexAttribPointerv& c) { 8386 uint32 immediate_data_size, const cmds::GetVertexAttribPointerv& c) {
8384 GLuint index = static_cast<GLuint>(c.index); 8387 GLuint index = static_cast<GLuint>(c.index);
8385 GLenum pname = static_cast<GLenum>(c.pname); 8388 GLenum pname = static_cast<GLenum>(c.pname);
8386 typedef gles2::GetVertexAttribPointerv::Result Result; 8389 typedef cmds::GetVertexAttribPointerv::Result Result;
8387 Result* result = GetSharedMemoryAs<Result*>( 8390 Result* result = GetSharedMemoryAs<Result*>(
8388 c.pointer_shm_id, c.pointer_shm_offset, Result::ComputeSize(1)); 8391 c.pointer_shm_id, c.pointer_shm_offset, Result::ComputeSize(1));
8389 if (!result) { 8392 if (!result) {
8390 return error::kOutOfBounds; 8393 return error::kOutOfBounds;
8391 } 8394 }
8392 // Check that the client initialized the result. 8395 // Check that the client initialized the result.
8393 if (result->size != 0) { 8396 if (result->size != 0) {
8394 return error::kInvalidArguments; 8397 return error::kInvalidArguments;
8395 } 8398 }
8396 if (!validators_->vertex_pointer.IsValid(pname)) { 8399 if (!validators_->vertex_pointer.IsValid(pname)) {
8397 SetGLErrorInvalidEnum("glGetVertexAttribPointerv", pname, "pname"); 8400 SetGLErrorInvalidEnum("glGetVertexAttribPointerv", pname, "pname");
8398 return error::kNoError; 8401 return error::kNoError;
8399 } 8402 }
8400 if (index >= group_->max_vertex_attribs()) { 8403 if (index >= group_->max_vertex_attribs()) {
8401 SetGLError(GL_INVALID_VALUE, 8404 SetGLError(GL_INVALID_VALUE,
8402 "glGetVertexAttribPointerv", "index out of range."); 8405 "glGetVertexAttribPointerv", "index out of range.");
8403 return error::kNoError; 8406 return error::kNoError;
8404 } 8407 }
8405 result->SetNumResults(1); 8408 result->SetNumResults(1);
8406 *result->GetData() = 8409 *result->GetData() =
8407 state_.vertex_attrib_manager->GetVertexAttribInfo(index)->offset(); 8410 state_.vertex_attrib_manager->GetVertexAttrib(index)->offset();
8408 return error::kNoError; 8411 return error::kNoError;
8409 } 8412 }
8410 8413
8411 bool GLES2DecoderImpl::GetUniformSetup( 8414 bool GLES2DecoderImpl::GetUniformSetup(
8412 GLuint program, GLint fake_location, 8415 GLuint program, GLint fake_location,
8413 uint32 shm_id, uint32 shm_offset, 8416 uint32 shm_id, uint32 shm_offset,
8414 error::Error* error, GLint* real_location, 8417 error::Error* error, GLint* real_location,
8415 GLuint* service_id, void** result_pointer, GLenum* result_type) { 8418 GLuint* service_id, void** result_pointer, GLenum* result_type) {
8416 DCHECK(error); 8419 DCHECK(error);
8417 DCHECK(service_id); 8420 DCHECK(service_id);
8418 DCHECK(result_pointer); 8421 DCHECK(result_pointer);
8419 DCHECK(result_type); 8422 DCHECK(result_type);
8420 DCHECK(real_location); 8423 DCHECK(real_location);
8421 *error = error::kNoError; 8424 *error = error::kNoError;
8422 // Make sure we have enough room for the result on failure. 8425 // Make sure we have enough room for the result on failure.
8423 SizedResult<GLint>* result; 8426 SizedResult<GLint>* result;
8424 result = GetSharedMemoryAs<SizedResult<GLint>*>( 8427 result = GetSharedMemoryAs<SizedResult<GLint>*>(
8425 shm_id, shm_offset, SizedResult<GLint>::ComputeSize(0)); 8428 shm_id, shm_offset, SizedResult<GLint>::ComputeSize(0));
8426 if (!result) { 8429 if (!result) {
8427 *error = error::kOutOfBounds; 8430 *error = error::kOutOfBounds;
8428 return false; 8431 return false;
8429 } 8432 }
8430 *result_pointer = result; 8433 *result_pointer = result;
8431 // Set the result size to 0 so the client does not have to check for success. 8434 // Set the result size to 0 so the client does not have to check for success.
8432 result->SetNumResults(0); 8435 result->SetNumResults(0);
8433 ProgramManager::ProgramInfo* info = GetProgramInfoNotShader( 8436 Program* info = GetProgramInfoNotShader(
8434 program, "glGetUniform"); 8437 program, "glGetUniform");
8435 if (!info) { 8438 if (!info) {
8436 return false; 8439 return false;
8437 } 8440 }
8438 if (!info->IsValid()) { 8441 if (!info->IsValid()) {
8439 // Program was not linked successfully. (ie, glLinkProgram) 8442 // Program was not linked successfully. (ie, glLinkProgram)
8440 SetGLError(GL_INVALID_OPERATION, "glGetUniform", "program not linked"); 8443 SetGLError(GL_INVALID_OPERATION, "glGetUniform", "program not linked");
8441 return false; 8444 return false;
8442 } 8445 }
8443 *service_id = info->service_id(); 8446 *service_id = info->service_id();
8444 GLint array_index = -1; 8447 GLint array_index = -1;
8445 const ProgramManager::ProgramInfo::UniformInfo* uniform_info = 8448 const Program::UniformInfo* uniform_info =
8446 info->GetUniformInfoByFakeLocation( 8449 info->GetUniformInfoByFakeLocation(
8447 fake_location, real_location, &array_index); 8450 fake_location, real_location, &array_index);
8448 if (!uniform_info) { 8451 if (!uniform_info) {
8449 // No such location. 8452 // No such location.
8450 SetGLError(GL_INVALID_OPERATION, "glGetUniform", "unknown location"); 8453 SetGLError(GL_INVALID_OPERATION, "glGetUniform", "unknown location");
8451 return false; 8454 return false;
8452 } 8455 }
8453 GLenum type = uniform_info->type; 8456 GLenum type = uniform_info->type;
8454 GLsizei size = GLES2Util::GetGLDataTypeSizeForUniforms(type); 8457 GLsizei size = GLES2Util::GetGLDataTypeSizeForUniforms(type);
8455 if (size == 0) { 8458 if (size == 0) {
8456 SetGLError(GL_INVALID_OPERATION, "glGetUniform", "unknown type"); 8459 SetGLError(GL_INVALID_OPERATION, "glGetUniform", "unknown type");
8457 return false; 8460 return false;
8458 } 8461 }
8459 result = GetSharedMemoryAs<SizedResult<GLint>*>( 8462 result = GetSharedMemoryAs<SizedResult<GLint>*>(
8460 shm_id, shm_offset, SizedResult<GLint>::ComputeSizeFromBytes(size)); 8463 shm_id, shm_offset, SizedResult<GLint>::ComputeSizeFromBytes(size));
8461 if (!result) { 8464 if (!result) {
8462 *error = error::kOutOfBounds; 8465 *error = error::kOutOfBounds;
8463 return false; 8466 return false;
8464 } 8467 }
8465 result->size = size; 8468 result->size = size;
8466 *result_type = type; 8469 *result_type = type;
8467 return true; 8470 return true;
8468 } 8471 }
8469 8472
8470 error::Error GLES2DecoderImpl::HandleGetUniformiv( 8473 error::Error GLES2DecoderImpl::HandleGetUniformiv(
8471 uint32 immediate_data_size, const gles2::GetUniformiv& c) { 8474 uint32 immediate_data_size, const cmds::GetUniformiv& c) {
8472 GLuint program = c.program; 8475 GLuint program = c.program;
8473 GLint fake_location = c.location; 8476 GLint fake_location = c.location;
8474 GLuint service_id; 8477 GLuint service_id;
8475 GLenum result_type; 8478 GLenum result_type;
8476 GLint real_location = -1; 8479 GLint real_location = -1;
8477 Error error; 8480 Error error;
8478 void* result; 8481 void* result;
8479 if (GetUniformSetup( 8482 if (GetUniformSetup(
8480 program, fake_location, c.params_shm_id, c.params_shm_offset, 8483 program, fake_location, c.params_shm_id, c.params_shm_offset,
8481 &error, &real_location, &service_id, &result, &result_type)) { 8484 &error, &real_location, &service_id, &result, &result_type)) {
8482 glGetUniformiv( 8485 glGetUniformiv(
8483 service_id, real_location, 8486 service_id, real_location,
8484 static_cast<gles2::GetUniformiv::Result*>(result)->GetData()); 8487 static_cast<cmds::GetUniformiv::Result*>(result)->GetData());
8485 } 8488 }
8486 return error; 8489 return error;
8487 } 8490 }
8488 8491
8489 error::Error GLES2DecoderImpl::HandleGetUniformfv( 8492 error::Error GLES2DecoderImpl::HandleGetUniformfv(
8490 uint32 immediate_data_size, const gles2::GetUniformfv& c) { 8493 uint32 immediate_data_size, const cmds::GetUniformfv& c) {
8491 GLuint program = c.program; 8494 GLuint program = c.program;
8492 GLint fake_location = c.location; 8495 GLint fake_location = c.location;
8493 GLuint service_id; 8496 GLuint service_id;
8494 GLint real_location = -1; 8497 GLint real_location = -1;
8495 Error error; 8498 Error error;
8496 typedef gles2::GetUniformfv::Result Result; 8499 typedef cmds::GetUniformfv::Result Result;
8497 Result* result; 8500 Result* result;
8498 GLenum result_type; 8501 GLenum result_type;
8499 if (GetUniformSetup( 8502 if (GetUniformSetup(
8500 program, fake_location, c.params_shm_id, c.params_shm_offset, 8503 program, fake_location, c.params_shm_id, c.params_shm_offset,
8501 &error, &real_location, &service_id, 8504 &error, &real_location, &service_id,
8502 reinterpret_cast<void**>(&result), &result_type)) { 8505 reinterpret_cast<void**>(&result), &result_type)) {
8503 if (result_type == GL_BOOL || result_type == GL_BOOL_VEC2 || 8506 if (result_type == GL_BOOL || result_type == GL_BOOL_VEC2 ||
8504 result_type == GL_BOOL_VEC3 || result_type == GL_BOOL_VEC4) { 8507 result_type == GL_BOOL_VEC3 || result_type == GL_BOOL_VEC4) {
8505 GLsizei num_values = result->GetNumResults(); 8508 GLsizei num_values = result->GetNumResults();
8506 scoped_array<GLint> temp(new GLint[num_values]); 8509 scoped_array<GLint> temp(new GLint[num_values]);
8507 glGetUniformiv(service_id, real_location, temp.get()); 8510 glGetUniformiv(service_id, real_location, temp.get());
8508 GLfloat* dst = result->GetData(); 8511 GLfloat* dst = result->GetData();
8509 for (GLsizei ii = 0; ii < num_values; ++ii) { 8512 for (GLsizei ii = 0; ii < num_values; ++ii) {
8510 dst[ii] = (temp[ii] != 0); 8513 dst[ii] = (temp[ii] != 0);
8511 } 8514 }
8512 } else { 8515 } else {
8513 glGetUniformfv(service_id, real_location, result->GetData()); 8516 glGetUniformfv(service_id, real_location, result->GetData());
8514 } 8517 }
8515 } 8518 }
8516 return error; 8519 return error;
8517 } 8520 }
8518 8521
8519 error::Error GLES2DecoderImpl::HandleGetShaderPrecisionFormat( 8522 error::Error GLES2DecoderImpl::HandleGetShaderPrecisionFormat(
8520 uint32 immediate_data_size, const gles2::GetShaderPrecisionFormat& c) { 8523 uint32 immediate_data_size, const cmds::GetShaderPrecisionFormat& c) {
8521 GLenum shader_type = static_cast<GLenum>(c.shadertype); 8524 GLenum shader_type = static_cast<GLenum>(c.shadertype);
8522 GLenum precision_type = static_cast<GLenum>(c.precisiontype); 8525 GLenum precision_type = static_cast<GLenum>(c.precisiontype);
8523 typedef gles2::GetShaderPrecisionFormat::Result Result; 8526 typedef cmds::GetShaderPrecisionFormat::Result Result;
8524 Result* result = GetSharedMemoryAs<Result*>( 8527 Result* result = GetSharedMemoryAs<Result*>(
8525 c.result_shm_id, c.result_shm_offset, sizeof(*result)); 8528 c.result_shm_id, c.result_shm_offset, sizeof(*result));
8526 if (!result) { 8529 if (!result) {
8527 return error::kOutOfBounds; 8530 return error::kOutOfBounds;
8528 } 8531 }
8529 // Check that the client initialized the result. 8532 // Check that the client initialized the result.
8530 if (result->success != 0) { 8533 if (result->success != 0) {
8531 return error::kInvalidArguments; 8534 return error::kInvalidArguments;
8532 } 8535 }
8533 if (!validators_->shader_type.IsValid(shader_type)) { 8536 if (!validators_->shader_type.IsValid(shader_type)) {
(...skipping 26 matching lines...) Expand all
8560 result->precision = 23; 8563 result->precision = 23;
8561 break; 8564 break;
8562 default: 8565 default:
8563 NOTREACHED(); 8566 NOTREACHED();
8564 break; 8567 break;
8565 } 8568 }
8566 return error::kNoError; 8569 return error::kNoError;
8567 } 8570 }
8568 8571
8569 error::Error GLES2DecoderImpl::HandleGetAttachedShaders( 8572 error::Error GLES2DecoderImpl::HandleGetAttachedShaders(
8570 uint32 immediate_data_size, const gles2::GetAttachedShaders& c) { 8573 uint32 immediate_data_size, const cmds::GetAttachedShaders& c) {
8571 uint32 result_size = c.result_size; 8574 uint32 result_size = c.result_size;
8572 GLuint program = static_cast<GLuint>(c.program); 8575 GLuint program = static_cast<GLuint>(c.program);
8573 ProgramManager::ProgramInfo* info = GetProgramInfoNotShader( 8576 Program* info = GetProgramInfoNotShader(
8574 program, "glGetAttachedShaders"); 8577 program, "glGetAttachedShaders");
8575 if (!info) { 8578 if (!info) {
8576 return error::kNoError; 8579 return error::kNoError;
8577 } 8580 }
8578 typedef gles2::GetAttachedShaders::Result Result; 8581 typedef cmds::GetAttachedShaders::Result Result;
8579 uint32 max_count = Result::ComputeMaxResults(result_size); 8582 uint32 max_count = Result::ComputeMaxResults(result_size);
8580 Result* result = GetSharedMemoryAs<Result*>( 8583 Result* result = GetSharedMemoryAs<Result*>(
8581 c.result_shm_id, c.result_shm_offset, Result::ComputeSize(max_count)); 8584 c.result_shm_id, c.result_shm_offset, Result::ComputeSize(max_count));
8582 if (!result) { 8585 if (!result) {
8583 return error::kOutOfBounds; 8586 return error::kOutOfBounds;
8584 } 8587 }
8585 // Check that the client initialized the result. 8588 // Check that the client initialized the result.
8586 if (result->size != 0) { 8589 if (result->size != 0) {
8587 return error::kInvalidArguments; 8590 return error::kInvalidArguments;
8588 } 8591 }
8589 GLsizei count = 0; 8592 GLsizei count = 0;
8590 glGetAttachedShaders( 8593 glGetAttachedShaders(
8591 info->service_id(), max_count, &count, result->GetData()); 8594 info->service_id(), max_count, &count, result->GetData());
8592 for (GLsizei ii = 0; ii < count; ++ii) { 8595 for (GLsizei ii = 0; ii < count; ++ii) {
8593 if (!shader_manager()->GetClientId(result->GetData()[ii], 8596 if (!shader_manager()->GetClientId(result->GetData()[ii],
8594 &result->GetData()[ii])) { 8597 &result->GetData()[ii])) {
8595 NOTREACHED(); 8598 NOTREACHED();
8596 return error::kGenericError; 8599 return error::kGenericError;
8597 } 8600 }
8598 } 8601 }
8599 result->SetNumResults(count); 8602 result->SetNumResults(count);
8600 return error::kNoError; 8603 return error::kNoError;
8601 } 8604 }
8602 8605
8603 error::Error GLES2DecoderImpl::HandleGetActiveUniform( 8606 error::Error GLES2DecoderImpl::HandleGetActiveUniform(
8604 uint32 immediate_data_size, const gles2::GetActiveUniform& c) { 8607 uint32 immediate_data_size, const cmds::GetActiveUniform& c) {
8605 GLuint program = c.program; 8608 GLuint program = c.program;
8606 GLuint index = c.index; 8609 GLuint index = c.index;
8607 uint32 name_bucket_id = c.name_bucket_id; 8610 uint32 name_bucket_id = c.name_bucket_id;
8608 typedef gles2::GetActiveUniform::Result Result; 8611 typedef cmds::GetActiveUniform::Result Result;
8609 Result* result = GetSharedMemoryAs<Result*>( 8612 Result* result = GetSharedMemoryAs<Result*>(
8610 c.result_shm_id, c.result_shm_offset, sizeof(*result)); 8613 c.result_shm_id, c.result_shm_offset, sizeof(*result));
8611 if (!result) { 8614 if (!result) {
8612 return error::kOutOfBounds; 8615 return error::kOutOfBounds;
8613 } 8616 }
8614 // Check that the client initialized the result. 8617 // Check that the client initialized the result.
8615 if (result->success != 0) { 8618 if (result->success != 0) {
8616 return error::kInvalidArguments; 8619 return error::kInvalidArguments;
8617 } 8620 }
8618 ProgramManager::ProgramInfo* info = GetProgramInfoNotShader( 8621 Program* info = GetProgramInfoNotShader(
8619 program, "glGetActiveUniform"); 8622 program, "glGetActiveUniform");
8620 if (!info) { 8623 if (!info) {
8621 return error::kNoError; 8624 return error::kNoError;
8622 } 8625 }
8623 const ProgramManager::ProgramInfo::UniformInfo* uniform_info = 8626 const Program::UniformInfo* uniform_info =
8624 info->GetUniformInfo(index); 8627 info->GetUniformInfo(index);
8625 if (!uniform_info) { 8628 if (!uniform_info) {
8626 SetGLError(GL_INVALID_VALUE, "glGetActiveUniform", "index out of range"); 8629 SetGLError(GL_INVALID_VALUE, "glGetActiveUniform", "index out of range");
8627 return error::kNoError; 8630 return error::kNoError;
8628 } 8631 }
8629 result->success = 1; // true. 8632 result->success = 1; // true.
8630 result->size = uniform_info->size; 8633 result->size = uniform_info->size;
8631 result->type = uniform_info->type; 8634 result->type = uniform_info->type;
8632 Bucket* bucket = CreateBucket(name_bucket_id); 8635 Bucket* bucket = CreateBucket(name_bucket_id);
8633 bucket->SetFromString(uniform_info->name.c_str()); 8636 bucket->SetFromString(uniform_info->name.c_str());
8634 return error::kNoError; 8637 return error::kNoError;
8635 } 8638 }
8636 8639
8637 error::Error GLES2DecoderImpl::HandleGetActiveAttrib( 8640 error::Error GLES2DecoderImpl::HandleGetActiveAttrib(
8638 uint32 immediate_data_size, const gles2::GetActiveAttrib& c) { 8641 uint32 immediate_data_size, const cmds::GetActiveAttrib& c) {
8639 GLuint program = c.program; 8642 GLuint program = c.program;
8640 GLuint index = c.index; 8643 GLuint index = c.index;
8641 uint32 name_bucket_id = c.name_bucket_id; 8644 uint32 name_bucket_id = c.name_bucket_id;
8642 typedef gles2::GetActiveAttrib::Result Result; 8645 typedef cmds::GetActiveAttrib::Result Result;
8643 Result* result = GetSharedMemoryAs<Result*>( 8646 Result* result = GetSharedMemoryAs<Result*>(
8644 c.result_shm_id, c.result_shm_offset, sizeof(*result)); 8647 c.result_shm_id, c.result_shm_offset, sizeof(*result));
8645 if (!result) { 8648 if (!result) {
8646 return error::kOutOfBounds; 8649 return error::kOutOfBounds;
8647 } 8650 }
8648 // Check that the client initialized the result. 8651 // Check that the client initialized the result.
8649 if (result->success != 0) { 8652 if (result->success != 0) {
8650 return error::kInvalidArguments; 8653 return error::kInvalidArguments;
8651 } 8654 }
8652 ProgramManager::ProgramInfo* info = GetProgramInfoNotShader( 8655 Program* info = GetProgramInfoNotShader(
8653 program, "glGetActiveAttrib"); 8656 program, "glGetActiveAttrib");
8654 if (!info) { 8657 if (!info) {
8655 return error::kNoError; 8658 return error::kNoError;
8656 } 8659 }
8657 const ProgramManager::ProgramInfo::VertexAttribInfo* attrib_info = 8660 const Program::VertexAttrib* attrib_info =
8658 info->GetAttribInfo(index); 8661 info->GetAttribInfo(index);
8659 if (!attrib_info) { 8662 if (!attrib_info) {
8660 SetGLError(GL_INVALID_VALUE, "glGetActiveAttrib", "index out of range"); 8663 SetGLError(GL_INVALID_VALUE, "glGetActiveAttrib", "index out of range");
8661 return error::kNoError; 8664 return error::kNoError;
8662 } 8665 }
8663 result->success = 1; // true. 8666 result->success = 1; // true.
8664 result->size = attrib_info->size; 8667 result->size = attrib_info->size;
8665 result->type = attrib_info->type; 8668 result->type = attrib_info->type;
8666 Bucket* bucket = CreateBucket(name_bucket_id); 8669 Bucket* bucket = CreateBucket(name_bucket_id);
8667 bucket->SetFromString(attrib_info->name.c_str()); 8670 bucket->SetFromString(attrib_info->name.c_str());
8668 return error::kNoError; 8671 return error::kNoError;
8669 } 8672 }
8670 8673
8671 error::Error GLES2DecoderImpl::HandleShaderBinary( 8674 error::Error GLES2DecoderImpl::HandleShaderBinary(
8672 uint32 immediate_data_size, const gles2::ShaderBinary& c) { 8675 uint32 immediate_data_size, const cmds::ShaderBinary& c) {
8673 #if 1 // No binary shader support. 8676 #if 1 // No binary shader support.
8674 SetGLError(GL_INVALID_OPERATION, "glShaderBinary", "not supported"); 8677 SetGLError(GL_INVALID_OPERATION, "glShaderBinary", "not supported");
8675 return error::kNoError; 8678 return error::kNoError;
8676 #else 8679 #else
8677 GLsizei n = static_cast<GLsizei>(c.n); 8680 GLsizei n = static_cast<GLsizei>(c.n);
8678 if (n < 0) { 8681 if (n < 0) {
8679 SetGLError(GL_INVALID_VALUE, "glShaderBinary", "n < 0"); 8682 SetGLError(GL_INVALID_VALUE, "glShaderBinary", "n < 0");
8680 return error::kNoError; 8683 return error::kNoError;
8681 } 8684 }
8682 GLsizei length = static_cast<GLsizei>(c.length); 8685 GLsizei length = static_cast<GLsizei>(c.length);
8683 if (length < 0) { 8686 if (length < 0) {
8684 SetGLError(GL_INVALID_VALUE, "glShaderBinary", "length < 0"); 8687 SetGLError(GL_INVALID_VALUE, "glShaderBinary", "length < 0");
8685 return error::kNoError; 8688 return error::kNoError;
8686 } 8689 }
8687 uint32 data_size; 8690 uint32 data_size;
8688 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) { 8691 if (!SafeMultiplyUint32(n, sizeof(GLuint), &data_size)) {
8689 return error::kOutOfBounds; 8692 return error::kOutOfBounds;
8690 } 8693 }
8691 const GLuint* shaders = GetSharedMemoryAs<const GLuint*>( 8694 const GLuint* shaders = GetSharedMemoryAs<const GLuint*>(
8692 c.shaders_shm_id, c.shaders_shm_offset, data_size); 8695 c.shaders_shm_id, c.shaders_shm_offset, data_size);
8693 GLenum binaryformat = static_cast<GLenum>(c.binaryformat); 8696 GLenum binaryformat = static_cast<GLenum>(c.binaryformat);
8694 const void* binary = GetSharedMemoryAs<const void*>( 8697 const void* binary = GetSharedMemoryAs<const void*>(
8695 c.binary_shm_id, c.binary_shm_offset, length); 8698 c.binary_shm_id, c.binary_shm_offset, length);
8696 if (shaders == NULL || binary == NULL) { 8699 if (shaders == NULL || binary == NULL) {
8697 return error::kOutOfBounds; 8700 return error::kOutOfBounds;
8698 } 8701 }
8699 scoped_array<GLuint> service_ids(new GLuint[n]); 8702 scoped_array<GLuint> service_ids(new GLuint[n]);
8700 for (GLsizei ii = 0; ii < n; ++ii) { 8703 for (GLsizei ii = 0; ii < n; ++ii) {
8701 ShaderManager::ShaderInfo* info = GetShaderInfo(shaders[ii]); 8704 Shader* info = GetShader(shaders[ii]);
8702 if (!info) { 8705 if (!info) {
8703 SetGLError(GL_INVALID_VALUE, "glShaderBinary", "unknown shader"); 8706 SetGLError(GL_INVALID_VALUE, "glShaderBinary", "unknown shader");
8704 return error::kNoError; 8707 return error::kNoError;
8705 } 8708 }
8706 service_ids[ii] = info->service_id(); 8709 service_ids[ii] = info->service_id();
8707 } 8710 }
8708 // TODO(gman): call glShaderBinary 8711 // TODO(gman): call glShaderBinary
8709 return error::kNoError; 8712 return error::kNoError;
8710 #endif 8713 #endif
8711 } 8714 }
8712 8715
8713 error::Error GLES2DecoderImpl::HandleSwapBuffers( 8716 error::Error GLES2DecoderImpl::HandleSwapBuffers(
8714 uint32 immediate_data_size, const gles2::SwapBuffers& c) { 8717 uint32 immediate_data_size, const cmds::SwapBuffers& c) {
8715 bool is_offscreen = !!offscreen_target_frame_buffer_.get(); 8718 bool is_offscreen = !!offscreen_target_frame_buffer_.get();
8716 8719
8717 int this_frame_number = frame_number_++; 8720 int this_frame_number = frame_number_++;
8718 // TRACE_EVENT for gpu tests: 8721 // TRACE_EVENT for gpu tests:
8719 TRACE_EVENT_INSTANT2("test_gpu", "SwapBuffersLatency", 8722 TRACE_EVENT_INSTANT2("test_gpu", "SwapBuffersLatency",
8720 "GLImpl", static_cast<int>(gfx::GetGLImplementation()), 8723 "GLImpl", static_cast<int>(gfx::GetGLImplementation()),
8721 "width", (is_offscreen ? offscreen_size_.width() : 8724 "width", (is_offscreen ? offscreen_size_.width() :
8722 surface_->GetSize().width())); 8725 surface_->GetSize().width()));
8723 TRACE_EVENT2("gpu", "GLES2DecoderImpl::HandleSwapBuffers", 8726 TRACE_EVENT2("gpu", "GLES2DecoderImpl::HandleSwapBuffers",
8724 "offscreen", is_offscreen, 8727 "offscreen", is_offscreen,
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
8810 if (!surface_->SwapBuffers()) { 8813 if (!surface_->SwapBuffers()) {
8811 LOG(ERROR) << "Context lost because SwapBuffers failed."; 8814 LOG(ERROR) << "Context lost because SwapBuffers failed.";
8812 return error::kLostContext; 8815 return error::kLostContext;
8813 } 8816 }
8814 } 8817 }
8815 8818
8816 return error::kNoError; 8819 return error::kNoError;
8817 } 8820 }
8818 8821
8819 error::Error GLES2DecoderImpl::HandleEnableFeatureCHROMIUM( 8822 error::Error GLES2DecoderImpl::HandleEnableFeatureCHROMIUM(
8820 uint32 immediate_data_size, const gles2::EnableFeatureCHROMIUM& c) { 8823 uint32 immediate_data_size, const cmds::EnableFeatureCHROMIUM& c) {
8821 Bucket* bucket = GetBucket(c.bucket_id); 8824 Bucket* bucket = GetBucket(c.bucket_id);
8822 if (!bucket || bucket->size() == 0) { 8825 if (!bucket || bucket->size() == 0) {
8823 return error::kInvalidArguments; 8826 return error::kInvalidArguments;
8824 } 8827 }
8825 typedef gles2::EnableFeatureCHROMIUM::Result Result; 8828 typedef cmds::EnableFeatureCHROMIUM::Result Result;
8826 Result* result = GetSharedMemoryAs<Result*>( 8829 Result* result = GetSharedMemoryAs<Result*>(
8827 c.result_shm_id, c.result_shm_offset, sizeof(*result)); 8830 c.result_shm_id, c.result_shm_offset, sizeof(*result));
8828 if (!result) { 8831 if (!result) {
8829 return error::kOutOfBounds; 8832 return error::kOutOfBounds;
8830 } 8833 }
8831 // Check that the client initialized the result. 8834 // Check that the client initialized the result.
8832 if (*result != 0) { 8835 if (*result != 0) {
8833 return error::kInvalidArguments; 8836 return error::kInvalidArguments;
8834 } 8837 }
8835 std::string feature_str; 8838 std::string feature_str;
(...skipping 22 matching lines...) Expand all
8858 } else { 8861 } else {
8859 return error::kNoError; 8862 return error::kNoError;
8860 } 8863 }
8861 8864
8862 *result = 1; // true. 8865 *result = 1; // true.
8863 return error::kNoError; 8866 return error::kNoError;
8864 } 8867 }
8865 8868
8866 error::Error GLES2DecoderImpl::HandleGetRequestableExtensionsCHROMIUM( 8869 error::Error GLES2DecoderImpl::HandleGetRequestableExtensionsCHROMIUM(
8867 uint32 immediate_data_size, 8870 uint32 immediate_data_size,
8868 const gles2::GetRequestableExtensionsCHROMIUM& c) { 8871 const cmds::GetRequestableExtensionsCHROMIUM& c) {
8869 Bucket* bucket = CreateBucket(c.bucket_id); 8872 Bucket* bucket = CreateBucket(c.bucket_id);
8870 FeatureInfo::Ref info(new FeatureInfo()); 8873 scoped_refptr<FeatureInfo> info(new FeatureInfo());
8871 info->Initialize(disallowed_features_, NULL); 8874 info->Initialize(disallowed_features_, NULL);
8872 bucket->SetFromString(info->extensions().c_str()); 8875 bucket->SetFromString(info->extensions().c_str());
8873 return error::kNoError; 8876 return error::kNoError;
8874 } 8877 }
8875 8878
8876 error::Error GLES2DecoderImpl::HandleRequestExtensionCHROMIUM( 8879 error::Error GLES2DecoderImpl::HandleRequestExtensionCHROMIUM(
8877 uint32 immediate_data_size, const gles2::RequestExtensionCHROMIUM& c) { 8880 uint32 immediate_data_size, const cmds::RequestExtensionCHROMIUM& c) {
8878 Bucket* bucket = GetBucket(c.bucket_id); 8881 Bucket* bucket = GetBucket(c.bucket_id);
8879 if (!bucket || bucket->size() == 0) { 8882 if (!bucket || bucket->size() == 0) {
8880 return error::kInvalidArguments; 8883 return error::kInvalidArguments;
8881 } 8884 }
8882 std::string feature_str; 8885 std::string feature_str;
8883 if (!bucket->GetAsString(&feature_str)) { 8886 if (!bucket->GetAsString(&feature_str)) {
8884 return error::kInvalidArguments; 8887 return error::kInvalidArguments;
8885 } 8888 }
8886 8889
8887 bool desire_webgl_glsl_validation = 8890 bool desire_webgl_glsl_validation =
(...skipping 10 matching lines...) Expand all
8898 derivatives_explicitly_enabled_ = desire_standard_derivatives; 8901 derivatives_explicitly_enabled_ = desire_standard_derivatives;
8899 InitializeShaderTranslator(); 8902 InitializeShaderTranslator();
8900 } 8903 }
8901 8904
8902 UpdateCapabilities(); 8905 UpdateCapabilities();
8903 8906
8904 return error::kNoError; 8907 return error::kNoError;
8905 } 8908 }
8906 8909
8907 error::Error GLES2DecoderImpl::HandleGetMultipleIntegervCHROMIUM( 8910 error::Error GLES2DecoderImpl::HandleGetMultipleIntegervCHROMIUM(
8908 uint32 immediate_data_size, const gles2::GetMultipleIntegervCHROMIUM& c) { 8911 uint32 immediate_data_size, const cmds::GetMultipleIntegervCHROMIUM& c) {
8909 GLuint count = c.count; 8912 GLuint count = c.count;
8910 uint32 pnames_size; 8913 uint32 pnames_size;
8911 if (!SafeMultiplyUint32(count, sizeof(GLenum), &pnames_size)) { 8914 if (!SafeMultiplyUint32(count, sizeof(GLenum), &pnames_size)) {
8912 return error::kOutOfBounds; 8915 return error::kOutOfBounds;
8913 } 8916 }
8914 const GLenum* pnames = GetSharedMemoryAs<const GLenum*>( 8917 const GLenum* pnames = GetSharedMemoryAs<const GLenum*>(
8915 c.pnames_shm_id, c.pnames_shm_offset, pnames_size); 8918 c.pnames_shm_id, c.pnames_shm_offset, pnames_size);
8916 if (pnames == NULL) { 8919 if (pnames == NULL) {
8917 return error::kOutOfBounds; 8920 return error::kOutOfBounds;
8918 } 8921 }
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
8975 8978
8976 // Just to verify. Should this be a DCHECK? 8979 // Just to verify. Should this be a DCHECK?
8977 if (static_cast<uint32>(results - start) != num_results) { 8980 if (static_cast<uint32>(results - start) != num_results) {
8978 return error::kOutOfBounds; 8981 return error::kOutOfBounds;
8979 } 8982 }
8980 8983
8981 return error::kNoError; 8984 return error::kNoError;
8982 } 8985 }
8983 8986
8984 error::Error GLES2DecoderImpl::HandleGetProgramInfoCHROMIUM( 8987 error::Error GLES2DecoderImpl::HandleGetProgramInfoCHROMIUM(
8985 uint32 immediate_data_size, const gles2::GetProgramInfoCHROMIUM& c) { 8988 uint32 immediate_data_size, const cmds::GetProgramInfoCHROMIUM& c) {
8986 GLuint program = static_cast<GLuint>(c.program); 8989 GLuint program = static_cast<GLuint>(c.program);
8987 uint32 bucket_id = c.bucket_id; 8990 uint32 bucket_id = c.bucket_id;
8988 Bucket* bucket = CreateBucket(bucket_id); 8991 Bucket* bucket = CreateBucket(bucket_id);
8989 bucket->SetSize(sizeof(ProgramInfoHeader)); // in case we fail. 8992 bucket->SetSize(sizeof(ProgramInfoHeader)); // in case we fail.
8990 ProgramManager::ProgramInfo* info = NULL; 8993 Program* info = NULL;
8991 info = GetProgramInfo(program); 8994 info = GetProgram(program);
8992 if (!info || !info->IsValid()) { 8995 if (!info || !info->IsValid()) {
8993 return error::kNoError; 8996 return error::kNoError;
8994 } 8997 }
8995 info->GetProgramInfo(program_manager(), bucket); 8998 info->GetProgram(program_manager(), bucket);
8996 return error::kNoError; 8999 return error::kNoError;
8997 } 9000 }
8998 9001
8999 error::ContextLostReason GLES2DecoderImpl::GetContextLostReason() { 9002 error::ContextLostReason GLES2DecoderImpl::GetContextLostReason() {
9000 switch (reset_status_) { 9003 switch (reset_status_) {
9001 case GL_NO_ERROR: 9004 case GL_NO_ERROR:
9002 // TODO(kbr): improve the precision of the error code in this case. 9005 // TODO(kbr): improve the precision of the error code in this case.
9003 // Consider delegating to context for error code if MakeCurrent fails. 9006 // Consider delegating to context for error code if MakeCurrent fails.
9004 return error::kUnknown; 9007 return error::kUnknown;
9005 case GL_GUILTY_CONTEXT_RESET_ARB: 9008 case GL_GUILTY_CONTEXT_RESET_ARB:
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
9051 9054
9052 // Loses any child contexts. 9055 // Loses any child contexts.
9053 for (ChildList::iterator it = children_.begin(); 9056 for (ChildList::iterator it = children_.begin();
9054 it != children_.end(); 9057 it != children_.end();
9055 ++it) { 9058 ++it) {
9056 (*it)->LoseContext(reset_status); 9059 (*it)->LoseContext(reset_status);
9057 } 9060 }
9058 } 9061 }
9059 9062
9060 error::Error GLES2DecoderImpl::HandleLoseContextCHROMIUM( 9063 error::Error GLES2DecoderImpl::HandleLoseContextCHROMIUM(
9061 uint32 immediate_data_size, const gles2::LoseContextCHROMIUM& c) { 9064 uint32 immediate_data_size, const cmds::LoseContextCHROMIUM& c) {
9062 GLenum current = static_cast<GLenum>(c.current); 9065 GLenum current = static_cast<GLenum>(c.current);
9063 GLenum other = static_cast<GLenum>(c.other); 9066 GLenum other = static_cast<GLenum>(c.other);
9064 if (!validators_->reset_status.IsValid(current)) { 9067 if (!validators_->reset_status.IsValid(current)) {
9065 SetGLErrorInvalidEnum("glLoseContextCHROMIUM", current, "current"); 9068 SetGLErrorInvalidEnum("glLoseContextCHROMIUM", current, "current");
9066 } 9069 }
9067 if (!validators_->reset_status.IsValid(other)) { 9070 if (!validators_->reset_status.IsValid(other)) {
9068 SetGLErrorInvalidEnum("glLoseContextCHROMIUM", other, "other"); 9071 SetGLErrorInvalidEnum("glLoseContextCHROMIUM", other, "other");
9069 } 9072 }
9070 group_->LoseContexts(other); 9073 group_->LoseContexts(other);
9071 reset_status_ = current; 9074 reset_status_ = current;
9072 current_decoder_error_ = error::kLostContext; 9075 current_decoder_error_ = error::kLostContext;
9073 return error::kLostContext; 9076 return error::kLostContext;
9074 } 9077 }
9075 9078
9076 error::Error GLES2DecoderImpl::HandleWaitSyncPointCHROMIUM( 9079 error::Error GLES2DecoderImpl::HandleWaitSyncPointCHROMIUM(
9077 uint32 immediate_data_size, const gles2::WaitSyncPointCHROMIUM& c) { 9080 uint32 immediate_data_size, const cmds::WaitSyncPointCHROMIUM& c) {
9078 if (wait_sync_point_callback_.is_null()) 9081 if (wait_sync_point_callback_.is_null())
9079 return error::kNoError; 9082 return error::kNoError;
9080 9083
9081 return wait_sync_point_callback_.Run(c.sync_point) ? 9084 return wait_sync_point_callback_.Run(c.sync_point) ?
9082 error::kNoError : error::kDeferCommandUntilLater; 9085 error::kNoError : error::kDeferCommandUntilLater;
9083 } 9086 }
9084 9087
9085 bool GLES2DecoderImpl::GenQueriesEXTHelper( 9088 bool GLES2DecoderImpl::GenQueriesEXTHelper(
9086 GLsizei n, const GLuint* client_ids) { 9089 GLsizei n, const GLuint* client_ids) {
9087 for (GLsizei ii = 0; ii < n; ++ii) { 9090 for (GLsizei ii = 0; ii < n; ++ii) {
(...skipping 23 matching lines...) Expand all
9111 if (query_manager_.get() == NULL) { 9114 if (query_manager_.get() == NULL) {
9112 return false; 9115 return false;
9113 } 9116 }
9114 if (!query_manager_->ProcessPendingQueries()) { 9117 if (!query_manager_->ProcessPendingQueries()) {
9115 current_decoder_error_ = error::kOutOfBounds; 9118 current_decoder_error_ = error::kOutOfBounds;
9116 } 9119 }
9117 return query_manager_->HavePendingQueries(); 9120 return query_manager_->HavePendingQueries();
9118 } 9121 }
9119 9122
9120 error::Error GLES2DecoderImpl::HandleBeginQueryEXT( 9123 error::Error GLES2DecoderImpl::HandleBeginQueryEXT(
9121 uint32 immediate_data_size, const gles2::BeginQueryEXT& c) { 9124 uint32 immediate_data_size, const cmds::BeginQueryEXT& c) {
9122 GLenum target = static_cast<GLenum>(c.target); 9125 GLenum target = static_cast<GLenum>(c.target);
9123 GLuint client_id = static_cast<GLuint>(c.id); 9126 GLuint client_id = static_cast<GLuint>(c.id);
9124 int32 sync_shm_id = static_cast<int32>(c.sync_data_shm_id); 9127 int32 sync_shm_id = static_cast<int32>(c.sync_data_shm_id);
9125 uint32 sync_shm_offset = static_cast<uint32>(c.sync_data_shm_offset); 9128 uint32 sync_shm_offset = static_cast<uint32>(c.sync_data_shm_offset);
9126 9129
9127 switch (target) { 9130 switch (target) {
9128 case GL_COMMANDS_ISSUED_CHROMIUM: 9131 case GL_COMMANDS_ISSUED_CHROMIUM:
9129 case GL_LATENCY_QUERY_CHROMIUM: 9132 case GL_LATENCY_QUERY_CHROMIUM:
9130 case GL_ASYNC_PIXEL_TRANSFERS_COMPLETED_CHROMIUM: 9133 case GL_ASYNC_PIXEL_TRANSFERS_COMPLETED_CHROMIUM:
9131 break; 9134 break;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
9183 9186
9184 if (!query_manager_->BeginQuery(query)) { 9187 if (!query_manager_->BeginQuery(query)) {
9185 return error::kOutOfBounds; 9188 return error::kOutOfBounds;
9186 } 9189 }
9187 9190
9188 state_.current_query = query; 9191 state_.current_query = query;
9189 return error::kNoError; 9192 return error::kNoError;
9190 } 9193 }
9191 9194
9192 error::Error GLES2DecoderImpl::HandleEndQueryEXT( 9195 error::Error GLES2DecoderImpl::HandleEndQueryEXT(
9193 uint32 immediate_data_size, const gles2::EndQueryEXT& c) { 9196 uint32 immediate_data_size, const cmds::EndQueryEXT& c) {
9194 GLenum target = static_cast<GLenum>(c.target); 9197 GLenum target = static_cast<GLenum>(c.target);
9195 uint32 submit_count = static_cast<GLuint>(c.submit_count); 9198 uint32 submit_count = static_cast<GLuint>(c.submit_count);
9196 9199
9197 if (!state_.current_query) { 9200 if (!state_.current_query) {
9198 SetGLError(GL_INVALID_OPERATION, "glEndQueryEXT", "No active query"); 9201 SetGLError(GL_INVALID_OPERATION, "glEndQueryEXT", "No active query");
9199 return error::kNoError; 9202 return error::kNoError;
9200 } 9203 }
9201 if (state_.current_query->target() != target) { 9204 if (state_.current_query->target() != target) {
9202 SetGLError(GL_INVALID_OPERATION, 9205 SetGLError(GL_INVALID_OPERATION,
9203 "glEndQueryEXT", "target does not match active query"); 9206 "glEndQueryEXT", "target does not match active query");
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
9286 } 9289 }
9287 9290
9288 // Used when OES_vertex_array_object isn't natively supported 9291 // Used when OES_vertex_array_object isn't natively supported
9289 void GLES2DecoderImpl::EmulateVertexArrayState() { 9292 void GLES2DecoderImpl::EmulateVertexArrayState() {
9290 // Setup the Vertex attribute state 9293 // Setup the Vertex attribute state
9291 for (uint32 vv = 0; vv < group_->max_vertex_attribs(); ++vv) { 9294 for (uint32 vv = 0; vv < group_->max_vertex_attribs(); ++vv) {
9292 RestoreStateForAttrib(vv); 9295 RestoreStateForAttrib(vv);
9293 } 9296 }
9294 9297
9295 // Setup the element buffer 9298 // Setup the element buffer
9296 BufferManager::BufferInfo* element_array_buffer = 9299 BufferManager::Buffer* element_array_buffer =
9297 state_.vertex_attrib_manager->element_array_buffer(); 9300 state_.vertex_attrib_manager->element_array_buffer();
9298 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 9301 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,
9299 element_array_buffer ? element_array_buffer->service_id() : 0); 9302 element_array_buffer ? element_array_buffer->service_id() : 0);
9300 } 9303 }
9301 9304
9302 bool GLES2DecoderImpl::DoIsVertexArrayOES(GLuint client_id) { 9305 bool GLES2DecoderImpl::DoIsVertexArrayOES(GLuint client_id) {
9303 const VertexAttribManager* vao = 9306 const VertexAttribManager* vao =
9304 GetVertexAttribManager(client_id); 9307 GetVertexAttribManager(client_id);
9305 return vao && vao->IsValid() && !vao->IsDeleted(); 9308 return vao && vao->IsValid() && !vao->IsDeleted();
9306 } 9309 }
9307 9310
9308 error::Error GLES2DecoderImpl::HandleCreateStreamTextureCHROMIUM( 9311 error::Error GLES2DecoderImpl::HandleCreateStreamTextureCHROMIUM(
9309 uint32 immediate_data_size, 9312 uint32 immediate_data_size,
9310 const gles2::CreateStreamTextureCHROMIUM& c) { 9313 const cmds::CreateStreamTextureCHROMIUM& c) {
9311 if (!features().chromium_stream_texture) { 9314 if (!features().chromium_stream_texture) {
9312 SetGLError(GL_INVALID_OPERATION, 9315 SetGLError(GL_INVALID_OPERATION,
9313 "glOpenStreamTextureCHROMIUM", "" 9316 "glOpenStreamTextureCHROMIUM", ""
9314 "not supported."); 9317 "not supported.");
9315 return error::kNoError; 9318 return error::kNoError;
9316 } 9319 }
9317 9320
9318 uint32 client_id = c.client_id; 9321 uint32 client_id = c.client_id;
9319 typedef gles2::CreateStreamTextureCHROMIUM::Result Result; 9322 typedef cmds::CreateStreamTextureCHROMIUM::Result Result;
9320 Result* result = GetSharedMemoryAs<Result*>( 9323 Result* result = GetSharedMemoryAs<Result*>(
9321 c.result_shm_id, c.result_shm_offset, sizeof(*result)); 9324 c.result_shm_id, c.result_shm_offset, sizeof(*result));
9322 9325
9323 if (!result) 9326 if (!result)
9324 return error::kOutOfBounds; 9327 return error::kOutOfBounds;
9325 *result = GL_ZERO; 9328 *result = GL_ZERO;
9326 TextureManager::TextureInfo* info = 9329 Texture* info =
9327 texture_manager()->GetTextureInfo(client_id); 9330 texture_manager()->GetTexture(client_id);
9328 if (!info) { 9331 if (!info) {
9329 SetGLError(GL_INVALID_VALUE, 9332 SetGLError(GL_INVALID_VALUE,
9330 "glCreateStreamTextureCHROMIUM", "" 9333 "glCreateStreamTextureCHROMIUM", ""
9331 "bad texture id."); 9334 "bad texture id.");
9332 return error::kNoError; 9335 return error::kNoError;
9333 } 9336 }
9334 9337
9335 if (info->IsStreamTexture()) { 9338 if (info->IsStreamTexture()) {
9336 SetGLError(GL_INVALID_OPERATION, 9339 SetGLError(GL_INVALID_OPERATION,
9337 "glCreateStreamTextureCHROMIUM", "" 9340 "glCreateStreamTextureCHROMIUM", ""
(...skipping 21 matching lines...) Expand all
9359 "glCreateStreamTextureCHROMIUM", "" 9362 "glCreateStreamTextureCHROMIUM", ""
9360 "failed to create platform texture."); 9363 "failed to create platform texture.");
9361 } 9364 }
9362 9365
9363 *result = object_id; 9366 *result = object_id;
9364 return error::kNoError; 9367 return error::kNoError;
9365 } 9368 }
9366 9369
9367 error::Error GLES2DecoderImpl::HandleDestroyStreamTextureCHROMIUM( 9370 error::Error GLES2DecoderImpl::HandleDestroyStreamTextureCHROMIUM(
9368 uint32 immediate_data_size, 9371 uint32 immediate_data_size,
9369 const gles2::DestroyStreamTextureCHROMIUM& c) { 9372 const cmds::DestroyStreamTextureCHROMIUM& c) {
9370 GLuint client_id = c.texture; 9373 GLuint client_id = c.texture;
9371 TextureManager::TextureInfo* info = 9374 Texture* info =
9372 texture_manager()->GetTextureInfo(client_id); 9375 texture_manager()->GetTexture(client_id);
9373 if (info && info->IsStreamTexture()) { 9376 if (info && info->IsStreamTexture()) {
9374 if (!stream_texture_manager_) 9377 if (!stream_texture_manager_)
9375 return error::kInvalidArguments; 9378 return error::kInvalidArguments;
9376 9379
9377 stream_texture_manager_->DestroyStreamTexture(info->service_id()); 9380 stream_texture_manager_->DestroyStreamTexture(info->service_id());
9378 info->SetStreamTexture(false); 9381 info->SetStreamTexture(false);
9379 } else { 9382 } else {
9380 SetGLError(GL_INVALID_VALUE, 9383 SetGLError(GL_INVALID_VALUE,
9381 "glDestroyStreamTextureCHROMIUM", "bad texture id."); 9384 "glDestroyStreamTextureCHROMIUM", "bad texture id.");
9382 } 9385 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
9422 // know what's going on. 9425 // know what's going on.
9423 SetGLError( 9426 SetGLError(
9424 GL_INVALID_OPERATION, 9427 GL_INVALID_OPERATION,
9425 "glTexImageIOSurface2DCHROMIUM", 9428 "glTexImageIOSurface2DCHROMIUM",
9426 "requires TEXTURE_RECTANGLE_ARB target"); 9429 "requires TEXTURE_RECTANGLE_ARB target");
9427 return; 9430 return;
9428 } 9431 }
9429 9432
9430 // Default target might be conceptually valid, but disallow it to avoid 9433 // Default target might be conceptually valid, but disallow it to avoid
9431 // accidents. 9434 // accidents.
9432 TextureManager::TextureInfo* info = GetTextureInfoForTargetUnlessDefault( 9435 Texture* info = GetTextureInfoForTargetUnlessDefault(
9433 target); 9436 target);
9434 if (!info) { 9437 if (!info) {
9435 SetGLError(GL_INVALID_OPERATION, 9438 SetGLError(GL_INVALID_OPERATION,
9436 "glTexImageIOSurface2DCHROMIUM", "no rectangle texture bound"); 9439 "glTexImageIOSurface2DCHROMIUM", "no rectangle texture bound");
9437 return; 9440 return;
9438 } 9441 }
9439 9442
9440 // Look up the new IOSurface. Note that because of asynchrony 9443 // Look up the new IOSurface. Note that because of asynchrony
9441 // between processes this might fail; during live resizing the 9444 // between processes this might fail; during live resizing the
9442 // plugin process might allocate and release an IOSurface before 9445 // plugin process might allocate and release an IOSurface before
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
9529 case GL_BGRA8_EXT: 9532 case GL_BGRA8_EXT:
9530 return GL_BGRA_EXT; 9533 return GL_BGRA_EXT;
9531 default: 9534 default:
9532 return GL_NONE; 9535 return GL_NONE;
9533 } 9536 }
9534 } 9537 }
9535 9538
9536 void GLES2DecoderImpl::DoCopyTextureCHROMIUM( 9539 void GLES2DecoderImpl::DoCopyTextureCHROMIUM(
9537 GLenum target, GLuint source_id, GLuint dest_id, GLint level, 9540 GLenum target, GLuint source_id, GLuint dest_id, GLint level,
9538 GLenum internal_format) { 9541 GLenum internal_format) {
9539 TextureManager::TextureInfo* dest_info = GetTextureInfo(dest_id); 9542 Texture* dest_info = GetTexture(dest_id);
9540 TextureManager::TextureInfo* source_info = GetTextureInfo(source_id); 9543 Texture* source_info = GetTexture(source_id);
9541 9544
9542 if (!source_info || !dest_info) { 9545 if (!source_info || !dest_info) {
9543 SetGLError(GL_INVALID_VALUE, "glCopyTextureCHROMIUM", "unknown texture id"); 9546 SetGLError(GL_INVALID_VALUE, "glCopyTextureCHROMIUM", "unknown texture id");
9544 return; 9547 return;
9545 } 9548 }
9546 9549
9547 if (GL_TEXTURE_2D != target) { 9550 if (GL_TEXTURE_2D != target) {
9548 SetGLError(GL_INVALID_VALUE, 9551 SetGLError(GL_INVALID_VALUE,
9549 "glCopyTextureCHROMIUM", "invalid texture target"); 9552 "glCopyTextureCHROMIUM", "invalid texture target");
9550 return; 9553 return;
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
9700 GLenum internal_format, 9703 GLenum internal_format,
9701 GLsizei width, 9704 GLsizei width,
9702 GLsizei height) { 9705 GLsizei height) {
9703 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoTexStorage2DEXT"); 9706 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoTexStorage2DEXT");
9704 if (!texture_manager()->ValidForTarget(target, 0, width, height, 1) || 9707 if (!texture_manager()->ValidForTarget(target, 0, width, height, 1) ||
9705 TextureManager::ComputeMipMapCount(width, height, 1) < levels) { 9708 TextureManager::ComputeMipMapCount(width, height, 1) < levels) {
9706 SetGLError( 9709 SetGLError(
9707 GL_INVALID_VALUE, "glTexStorage2DEXT", "dimensions out of range"); 9710 GL_INVALID_VALUE, "glTexStorage2DEXT", "dimensions out of range");
9708 return; 9711 return;
9709 } 9712 }
9710 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target); 9713 Texture* info = GetTextureInfoForTarget(target);
9711 if (!info) { 9714 if (!info) {
9712 SetGLError(GL_INVALID_OPERATION, 9715 SetGLError(GL_INVALID_OPERATION,
9713 "glTexStorage2DEXT", "unknown texture for target"); 9716 "glTexStorage2DEXT", "unknown texture for target");
9714 return; 9717 return;
9715 } 9718 }
9716 if (info->IsAttachedToFramebuffer()) { 9719 if (info->IsAttachedToFramebuffer()) {
9717 clear_state_dirty_ = true; 9720 clear_state_dirty_ = true;
9718 } 9721 }
9719 if (info->IsImmutable()) { 9722 if (info->IsImmutable()) {
9720 SetGLError(GL_INVALID_OPERATION, 9723 SetGLError(GL_INVALID_OPERATION,
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
9760 info, target, ii, format, level_width, level_height, 1, 0, format, 9763 info, target, ii, format, level_width, level_height, 1, 0, format,
9761 type, false); 9764 type, false);
9762 level_width = std::max(1, level_width >> 1); 9765 level_width = std::max(1, level_width >> 1);
9763 level_height = std::max(1, level_height >> 1); 9766 level_height = std::max(1, level_height >> 1);
9764 } 9767 }
9765 info->SetImmutable(true); 9768 info->SetImmutable(true);
9766 } 9769 }
9767 } 9770 }
9768 9771
9769 error::Error GLES2DecoderImpl::HandleGenMailboxCHROMIUM( 9772 error::Error GLES2DecoderImpl::HandleGenMailboxCHROMIUM(
9770 uint32 immediate_data_size, const gles2::GenMailboxCHROMIUM& c) { 9773 uint32 immediate_data_size, const cmds::GenMailboxCHROMIUM& c) {
9771 MailboxName name; 9774 MailboxName name;
9772 mailbox_manager()->GenerateMailboxName(&name); 9775 mailbox_manager()->GenerateMailboxName(&name);
9773 uint32 bucket_id = static_cast<uint32>(c.bucket_id); 9776 uint32 bucket_id = static_cast<uint32>(c.bucket_id);
9774 Bucket* bucket = CreateBucket(bucket_id); 9777 Bucket* bucket = CreateBucket(bucket_id);
9775 9778
9776 bucket->SetSize(GL_MAILBOX_SIZE_CHROMIUM); 9779 bucket->SetSize(GL_MAILBOX_SIZE_CHROMIUM);
9777 bucket->SetData(&name, 0, GL_MAILBOX_SIZE_CHROMIUM); 9780 bucket->SetData(&name, 0, GL_MAILBOX_SIZE_CHROMIUM);
9778 9781
9779 return error::kNoError; 9782 return error::kNoError;
9780 } 9783 }
9781 9784
9782 void GLES2DecoderImpl::DoProduceTextureCHROMIUM(GLenum target, 9785 void GLES2DecoderImpl::DoProduceTextureCHROMIUM(GLenum target,
9783 const GLbyte* mailbox) { 9786 const GLbyte* mailbox) {
9784 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target); 9787 Texture* info = GetTextureInfoForTarget(target);
9785 if (!info) { 9788 if (!info) {
9786 SetGLError(GL_INVALID_OPERATION, 9789 SetGLError(GL_INVALID_OPERATION,
9787 "glProduceTextureCHROMIUM", "unknown texture for target"); 9790 "glProduceTextureCHROMIUM", "unknown texture for target");
9788 return; 9791 return;
9789 } 9792 }
9790 9793
9791 TextureDefinition* definition = texture_manager()->Save(info); 9794 TextureDefinition* definition = texture_manager()->Save(info);
9792 if (!definition) { 9795 if (!definition) {
9793 SetGLError(GL_INVALID_OPERATION, 9796 SetGLError(GL_INVALID_OPERATION,
9794 "glProduceTextureCHROMIUM", "invalid texture"); 9797 "glProduceTextureCHROMIUM", "invalid texture");
(...skipping 10 matching lines...) Expand all
9805 SetGLError(GL_INVALID_OPERATION, 9808 SetGLError(GL_INVALID_OPERATION,
9806 "glProduceTextureCHROMIUM", "invalid mailbox name"); 9809 "glProduceTextureCHROMIUM", "invalid mailbox name");
9807 return; 9810 return;
9808 } 9811 }
9809 9812
9810 glBindTexture(info->target(), info->service_id()); 9813 glBindTexture(info->target(), info->service_id());
9811 } 9814 }
9812 9815
9813 void GLES2DecoderImpl::DoConsumeTextureCHROMIUM(GLenum target, 9816 void GLES2DecoderImpl::DoConsumeTextureCHROMIUM(GLenum target,
9814 const GLbyte* mailbox) { 9817 const GLbyte* mailbox) {
9815 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target); 9818 Texture* info = GetTextureInfoForTarget(target);
9816 if (!info) { 9819 if (!info) {
9817 SetGLError(GL_INVALID_OPERATION, 9820 SetGLError(GL_INVALID_OPERATION,
9818 "glConsumeTextureCHROMIUM", "unknown texture for target"); 9821 "glConsumeTextureCHROMIUM", "unknown texture for target");
9819 return; 9822 return;
9820 } 9823 }
9821 9824
9822 scoped_ptr<TextureDefinition> definition( 9825 scoped_ptr<TextureDefinition> definition(
9823 group_->mailbox_manager()->ConsumeTexture( 9826 group_->mailbox_manager()->ConsumeTexture(
9824 target, 9827 target,
9825 *reinterpret_cast<const MailboxName*>(mailbox))); 9828 *reinterpret_cast<const MailboxName*>(mailbox)));
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
9866 if (target != GL_TEXTURE_2D) { 9869 if (target != GL_TEXTURE_2D) {
9867 // This might be supported in the future. 9870 // This might be supported in the future.
9868 SetGLError( 9871 SetGLError(
9869 GL_INVALID_OPERATION, 9872 GL_INVALID_OPERATION,
9870 "glBindTexImage2DCHROMIUM", "requires TEXTURE_2D target"); 9873 "glBindTexImage2DCHROMIUM", "requires TEXTURE_2D target");
9871 return; 9874 return;
9872 } 9875 }
9873 9876
9874 // Default target might be conceptually valid, but disallow it to avoid 9877 // Default target might be conceptually valid, but disallow it to avoid
9875 // accidents. 9878 // accidents.
9876 TextureManager::TextureInfo* info = GetTextureInfoForTargetUnlessDefault( 9879 Texture* info = GetTextureInfoForTargetUnlessDefault(
9877 target); 9880 target);
9878 if (!info) { 9881 if (!info) {
9879 SetGLError(GL_INVALID_OPERATION, 9882 SetGLError(GL_INVALID_OPERATION,
9880 "glBindTexImage2DCHROMIUM", "no texture bound"); 9883 "glBindTexImage2DCHROMIUM", "no texture bound");
9881 return; 9884 return;
9882 } 9885 }
9883 9886
9884 gfx::GLImage* gl_image = image_manager()->LookupImage(image_id); 9887 gfx::GLImage* gl_image = image_manager()->LookupImage(image_id);
9885 if (!gl_image) { 9888 if (!gl_image) {
9886 SetGLError(GL_INVALID_OPERATION, 9889 SetGLError(GL_INVALID_OPERATION,
(...skipping 22 matching lines...) Expand all
9909 if (target != GL_TEXTURE_2D) { 9912 if (target != GL_TEXTURE_2D) {
9910 // This might be supported in the future. 9913 // This might be supported in the future.
9911 SetGLError( 9914 SetGLError(
9912 GL_INVALID_OPERATION, 9915 GL_INVALID_OPERATION,
9913 "glReleaseTexImage2DCHROMIUM", "requires TEXTURE_2D target"); 9916 "glReleaseTexImage2DCHROMIUM", "requires TEXTURE_2D target");
9914 return; 9917 return;
9915 } 9918 }
9916 9919
9917 // Default target might be conceptually valid, but disallow it to avoid 9920 // Default target might be conceptually valid, but disallow it to avoid
9918 // accidents. 9921 // accidents.
9919 TextureManager::TextureInfo* info = GetTextureInfoForTargetUnlessDefault( 9922 Texture* info = GetTextureInfoForTargetUnlessDefault(
9920 target); 9923 target);
9921 if (!info) { 9924 if (!info) {
9922 SetGLError(GL_INVALID_OPERATION, 9925 SetGLError(GL_INVALID_OPERATION,
9923 "glReleaseTexImage2DCHROMIUM", "no texture bound"); 9926 "glReleaseTexImage2DCHROMIUM", "no texture bound");
9924 return; 9927 return;
9925 } 9928 }
9926 9929
9927 gfx::GLImage* gl_image = image_manager()->LookupImage(image_id); 9930 gfx::GLImage* gl_image = image_manager()->LookupImage(image_id);
9928 if (!gl_image) { 9931 if (!gl_image) {
9929 SetGLError(GL_INVALID_OPERATION, 9932 SetGLError(GL_INVALID_OPERATION,
9930 "glReleaseTexImage2DCHROMIUM", 9933 "glReleaseTexImage2DCHROMIUM",
9931 "no image found with the given ID"); 9934 "no image found with the given ID");
9932 return; 9935 return;
9933 } 9936 }
9934 9937
9935 // Do nothing when image is not currently bound. 9938 // Do nothing when image is not currently bound.
9936 if (info->GetLevelImage(target, 0) != gl_image) 9939 if (info->GetLevelImage(target, 0) != gl_image)
9937 return; 9940 return;
9938 9941
9939 gl_image->ReleaseTexImage(); 9942 gl_image->ReleaseTexImage();
9940 9943
9941 texture_manager()->SetLevelInfo( 9944 texture_manager()->SetLevelInfo(
9942 info, target, 0, GL_RGBA, 0, 0, 1, 0, 9945 info, target, 0, GL_RGBA, 0, 0, 1, 0,
9943 GL_RGBA, GL_UNSIGNED_BYTE, false); 9946 GL_RGBA, GL_UNSIGNED_BYTE, false);
9944 } 9947 }
9945 9948
9946 error::Error GLES2DecoderImpl::HandleTraceBeginCHROMIUM( 9949 error::Error GLES2DecoderImpl::HandleTraceBeginCHROMIUM(
9947 uint32 immediate_data_size, const gles2::TraceBeginCHROMIUM& c) { 9950 uint32 immediate_data_size, const cmds::TraceBeginCHROMIUM& c) {
9948 Bucket* bucket = GetBucket(c.bucket_id); 9951 Bucket* bucket = GetBucket(c.bucket_id);
9949 if (!bucket || bucket->size() == 0) { 9952 if (!bucket || bucket->size() == 0) {
9950 return error::kInvalidArguments; 9953 return error::kInvalidArguments;
9951 } 9954 }
9952 std::string command_name; 9955 std::string command_name;
9953 if (!bucket->GetAsString(&command_name)) { 9956 if (!bucket->GetAsString(&command_name)) {
9954 return error::kInvalidArguments; 9957 return error::kInvalidArguments;
9955 } 9958 }
9956 TRACE_EVENT_COPY_ASYNC_BEGIN0("gpu", command_name.c_str(), this); 9959 TRACE_EVENT_COPY_ASYNC_BEGIN0("gpu", command_name.c_str(), this);
9957 if (!gpu_tracer_->Begin(command_name)) { 9960 if (!gpu_tracer_->Begin(command_name)) {
9958 SetGLError(GL_INVALID_OPERATION, 9961 SetGLError(GL_INVALID_OPERATION,
9959 "glTraceBeginCHROMIUM", "unable to create begin trace"); 9962 "glTraceBeginCHROMIUM", "unable to create begin trace");
9960 return error::kNoError; 9963 return error::kNoError;
9961 } 9964 }
9962 return error::kNoError; 9965 return error::kNoError;
9963 } 9966 }
9964 9967
9965 void GLES2DecoderImpl::DoTraceEndCHROMIUM() { 9968 void GLES2DecoderImpl::DoTraceEndCHROMIUM() {
9966 if (gpu_tracer_->CurrentName().empty()) { 9969 if (gpu_tracer_->CurrentName().empty()) {
9967 SetGLError(GL_INVALID_OPERATION, 9970 SetGLError(GL_INVALID_OPERATION,
9968 "glTraceEndCHROMIUM", "no trace begin found"); 9971 "glTraceEndCHROMIUM", "no trace begin found");
9969 return; 9972 return;
9970 } 9973 }
9971 TRACE_EVENT_COPY_ASYNC_END0("gpu", gpu_tracer_->CurrentName().c_str(), this); 9974 TRACE_EVENT_COPY_ASYNC_END0("gpu", gpu_tracer_->CurrentName().c_str(), this);
9972 gpu_tracer_->End(); 9975 gpu_tracer_->End();
9973 } 9976 }
9974 9977
9975 bool GLES2DecoderImpl::ValidateAsyncTransfer( 9978 bool GLES2DecoderImpl::ValidateAsyncTransfer(
9976 const char* function_name, 9979 const char* function_name,
9977 TextureManager::TextureInfo* info, 9980 Texture* info,
9978 GLenum target, 9981 GLenum target,
9979 GLint level, 9982 GLint level,
9980 const void * data) { 9983 const void * data) {
9981 // We only support async uploads to 2D textures for now. 9984 // We only support async uploads to 2D textures for now.
9982 if (GL_TEXTURE_2D != target) { 9985 if (GL_TEXTURE_2D != target) {
9983 SetGLErrorInvalidEnum(function_name, target, "target"); 9986 SetGLErrorInvalidEnum(function_name, target, "target");
9984 return false; 9987 return false;
9985 } 9988 }
9986 // We only support uploads to level zero for now. 9989 // We only support uploads to level zero for now.
9987 if (level != 0) { 9990 if (level != 0) {
9988 SetGLError(GL_INVALID_VALUE, function_name, "level != 0"); 9991 SetGLError(GL_INVALID_VALUE, function_name, "level != 0");
9989 return false; 9992 return false;
9990 } 9993 }
9991 // A transfer buffer must be bound, even for asyncTexImage2D. 9994 // A transfer buffer must be bound, even for asyncTexImage2D.
9992 if (data == NULL) { 9995 if (data == NULL) {
9993 SetGLError(GL_INVALID_OPERATION, function_name, "buffer == 0"); 9996 SetGLError(GL_INVALID_OPERATION, function_name, "buffer == 0");
9994 return false; 9997 return false;
9995 } 9998 }
9996 // We only support one async transfer in progress. 9999 // We only support one async transfer in progress.
9997 if (!info || info->AsyncTransferIsInProgress()) { 10000 if (!info || info->AsyncTransferIsInProgress()) {
9998 SetGLError(GL_INVALID_OPERATION, 10001 SetGLError(GL_INVALID_OPERATION,
9999 function_name, "transfer already in progress"); 10002 function_name, "transfer already in progress");
10000 return false; 10003 return false;
10001 } 10004 }
10002 return true; 10005 return true;
10003 } 10006 }
10004 10007
10005 error::Error GLES2DecoderImpl::HandleAsyncTexImage2DCHROMIUM( 10008 error::Error GLES2DecoderImpl::HandleAsyncTexImage2DCHROMIUM(
10006 uint32 immediate_data_size, const gles2::AsyncTexImage2DCHROMIUM& c) { 10009 uint32 immediate_data_size, const cmds::AsyncTexImage2DCHROMIUM& c) {
10007 TRACE_EVENT0("gpu", "GLES2DecoderImpl::HandleAsyncTexImage2DCHROMIUM"); 10010 TRACE_EVENT0("gpu", "GLES2DecoderImpl::HandleAsyncTexImage2DCHROMIUM");
10008 GLenum target = static_cast<GLenum>(c.target); 10011 GLenum target = static_cast<GLenum>(c.target);
10009 GLint level = static_cast<GLint>(c.level); 10012 GLint level = static_cast<GLint>(c.level);
10010 GLint internal_format = static_cast<GLint>(c.internalformat); 10013 GLint internal_format = static_cast<GLint>(c.internalformat);
10011 GLsizei width = static_cast<GLsizei>(c.width); 10014 GLsizei width = static_cast<GLsizei>(c.width);
10012 GLsizei height = static_cast<GLsizei>(c.height); 10015 GLsizei height = static_cast<GLsizei>(c.height);
10013 GLint border = static_cast<GLint>(c.border); 10016 GLint border = static_cast<GLint>(c.border);
10014 GLenum format = static_cast<GLenum>(c.format); 10017 GLenum format = static_cast<GLenum>(c.format);
10015 GLenum type = static_cast<GLenum>(c.type); 10018 GLenum type = static_cast<GLenum>(c.type);
10016 uint32 pixels_shm_id = static_cast<uint32>(c.pixels_shm_id); 10019 uint32 pixels_shm_id = static_cast<uint32>(c.pixels_shm_id);
(...skipping 17 matching lines...) Expand all
10034 } 10037 }
10035 10038
10036 // All the normal glTexSubImage2D validation. 10039 // All the normal glTexSubImage2D validation.
10037 if (!ValidateTexImage2D( 10040 if (!ValidateTexImage2D(
10038 "glAsyncTexImage2DCHROMIUM", target, level, internal_format, 10041 "glAsyncTexImage2DCHROMIUM", target, level, internal_format,
10039 width, height, border, format, type, pixels, pixels_size)) { 10042 width, height, border, format, type, pixels, pixels_size)) {
10040 return error::kNoError; 10043 return error::kNoError;
10041 } 10044 }
10042 10045
10043 // Extra async validation. 10046 // Extra async validation.
10044 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target); 10047 Texture* info = GetTextureInfoForTarget(target);
10045 if (!ValidateAsyncTransfer( 10048 if (!ValidateAsyncTransfer(
10046 "glAsyncTexImage2DCHROMIUM", info, target, level, pixels)) 10049 "glAsyncTexImage2DCHROMIUM", info, target, level, pixels))
10047 return error::kNoError; 10050 return error::kNoError;
10048 10051
10049 // Don't allow async redefinition of a textures. 10052 // Don't allow async redefinition of a textures.
10050 if (info->IsDefined()) { 10053 if (info->IsDefined()) {
10051 SetGLError(GL_INVALID_OPERATION, 10054 SetGLError(GL_INVALID_OPERATION,
10052 "glAsyncTexImage2DCHROMIUM", "already defined"); 10055 "glAsyncTexImage2DCHROMIUM", "already defined");
10053 return error::kNoError; 10056 return error::kNoError;
10054 } 10057 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
10088 // after the the transfer is complete. 10091 // after the the transfer is complete.
10089 texture_manager()->AddPendingAsyncPixelTransfer( 10092 texture_manager()->AddPendingAsyncPixelTransfer(
10090 info->GetAsyncTransferState()->AsWeakPtr(), info); 10093 info->GetAsyncTransferState()->AsWeakPtr(), info);
10091 10094
10092 async_pixel_transfer_delegate_->AsyncTexImage2D( 10095 async_pixel_transfer_delegate_->AsyncTexImage2D(
10093 info->GetAsyncTransferState(), tex_params, mem_params); 10096 info->GetAsyncTransferState(), tex_params, mem_params);
10094 return error::kNoError; 10097 return error::kNoError;
10095 } 10098 }
10096 10099
10097 error::Error GLES2DecoderImpl::HandleAsyncTexSubImage2DCHROMIUM( 10100 error::Error GLES2DecoderImpl::HandleAsyncTexSubImage2DCHROMIUM(
10098 uint32 immediate_data_size, const gles2::AsyncTexSubImage2DCHROMIUM& c) { 10101 uint32 immediate_data_size, const cmds::AsyncTexSubImage2DCHROMIUM& c) {
10099 TRACE_EVENT0("gpu", "GLES2DecoderImpl::HandleAsyncTexSubImage2DCHROMIUM"); 10102 TRACE_EVENT0("gpu", "GLES2DecoderImpl::HandleAsyncTexSubImage2DCHROMIUM");
10100 GLenum target = static_cast<GLenum>(c.target); 10103 GLenum target = static_cast<GLenum>(c.target);
10101 GLint level = static_cast<GLint>(c.level); 10104 GLint level = static_cast<GLint>(c.level);
10102 GLint xoffset = static_cast<GLint>(c.xoffset); 10105 GLint xoffset = static_cast<GLint>(c.xoffset);
10103 GLint yoffset = static_cast<GLint>(c.yoffset); 10106 GLint yoffset = static_cast<GLint>(c.yoffset);
10104 GLsizei width = static_cast<GLsizei>(c.width); 10107 GLsizei width = static_cast<GLsizei>(c.width);
10105 GLsizei height = static_cast<GLsizei>(c.height); 10108 GLsizei height = static_cast<GLsizei>(c.height);
10106 GLenum format = static_cast<GLenum>(c.format); 10109 GLenum format = static_cast<GLenum>(c.format);
10107 GLenum type = static_cast<GLenum>(c.type); 10110 GLenum type = static_cast<GLenum>(c.type);
10108 10111
10109 // TODO(epenner): Move this and copies of this memory validation 10112 // TODO(epenner): Move this and copies of this memory validation
10110 // into ValidateTexSubImage2D step. 10113 // into ValidateTexSubImage2D step.
10111 uint32 data_size; 10114 uint32 data_size;
10112 if (!GLES2Util::ComputeImageDataSizes( 10115 if (!GLES2Util::ComputeImageDataSizes(
10113 width, height, format, type, state_.unpack_alignment, &data_size, 10116 width, height, format, type, state_.unpack_alignment, &data_size,
10114 NULL, NULL)) { 10117 NULL, NULL)) {
10115 return error::kOutOfBounds; 10118 return error::kOutOfBounds;
10116 } 10119 }
10117 const void* pixels = GetSharedMemoryAs<const void*>( 10120 const void* pixels = GetSharedMemoryAs<const void*>(
10118 c.data_shm_id, c.data_shm_offset, data_size); 10121 c.data_shm_id, c.data_shm_offset, data_size);
10119 10122
10120 // All the normal glTexSubImage2D validation. 10123 // All the normal glTexSubImage2D validation.
10121 error::Error error = error::kNoError; 10124 error::Error error = error::kNoError;
10122 if (!ValidateTexSubImage2D(&error, "glAsyncTexSubImage2DCHROMIUM", 10125 if (!ValidateTexSubImage2D(&error, "glAsyncTexSubImage2DCHROMIUM",
10123 target, level, xoffset, yoffset, width, height, format, type, pixels)) { 10126 target, level, xoffset, yoffset, width, height, format, type, pixels)) {
10124 return error; 10127 return error;
10125 } 10128 }
10126 10129
10127 // Extra async validation. 10130 // Extra async validation.
10128 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target); 10131 Texture* info = GetTextureInfoForTarget(target);
10129 if (!ValidateAsyncTransfer( 10132 if (!ValidateAsyncTransfer(
10130 "glAsyncTexSubImage2DCHROMIUM", info, target, level, pixels)) 10133 "glAsyncTexSubImage2DCHROMIUM", info, target, level, pixels))
10131 return error::kNoError; 10134 return error::kNoError;
10132 10135
10133 // Guarantee async textures are always 'cleared' as follows: 10136 // Guarantee async textures are always 'cleared' as follows:
10134 // - AsyncTexImage2D can not redefine an existing texture 10137 // - AsyncTexImage2D can not redefine an existing texture
10135 // - AsyncTexImage2D must initialize the entire image via non-null buffer. 10138 // - AsyncTexImage2D must initialize the entire image via non-null buffer.
10136 // - AsyncTexSubImage2D clears synchronously if not already cleared. 10139 // - AsyncTexSubImage2D clears synchronously if not already cleared.
10137 // - Textures become immutable after an async call. 10140 // - Textures become immutable after an async call.
10138 // This way we know in all cases that an async texture is always clear. 10141 // This way we know in all cases that an async texture is always clear.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
10170 return error::kNoError; 10173 return error::kNoError;
10171 } 10174 }
10172 10175
10173 // Include the auto-generated part of this file. We split this because it means 10176 // Include the auto-generated part of this file. We split this because it means
10174 // we can easily edit the non-auto generated parts right here in this file 10177 // we can easily edit the non-auto generated parts right here in this file
10175 // instead of having to edit some template or the code generator. 10178 // instead of having to edit some template or the code generator.
10176 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 10179 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
10177 10180
10178 } // namespace gles2 10181 } // namespace gles2
10179 } // namespace gpu 10182 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/framebuffer_manager_unittest.cc ('k') | gpu/command_buffer/service/gles2_cmd_decoder_autogen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698