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 2663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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(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 // |size| is set if the GL context is offscreen. | |
2685 state_.viewport_width = size.width(); | |
2686 state_.viewport_height = size.height(); | |
2687 | |
2684 // Allocate the offscreen saved color texture. | 2688 // Allocate the offscreen saved color texture. |
2685 DCHECK(offscreen_saved_color_format_); | 2689 DCHECK(offscreen_saved_color_format_); |
2686 offscreen_saved_color_texture_->AllocateStorage( | 2690 offscreen_saved_color_texture_->AllocateStorage( |
2687 gfx::Size(1, 1), offscreen_saved_color_format_, true); | 2691 gfx::Size(1, 1), offscreen_saved_color_format_, true); |
2688 | 2692 |
2689 offscreen_saved_frame_buffer_->AttachRenderTexture( | 2693 offscreen_saved_frame_buffer_->AttachRenderTexture( |
2690 offscreen_saved_color_texture_.get()); | 2694 offscreen_saved_color_texture_.get()); |
2691 if (offscreen_saved_frame_buffer_->CheckStatus() != | 2695 if (offscreen_saved_frame_buffer_->CheckStatus() != |
2692 GL_FRAMEBUFFER_COMPLETE) { | 2696 GL_FRAMEBUFFER_COMPLETE) { |
2693 LOG(ERROR) << "Offscreen saved FBO was incomplete."; | 2697 LOG(ERROR) << "Offscreen saved FBO was incomplete."; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2735 | 2739 |
2736 has_robustness_extension_ = | 2740 has_robustness_extension_ = |
2737 context->HasExtension("GL_ARB_robustness") || | 2741 context->HasExtension("GL_ARB_robustness") || |
2738 context->HasExtension("GL_KHR_robustness") || | 2742 context->HasExtension("GL_KHR_robustness") || |
2739 context->HasExtension("GL_EXT_robustness"); | 2743 context->HasExtension("GL_EXT_robustness"); |
2740 | 2744 |
2741 if (!InitializeShaderTranslator()) { | 2745 if (!InitializeShaderTranslator()) { |
2742 return false; | 2746 return false; |
2743 } | 2747 } |
2744 | 2748 |
2745 state_.viewport_width = size.width(); | |
2746 state_.viewport_height = size.height(); | |
no sievers
2015/03/02 20:37:12
What's the bug?
We call InitState() in line 2758,
dshwang
2015/03/03 09:20:29
There's no bug. I just confused why onscreen viewp
| |
2747 | |
2748 GLint viewport_params[4] = { 0 }; | 2749 GLint viewport_params[4] = { 0 }; |
2749 glGetIntegerv(GL_MAX_VIEWPORT_DIMS, viewport_params); | 2750 glGetIntegerv(GL_MAX_VIEWPORT_DIMS, viewport_params); |
2750 viewport_max_width_ = viewport_params[0]; | 2751 viewport_max_width_ = viewport_params[0]; |
2751 viewport_max_height_ = viewport_params[1]; | 2752 viewport_max_height_ = viewport_params[1]; |
2752 | 2753 |
2753 state_.scissor_width = state_.viewport_width; | 2754 state_.scissor_width = state_.viewport_width; |
2754 state_.scissor_height = state_.viewport_height; | 2755 state_.scissor_height = state_.viewport_height; |
2755 | 2756 |
2756 // Set all the default state because some GL drivers get it wrong. | 2757 // Set all the default state because some GL drivers get it wrong. |
2757 state_.InitCapabilities(NULL); | 2758 state_.InitCapabilities(NULL); |
(...skipping 9369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
12127 } | 12128 } |
12128 } | 12129 } |
12129 | 12130 |
12130 // Include the auto-generated part of this file. We split this because it means | 12131 // 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 | 12132 // 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. | 12133 // instead of having to edit some template or the code generator. |
12133 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 12134 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
12134 | 12135 |
12135 } // namespace gles2 | 12136 } // namespace gles2 |
12136 } // namespace gpu | 12137 } // namespace gpu |
OLD | NEW |