OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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> |
11 #include <map> | 11 #include <map> |
12 #include <string> | 12 #include <string> |
13 #include <vector> | 13 #include <vector> |
14 | 14 |
15 #include "base/atomicops.h" | 15 #include "base/atomicops.h" |
16 #include "base/at_exit.h" | 16 #include "base/at_exit.h" |
17 #include "base/callback.h" | 17 #include "base/callback.h" |
| 18 #include "base/logging.h" |
18 #include "base/memory/scoped_ptr.h" | 19 #include "base/memory/scoped_ptr.h" |
19 #include "base/memory/weak_ptr.h" | 20 #include "base/memory/weak_ptr.h" |
20 #include "build/build_config.h" | 21 #include "build/build_config.h" |
21 #define GLES2_GPU_SERVICE 1 | 22 #define GLES2_GPU_SERVICE 1 |
22 #include "gpu/command_buffer/common/gles2_cmd_format.h" | 23 #include "gpu/command_buffer/common/gles2_cmd_format.h" |
23 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 24 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
24 #include "gpu/command_buffer/common/id_allocator.h" | 25 #include "gpu/command_buffer/common/id_allocator.h" |
25 #include "gpu/command_buffer/common/trace_event.h" | 26 #include "gpu/command_buffer/common/trace_event.h" |
26 #include "gpu/command_buffer/service/buffer_manager.h" | 27 #include "gpu/command_buffer/service/buffer_manager.h" |
27 #include "gpu/command_buffer/service/cmd_buffer_engine.h" | 28 #include "gpu/command_buffer/service/cmd_buffer_engine.h" |
28 #include "gpu/command_buffer/service/context_group.h" | 29 #include "gpu/command_buffer/service/context_group.h" |
29 #include "gpu/command_buffer/service/feature_info.h" | 30 #include "gpu/command_buffer/service/feature_info.h" |
30 #include "gpu/command_buffer/service/framebuffer_manager.h" | 31 #include "gpu/command_buffer/service/framebuffer_manager.h" |
31 #include "gpu/command_buffer/service/gl_utils.h" | 32 #include "gpu/command_buffer/service/gl_utils.h" |
32 #include "gpu/command_buffer/service/gles2_cmd_validation.h" | 33 #include "gpu/command_buffer/service/gles2_cmd_validation.h" |
33 #include "gpu/command_buffer/service/program_manager.h" | 34 #include "gpu/command_buffer/service/program_manager.h" |
34 #include "gpu/command_buffer/service/renderbuffer_manager.h" | 35 #include "gpu/command_buffer/service/renderbuffer_manager.h" |
35 #include "gpu/command_buffer/service/shader_manager.h" | 36 #include "gpu/command_buffer/service/shader_manager.h" |
36 #include "gpu/command_buffer/service/shader_translator.h" | 37 #include "gpu/command_buffer/service/shader_translator.h" |
37 #include "gpu/command_buffer/service/texture_manager.h" | 38 #include "gpu/command_buffer/service/texture_manager.h" |
38 #include "gpu/command_buffer/service/vertex_attrib_manager.h" | 39 #include "gpu/command_buffer/service/vertex_attrib_manager.h" |
39 #include "ui/gfx/gl/gl_context.h" | 40 #include "ui/gfx/gl/gl_context.h" |
40 #include "ui/gfx/gl/gl_implementation.h" | 41 #include "ui/gfx/gl/gl_implementation.h" |
41 #include "ui/gfx/gl/gl_surface.h" | 42 #include "ui/gfx/gl/gl_surface.h" |
42 | 43 |
| 44 #if defined(USE_X11) |
| 45 #include "ui/base/x/x11_util_internal.h" |
| 46 #define CHECK_X_ERROR() ui::CheckForReportedX11Error() |
| 47 #else // USE_X11 |
| 48 #define CHECK_X_ERROR() void(0) |
| 49 #endif // USE_X11 |
| 50 |
43 #if !defined(GL_DEPTH24_STENCIL8) | 51 #if !defined(GL_DEPTH24_STENCIL8) |
44 #define GL_DEPTH24_STENCIL8 0x88F0 | 52 #define GL_DEPTH24_STENCIL8 0x88F0 |
45 #endif | 53 #endif |
46 | 54 |
47 namespace gpu { | 55 namespace gpu { |
48 namespace gles2 { | 56 namespace gles2 { |
49 | 57 |
50 class GLES2DecoderImpl; | 58 class GLES2DecoderImpl; |
51 | 59 |
52 // Check that certain assumptions the code makes are true. There are places in | 60 // Check that certain assumptions the code makes are true. There are places in |
(...skipping 1672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1725 // Take ownership of the GLSurface. TODO(apatrick): once the parent / child | 1733 // Take ownership of the GLSurface. TODO(apatrick): once the parent / child |
1726 // context is retired, the decoder should not take an initial surface as | 1734 // context is retired, the decoder should not take an initial surface as |
1727 // an argument to this function. | 1735 // an argument to this function. |
1728 // Maybe create a short lived offscreen GLSurface for the purpose of | 1736 // Maybe create a short lived offscreen GLSurface for the purpose of |
1729 // initializing the decoder's GLContext. | 1737 // initializing the decoder's GLContext. |
1730 surface_ = surface; | 1738 surface_ = surface; |
1731 | 1739 |
1732 // Take ownership of the GLContext. | 1740 // Take ownership of the GLContext. |
1733 context_ = context; | 1741 context_ = context; |
1734 | 1742 |
| 1743 CHECK_X_ERROR(); |
| 1744 |
1735 if (!MakeCurrent()) { | 1745 if (!MakeCurrent()) { |
1736 LOG(ERROR) << "GLES2DecoderImpl::Initialize failed because " | 1746 LOG(ERROR) << "GLES2DecoderImpl::Initialize failed because " |
1737 << "MakeCurrent failed."; | 1747 << "MakeCurrent failed."; |
1738 Destroy(); | 1748 Destroy(); |
1739 return false; | 1749 return false; |
1740 } | 1750 } |
1741 | 1751 |
1742 if (!group_->Initialize(disallowed_features, allowed_extensions)) { | 1752 if (!group_->Initialize(disallowed_features, allowed_extensions)) { |
1743 LOG(ERROR) << "GpuScheduler::InitializeCommon failed because group " | 1753 LOG(ERROR) << "GpuScheduler::InitializeCommon failed because group " |
1744 << "failed to initialize."; | 1754 << "failed to initialize."; |
1745 Destroy(); | 1755 Destroy(); |
1746 return false; | 1756 return false; |
1747 } | 1757 } |
1748 | 1758 |
| 1759 CHECK_X_ERROR(); |
1749 CHECK_GL_ERROR(); | 1760 CHECK_GL_ERROR(); |
1750 disallowed_features_ = disallowed_features; | 1761 disallowed_features_ = disallowed_features; |
1751 | 1762 |
1752 vertex_attrib_manager_.Initialize(group_->max_vertex_attribs()); | 1763 vertex_attrib_manager_.Initialize(group_->max_vertex_attribs()); |
1753 | 1764 |
1754 util_.set_num_compressed_texture_formats( | 1765 util_.set_num_compressed_texture_formats( |
1755 validators_->compressed_texture_format.GetValues().size()); | 1766 validators_->compressed_texture_format.GetValues().size()); |
1756 | 1767 |
1757 if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) { | 1768 if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) { |
1758 // We have to enable vertex array 0 on OpenGL or it won't render. Note that | 1769 // We have to enable vertex array 0 on OpenGL or it won't render. Note that |
(...skipping 5126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6885 return false; | 6896 return false; |
6886 } | 6897 } |
6887 | 6898 |
6888 // Include the auto-generated part of this file. We split this because it means | 6899 // Include the auto-generated part of this file. We split this because it means |
6889 // we can easily edit the non-auto generated parts right here in this file | 6900 // we can easily edit the non-auto generated parts right here in this file |
6890 // instead of having to edit some template or the code generator. | 6901 // instead of having to edit some template or the code generator. |
6891 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 6902 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
6892 | 6903 |
6893 } // namespace gles2 | 6904 } // namespace gles2 |
6894 } // namespace gpu | 6905 } // namespace gpu |
OLD | NEW |