| 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 <limits.h> | 7 #include <limits.h> |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 #include <stdio.h> | 10 #include <stdio.h> |
| (...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<gl::GLSurface>& surface, | 585 bool Initialize(const scoped_refptr<gl::GLSurface>& surface, |
| 586 const scoped_refptr<gl::GLContext>& context, | 586 const scoped_refptr<gl::GLContext>& context, |
| 587 bool offscreen, | 587 bool offscreen, |
| 588 const gfx::Size& offscreen_size, | |
| 589 const DisallowedFeatures& disallowed_features, | 588 const DisallowedFeatures& disallowed_features, |
| 590 const ContextCreationAttribHelper& attrib_helper) override; | 589 const ContextCreationAttribHelper& attrib_helper) override; |
| 591 void Destroy(bool have_context) override; | 590 void Destroy(bool have_context) override; |
| 592 void SetSurface(const scoped_refptr<gl::GLSurface>& surface) override; | 591 void SetSurface(const scoped_refptr<gl::GLSurface>& surface) override; |
| 593 void ReleaseSurface() override; | 592 void ReleaseSurface() override; |
| 594 void TakeFrontBuffer(const Mailbox& mailbox) override; | 593 void TakeFrontBuffer(const Mailbox& mailbox) override; |
| 595 void ReturnFrontBuffer(const Mailbox& mailbox, bool is_lost) override; | 594 void ReturnFrontBuffer(const Mailbox& mailbox, bool is_lost) override; |
| 596 bool ResizeOffscreenFrameBuffer(const gfx::Size& size) override; | 595 bool ResizeOffscreenFrameBuffer(const gfx::Size& size) override; |
| 597 bool MakeCurrent() override; | 596 bool MakeCurrent() override; |
| 598 GLES2Util* GetGLES2Util() override { return &util_; } | 597 GLES2Util* GetGLES2Util() override { return &util_; } |
| (...skipping 2306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2905 DCHECK(group); | 2904 DCHECK(group); |
| 2906 } | 2905 } |
| 2907 | 2906 |
| 2908 GLES2DecoderImpl::~GLES2DecoderImpl() { | 2907 GLES2DecoderImpl::~GLES2DecoderImpl() { |
| 2909 } | 2908 } |
| 2910 | 2909 |
| 2911 bool GLES2DecoderImpl::Initialize( | 2910 bool GLES2DecoderImpl::Initialize( |
| 2912 const scoped_refptr<gl::GLSurface>& surface, | 2911 const scoped_refptr<gl::GLSurface>& surface, |
| 2913 const scoped_refptr<gl::GLContext>& context, | 2912 const scoped_refptr<gl::GLContext>& context, |
| 2914 bool offscreen, | 2913 bool offscreen, |
| 2915 const gfx::Size& offscreen_size, | |
| 2916 const DisallowedFeatures& disallowed_features, | 2914 const DisallowedFeatures& disallowed_features, |
| 2917 const ContextCreationAttribHelper& attrib_helper) { | 2915 const ContextCreationAttribHelper& attrib_helper) { |
| 2918 TRACE_EVENT0("gpu", "GLES2DecoderImpl::Initialize"); | 2916 TRACE_EVENT0("gpu", "GLES2DecoderImpl::Initialize"); |
| 2919 DCHECK(context->IsCurrent(surface.get())); | 2917 DCHECK(context->IsCurrent(surface.get())); |
| 2920 DCHECK(!context_.get()); | 2918 DCHECK(!context_.get()); |
| 2921 DCHECK(!offscreen || !offscreen_size.IsEmpty()); | |
| 2922 | 2919 |
| 2923 surfaceless_ = surface->IsSurfaceless() && !offscreen; | 2920 surfaceless_ = surface->IsSurfaceless() && !offscreen; |
| 2924 | 2921 |
| 2925 set_initialized(); | 2922 set_initialized(); |
| 2926 gpu_state_tracer_ = GPUStateTracer::Create(&state_); | 2923 gpu_state_tracer_ = GPUStateTracer::Create(&state_); |
| 2927 | 2924 |
| 2928 if (group_->gpu_preferences().enable_gpu_debugging) | 2925 if (group_->gpu_preferences().enable_gpu_debugging) |
| 2929 set_debug(true); | 2926 set_debug(true); |
| 2930 | 2927 |
| 2931 if (group_->gpu_preferences().enable_gpu_command_logging) | 2928 if (group_->gpu_preferences().enable_gpu_command_logging) |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3207 offscreen_target_stencil_render_buffer_->Create(); | 3204 offscreen_target_stencil_render_buffer_->Create(); |
| 3208 | 3205 |
| 3209 // Create the saved offscreen texture. The target frame buffer is copied | 3206 // Create the saved offscreen texture. The target frame buffer is copied |
| 3210 // here when SwapBuffers is called. | 3207 // here when SwapBuffers is called. |
| 3211 offscreen_saved_frame_buffer_.reset(new BackFramebuffer(this)); | 3208 offscreen_saved_frame_buffer_.reset(new BackFramebuffer(this)); |
| 3212 offscreen_saved_frame_buffer_->Create(); | 3209 offscreen_saved_frame_buffer_->Create(); |
| 3213 // | 3210 // |
| 3214 offscreen_saved_color_texture_.reset(new BackTexture(this)); | 3211 offscreen_saved_color_texture_.reset(new BackTexture(this)); |
| 3215 offscreen_saved_color_texture_->Create(); | 3212 offscreen_saved_color_texture_->Create(); |
| 3216 | 3213 |
| 3214 gfx::Size initial_size = attrib_helper.offscreen_framebuffer_size; |
| 3215 if (initial_size.IsEmpty()) { |
| 3216 // If we're an offscreen surface with zero width and/or height, set to a |
| 3217 // non-zero size so that we have a complete framebuffer for operations |
| 3218 // like glClear. |
| 3219 // TODO(piman): allow empty framebuffers, similar to |
| 3220 // EGL_KHR_surfaceless_context / GL_OES_surfaceless_context. |
| 3221 initial_size = gfx::Size(1, 1); |
| 3222 } |
| 3223 |
| 3217 // Allocate the render buffers at their initial size and check the status | 3224 // Allocate the render buffers at their initial size and check the status |
| 3218 // of the frame buffers is okay. | 3225 // of the frame buffers is okay. |
| 3219 if (!ResizeOffscreenFrameBuffer(offscreen_size)) { | 3226 if (!ResizeOffscreenFrameBuffer(initial_size)) { |
| 3220 LOG(ERROR) << "Could not allocate offscreen buffer storage."; | 3227 LOG(ERROR) << "Could not allocate offscreen buffer storage."; |
| 3221 Destroy(true); | 3228 Destroy(true); |
| 3222 return false; | 3229 return false; |
| 3223 } | 3230 } |
| 3224 | 3231 |
| 3225 state_.viewport_width = offscreen_size.width(); | 3232 state_.viewport_width = initial_size.width(); |
| 3226 state_.viewport_height = offscreen_size.height(); | 3233 state_.viewport_height = initial_size.height(); |
| 3227 | 3234 |
| 3228 // Allocate the offscreen saved color texture. | 3235 // Allocate the offscreen saved color texture. |
| 3229 DCHECK(offscreen_saved_color_format_); | 3236 DCHECK(offscreen_saved_color_format_); |
| 3230 offscreen_saved_color_texture_->AllocateStorage( | 3237 offscreen_saved_color_texture_->AllocateStorage( |
| 3231 gfx::Size(1, 1), offscreen_saved_color_format_, true); | 3238 gfx::Size(1, 1), offscreen_saved_color_format_, true); |
| 3232 | 3239 |
| 3233 offscreen_saved_frame_buffer_->AttachRenderTexture( | 3240 offscreen_saved_frame_buffer_->AttachRenderTexture( |
| 3234 offscreen_saved_color_texture_.get()); | 3241 offscreen_saved_color_texture_.get()); |
| 3235 if (offscreen_saved_frame_buffer_->CheckStatus() != | 3242 if (offscreen_saved_frame_buffer_->CheckStatus() != |
| 3236 GL_FRAMEBUFFER_COMPLETE) { | 3243 GL_FRAMEBUFFER_COMPLETE) { |
| (...skipping 13810 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 17047 } | 17054 } |
| 17048 | 17055 |
| 17049 // Include the auto-generated part of this file. We split this because it means | 17056 // Include the auto-generated part of this file. We split this because it means |
| 17050 // we can easily edit the non-auto generated parts right here in this file | 17057 // we can easily edit the non-auto generated parts right here in this file |
| 17051 // instead of having to edit some template or the code generator. | 17058 // instead of having to edit some template or the code generator. |
| 17052 #include "base/macros.h" | 17059 #include "base/macros.h" |
| 17053 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 17060 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 17054 | 17061 |
| 17055 } // namespace gles2 | 17062 } // namespace gles2 |
| 17056 } // namespace gpu | 17063 } // namespace gpu |
| OLD | NEW |