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