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

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

Issue 988693005: Chromium roll (https://codereview.chromium.org/976353002) (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: fixed bad android build patch Created 5 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
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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 74
75 #if defined(OS_WIN) 75 #if defined(OS_WIN)
76 #include "base/win/win_util.h" 76 #include "base/win/win_util.h"
77 #endif 77 #endif
78 78
79 namespace gpu { 79 namespace gpu {
80 namespace gles2 { 80 namespace gles2 {
81 81
82 namespace { 82 namespace {
83 83
84 static const char kOESDerivativeExtension[] = "GL_OES_standard_derivatives"; 84 const char kOESDerivativeExtension[] = "GL_OES_standard_derivatives";
85 static const char kEXTFragDepthExtension[] = "GL_EXT_frag_depth"; 85 const char kEXTFragDepthExtension[] = "GL_EXT_frag_depth";
86 static const char kEXTDrawBuffersExtension[] = "GL_EXT_draw_buffers"; 86 const char kEXTDrawBuffersExtension[] = "GL_EXT_draw_buffers";
87 static const char kEXTShaderTextureLodExtension[] = "GL_EXT_shader_texture_lod"; 87 const char kEXTShaderTextureLodExtension[] = "GL_EXT_shader_texture_lod";
88
89 const GLfloat kIdentityMatrix[16] = {1.0f, 0.0f, 0.0f, 0.0f,
90 0.0f, 1.0f, 0.0f, 0.0f,
91 0.0f, 0.0f, 1.0f, 0.0f,
92 0.0f, 0.0f, 0.0f, 1.0f};
88 93
89 static bool PrecisionMeetsSpecForHighpFloat(GLint rangeMin, 94 static bool PrecisionMeetsSpecForHighpFloat(GLint rangeMin,
90 GLint rangeMax, 95 GLint rangeMax,
91 GLint precision) { 96 GLint precision) {
92 return (rangeMin >= 62) && (rangeMax >= 62) && (precision >= 16); 97 return (rangeMin >= 62) && (rangeMax >= 62) && (precision >= 16);
93 } 98 }
94 99
95 static void GetShaderPrecisionFormatImpl(GLenum shader_type, 100 static void GetShaderPrecisionFormatImpl(GLenum shader_type,
96 GLenum precision_type, 101 GLenum precision_type,
97 GLint *range, GLint *precision) { 102 GLint *range, GLint *precision) {
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 int num_entries, 583 int num_entries,
579 int* entries_processed); 584 int* entries_processed);
580 585
581 // Overridden from AsyncAPIInterface. 586 // Overridden from AsyncAPIInterface.
582 const char* GetCommandName(unsigned int command_id) const override; 587 const char* GetCommandName(unsigned int command_id) const override;
583 588
584 // Overridden from GLES2Decoder. 589 // Overridden from GLES2Decoder.
585 bool Initialize(const scoped_refptr<gfx::GLSurface>& surface, 590 bool Initialize(const scoped_refptr<gfx::GLSurface>& surface,
586 const scoped_refptr<gfx::GLContext>& context, 591 const scoped_refptr<gfx::GLContext>& context,
587 bool offscreen, 592 bool offscreen,
588 const gfx::Size& size, 593 const gfx::Size& offscreen_size,
589 const DisallowedFeatures& disallowed_features, 594 const DisallowedFeatures& disallowed_features,
590 const std::vector<int32>& attribs) override; 595 const std::vector<int32>& attribs) override;
591 void Destroy(bool have_context) override; 596 void Destroy(bool have_context) override;
592 void SetSurface(const scoped_refptr<gfx::GLSurface>& surface) override; 597 void SetSurface(const scoped_refptr<gfx::GLSurface>& surface) override;
593 void ProduceFrontBuffer(const Mailbox& mailbox) override; 598 void ProduceFrontBuffer(const Mailbox& mailbox) override;
594 bool ResizeOffscreenFrameBuffer(const gfx::Size& size) override; 599 bool ResizeOffscreenFrameBuffer(const gfx::Size& size) override;
595 void UpdateParentTextureInfo(); 600 void UpdateParentTextureInfo();
596 bool MakeCurrent() override; 601 bool MakeCurrent() override;
597 GLES2Util* GetGLES2Util() override { return &util_; } 602 GLES2Util* GetGLES2Util() override { return &util_; }
598 gfx::GLContext* GetGLContext() override { return context_.get(); } 603 gfx::GLContext* GetGLContext() override { return context_.get(); }
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
929 const void * data); 934 const void * data);
930 935
931 // Wrapper for TexImageIOSurface2DCHROMIUM. 936 // Wrapper for TexImageIOSurface2DCHROMIUM.
932 void DoTexImageIOSurface2DCHROMIUM( 937 void DoTexImageIOSurface2DCHROMIUM(
933 GLenum target, 938 GLenum target,
934 GLsizei width, 939 GLsizei width,
935 GLsizei height, 940 GLsizei height,
936 GLuint io_surface_id, 941 GLuint io_surface_id,
937 GLuint plane); 942 GLuint plane);
938 943
939 void DoCopyTextureCHROMIUM( 944 void DoCopyTextureCHROMIUM(GLenum target,
940 GLenum target, 945 GLuint source_id,
941 GLuint source_id, 946 GLuint dest_id,
942 GLuint target_id, 947 GLenum internal_format,
943 GLint level, 948 GLenum dest_type);
944 GLenum internal_format, 949
945 GLenum dest_type); 950 void DoCopySubTextureCHROMIUM(GLenum target,
951 GLuint source_id,
952 GLuint dest_id,
953 GLint xoffset,
954 GLint yoffset);
946 955
947 // Wrapper for TexStorage2DEXT. 956 // Wrapper for TexStorage2DEXT.
948 void DoTexStorage2DEXT( 957 void DoTexStorage2DEXT(
949 GLenum target, 958 GLenum target,
950 GLint levels, 959 GLint levels,
951 GLenum internal_format, 960 GLenum internal_format,
952 GLsizei width, 961 GLsizei width,
953 GLsizei height); 962 GLsizei height);
954 963
955 void DoProduceTextureCHROMIUM(GLenum target, const GLbyte* key); 964 void DoProduceTextureCHROMIUM(GLenum target, const GLbyte* key);
(...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after
1651 const char* function_name, 1660 const char* function_name,
1652 GLint level, GLsizei width, GLsizei height, GLenum format); 1661 GLint level, GLsizei width, GLsizei height, GLenum format);
1653 bool ValidateCompressedTexFuncData( 1662 bool ValidateCompressedTexFuncData(
1654 const char* function_name, 1663 const char* function_name,
1655 GLsizei width, GLsizei height, GLenum format, size_t size); 1664 GLsizei width, GLsizei height, GLenum format, size_t size);
1656 bool ValidateCompressedTexSubDimensions( 1665 bool ValidateCompressedTexSubDimensions(
1657 const char* function_name, 1666 const char* function_name,
1658 GLenum target, GLint level, GLint xoffset, GLint yoffset, 1667 GLenum target, GLint level, GLint xoffset, GLint yoffset,
1659 GLsizei width, GLsizei height, GLenum format, 1668 GLsizei width, GLsizei height, GLenum format,
1660 Texture* texture); 1669 Texture* texture);
1670 bool ValidateCopyTextureCHROMIUM(const char* function_name,
1671 GLenum target,
1672 TextureRef* source_texture_ref,
1673 TextureRef* dest_texture_ref,
1674 GLenum dest_internal_format);
1661 1675
1662 void RenderWarning(const char* filename, int line, const std::string& msg); 1676 void RenderWarning(const char* filename, int line, const std::string& msg);
1663 void PerformanceWarning( 1677 void PerformanceWarning(
1664 const char* filename, int line, const std::string& msg); 1678 const char* filename, int line, const std::string& msg);
1665 1679
1666 const FeatureInfo::FeatureFlags& features() const { 1680 const FeatureInfo::FeatureFlags& features() const {
1667 return feature_info_->feature_flags(); 1681 return feature_info_->feature_flags();
1668 } 1682 }
1669 1683
1670 const FeatureInfo::Workarounds& workarounds() const { 1684 const FeatureInfo::Workarounds& workarounds() const {
(...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after
2427 } 2441 }
2428 } 2442 }
2429 2443
2430 GLES2DecoderImpl::~GLES2DecoderImpl() { 2444 GLES2DecoderImpl::~GLES2DecoderImpl() {
2431 } 2445 }
2432 2446
2433 bool GLES2DecoderImpl::Initialize( 2447 bool GLES2DecoderImpl::Initialize(
2434 const scoped_refptr<gfx::GLSurface>& surface, 2448 const scoped_refptr<gfx::GLSurface>& surface,
2435 const scoped_refptr<gfx::GLContext>& context, 2449 const scoped_refptr<gfx::GLContext>& context,
2436 bool offscreen, 2450 bool offscreen,
2437 const gfx::Size& size, 2451 const gfx::Size& offscreen_size,
2438 const DisallowedFeatures& disallowed_features, 2452 const DisallowedFeatures& disallowed_features,
2439 const std::vector<int32>& attribs) { 2453 const std::vector<int32>& attribs) {
2440 TRACE_EVENT0("gpu", "GLES2DecoderImpl::Initialize"); 2454 TRACE_EVENT0("gpu", "GLES2DecoderImpl::Initialize");
2441 DCHECK(context->IsCurrent(surface.get())); 2455 DCHECK(context->IsCurrent(surface.get()));
2442 DCHECK(!context_.get()); 2456 DCHECK(!context_.get());
2443 2457
2458 ContextCreationAttribHelper attrib_parser;
2459 if (!attrib_parser.Parse(attribs))
2460 return false;
2461
2444 surfaceless_ = surface->IsSurfaceless() && !offscreen; 2462 surfaceless_ = surface->IsSurfaceless() && !offscreen;
2445 2463
2446 set_initialized(); 2464 set_initialized();
2447 gpu_state_tracer_ = GPUStateTracer::Create(&state_); 2465 gpu_state_tracer_ = GPUStateTracer::Create(&state_);
2448 2466
2449 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 2467 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
2450 switches::kEnableGPUDebugging)) { 2468 switches::kEnableGPUDebugging)) {
2451 set_debug(true); 2469 set_debug(true);
2452 } 2470 }
2453 2471
2454 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 2472 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
2455 switches::kEnableGPUCommandLogging)) { 2473 switches::kEnableGPUCommandLogging)) {
2456 set_log_commands(true); 2474 set_log_commands(true);
2457 } 2475 }
2458 2476
2459 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 2477 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
2460 switches::kEnableUnsafeES3APIs)) { 2478 switches::kEnableUnsafeES3APIs) &&
2479 attrib_parser.es3_context_required) {
2480 // TODO(zmo): We need to implement capabilities check to ensure we can
2481 // actually create ES3 contexts.
2461 set_unsafe_es3_apis_enabled(true); 2482 set_unsafe_es3_apis_enabled(true);
2462 } 2483 }
2463 2484
2464 compile_shader_always_succeeds_ = 2485 compile_shader_always_succeeds_ =
2465 base::CommandLine::ForCurrentProcess()->HasSwitch( 2486 base::CommandLine::ForCurrentProcess()->HasSwitch(
2466 switches::kCompileShaderAlwaysSucceeds); 2487 switches::kCompileShaderAlwaysSucceeds);
2467 2488
2468 // Take ownership of the context and surface. The surface can be replaced with 2489 // Take ownership of the context and surface. The surface can be replaced with
2469 // SetSurface. 2490 // SetSurface.
2470 context_ = context; 2491 context_ = context;
2471 surface_ = surface; 2492 surface_ = surface;
2472 2493
2473 ContextCreationAttribHelper attrib_parser;
2474 if (!attrib_parser.Parse(attribs))
2475 return false;
2476
2477 // Create GPU Tracer for timing values. 2494 // Create GPU Tracer for timing values.
2478 gpu_tracer_.reset(new GPUTracer(this)); 2495 gpu_tracer_.reset(new GPUTracer(this));
2479 2496
2480 // Save the loseContextWhenOutOfMemory context creation attribute. 2497 // Save the loseContextWhenOutOfMemory context creation attribute.
2481 lose_context_when_out_of_memory_ = 2498 lose_context_when_out_of_memory_ =
2482 attrib_parser.lose_context_when_out_of_memory; 2499 attrib_parser.lose_context_when_out_of_memory;
2483 2500
2484 // If the failIfMajorPerformanceCaveat context creation attribute was true 2501 // If the failIfMajorPerformanceCaveat context creation attribute was true
2485 // and we are using a software renderer, fail. 2502 // and we are using a software renderer, fail.
2486 if (attrib_parser.fail_if_major_perf_caveat && 2503 if (attrib_parser.fail_if_major_perf_caveat &&
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
2668 // here when SwapBuffers is called. 2685 // here when SwapBuffers is called.
2669 offscreen_saved_frame_buffer_.reset(new BackFramebuffer(this)); 2686 offscreen_saved_frame_buffer_.reset(new BackFramebuffer(this));
2670 offscreen_saved_frame_buffer_->Create(); 2687 offscreen_saved_frame_buffer_->Create();
2671 // 2688 //
2672 offscreen_saved_color_texture_.reset(new BackTexture( 2689 offscreen_saved_color_texture_.reset(new BackTexture(
2673 memory_tracker(), &state_)); 2690 memory_tracker(), &state_));
2674 offscreen_saved_color_texture_->Create(); 2691 offscreen_saved_color_texture_->Create();
2675 2692
2676 // Allocate the render buffers at their initial size and check the status 2693 // Allocate the render buffers at their initial size and check the status
2677 // of the frame buffers is okay. 2694 // of the frame buffers is okay.
2678 if (!ResizeOffscreenFrameBuffer(size)) { 2695 if (!ResizeOffscreenFrameBuffer(offscreen_size)) {
2679 LOG(ERROR) << "Could not allocate offscreen buffer storage."; 2696 LOG(ERROR) << "Could not allocate offscreen buffer storage.";
2680 Destroy(true); 2697 Destroy(true);
2681 return false; 2698 return false;
2682 } 2699 }
2683 2700
2701 state_.viewport_width = offscreen_size.width();
2702 state_.viewport_height = offscreen_size.height();
2703
2684 // Allocate the offscreen saved color texture. 2704 // Allocate the offscreen saved color texture.
2685 DCHECK(offscreen_saved_color_format_); 2705 DCHECK(offscreen_saved_color_format_);
2686 offscreen_saved_color_texture_->AllocateStorage( 2706 offscreen_saved_color_texture_->AllocateStorage(
2687 gfx::Size(1, 1), offscreen_saved_color_format_, true); 2707 gfx::Size(1, 1), offscreen_saved_color_format_, true);
2688 2708
2689 offscreen_saved_frame_buffer_->AttachRenderTexture( 2709 offscreen_saved_frame_buffer_->AttachRenderTexture(
2690 offscreen_saved_color_texture_.get()); 2710 offscreen_saved_color_texture_.get());
2691 if (offscreen_saved_frame_buffer_->CheckStatus() != 2711 if (offscreen_saved_frame_buffer_->CheckStatus() !=
2692 GL_FRAMEBUFFER_COMPLETE) { 2712 GL_FRAMEBUFFER_COMPLETE) {
2693 LOG(ERROR) << "Offscreen saved FBO was incomplete."; 2713 LOG(ERROR) << "Offscreen saved FBO was incomplete.";
(...skipping 19 matching lines...) Expand all
2713 // This checks if the user requested RGBA and we have RGBA then RGBA. If 2733 // This checks if the user requested RGBA and we have RGBA then RGBA. If
2714 // the user requested RGB then RGB. If the user did not specify a 2734 // the user requested RGB then RGB. If the user did not specify a
2715 // preference than use whatever we were given. Same for DEPTH and STENCIL. 2735 // preference than use whatever we were given. Same for DEPTH and STENCIL.
2716 back_buffer_color_format_ = 2736 back_buffer_color_format_ =
2717 (attrib_parser.alpha_size != 0 && v > 0) ? GL_RGBA : GL_RGB; 2737 (attrib_parser.alpha_size != 0 && v > 0) ? GL_RGBA : GL_RGB;
2718 glGetIntegerv(GL_DEPTH_BITS, &v); 2738 glGetIntegerv(GL_DEPTH_BITS, &v);
2719 back_buffer_has_depth_ = attrib_parser.depth_size != 0 && v > 0; 2739 back_buffer_has_depth_ = attrib_parser.depth_size != 0 && v > 0;
2720 glGetIntegerv(GL_STENCIL_BITS, &v); 2740 glGetIntegerv(GL_STENCIL_BITS, &v);
2721 back_buffer_has_stencil_ = attrib_parser.stencil_size != 0 && v > 0; 2741 back_buffer_has_stencil_ = attrib_parser.stencil_size != 0 && v > 0;
2722 } 2742 }
2743
2744 state_.viewport_width = surface->GetSize().width();
2745 state_.viewport_height = surface->GetSize().height();
2723 } 2746 }
2724 2747
2725 // OpenGL ES 2.0 implicitly enables the desktop GL capability 2748 // OpenGL ES 2.0 implicitly enables the desktop GL capability
2726 // VERTEX_PROGRAM_POINT_SIZE and doesn't expose this enum. This fact 2749 // VERTEX_PROGRAM_POINT_SIZE and doesn't expose this enum. This fact
2727 // isn't well documented; it was discovered in the Khronos OpenGL ES 2750 // isn't well documented; it was discovered in the Khronos OpenGL ES
2728 // mailing list archives. It also implicitly enables the desktop GL 2751 // mailing list archives. It also implicitly enables the desktop GL
2729 // capability GL_POINT_SPRITE to provide access to the gl_PointCoord 2752 // capability GL_POINT_SPRITE to provide access to the gl_PointCoord
2730 // variable in fragment shaders. 2753 // variable in fragment shaders.
2731 if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) { 2754 if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) {
2732 glEnable(GL_VERTEX_PROGRAM_POINT_SIZE); 2755 glEnable(GL_VERTEX_PROGRAM_POINT_SIZE);
2733 glEnable(GL_POINT_SPRITE); 2756 glEnable(GL_POINT_SPRITE);
2734 } 2757 }
2735 2758
2736 has_robustness_extension_ = 2759 has_robustness_extension_ =
2737 context->HasExtension("GL_ARB_robustness") || 2760 context->HasExtension("GL_ARB_robustness") ||
2738 context->HasExtension("GL_KHR_robustness") || 2761 context->HasExtension("GL_KHR_robustness") ||
2739 context->HasExtension("GL_EXT_robustness"); 2762 context->HasExtension("GL_EXT_robustness");
2740 2763
2741 if (!InitializeShaderTranslator()) { 2764 if (!InitializeShaderTranslator()) {
2742 return false; 2765 return false;
2743 } 2766 }
2744 2767
2745 state_.viewport_width = size.width();
2746 state_.viewport_height = size.height();
2747
2748 GLint viewport_params[4] = { 0 }; 2768 GLint viewport_params[4] = { 0 };
2749 glGetIntegerv(GL_MAX_VIEWPORT_DIMS, viewport_params); 2769 glGetIntegerv(GL_MAX_VIEWPORT_DIMS, viewport_params);
2750 viewport_max_width_ = viewport_params[0]; 2770 viewport_max_width_ = viewport_params[0];
2751 viewport_max_height_ = viewport_params[1]; 2771 viewport_max_height_ = viewport_params[1];
2752 2772
2753 state_.scissor_width = state_.viewport_width; 2773 state_.scissor_width = state_.viewport_width;
2754 state_.scissor_height = state_.viewport_height; 2774 state_.scissor_height = state_.viewport_height;
2755 2775
2756 // Set all the default state because some GL drivers get it wrong. 2776 // Set all the default state because some GL drivers get it wrong.
2757 state_.InitCapabilities(NULL); 2777 state_.InitCapabilities(NULL);
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
2949 resources.EXT_draw_buffers = 2969 resources.EXT_draw_buffers =
2950 features().ext_draw_buffers ? 1 : 0; 2970 features().ext_draw_buffers ? 1 : 0;
2951 resources.EXT_frag_depth = 2971 resources.EXT_frag_depth =
2952 features().ext_frag_depth ? 1 : 0; 2972 features().ext_frag_depth ? 1 : 0;
2953 resources.EXT_shader_texture_lod = 2973 resources.EXT_shader_texture_lod =
2954 features().ext_shader_texture_lod ? 1 : 0; 2974 features().ext_shader_texture_lod ? 1 : 0;
2955 resources.NV_draw_buffers = 2975 resources.NV_draw_buffers =
2956 features().nv_draw_buffers ? 1 : 0; 2976 features().nv_draw_buffers ? 1 : 0;
2957 } 2977 }
2958 2978
2959 ShShaderSpec shader_spec = force_webgl_glsl_validation_ ? SH_WEBGL_SPEC 2979 ShShaderSpec shader_spec;
2960 : SH_GLES2_SPEC; 2980 if (force_webgl_glsl_validation_) {
2961 if (shader_spec == SH_WEBGL_SPEC && features().enable_shader_name_hashing) 2981 shader_spec = unsafe_es3_apis_enabled() ? SH_WEBGL2_SPEC : SH_WEBGL_SPEC;
2982 } else {
2983 shader_spec = unsafe_es3_apis_enabled() ? SH_GLES3_SPEC : SH_GLES2_SPEC;
2984 }
2985
2986 if ((shader_spec == SH_WEBGL_SPEC || shader_spec == SH_WEBGL2_SPEC) &&
2987 features().enable_shader_name_hashing)
2962 resources.HashFunction = &CityHash64; 2988 resources.HashFunction = &CityHash64;
2963 else 2989 else
2964 resources.HashFunction = NULL; 2990 resources.HashFunction = NULL;
2965 ShaderTranslatorInterface::GlslImplementationType implementation_type = 2991 ShaderTranslatorInterface::GlslImplementationType implementation_type =
2966 gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2 ? 2992 gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2 ?
2967 ShaderTranslatorInterface::kGlslES : ShaderTranslatorInterface::kGlsl; 2993 ShaderTranslatorInterface::kGlslES : ShaderTranslatorInterface::kGlsl;
2968 int driver_bug_workarounds = 0; 2994 int driver_bug_workarounds = 0;
2969 if (workarounds().needs_glsl_built_in_function_emulation) 2995 if (workarounds().needs_glsl_built_in_function_emulation)
2970 driver_bug_workarounds |= SH_EMULATE_BUILT_IN_FUNCTIONS; 2996 driver_bug_workarounds |= SH_EMULATE_BUILT_IN_FUNCTIONS;
2971 if (workarounds().init_gl_position_in_vertex_shader) 2997 if (workarounds().init_gl_position_in_vertex_shader)
(...skipping 7956 matching lines...) Expand 10 before | Expand all | Expand 10 after
10928 return GL_LUMINANCE_ALPHA; 10954 return GL_LUMINANCE_ALPHA;
10929 case GL_BGRA8_EXT: 10955 case GL_BGRA8_EXT:
10930 return GL_BGRA_EXT; 10956 return GL_BGRA_EXT;
10931 case GL_SRGB8_ALPHA8_EXT: 10957 case GL_SRGB8_ALPHA8_EXT:
10932 return GL_SRGB_ALPHA_EXT; 10958 return GL_SRGB_ALPHA_EXT;
10933 default: 10959 default:
10934 return GL_NONE; 10960 return GL_NONE;
10935 } 10961 }
10936 } 10962 }
10937 10963
10938 void GLES2DecoderImpl::DoCopyTextureCHROMIUM( 10964 bool GLES2DecoderImpl::ValidateCopyTextureCHROMIUM(
10939 GLenum target, GLuint source_id, GLuint dest_id, GLint level, 10965 const char* function_name,
10940 GLenum internal_format, GLenum dest_type) { 10966 GLenum target,
10941 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCopyTextureCHROMIUM"); 10967 TextureRef* source_texture_ref,
10942 10968 TextureRef* dest_texture_ref,
10943 TextureRef* dest_texture_ref = GetTexture(dest_id); 10969 GLenum dest_internal_format) {
10944 TextureRef* source_texture_ref = GetTexture(source_id);
10945
10946 if (!source_texture_ref || !dest_texture_ref) { 10970 if (!source_texture_ref || !dest_texture_ref) {
10947 LOCAL_SET_GL_ERROR( 10971 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, "unknown texture id");
10948 GL_INVALID_VALUE, "glCopyTextureCHROMIUM", "unknown texture id"); 10972 return false;
10949 return;
10950 } 10973 }
10951 10974
10952 if (GL_TEXTURE_2D != target) { 10975 if (GL_TEXTURE_2D != target) {
10953 LOCAL_SET_GL_ERROR( 10976 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name,
10954 GL_INVALID_VALUE, "glCopyTextureCHROMIUM", "invalid texture target"); 10977 "invalid texture target");
10955 return; 10978 return false;
10956 } 10979 }
10957 10980
10958 Texture* source_texture = source_texture_ref->texture(); 10981 Texture* source_texture = source_texture_ref->texture();
10959 Texture* dest_texture = dest_texture_ref->texture(); 10982 Texture* dest_texture = dest_texture_ref->texture();
10983 if (source_texture == dest_texture) {
10984 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name,
10985 "source and destination textures are the same");
10986 return false;
10987 }
10988
10960 if (dest_texture->target() != GL_TEXTURE_2D || 10989 if (dest_texture->target() != GL_TEXTURE_2D ||
10961 (source_texture->target() != GL_TEXTURE_2D && 10990 (source_texture->target() != GL_TEXTURE_2D &&
10962 source_texture->target() != GL_TEXTURE_RECTANGLE_ARB && 10991 source_texture->target() != GL_TEXTURE_RECTANGLE_ARB &&
10963 source_texture->target() != GL_TEXTURE_EXTERNAL_OES)) { 10992 source_texture->target() != GL_TEXTURE_EXTERNAL_OES)) {
10964 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, 10993 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name,
10965 "glCopyTextureCHROMIUM",
10966 "invalid texture target binding"); 10994 "invalid texture target binding");
10967 return; 10995 return false;
10968 } 10996 }
10969 10997
10970 int source_width, source_height, dest_width, dest_height; 10998 GLenum source_type = 0;
10999 GLenum source_internal_format = 0;
11000 source_texture->GetLevelType(source_texture->target(), 0, &source_type,
11001 &source_internal_format);
10971 11002
11003 // The destination format should be GL_RGB, or GL_RGBA. GL_ALPHA,
11004 // GL_LUMINANCE, and GL_LUMINANCE_ALPHA are not supported because they are not
11005 // renderable on some platforms.
11006 bool valid_dest_format = dest_internal_format == GL_RGB ||
11007 dest_internal_format == GL_RGBA ||
11008 dest_internal_format == GL_BGRA_EXT;
11009 bool valid_source_format = source_internal_format == GL_ALPHA ||
11010 source_internal_format == GL_RGB ||
11011 source_internal_format == GL_RGBA ||
11012 source_internal_format == GL_LUMINANCE ||
11013 source_internal_format == GL_LUMINANCE_ALPHA ||
11014 source_internal_format == GL_BGRA_EXT;
11015 if (!valid_source_format || !valid_dest_format) {
11016 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name,
11017 "invalid internal format");
11018 return false;
11019 }
11020 return true;
11021 }
11022
11023 void GLES2DecoderImpl::DoCopyTextureCHROMIUM(GLenum target,
11024 GLuint source_id,
11025 GLuint dest_id,
11026 GLenum internal_format,
11027 GLenum dest_type) {
11028 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCopyTextureCHROMIUM");
11029
11030 TextureRef* source_texture_ref = GetTexture(source_id);
11031 TextureRef* dest_texture_ref = GetTexture(dest_id);
11032 Texture* source_texture = source_texture_ref->texture();
11033 Texture* dest_texture = dest_texture_ref->texture();
11034 int source_width = 0;
11035 int source_height = 0;
10972 gfx::GLImage* image = 11036 gfx::GLImage* image =
10973 source_texture->GetLevelImage(source_texture->target(), 0); 11037 source_texture->GetLevelImage(source_texture->target(), 0);
10974 if (image) { 11038 if (image) {
10975 gfx::Size size = image->GetSize(); 11039 gfx::Size size = image->GetSize();
10976 source_width = size.width(); 11040 source_width = size.width();
10977 source_height = size.height(); 11041 source_height = size.height();
10978 if (source_width <= 0 || source_height <= 0) { 11042 if (source_width <= 0 || source_height <= 0) {
10979 LOCAL_SET_GL_ERROR( 11043 LOCAL_SET_GL_ERROR(
10980 GL_INVALID_VALUE, 11044 GL_INVALID_VALUE,
10981 "glCopyTextureChromium", "invalid image size"); 11045 "glCopyTextureChromium", "invalid image size");
10982 return; 11046 return;
10983 } 11047 }
10984 } else { 11048 } else {
10985 if (!source_texture->GetLevelSize( 11049 if (!source_texture->GetLevelSize(
10986 source_texture->target(), 0, &source_width, &source_height)) { 11050 source_texture->target(), 0, &source_width, &source_height)) {
10987 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, 11051 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE,
10988 "glCopyTextureChromium", 11052 "glCopyTextureChromium",
10989 "source texture has no level 0"); 11053 "source texture has no level 0");
10990 return; 11054 return;
10991 } 11055 }
10992 11056
10993 // Check that this type of texture is allowed. 11057 // Check that this type of texture is allowed.
10994 if (!texture_manager()->ValidForTarget( 11058 if (!texture_manager()->ValidForTarget(source_texture->target(), 0,
10995 source_texture->target(), level, source_width, source_height, 1)) { 11059 source_width, source_height, 1)) {
10996 LOCAL_SET_GL_ERROR( 11060 LOCAL_SET_GL_ERROR(
10997 GL_INVALID_VALUE, "glCopyTextureCHROMIUM", "Bad dimensions"); 11061 GL_INVALID_VALUE, "glCopyTextureCHROMIUM", "Bad dimensions");
10998 return; 11062 return;
10999 } 11063 }
11000 } 11064 }
11001 11065
11002 // Clear the source texture if necessary.
11003 if (!texture_manager()->ClearTextureLevel(
11004 this, source_texture_ref, source_texture->target(), 0)) {
11005 LOCAL_SET_GL_ERROR(
11006 GL_OUT_OF_MEMORY, "glCopyTextureCHROMIUM", "dimensions too big");
11007 return;
11008 }
11009
11010 GLenum source_type = 0; 11066 GLenum source_type = 0;
11011 GLenum source_internal_format = 0; 11067 GLenum source_internal_format = 0;
11012 source_texture->GetLevelType( 11068 source_texture->GetLevelType(
11013 source_texture->target(), 0, &source_type, &source_internal_format); 11069 source_texture->target(), 0, &source_type, &source_internal_format);
11014 11070
11015 // The destination format should be GL_RGB, or GL_RGBA. GL_ALPHA, 11071 if (dest_texture->IsImmutable()) {
11016 // GL_LUMINANCE, and GL_LUMINANCE_ALPHA are not supported because they are not 11072 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glCopyTextureCHROMIUM",
11017 // renderable on some platforms. 11073 "texture is immutable");
11018 bool valid_dest_format = internal_format == GL_RGB ||
11019 internal_format == GL_RGBA ||
11020 internal_format == GL_BGRA_EXT;
11021 bool valid_source_format = source_internal_format == GL_ALPHA ||
11022 source_internal_format == GL_RGB ||
11023 source_internal_format == GL_RGBA ||
11024 source_internal_format == GL_LUMINANCE ||
11025 source_internal_format == GL_LUMINANCE_ALPHA ||
11026 source_internal_format == GL_BGRA_EXT;
11027 if (!valid_source_format || !valid_dest_format) {
11028 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION,
11029 "glCopyTextureCHROMIUM",
11030 "invalid internal format");
11031 return; 11074 return;
11032 } 11075 }
11033 11076
11077 if (!ValidateCopyTextureCHROMIUM("glCopyTextureCHROMIUM", target,
11078 source_texture_ref, dest_texture_ref,
11079 internal_format)) {
11080 return;
11081 }
11082
11083 // Clear the source texture if necessary.
11084 if (!texture_manager()->ClearTextureLevel(this, source_texture_ref,
11085 source_texture->target(), 0)) {
11086 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, "glCopyTextureCHROMIUM",
11087 "dimensions too big");
11088 return;
11089 }
11090
11034 // Defer initializing the CopyTextureCHROMIUMResourceManager until it is 11091 // Defer initializing the CopyTextureCHROMIUMResourceManager until it is
11035 // needed because it takes 10s of milliseconds to initialize. 11092 // needed because it takes 10s of milliseconds to initialize.
11036 if (!copy_texture_CHROMIUM_.get()) { 11093 if (!copy_texture_CHROMIUM_.get()) {
11037 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCopyTextureCHROMIUM"); 11094 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCopyTextureCHROMIUM");
11038 copy_texture_CHROMIUM_.reset(new CopyTextureCHROMIUMResourceManager()); 11095 copy_texture_CHROMIUM_.reset(new CopyTextureCHROMIUMResourceManager());
11039 copy_texture_CHROMIUM_->Initialize(this); 11096 copy_texture_CHROMIUM_->Initialize(this);
11040 RestoreCurrentFramebufferBindings(); 11097 RestoreCurrentFramebufferBindings();
11041 if (LOCAL_PEEK_GL_ERROR("glCopyTextureCHROMIUM") != GL_NO_ERROR) 11098 if (LOCAL_PEEK_GL_ERROR("glCopyTextureCHROMIUM") != GL_NO_ERROR)
11042 return; 11099 return;
11043 } 11100 }
11044 11101
11045 GLenum dest_type_previous = dest_type; 11102 GLenum dest_type_previous = dest_type;
11046 GLenum dest_internal_format = internal_format; 11103 GLenum dest_internal_format = internal_format;
11047 bool dest_level_defined = dest_texture->GetLevelSize( 11104 int dest_width = 0;
11048 GL_TEXTURE_2D, level, &dest_width, &dest_height); 11105 int dest_height = 0;
11106 bool dest_level_defined =
11107 dest_texture->GetLevelSize(GL_TEXTURE_2D, 0, &dest_width, &dest_height);
11049 11108
11050 if (dest_level_defined) { 11109 if (dest_level_defined) {
11051 dest_texture->GetLevelType(GL_TEXTURE_2D, level, &dest_type_previous, 11110 dest_texture->GetLevelType(GL_TEXTURE_2D, 0, &dest_type_previous,
11052 &dest_internal_format); 11111 &dest_internal_format);
11053 } 11112 }
11054 11113
11055 // Resize the destination texture to the dimensions of the source texture. 11114 // Resize the destination texture to the dimensions of the source texture.
11056 if (!dest_level_defined || dest_width != source_width || 11115 if (!dest_level_defined || dest_width != source_width ||
11057 dest_height != source_height || 11116 dest_height != source_height ||
11058 dest_internal_format != internal_format || 11117 dest_internal_format != internal_format ||
11059 dest_type_previous != dest_type) { 11118 dest_type_previous != dest_type) {
11060 // Ensure that the glTexImage2D succeeds. 11119 // Ensure that the glTexImage2D succeeds.
11061 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCopyTextureCHROMIUM"); 11120 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCopyTextureCHROMIUM");
11062 glBindTexture(GL_TEXTURE_2D, dest_texture->service_id()); 11121 glBindTexture(GL_TEXTURE_2D, dest_texture->service_id());
11063 glTexImage2D( 11122 glTexImage2D(GL_TEXTURE_2D, 0, internal_format, source_width, source_height,
11064 GL_TEXTURE_2D, level, internal_format, source_width, source_height, 11123 0, internal_format, dest_type, NULL);
11065 0, internal_format, dest_type, NULL);
11066 GLenum error = LOCAL_PEEK_GL_ERROR("glCopyTextureCHROMIUM"); 11124 GLenum error = LOCAL_PEEK_GL_ERROR("glCopyTextureCHROMIUM");
11067 if (error != GL_NO_ERROR) { 11125 if (error != GL_NO_ERROR) {
11068 RestoreCurrentTextureBindings(&state_, GL_TEXTURE_2D); 11126 RestoreCurrentTextureBindings(&state_, GL_TEXTURE_2D);
11069 return; 11127 return;
11070 } 11128 }
11071 11129
11072 texture_manager()->SetLevelInfo( 11130 texture_manager()->SetLevelInfo(
11073 dest_texture_ref, GL_TEXTURE_2D, level, internal_format, source_width, 11131 dest_texture_ref, GL_TEXTURE_2D, 0, internal_format, source_width,
11074 source_height, 1, 0, internal_format, dest_type, true); 11132 source_height, 1, 0, internal_format, dest_type, true);
11075 } else { 11133 } else {
11076 texture_manager()->SetLevelCleared( 11134 texture_manager()->SetLevelCleared(dest_texture_ref, GL_TEXTURE_2D, 0,
11077 dest_texture_ref, GL_TEXTURE_2D, level, true); 11135 true);
11078 } 11136 }
11079 11137
11080 ScopedModifyPixels modify(dest_texture_ref); 11138 ScopedModifyPixels modify(dest_texture_ref);
11081 11139
11082 // Try using GLImage::CopyTexImage when possible. 11140 // Try using GLImage::CopyTexImage when possible.
11083 bool unpack_premultiply_alpha_change = 11141 bool unpack_premultiply_alpha_change =
11084 unpack_premultiply_alpha_ ^ unpack_unpremultiply_alpha_; 11142 unpack_premultiply_alpha_ ^ unpack_unpremultiply_alpha_;
11085 if (image && !unpack_flip_y_ && !unpack_premultiply_alpha_change && !level) { 11143 if (image && !unpack_flip_y_ && !unpack_premultiply_alpha_change) {
11086 glBindTexture(GL_TEXTURE_2D, dest_texture->service_id()); 11144 glBindTexture(GL_TEXTURE_2D, dest_texture->service_id());
11087 if (image->CopyTexImage(GL_TEXTURE_2D)) 11145 if (image->CopyTexImage(GL_TEXTURE_2D))
11088 return; 11146 return;
11089 } 11147 }
11090 11148
11091 DoWillUseTexImageIfNeeded(source_texture, source_texture->target()); 11149 DoWillUseTexImageIfNeeded(source_texture, source_texture->target());
11092 11150
11093 // GL_TEXTURE_EXTERNAL_OES texture requires apply a transform matrix 11151 // GL_TEXTURE_EXTERNAL_OES texture requires apply a transform matrix
11094 // before presenting. 11152 // before presenting.
11095 if (source_texture->target() == GL_TEXTURE_EXTERNAL_OES) { 11153 if (source_texture->target() == GL_TEXTURE_EXTERNAL_OES) {
11096 // TODO(hkuang): get the StreamTexture transform matrix in GPU process 11154 // TODO(hkuang): get the StreamTexture transform matrix in GPU process
11097 // instead of using default matrix crbug.com/226218. 11155 // instead of using kIdentityMatrix crbug.com/226218.
11098 const static GLfloat default_matrix[16] = {1.0f, 0.0f, 0.0f, 0.0f,
11099 0.0f, 1.0f, 0.0f, 0.0f,
11100 0.0f, 0.0f, 1.0f, 0.0f,
11101 0.0f, 0.0f, 0.0f, 1.0f};
11102 copy_texture_CHROMIUM_->DoCopyTextureWithTransform( 11156 copy_texture_CHROMIUM_->DoCopyTextureWithTransform(
11103 this, 11157 this, source_texture->target(), source_texture->service_id(),
11104 source_texture->target(), 11158 dest_texture->service_id(), source_width, source_height, unpack_flip_y_,
11105 source_texture->service_id(), 11159 unpack_premultiply_alpha_, unpack_unpremultiply_alpha_,
11106 dest_texture->service_id(), 11160 kIdentityMatrix);
11107 level,
11108 source_width,
11109 source_height,
11110 unpack_flip_y_,
11111 unpack_premultiply_alpha_,
11112 unpack_unpremultiply_alpha_,
11113 default_matrix);
11114 } else { 11161 } else {
11115 copy_texture_CHROMIUM_->DoCopyTexture(this, 11162 copy_texture_CHROMIUM_->DoCopyTexture(
11116 source_texture->target(), 11163 this, source_texture->target(), source_texture->service_id(),
11117 source_texture->service_id(), 11164 source_internal_format, dest_texture->service_id(), internal_format,
11118 source_internal_format, 11165 source_width, source_height, unpack_flip_y_, unpack_premultiply_alpha_,
11119 dest_texture->service_id(), 11166 unpack_unpremultiply_alpha_);
11120 level,
11121 internal_format,
11122 source_width,
11123 source_height,
11124 unpack_flip_y_,
11125 unpack_premultiply_alpha_,
11126 unpack_unpremultiply_alpha_);
11127 } 11167 }
11128 11168
11129 DoDidUseTexImageIfNeeded(source_texture, source_texture->target()); 11169 DoDidUseTexImageIfNeeded(source_texture, source_texture->target());
11170 }
11171
11172 void GLES2DecoderImpl::DoCopySubTextureCHROMIUM(GLenum target,
11173 GLuint source_id,
11174 GLuint dest_id,
11175 GLint xoffset,
11176 GLint yoffset) {
11177 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCopySubTextureCHROMIUM");
11178
11179 TextureRef* source_texture_ref = GetTexture(source_id);
11180 TextureRef* dest_texture_ref = GetTexture(dest_id);
11181 Texture* source_texture = source_texture_ref->texture();
11182 Texture* dest_texture = dest_texture_ref->texture();
11183 int source_width = 0;
11184 int source_height = 0;
11185 gfx::GLImage* image =
11186 source_texture->GetLevelImage(source_texture->target(), 0);
11187 if (image) {
11188 gfx::Size size = image->GetSize();
11189 source_width = size.width();
11190 source_height = size.height();
11191 if (source_width <= 0 || source_height <= 0) {
11192 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM",
11193 "invalid image size");
11194 return;
11195 }
11196 } else {
11197 if (!source_texture->GetLevelSize(source_texture->target(), 0,
11198 &source_width, &source_height)) {
11199 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM",
11200 "source texture has no level 0");
11201 return;
11202 }
11203
11204 // Check that this type of texture is allowed.
11205 if (!texture_manager()->ValidForTarget(source_texture->target(), 0,
11206 source_width, source_height, 1)) {
11207 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM",
11208 "source texture bad dimensions");
11209 return;
11210 }
11211 }
11212
11213 GLenum source_type = 0;
11214 GLenum source_internal_format = 0;
11215 source_texture->GetLevelType(source_texture->target(), 0, &source_type,
11216 &source_internal_format);
11217 GLenum dest_type = 0;
11218 GLenum dest_internal_format = 0;
11219 bool dest_level_defined = dest_texture->GetLevelType(
11220 dest_texture->target(), 0, &dest_type, &dest_internal_format);
11221 if (!dest_level_defined) {
11222 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glCopySubTextureCHROMIUM",
11223 "destination texture is not defined");
11224 return;
11225 }
11226 if (!dest_texture->ValidForTexture(dest_texture->target(), 0, xoffset,
11227 yoffset, source_width, source_height,
11228 dest_type)) {
11229 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glCopySubTextureCHROMIUM",
11230 "destination texture bad dimensions.");
11231 return;
11232 }
11233
11234 if (!ValidateCopyTextureCHROMIUM("glCopySubTextureCHROMIUM", target,
11235 source_texture_ref, dest_texture_ref,
11236 dest_internal_format)) {
11237 return;
11238 }
11239
11240 // Clear the source texture if necessary.
11241 if (!texture_manager()->ClearTextureLevel(this, source_texture_ref,
11242 source_texture->target(), 0)) {
11243 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, "glCopySubTextureCHROMIUM",
11244 "source texture dimensions too big");
11245 return;
11246 }
11247
11248 // Defer initializing the CopyTextureCHROMIUMResourceManager until it is
11249 // needed because it takes 10s of milliseconds to initialize.
11250 if (!copy_texture_CHROMIUM_.get()) {
11251 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glCopySubTextureCHROMIUM");
11252 copy_texture_CHROMIUM_.reset(new CopyTextureCHROMIUMResourceManager());
11253 copy_texture_CHROMIUM_->Initialize(this);
11254 RestoreCurrentFramebufferBindings();
11255 if (LOCAL_PEEK_GL_ERROR("glCopySubTextureCHROMIUM") != GL_NO_ERROR)
11256 return;
11257 }
11258
11259 int dest_width = 0;
11260 int dest_height = 0;
11261 bool ok =
11262 dest_texture->GetLevelSize(GL_TEXTURE_2D, 0, &dest_width, &dest_height);
11263 DCHECK(ok);
11264 if (xoffset != 0 || yoffset != 0 || source_width != dest_width ||
11265 source_height != dest_height) {
11266 if (!texture_manager()->ClearTextureLevel(this, dest_texture_ref, target,
11267 0)) {
11268 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, "glCopySubTextureCHROMIUM",
11269 "destination texture dimensions too big");
11270 return;
11271 }
11272 } else {
11273 texture_manager()->SetLevelCleared(dest_texture_ref, GL_TEXTURE_2D, 0,
11274 true);
11275 }
11276
11277 ScopedModifyPixels modify(dest_texture_ref);
11278
11279 // Try using GLImage::CopyTexSubImage when possible.
11280 bool unpack_premultiply_alpha_change =
11281 unpack_premultiply_alpha_ ^ unpack_unpremultiply_alpha_;
11282 if (image && !unpack_flip_y_ && !unpack_premultiply_alpha_change &&
11283 !xoffset && !yoffset) {
11284 glBindTexture(GL_TEXTURE_2D, dest_texture->service_id());
11285 if (image->CopyTexImage(GL_TEXTURE_2D))
11286 return;
11287 }
11288
11289 DoWillUseTexImageIfNeeded(source_texture, source_texture->target());
11290
11291 // GL_TEXTURE_EXTERNAL_OES texture requires apply a transform matrix
11292 // before presenting.
11293 if (source_texture->target() == GL_TEXTURE_EXTERNAL_OES) {
11294 // TODO(hkuang): get the StreamTexture transform matrix in GPU process
11295 // instead of using kIdentityMatrix crbug.com/226218.
11296 copy_texture_CHROMIUM_->DoCopySubTextureWithTransform(
11297 this, source_texture->target(), source_texture->service_id(),
11298 dest_texture->service_id(), xoffset, yoffset, dest_width, dest_height,
11299 source_width, source_height, unpack_flip_y_, unpack_premultiply_alpha_,
11300 unpack_unpremultiply_alpha_, kIdentityMatrix);
11301 } else {
11302 copy_texture_CHROMIUM_->DoCopySubTexture(
11303 this, source_texture->target(), source_texture->service_id(),
11304 source_internal_format, dest_texture->service_id(),
11305 dest_internal_format, xoffset, yoffset, dest_width, dest_height,
11306 source_width, source_height, unpack_flip_y_, unpack_premultiply_alpha_,
11307 unpack_unpremultiply_alpha_);
11308 }
11309
11310 DoDidUseTexImageIfNeeded(source_texture, source_texture->target());
11130 } 11311 }
11131 11312
11132 static GLenum ExtractTypeFromStorageFormat(GLenum internalformat) { 11313 static GLenum ExtractTypeFromStorageFormat(GLenum internalformat) {
11133 switch (internalformat) { 11314 switch (internalformat) {
11134 case GL_RGB565: 11315 case GL_RGB565:
11135 return GL_UNSIGNED_SHORT_5_6_5; 11316 return GL_UNSIGNED_SHORT_5_6_5;
11136 case GL_RGBA4: 11317 case GL_RGBA4:
11137 return GL_UNSIGNED_SHORT_4_4_4_4; 11318 return GL_UNSIGNED_SHORT_4_4_4_4;
11138 case GL_RGB5_A1: 11319 case GL_RGB5_A1:
11139 return GL_UNSIGNED_SHORT_5_5_5_1; 11320 return GL_UNSIGNED_SHORT_5_5_5_1;
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after
11721 DCHECK(matrix_mode == GL_PATH_PROJECTION_CHROMIUM || 11902 DCHECK(matrix_mode == GL_PATH_PROJECTION_CHROMIUM ||
11722 matrix_mode == GL_PATH_MODELVIEW_CHROMIUM); 11903 matrix_mode == GL_PATH_MODELVIEW_CHROMIUM);
11723 11904
11724 if (!features().chromium_path_rendering) { 11905 if (!features().chromium_path_rendering) {
11725 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, 11906 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION,
11726 "glMatrixLoadIdentityCHROMIUM", 11907 "glMatrixLoadIdentityCHROMIUM",
11727 "function not available"); 11908 "function not available");
11728 return; 11909 return;
11729 } 11910 }
11730 11911
11731 static GLfloat kIdentityMatrix[16] = {1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f,
11732 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f,
11733 0.0f, 0.0f, 0.0f, 1.0f};
11734
11735 GLfloat* target_matrix = matrix_mode == GL_PATH_PROJECTION_CHROMIUM 11912 GLfloat* target_matrix = matrix_mode == GL_PATH_PROJECTION_CHROMIUM
11736 ? state_.projection_matrix 11913 ? state_.projection_matrix
11737 : state_.modelview_matrix; 11914 : state_.modelview_matrix;
11738 memcpy(target_matrix, kIdentityMatrix, sizeof(kIdentityMatrix)); 11915 memcpy(target_matrix, kIdentityMatrix, sizeof(kIdentityMatrix));
11739 // The matrix_mode is either GL_PATH_MODELVIEW_NV or GL_PATH_PROJECTION_NV 11916 // The matrix_mode is either GL_PATH_MODELVIEW_NV or GL_PATH_PROJECTION_NV
11740 // since the values of the _NV and _CHROMIUM tokens match. 11917 // since the values of the _NV and _CHROMIUM tokens match.
11741 glMatrixLoadIdentityEXT(matrix_mode); 11918 glMatrixLoadIdentityEXT(matrix_mode);
11742 } 11919 }
11743 11920
11744 bool GLES2DecoderImpl::ValidateAsyncTransfer( 11921 bool GLES2DecoderImpl::ValidateAsyncTransfer(
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
12127 } 12304 }
12128 } 12305 }
12129 12306
12130 // Include the auto-generated part of this file. We split this because it means 12307 // Include the auto-generated part of this file. We split this because it means
12131 // we can easily edit the non-auto generated parts right here in this file 12308 // we can easily edit the non-auto generated parts right here in this file
12132 // instead of having to edit some template or the code generator. 12309 // instead of having to edit some template or the code generator.
12133 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 12310 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
12134 12311
12135 } // namespace gles2 12312 } // namespace gles2
12136 } // namespace gpu 12313 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_decoder.h ('k') | gpu/command_buffer/service/gles2_cmd_decoder_autogen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698