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

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

Issue 2106103005: Revert of Pass initial size and GPU preference via context attributes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 <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
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,
588 const DisallowedFeatures& disallowed_features, 589 const DisallowedFeatures& disallowed_features,
589 const ContextCreationAttribHelper& attrib_helper) override; 590 const ContextCreationAttribHelper& attrib_helper) override;
590 void Destroy(bool have_context) override; 591 void Destroy(bool have_context) override;
591 void SetSurface(const scoped_refptr<gl::GLSurface>& surface) override; 592 void SetSurface(const scoped_refptr<gl::GLSurface>& surface) override;
592 void ReleaseSurface() override; 593 void ReleaseSurface() override;
593 void TakeFrontBuffer(const Mailbox& mailbox) override; 594 void TakeFrontBuffer(const Mailbox& mailbox) override;
594 void ReturnFrontBuffer(const Mailbox& mailbox, bool is_lost) override; 595 void ReturnFrontBuffer(const Mailbox& mailbox, bool is_lost) override;
595 bool ResizeOffscreenFrameBuffer(const gfx::Size& size) override; 596 bool ResizeOffscreenFrameBuffer(const gfx::Size& size) override;
596 bool MakeCurrent() override; 597 bool MakeCurrent() override;
597 GLES2Util* GetGLES2Util() override { return &util_; } 598 GLES2Util* GetGLES2Util() override { return &util_; }
(...skipping 2306 matching lines...) Expand 10 before | Expand all | Expand 10 after
2904 DCHECK(group); 2905 DCHECK(group);
2905 } 2906 }
2906 2907
2907 GLES2DecoderImpl::~GLES2DecoderImpl() { 2908 GLES2DecoderImpl::~GLES2DecoderImpl() {
2908 } 2909 }
2909 2910
2910 bool GLES2DecoderImpl::Initialize( 2911 bool GLES2DecoderImpl::Initialize(
2911 const scoped_refptr<gl::GLSurface>& surface, 2912 const scoped_refptr<gl::GLSurface>& surface,
2912 const scoped_refptr<gl::GLContext>& context, 2913 const scoped_refptr<gl::GLContext>& context,
2913 bool offscreen, 2914 bool offscreen,
2915 const gfx::Size& offscreen_size,
2914 const DisallowedFeatures& disallowed_features, 2916 const DisallowedFeatures& disallowed_features,
2915 const ContextCreationAttribHelper& attrib_helper) { 2917 const ContextCreationAttribHelper& attrib_helper) {
2916 TRACE_EVENT0("gpu", "GLES2DecoderImpl::Initialize"); 2918 TRACE_EVENT0("gpu", "GLES2DecoderImpl::Initialize");
2917 DCHECK(context->IsCurrent(surface.get())); 2919 DCHECK(context->IsCurrent(surface.get()));
2918 DCHECK(!context_.get()); 2920 DCHECK(!context_.get());
2921 DCHECK(!offscreen || !offscreen_size.IsEmpty());
2919 2922
2920 surfaceless_ = surface->IsSurfaceless() && !offscreen; 2923 surfaceless_ = surface->IsSurfaceless() && !offscreen;
2921 2924
2922 set_initialized(); 2925 set_initialized();
2923 gpu_state_tracer_ = GPUStateTracer::Create(&state_); 2926 gpu_state_tracer_ = GPUStateTracer::Create(&state_);
2924 2927
2925 if (group_->gpu_preferences().enable_gpu_debugging) 2928 if (group_->gpu_preferences().enable_gpu_debugging)
2926 set_debug(true); 2929 set_debug(true);
2927 2930
2928 if (group_->gpu_preferences().enable_gpu_command_logging) 2931 if (group_->gpu_preferences().enable_gpu_command_logging)
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
3204 offscreen_target_stencil_render_buffer_->Create(); 3207 offscreen_target_stencil_render_buffer_->Create();
3205 3208
3206 // Create the saved offscreen texture. The target frame buffer is copied 3209 // Create the saved offscreen texture. The target frame buffer is copied
3207 // here when SwapBuffers is called. 3210 // here when SwapBuffers is called.
3208 offscreen_saved_frame_buffer_.reset(new BackFramebuffer(this)); 3211 offscreen_saved_frame_buffer_.reset(new BackFramebuffer(this));
3209 offscreen_saved_frame_buffer_->Create(); 3212 offscreen_saved_frame_buffer_->Create();
3210 // 3213 //
3211 offscreen_saved_color_texture_.reset(new BackTexture(this)); 3214 offscreen_saved_color_texture_.reset(new BackTexture(this));
3212 offscreen_saved_color_texture_->Create(); 3215 offscreen_saved_color_texture_->Create();
3213 3216
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
3224 // Allocate the render buffers at their initial size and check the status 3217 // Allocate the render buffers at their initial size and check the status
3225 // of the frame buffers is okay. 3218 // of the frame buffers is okay.
3226 if (!ResizeOffscreenFrameBuffer(initial_size)) { 3219 if (!ResizeOffscreenFrameBuffer(offscreen_size)) {
3227 LOG(ERROR) << "Could not allocate offscreen buffer storage."; 3220 LOG(ERROR) << "Could not allocate offscreen buffer storage.";
3228 Destroy(true); 3221 Destroy(true);
3229 return false; 3222 return false;
3230 } 3223 }
3231 3224
3232 state_.viewport_width = initial_size.width(); 3225 state_.viewport_width = offscreen_size.width();
3233 state_.viewport_height = initial_size.height(); 3226 state_.viewport_height = offscreen_size.height();
3234 3227
3235 // Allocate the offscreen saved color texture. 3228 // Allocate the offscreen saved color texture.
3236 DCHECK(offscreen_saved_color_format_); 3229 DCHECK(offscreen_saved_color_format_);
3237 offscreen_saved_color_texture_->AllocateStorage( 3230 offscreen_saved_color_texture_->AllocateStorage(
3238 gfx::Size(1, 1), offscreen_saved_color_format_, true); 3231 gfx::Size(1, 1), offscreen_saved_color_format_, true);
3239 3232
3240 offscreen_saved_frame_buffer_->AttachRenderTexture( 3233 offscreen_saved_frame_buffer_->AttachRenderTexture(
3241 offscreen_saved_color_texture_.get()); 3234 offscreen_saved_color_texture_.get());
3242 if (offscreen_saved_frame_buffer_->CheckStatus() != 3235 if (offscreen_saved_frame_buffer_->CheckStatus() !=
3243 GL_FRAMEBUFFER_COMPLETE) { 3236 GL_FRAMEBUFFER_COMPLETE) {
(...skipping 13810 matching lines...) Expand 10 before | Expand all | Expand 10 after
17054 } 17047 }
17055 17048
17056 // Include the auto-generated part of this file. We split this because it means 17049 // Include the auto-generated part of this file. We split this because it means
17057 // we can easily edit the non-auto generated parts right here in this file 17050 // we can easily edit the non-auto generated parts right here in this file
17058 // instead of having to edit some template or the code generator. 17051 // instead of having to edit some template or the code generator.
17059 #include "base/macros.h" 17052 #include "base/macros.h"
17060 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 17053 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
17061 17054
17062 } // namespace gles2 17055 } // namespace gles2
17063 } // namespace gpu 17056 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_decoder.h ('k') | gpu/command_buffer/service/gles2_cmd_decoder_mock.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698