OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
6 | 6 |
7 #include <stdio.h> | 7 #include <stdio.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <list> | 10 #include <list> |
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
578 int num_entries, | 578 int num_entries, |
579 int* entries_processed); | 579 int* entries_processed); |
580 | 580 |
581 // Overridden from AsyncAPIInterface. | 581 // Overridden from AsyncAPIInterface. |
582 const char* GetCommandName(unsigned int command_id) const override; | 582 const char* GetCommandName(unsigned int command_id) const override; |
583 | 583 |
584 // Overridden from GLES2Decoder. | 584 // Overridden from GLES2Decoder. |
585 bool Initialize(const scoped_refptr<gfx::GLSurface>& surface, | 585 bool Initialize(const scoped_refptr<gfx::GLSurface>& surface, |
586 const scoped_refptr<gfx::GLContext>& context, | 586 const scoped_refptr<gfx::GLContext>& context, |
587 bool offscreen, | 587 bool offscreen, |
588 const gfx::Size& size, | 588 const gfx::Size& offscreen_size, |
589 const DisallowedFeatures& disallowed_features, | 589 const DisallowedFeatures& disallowed_features, |
590 const std::vector<int32>& attribs) override; | 590 const std::vector<int32>& attribs) override; |
591 void Destroy(bool have_context) override; | 591 void Destroy(bool have_context) override; |
592 void SetSurface(const scoped_refptr<gfx::GLSurface>& surface) override; | 592 void SetSurface(const scoped_refptr<gfx::GLSurface>& surface) override; |
593 void ProduceFrontBuffer(const Mailbox& mailbox) override; | 593 void ProduceFrontBuffer(const Mailbox& mailbox) override; |
594 bool ResizeOffscreenFrameBuffer(const gfx::Size& size) override; | 594 bool ResizeOffscreenFrameBuffer(const gfx::Size& size) override; |
595 void UpdateParentTextureInfo(); | 595 void UpdateParentTextureInfo(); |
596 bool MakeCurrent() override; | 596 bool MakeCurrent() override; |
597 GLES2Util* GetGLES2Util() override { return &util_; } | 597 GLES2Util* GetGLES2Util() override { return &util_; } |
598 gfx::GLContext* GetGLContext() override { return context_.get(); } | 598 gfx::GLContext* GetGLContext() override { return context_.get(); } |
(...skipping 1828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2427 } | 2427 } |
2428 } | 2428 } |
2429 | 2429 |
2430 GLES2DecoderImpl::~GLES2DecoderImpl() { | 2430 GLES2DecoderImpl::~GLES2DecoderImpl() { |
2431 } | 2431 } |
2432 | 2432 |
2433 bool GLES2DecoderImpl::Initialize( | 2433 bool GLES2DecoderImpl::Initialize( |
2434 const scoped_refptr<gfx::GLSurface>& surface, | 2434 const scoped_refptr<gfx::GLSurface>& surface, |
2435 const scoped_refptr<gfx::GLContext>& context, | 2435 const scoped_refptr<gfx::GLContext>& context, |
2436 bool offscreen, | 2436 bool offscreen, |
2437 const gfx::Size& size, | 2437 const gfx::Size& offscreen_size, |
2438 const DisallowedFeatures& disallowed_features, | 2438 const DisallowedFeatures& disallowed_features, |
2439 const std::vector<int32>& attribs) { | 2439 const std::vector<int32>& attribs) { |
2440 TRACE_EVENT0("gpu", "GLES2DecoderImpl::Initialize"); | 2440 TRACE_EVENT0("gpu", "GLES2DecoderImpl::Initialize"); |
2441 DCHECK(context->IsCurrent(surface.get())); | 2441 DCHECK(context->IsCurrent(surface.get())); |
2442 DCHECK(!context_.get()); | 2442 DCHECK(!context_.get()); |
2443 | 2443 |
2444 surfaceless_ = surface->IsSurfaceless() && !offscreen; | 2444 surfaceless_ = surface->IsSurfaceless() && !offscreen; |
2445 | 2445 |
2446 set_initialized(); | 2446 set_initialized(); |
2447 gpu_state_tracer_ = GPUStateTracer::Create(&state_); | 2447 gpu_state_tracer_ = GPUStateTracer::Create(&state_); |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2668 // here when SwapBuffers is called. | 2668 // here when SwapBuffers is called. |
2669 offscreen_saved_frame_buffer_.reset(new BackFramebuffer(this)); | 2669 offscreen_saved_frame_buffer_.reset(new BackFramebuffer(this)); |
2670 offscreen_saved_frame_buffer_->Create(); | 2670 offscreen_saved_frame_buffer_->Create(); |
2671 // | 2671 // |
2672 offscreen_saved_color_texture_.reset(new BackTexture( | 2672 offscreen_saved_color_texture_.reset(new BackTexture( |
2673 memory_tracker(), &state_)); | 2673 memory_tracker(), &state_)); |
2674 offscreen_saved_color_texture_->Create(); | 2674 offscreen_saved_color_texture_->Create(); |
2675 | 2675 |
2676 // Allocate the render buffers at their initial size and check the status | 2676 // Allocate the render buffers at their initial size and check the status |
2677 // of the frame buffers is okay. | 2677 // of the frame buffers is okay. |
2678 if (!ResizeOffscreenFrameBuffer(size)) { | 2678 if (!ResizeOffscreenFrameBuffer(offscreen_size)) { |
2679 LOG(ERROR) << "Could not allocate offscreen buffer storage."; | 2679 LOG(ERROR) << "Could not allocate offscreen buffer storage."; |
2680 Destroy(true); | 2680 Destroy(true); |
2681 return false; | 2681 return false; |
2682 } | 2682 } |
2683 | 2683 |
| 2684 state_.viewport_width = offscreen_size.width(); |
| 2685 state_.viewport_height = offscreen_size.height(); |
| 2686 |
2684 // Allocate the offscreen saved color texture. | 2687 // Allocate the offscreen saved color texture. |
2685 DCHECK(offscreen_saved_color_format_); | 2688 DCHECK(offscreen_saved_color_format_); |
2686 offscreen_saved_color_texture_->AllocateStorage( | 2689 offscreen_saved_color_texture_->AllocateStorage( |
2687 gfx::Size(1, 1), offscreen_saved_color_format_, true); | 2690 gfx::Size(1, 1), offscreen_saved_color_format_, true); |
2688 | 2691 |
2689 offscreen_saved_frame_buffer_->AttachRenderTexture( | 2692 offscreen_saved_frame_buffer_->AttachRenderTexture( |
2690 offscreen_saved_color_texture_.get()); | 2693 offscreen_saved_color_texture_.get()); |
2691 if (offscreen_saved_frame_buffer_->CheckStatus() != | 2694 if (offscreen_saved_frame_buffer_->CheckStatus() != |
2692 GL_FRAMEBUFFER_COMPLETE) { | 2695 GL_FRAMEBUFFER_COMPLETE) { |
2693 LOG(ERROR) << "Offscreen saved FBO was incomplete."; | 2696 LOG(ERROR) << "Offscreen saved FBO was incomplete."; |
(...skipping 19 matching lines...) Expand all Loading... |
2713 // This checks if the user requested RGBA and we have RGBA then RGBA. If | 2716 // 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 | 2717 // 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. | 2718 // preference than use whatever we were given. Same for DEPTH and STENCIL. |
2716 back_buffer_color_format_ = | 2719 back_buffer_color_format_ = |
2717 (attrib_parser.alpha_size != 0 && v > 0) ? GL_RGBA : GL_RGB; | 2720 (attrib_parser.alpha_size != 0 && v > 0) ? GL_RGBA : GL_RGB; |
2718 glGetIntegerv(GL_DEPTH_BITS, &v); | 2721 glGetIntegerv(GL_DEPTH_BITS, &v); |
2719 back_buffer_has_depth_ = attrib_parser.depth_size != 0 && v > 0; | 2722 back_buffer_has_depth_ = attrib_parser.depth_size != 0 && v > 0; |
2720 glGetIntegerv(GL_STENCIL_BITS, &v); | 2723 glGetIntegerv(GL_STENCIL_BITS, &v); |
2721 back_buffer_has_stencil_ = attrib_parser.stencil_size != 0 && v > 0; | 2724 back_buffer_has_stencil_ = attrib_parser.stencil_size != 0 && v > 0; |
2722 } | 2725 } |
| 2726 |
| 2727 state_.viewport_width = surface->GetSize().width(); |
| 2728 state_.viewport_height = surface->GetSize().height(); |
2723 } | 2729 } |
2724 | 2730 |
2725 // OpenGL ES 2.0 implicitly enables the desktop GL capability | 2731 // OpenGL ES 2.0 implicitly enables the desktop GL capability |
2726 // VERTEX_PROGRAM_POINT_SIZE and doesn't expose this enum. This fact | 2732 // 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 | 2733 // isn't well documented; it was discovered in the Khronos OpenGL ES |
2728 // mailing list archives. It also implicitly enables the desktop GL | 2734 // mailing list archives. It also implicitly enables the desktop GL |
2729 // capability GL_POINT_SPRITE to provide access to the gl_PointCoord | 2735 // capability GL_POINT_SPRITE to provide access to the gl_PointCoord |
2730 // variable in fragment shaders. | 2736 // variable in fragment shaders. |
2731 if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) { | 2737 if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) { |
2732 glEnable(GL_VERTEX_PROGRAM_POINT_SIZE); | 2738 glEnable(GL_VERTEX_PROGRAM_POINT_SIZE); |
2733 glEnable(GL_POINT_SPRITE); | 2739 glEnable(GL_POINT_SPRITE); |
2734 } | 2740 } |
2735 | 2741 |
2736 has_robustness_extension_ = | 2742 has_robustness_extension_ = |
2737 context->HasExtension("GL_ARB_robustness") || | 2743 context->HasExtension("GL_ARB_robustness") || |
2738 context->HasExtension("GL_KHR_robustness") || | 2744 context->HasExtension("GL_KHR_robustness") || |
2739 context->HasExtension("GL_EXT_robustness"); | 2745 context->HasExtension("GL_EXT_robustness"); |
2740 | 2746 |
2741 if (!InitializeShaderTranslator()) { | 2747 if (!InitializeShaderTranslator()) { |
2742 return false; | 2748 return false; |
2743 } | 2749 } |
2744 | 2750 |
2745 state_.viewport_width = size.width(); | |
2746 state_.viewport_height = size.height(); | |
2747 | |
2748 GLint viewport_params[4] = { 0 }; | 2751 GLint viewport_params[4] = { 0 }; |
2749 glGetIntegerv(GL_MAX_VIEWPORT_DIMS, viewport_params); | 2752 glGetIntegerv(GL_MAX_VIEWPORT_DIMS, viewport_params); |
2750 viewport_max_width_ = viewport_params[0]; | 2753 viewport_max_width_ = viewport_params[0]; |
2751 viewport_max_height_ = viewport_params[1]; | 2754 viewport_max_height_ = viewport_params[1]; |
2752 | 2755 |
2753 state_.scissor_width = state_.viewport_width; | 2756 state_.scissor_width = state_.viewport_width; |
2754 state_.scissor_height = state_.viewport_height; | 2757 state_.scissor_height = state_.viewport_height; |
2755 | 2758 |
2756 // Set all the default state because some GL drivers get it wrong. | 2759 // Set all the default state because some GL drivers get it wrong. |
2757 state_.InitCapabilities(NULL); | 2760 state_.InitCapabilities(NULL); |
(...skipping 9369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12127 } | 12130 } |
12128 } | 12131 } |
12129 | 12132 |
12130 // Include the auto-generated part of this file. We split this because it means | 12133 // 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 | 12134 // 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. | 12135 // instead of having to edit some template or the code generator. |
12133 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 12136 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
12134 | 12137 |
12135 } // namespace gles2 | 12138 } // namespace gles2 |
12136 } // namespace gpu | 12139 } // namespace gpu |
OLD | NEW |