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

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

Issue 1998723002: Move code in ui/gl/* from gfx:: to gl:: (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 6 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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 // These values are for an IEEE single-precision floating-point format. 121 // These values are for an IEEE single-precision floating-point format.
122 range[0] = 127; 122 range[0] = 127;
123 range[1] = 127; 123 range[1] = 127;
124 *precision = 23; 124 *precision = 23;
125 break; 125 break;
126 default: 126 default:
127 NOTREACHED(); 127 NOTREACHED();
128 break; 128 break;
129 } 129 }
130 130
131 if (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2 && 131 if (gl::GetGLImplementation() == gl::kGLImplementationEGLGLES2 &&
132 gfx::g_driver_gl.fn.glGetShaderPrecisionFormatFn) { 132 gl::g_driver_gl.fn.glGetShaderPrecisionFormatFn) {
133 // This function is sometimes defined even though it's really just 133 // This function is sometimes defined even though it's really just
134 // a stub, so we need to set range and precision as if it weren't 134 // a stub, so we need to set range and precision as if it weren't
135 // defined before calling it. 135 // defined before calling it.
136 // On Mac OS with some GPUs, calling this generates a 136 // On Mac OS with some GPUs, calling this generates a
137 // GL_INVALID_OPERATION error. Avoid calling it on non-GLES2 137 // GL_INVALID_OPERATION error. Avoid calling it on non-GLES2
138 // platforms. 138 // platforms.
139 glGetShaderPrecisionFormat(shader_type, precision_type, 139 glGetShaderPrecisionFormat(shader_type, precision_type,
140 range, precision); 140 range, precision);
141 141
142 // TODO(brianderson): Make the following official workarounds. 142 // TODO(brianderson): Make the following official workarounds.
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 return id_; 508 return id_;
509 } 509 }
510 510
511 private: 511 private:
512 GLES2DecoderImpl* decoder_; 512 GLES2DecoderImpl* decoder_;
513 GLuint id_; 513 GLuint id_;
514 DISALLOW_COPY_AND_ASSIGN(BackFramebuffer); 514 DISALLOW_COPY_AND_ASSIGN(BackFramebuffer);
515 }; 515 };
516 516
517 struct FenceCallback { 517 struct FenceCallback {
518 FenceCallback() 518 FenceCallback() : fence(gl::GLFence::Create()) { DCHECK(fence); }
519 : fence(gfx::GLFence::Create()) {
520 DCHECK(fence);
521 }
522 std::vector<base::Closure> callbacks; 519 std::vector<base::Closure> callbacks;
523 std::unique_ptr<gfx::GLFence> fence; 520 std::unique_ptr<gl::GLFence> fence;
524 }; 521 };
525 522
526 // } // anonymous namespace. 523 // } // anonymous namespace.
527 524
528 // static 525 // static
529 const unsigned int GLES2Decoder::kDefaultStencilMask = 526 const unsigned int GLES2Decoder::kDefaultStencilMask =
530 static_cast<unsigned int>(-1); 527 static_cast<unsigned int>(-1);
531 528
532 bool GLES2Decoder::GetServiceTextureId(uint32_t client_texture_id, 529 bool GLES2Decoder::GetServiceTextureId(uint32_t client_texture_id,
533 uint32_t* service_texture_id) { 530 uint32_t* service_texture_id) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 template <bool DebugImpl> 570 template <bool DebugImpl>
574 error::Error DoCommandsImpl(unsigned int num_commands, 571 error::Error DoCommandsImpl(unsigned int num_commands,
575 const void* buffer, 572 const void* buffer,
576 int num_entries, 573 int num_entries,
577 int* entries_processed); 574 int* entries_processed);
578 575
579 // Overridden from AsyncAPIInterface. 576 // Overridden from AsyncAPIInterface.
580 const char* GetCommandName(unsigned int command_id) const override; 577 const char* GetCommandName(unsigned int command_id) const override;
581 578
582 // Overridden from GLES2Decoder. 579 // Overridden from GLES2Decoder.
583 bool Initialize(const scoped_refptr<gfx::GLSurface>& surface, 580 bool Initialize(const scoped_refptr<gl::GLSurface>& surface,
584 const scoped_refptr<gfx::GLContext>& context, 581 const scoped_refptr<gl::GLContext>& context,
585 bool offscreen, 582 bool offscreen,
586 const gfx::Size& offscreen_size, 583 const gfx::Size& offscreen_size,
587 const DisallowedFeatures& disallowed_features, 584 const DisallowedFeatures& disallowed_features,
588 const ContextCreationAttribHelper& attrib_helper) override; 585 const ContextCreationAttribHelper& attrib_helper) override;
589 void Destroy(bool have_context) override; 586 void Destroy(bool have_context) override;
590 void SetSurface(const scoped_refptr<gfx::GLSurface>& surface) override; 587 void SetSurface(const scoped_refptr<gl::GLSurface>& surface) override;
591 void ReleaseSurface() override; 588 void ReleaseSurface() override;
592 void TakeFrontBuffer(const Mailbox& mailbox) override; 589 void TakeFrontBuffer(const Mailbox& mailbox) override;
593 void ReturnFrontBuffer(const Mailbox& mailbox, bool is_lost) override; 590 void ReturnFrontBuffer(const Mailbox& mailbox, bool is_lost) override;
594 bool ResizeOffscreenFrameBuffer(const gfx::Size& size) override; 591 bool ResizeOffscreenFrameBuffer(const gfx::Size& size) override;
595 void UpdateParentTextureInfo(); 592 void UpdateParentTextureInfo();
596 bool MakeCurrent() override; 593 bool MakeCurrent() override;
597 GLES2Util* GetGLES2Util() override { return &util_; } 594 GLES2Util* GetGLES2Util() override { return &util_; }
598 gfx::GLContext* GetGLContext() override { return context_.get(); } 595 gl::GLContext* GetGLContext() override { return context_.get(); }
599 ContextGroup* GetContextGroup() override { return group_.get(); } 596 ContextGroup* GetContextGroup() override { return group_.get(); }
600 Capabilities GetCapabilities() override; 597 Capabilities GetCapabilities() override;
601 void RestoreState(const ContextState* prev_state) override; 598 void RestoreState(const ContextState* prev_state) override;
602 599
603 void RestoreActiveTexture() const override { state_.RestoreActiveTexture(); } 600 void RestoreActiveTexture() const override { state_.RestoreActiveTexture(); }
604 void RestoreAllTextureUnitBindings( 601 void RestoreAllTextureUnitBindings(
605 const ContextState* prev_state) const override { 602 const ContextState* prev_state) const override {
606 state_.RestoreAllTextureUnitBindings(prev_state); 603 state_.RestoreAllTextureUnitBindings(prev_state);
607 } 604 }
608 void RestoreActiveTextureUnitBinding(unsigned int target) const override { 605 void RestoreActiveTextureUnitBinding(unsigned int target) const override {
(...skipping 1386 matching lines...) Expand 10 before | Expand all | Expand 10 after
1995 // Generate a member function prototype for each command in an automated and 1992 // Generate a member function prototype for each command in an automated and
1996 // typesafe way. 1993 // typesafe way.
1997 #define GLES2_CMD_OP(name) \ 1994 #define GLES2_CMD_OP(name) \
1998 Error Handle##name(uint32_t immediate_data_size, const void* data); 1995 Error Handle##name(uint32_t immediate_data_size, const void* data);
1999 1996
2000 GLES2_COMMAND_LIST(GLES2_CMD_OP) 1997 GLES2_COMMAND_LIST(GLES2_CMD_OP)
2001 1998
2002 #undef GLES2_CMD_OP 1999 #undef GLES2_CMD_OP
2003 2000
2004 // The GL context this decoder renders to on behalf of the client. 2001 // The GL context this decoder renders to on behalf of the client.
2005 scoped_refptr<gfx::GLSurface> surface_; 2002 scoped_refptr<gl::GLSurface> surface_;
2006 scoped_refptr<gfx::GLContext> context_; 2003 scoped_refptr<gl::GLContext> context_;
2007 2004
2008 // The ContextGroup for this decoder uses to track resources. 2005 // The ContextGroup for this decoder uses to track resources.
2009 scoped_refptr<ContextGroup> group_; 2006 scoped_refptr<ContextGroup> group_;
2010 2007
2011 DebugMarkerManager debug_marker_manager_; 2008 DebugMarkerManager debug_marker_manager_;
2012 Logger logger_; 2009 Logger logger_;
2013 2010
2014 // All the state for this context. 2011 // All the state for this context.
2015 ContextState state_; 2012 ContextState state_;
2016 2013
(...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after
2748 validation_fbo_(0), 2745 validation_fbo_(0),
2749 texture_manager_service_id_generation_(0), 2746 texture_manager_service_id_generation_(0),
2750 force_shader_name_hashing_for_test(false) { 2747 force_shader_name_hashing_for_test(false) {
2751 DCHECK(group); 2748 DCHECK(group);
2752 } 2749 }
2753 2750
2754 GLES2DecoderImpl::~GLES2DecoderImpl() { 2751 GLES2DecoderImpl::~GLES2DecoderImpl() {
2755 } 2752 }
2756 2753
2757 bool GLES2DecoderImpl::Initialize( 2754 bool GLES2DecoderImpl::Initialize(
2758 const scoped_refptr<gfx::GLSurface>& surface, 2755 const scoped_refptr<gl::GLSurface>& surface,
2759 const scoped_refptr<gfx::GLContext>& context, 2756 const scoped_refptr<gl::GLContext>& context,
2760 bool offscreen, 2757 bool offscreen,
2761 const gfx::Size& offscreen_size, 2758 const gfx::Size& offscreen_size,
2762 const DisallowedFeatures& disallowed_features, 2759 const DisallowedFeatures& disallowed_features,
2763 const ContextCreationAttribHelper& attrib_helper) { 2760 const ContextCreationAttribHelper& attrib_helper) {
2764 TRACE_EVENT0("gpu", "GLES2DecoderImpl::Initialize"); 2761 TRACE_EVENT0("gpu", "GLES2DecoderImpl::Initialize");
2765 DCHECK(context->IsCurrent(surface.get())); 2762 DCHECK(context->IsCurrent(surface.get()));
2766 DCHECK(!context_.get()); 2763 DCHECK(!context_.get());
2767 DCHECK(!offscreen || !offscreen_size.IsEmpty()); 2764 DCHECK(!offscreen || !offscreen_size.IsEmpty());
2768 2765
2769 surfaceless_ = surface->IsSurfaceless() && !offscreen; 2766 surfaceless_ = surface->IsSurfaceless() && !offscreen;
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
2923 // glGetIntegerv() throws a GL error, it leaves its argument unchanged. 2920 // glGetIntegerv() throws a GL error, it leaves its argument unchanged.
2924 GLint max_sample_count = 1; 2921 GLint max_sample_count = 1;
2925 glGetIntegerv(GL_MAX_SAMPLES_EXT, &max_sample_count); 2922 glGetIntegerv(GL_MAX_SAMPLES_EXT, &max_sample_count);
2926 offscreen_target_samples_ = std::min(attrib_helper.samples, 2923 offscreen_target_samples_ = std::min(attrib_helper.samples,
2927 max_sample_count); 2924 max_sample_count);
2928 } else { 2925 } else {
2929 offscreen_target_samples_ = 1; 2926 offscreen_target_samples_ = 1;
2930 } 2927 }
2931 offscreen_target_buffer_preserved_ = attrib_helper.buffer_preserved; 2928 offscreen_target_buffer_preserved_ = attrib_helper.buffer_preserved;
2932 2929
2933 if (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2) { 2930 if (gl::GetGLImplementation() == gl::kGLImplementationEGLGLES2) {
2934 const bool rgb8_supported = 2931 const bool rgb8_supported =
2935 context_->HasExtension("GL_OES_rgb8_rgba8"); 2932 context_->HasExtension("GL_OES_rgb8_rgba8");
2936 // The only available default render buffer formats in GLES2 have very 2933 // The only available default render buffer formats in GLES2 have very
2937 // little precision. Don't enable multisampling unless 8-bit render 2934 // little precision. Don't enable multisampling unless 8-bit render
2938 // buffer formats are available--instead fall back to 8-bit textures. 2935 // buffer formats are available--instead fall back to 8-bit textures.
2939 if (rgb8_supported && offscreen_target_samples_ > 1) { 2936 if (rgb8_supported && offscreen_target_samples_ > 1) {
2940 offscreen_target_color_format_ = attrib_helper.alpha_size > 0 ? 2937 offscreen_target_color_format_ = attrib_helper.alpha_size > 0 ?
2941 GL_RGBA8 : GL_RGB8; 2938 GL_RGBA8 : GL_RGB8;
2942 } else { 2939 } else {
2943 offscreen_target_samples_ = 1; 2940 offscreen_target_samples_ = 1;
(...skipping 1426 matching lines...) Expand 10 before | Expand all | Expand 10 after
4370 4367
4371 #if defined(OS_MACOSX) 4368 #if defined(OS_MACOSX)
4372 for (TextureToIOSurfaceMap::iterator it = texture_to_io_surface_map_.begin(); 4369 for (TextureToIOSurfaceMap::iterator it = texture_to_io_surface_map_.begin();
4373 it != texture_to_io_surface_map_.end(); ++it) { 4370 it != texture_to_io_surface_map_.end(); ++it) {
4374 CFRelease(it->second); 4371 CFRelease(it->second);
4375 } 4372 }
4376 texture_to_io_surface_map_.clear(); 4373 texture_to_io_surface_map_.clear();
4377 #endif 4374 #endif
4378 } 4375 }
4379 4376
4380 void GLES2DecoderImpl::SetSurface( 4377 void GLES2DecoderImpl::SetSurface(const scoped_refptr<gl::GLSurface>& surface) {
4381 const scoped_refptr<gfx::GLSurface>& surface) {
4382 DCHECK(context_->IsCurrent(NULL)); 4378 DCHECK(context_->IsCurrent(NULL));
4383 DCHECK(surface); 4379 DCHECK(surface);
4384 surface_ = surface; 4380 surface_ = surface;
4385 RestoreCurrentFramebufferBindings(); 4381 RestoreCurrentFramebufferBindings();
4386 } 4382 }
4387 4383
4388 void GLES2DecoderImpl::ReleaseSurface() { 4384 void GLES2DecoderImpl::ReleaseSurface() {
4389 if (!context_.get()) 4385 if (!context_.get())
4390 return; 4386 return;
4391 if (WasContextLost()) { 4387 if (WasContextLost()) {
(...skipping 1269 matching lines...) Expand 10 before | Expand all | Expand 10 after
5661 (feature_info_->context_type() == CONTEXT_TYPE_WEBGL1 || 5657 (feature_info_->context_type() == CONTEXT_TYPE_WEBGL1 ||
5662 feature_info_->context_type() == CONTEXT_TYPE_OPENGLES2)) { 5658 feature_info_->context_type() == CONTEXT_TYPE_OPENGLES2)) {
5663 *params = GL_HALF_FLOAT_OES; 5659 *params = GL_HALF_FLOAT_OES;
5664 } 5660 }
5665 } 5661 }
5666 return true; 5662 return true;
5667 default: 5663 default:
5668 break; 5664 break;
5669 } 5665 }
5670 5666
5671 if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) { 5667 if (gl::GetGLImplementation() != gl::kGLImplementationEGLGLES2) {
5672 switch (pname) { 5668 switch (pname) {
5673 case GL_MAX_FRAGMENT_UNIFORM_VECTORS: 5669 case GL_MAX_FRAGMENT_UNIFORM_VECTORS:
5674 *num_written = 1; 5670 *num_written = 1;
5675 if (params) { 5671 if (params) {
5676 *params = group_->max_fragment_uniform_vectors(); 5672 *params = group_->max_fragment_uniform_vectors();
5677 } 5673 }
5678 return true; 5674 return true;
5679 case GL_MAX_VARYING_VECTORS: 5675 case GL_MAX_VARYING_VECTORS:
5680 *num_written = 1; 5676 *num_written = 1;
5681 if (params) { 5677 if (params) {
(...skipping 7462 matching lines...) Expand 10 before | Expand all | Expand 10 after
13144 // TODO(gman): call glShaderBinary 13140 // TODO(gman): call glShaderBinary
13145 return error::kNoError; 13141 return error::kNoError;
13146 #endif 13142 #endif
13147 } 13143 }
13148 13144
13149 void GLES2DecoderImpl::DoSwapBuffers() { 13145 void GLES2DecoderImpl::DoSwapBuffers() {
13150 bool is_offscreen = !!offscreen_target_frame_buffer_.get(); 13146 bool is_offscreen = !!offscreen_target_frame_buffer_.get();
13151 13147
13152 int this_frame_number = frame_number_++; 13148 int this_frame_number = frame_number_++;
13153 // TRACE_EVENT for gpu tests: 13149 // TRACE_EVENT for gpu tests:
13154 TRACE_EVENT_INSTANT2("test_gpu", "SwapBuffersLatency", 13150 TRACE_EVENT_INSTANT2(
13155 TRACE_EVENT_SCOPE_THREAD, 13151 "test_gpu", "SwapBuffersLatency", TRACE_EVENT_SCOPE_THREAD, "GLImpl",
13156 "GLImpl", static_cast<int>(gfx::GetGLImplementation()), 13152 static_cast<int>(gl::GetGLImplementation()), "width",
13157 "width", (is_offscreen ? offscreen_size_.width() : 13153 (is_offscreen ? offscreen_size_.width() : surface_->GetSize().width()));
13158 surface_->GetSize().width()));
13159 TRACE_EVENT2("gpu", "GLES2DecoderImpl::DoSwapBuffers", 13154 TRACE_EVENT2("gpu", "GLES2DecoderImpl::DoSwapBuffers",
13160 "offscreen", is_offscreen, 13155 "offscreen", is_offscreen,
13161 "frame", this_frame_number); 13156 "frame", this_frame_number);
13162 { 13157 {
13163 TRACE_EVENT_SYNTHETIC_DELAY("gpu.PresentingFrame"); 13158 TRACE_EVENT_SYNTHETIC_DELAY("gpu.PresentingFrame");
13164 } 13159 }
13165 13160
13166 ScopedGPUTrace scoped_gpu_trace(gpu_tracer_.get(), kTraceDecoder, 13161 ScopedGPUTrace scoped_gpu_trace(gpu_tracer_.get(), kTraceDecoder,
13167 "GLES2Decoder", "SwapBuffer"); 13162 "GLES2Decoder", "SwapBuffer");
13168 13163
(...skipping 907 matching lines...) Expand 10 before | Expand all | Expand 10 after
14076 CFRelease(surface); 14071 CFRelease(surface);
14077 texture_to_io_surface_map_.erase(it); 14072 texture_to_io_surface_map_.erase(it);
14078 } 14073 }
14079 } 14074 }
14080 #endif 14075 #endif
14081 14076
14082 void GLES2DecoderImpl::DoTexImageIOSurface2DCHROMIUM( 14077 void GLES2DecoderImpl::DoTexImageIOSurface2DCHROMIUM(
14083 GLenum target, GLsizei width, GLsizei height, 14078 GLenum target, GLsizei width, GLsizei height,
14084 GLuint io_surface_id, GLuint plane) { 14079 GLuint io_surface_id, GLuint plane) {
14085 #if defined(OS_MACOSX) 14080 #if defined(OS_MACOSX)
14086 if (gfx::GetGLImplementation() != gfx::kGLImplementationDesktopGL) { 14081 if (gl::GetGLImplementation() != gl::kGLImplementationDesktopGL) {
14087 LOCAL_SET_GL_ERROR( 14082 LOCAL_SET_GL_ERROR(
14088 GL_INVALID_OPERATION, 14083 GL_INVALID_OPERATION,
14089 "glTexImageIOSurface2DCHROMIUM", "only supported on desktop GL."); 14084 "glTexImageIOSurface2DCHROMIUM", "only supported on desktop GL.");
14090 return; 14085 return;
14091 } 14086 }
14092 14087
14093 if (target != GL_TEXTURE_RECTANGLE_ARB) { 14088 if (target != GL_TEXTURE_RECTANGLE_ARB) {
14094 // This might be supported in the future, and if we could require 14089 // This might be supported in the future, and if we could require
14095 // support for binding an IOSurface to a NPOT TEXTURE_2D texture, we 14090 // support for binding an IOSurface to a NPOT TEXTURE_2D texture, we
14096 // could delete a lot of code. For now, perform strict validation so we 14091 // could delete a lot of code. For now, perform strict validation so we
(...skipping 2733 matching lines...) Expand 10 before | Expand all | Expand 10 after
16830 } 16825 }
16831 16826
16832 // Include the auto-generated part of this file. We split this because it means 16827 // Include the auto-generated part of this file. We split this because it means
16833 // we can easily edit the non-auto generated parts right here in this file 16828 // we can easily edit the non-auto generated parts right here in this file
16834 // instead of having to edit some template or the code generator. 16829 // instead of having to edit some template or the code generator.
16835 #include "base/macros.h" 16830 #include "base/macros.h"
16836 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 16831 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
16837 16832
16838 } // namespace gles2 16833 } // namespace gles2
16839 } // namespace gpu 16834 } // 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