| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "shell/native_application_support.h" | 5 #include "shell/native_application_support.h" |
| 6 | 6 |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "mojo/public/platform/native/gles2_impl_chromium_miscellaneous_thunks.h
" | 10 #include "mojo/public/platform/native/gles2_impl_chromium_miscellaneous_thunks.h
" |
| 11 #include "mojo/public/platform/native/gles2_impl_chromium_resize_thunks.h" | 11 #include "mojo/public/platform/native/gles2_impl_chromium_resize_thunks.h" |
| 12 #include "mojo/public/platform/native/gles2_impl_chromium_sub_image_thunks.h" | 12 #include "mojo/public/platform/native/gles2_impl_chromium_sub_image_thunks.h" |
| 13 #include "mojo/public/platform/native/gles2_impl_chromium_sync_point_thunks.h" | 13 #include "mojo/public/platform/native/gles2_impl_chromium_sync_point_thunks.h" |
| 14 #include "mojo/public/platform/native/gles2_impl_chromium_texture_mailbox_thunks
.h" | 14 #include "mojo/public/platform/native/gles2_impl_chromium_texture_mailbox_thunks
.h" |
| 15 #include "mojo/public/platform/native/gles2_impl_ext_debug_marker_thunks.h" | 15 #include "mojo/public/platform/native/gles2_impl_ext_debug_marker_thunks.h" |
| 16 #include "mojo/public/platform/native/gles2_impl_occlusion_query_ext_thunks.h" | 16 #include "mojo/public/platform/native/gles2_impl_occlusion_query_ext_thunks.h" |
| 17 #include "mojo/public/platform/native/gles2_impl_oes_vertex_array_object_thunks.
h" | 17 #include "mojo/public/platform/native/gles2_impl_oes_vertex_array_object_thunks.
h" |
| 18 #include "mojo/public/platform/native/gles2_impl_thunks.h" | 18 #include "mojo/public/platform/native/gles2_impl_thunks.h" |
| 19 #include "mojo/public/platform/native/gles2_thunks.h" | 19 #include "mojo/public/platform/native/gles2_thunks.h" |
| 20 #include "mojo/public/platform/native/mgl_onscreen_thunks.h" |
| 21 #include "mojo/public/platform/native/mgl_thunks.h" |
| 20 #include "mojo/public/platform/native/system_impl_private_thunks.h" | 22 #include "mojo/public/platform/native/system_impl_private_thunks.h" |
| 21 #include "mojo/public/platform/native/system_thunks.h" | 23 #include "mojo/public/platform/native/system_thunks.h" |
| 22 | 24 |
| 23 namespace shell { | 25 namespace shell { |
| 24 | 26 |
| 25 namespace { | 27 namespace { |
| 26 | 28 |
| 27 template <typename Thunks> | 29 template <typename Thunks> |
| 28 bool SetThunks(Thunks (*make_thunks)(), | 30 bool SetThunks(Thunks (*make_thunks)(), |
| 29 const char* function_name, | 31 const char* function_name, |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 LOG(ERROR) << "MojoSetSystemThunks not found"; | 68 LOG(ERROR) << "MojoSetSystemThunks not found"; |
| 67 return false; | 69 return false; |
| 68 } | 70 } |
| 69 | 71 |
| 70 // TODO(ncbray): enforce the private nature of this API, somehow? | 72 // TODO(ncbray): enforce the private nature of this API, somehow? |
| 71 SetThunks(&MojoMakeSystemImplControlThunksPrivate, | 73 SetThunks(&MojoMakeSystemImplControlThunksPrivate, |
| 72 "MojoSetSystemImplControlThunksPrivate", app_library); | 74 "MojoSetSystemImplControlThunksPrivate", app_library); |
| 73 SetThunks(&MojoMakeSystemImplThunksPrivate, "MojoSetSystemImplThunksPrivate", | 75 SetThunks(&MojoMakeSystemImplThunksPrivate, "MojoSetSystemImplThunksPrivate", |
| 74 app_library); | 76 app_library); |
| 75 | 77 |
| 76 if (SetThunks(&MojoMakeGLES2ControlThunks, "MojoSetGLES2ControlThunks", | 78 SetThunks(&MojoMakeGLES2ControlThunks, "MojoSetGLES2ControlThunks", |
| 77 app_library)) { | 79 app_library); |
| 78 // If we have the control thunks, we should also have the GLES2 | 80 SetThunks(&MojoMakeGLES2ImplThunks, "MojoSetGLES2ImplThunks", |
| 79 // implementation thunks. | 81 app_library); |
| 80 if (!SetThunks(&MojoMakeGLES2ImplThunks, "MojoSetGLES2ImplThunks", | 82 SetThunks(MojoMakeGLES2ImplExtDebugMarkerThunks, |
| 81 app_library)) { | 83 "MojoSetGLES2ImplExtDebugMarkerThunks", app_library); |
| 82 LOG(ERROR) | 84 SetThunks(MojoMakeGLES2ImplOcclusionQueryExtThunks, |
| 83 << "MojoSetGLES2ControlThunks found, but not MojoSetGLES2ImplThunks"; | 85 "MojoSetGLES2ImplOcclusionQueryExtThunks", app_library); |
| 84 return false; | 86 SetThunks(MojoMakeGLES2ImplOesVertexArrayObjectThunks, |
| 85 } | 87 "MojoSetGLES2ImplOesVertexArrayObjectThunks", app_library); |
| 88 // "Chromium" extensions: |
| 89 SetThunks(MojoMakeGLES2ImplChromiumMiscellaneousThunks, |
| 90 "MojoSetGLES2ImplChromiumMiscellaneousThunks", app_library); |
| 91 SetThunks(MojoMakeGLES2ImplChromiumResizeThunks, |
| 92 "MojoSetGLES2ImplChromiumResizeThunks", app_library); |
| 93 SetThunks(MojoMakeGLES2ImplChromiumSubImageThunks, |
| 94 "MojoSetGLES2ImplChromiumSubImageThunks", app_library); |
| 95 SetThunks(MojoMakeGLES2ImplChromiumSyncPointThunks, |
| 96 "MojoSetGLES2ImplChromiumSyncPointThunks", app_library); |
| 97 SetThunks(MojoMakeGLES2ImplChromiumTextureMailboxThunks, |
| 98 "MojoSetGLES2ImplChromiumTextureMailboxThunks", app_library); |
| 86 | 99 |
| 87 // If the application is using GLES2 extension points, register those | 100 if (SetThunks(MojoMakeMGLThunks, "MojoSetMGLThunks", app_library)) { |
| 88 // thunks. Applications may use or not use any of these, so don't warn if | 101 // TODO(jamesr): We should only need to expose these on apps that need to |
| 89 // they are missing. | 102 // draw to the screen like the system compositor. |
| 90 SetThunks(MojoMakeGLES2ImplExtDebugMarkerThunks, | 103 SetThunks(MojoMakeMGLOnscreenThunks, "MojoSetMGLOnscreenThunks", |
| 91 "MojoSetGLES2ImplExtDebugMarkerThunks", app_library); | 104 app_library); |
| 92 SetThunks(MojoMakeGLES2ImplOcclusionQueryExtThunks, | |
| 93 "MojoSetGLES2ImplOcclusionQueryExtThunks", app_library); | |
| 94 SetThunks(MojoMakeGLES2ImplOesVertexArrayObjectThunks, | |
| 95 "MojoSetGLES2ImplOesVertexArrayObjectThunks", app_library); | |
| 96 // "Chromium" extensions: | |
| 97 SetThunks(MojoMakeGLES2ImplChromiumMiscellaneousThunks, | |
| 98 "MojoSetGLES2ImplChromiumMiscellaneousThunks", app_library); | |
| 99 SetThunks(MojoMakeGLES2ImplChromiumResizeThunks, | |
| 100 "MojoSetGLES2ImplChromiumResizeThunks", app_library); | |
| 101 SetThunks(MojoMakeGLES2ImplChromiumSubImageThunks, | |
| 102 "MojoSetGLES2ImplChromiumSubImageThunks", app_library); | |
| 103 SetThunks(MojoMakeGLES2ImplChromiumSyncPointThunks, | |
| 104 "MojoSetGLES2ImplChromiumSyncPointThunks", app_library); | |
| 105 SetThunks(MojoMakeGLES2ImplChromiumTextureMailboxThunks, | |
| 106 "MojoSetGLES2ImplChromiumTextureMailboxThunks", app_library); | |
| 107 } | 105 } |
| 106 |
| 108 // Unlike system thunks, we don't warn on a lack of GLES2 thunks because | 107 // Unlike system thunks, we don't warn on a lack of GLES2 thunks because |
| 109 // not everything is a visual app. | 108 // not everything is a visual app. |
| 110 | 109 |
| 111 typedef MojoResult (*MojoMainFunction)(MojoHandle); | 110 typedef MojoResult (*MojoMainFunction)(MojoHandle); |
| 112 MojoMainFunction main_function = reinterpret_cast<MojoMainFunction>( | 111 MojoMainFunction main_function = reinterpret_cast<MojoMainFunction>( |
| 113 base::GetFunctionPointerFromNativeLibrary(app_library, "MojoMain")); | 112 base::GetFunctionPointerFromNativeLibrary(app_library, "MojoMain")); |
| 114 if (!main_function) { | 113 if (!main_function) { |
| 115 LOG(ERROR) << "MojoMain not found"; | 114 LOG(ERROR) << "MojoMain not found"; |
| 116 return false; | 115 return false; |
| 117 } | 116 } |
| 118 // |MojoMain()| takes ownership of the Application request handle. | 117 // |MojoMain()| takes ownership of the Application request handle. |
| 119 MojoHandle handle = application_request.PassMessagePipe().release().value(); | 118 MojoHandle handle = application_request.PassMessagePipe().release().value(); |
| 120 MojoResult result = main_function(handle); | 119 MojoResult result = main_function(handle); |
| 121 LOG_IF(ERROR, result != MOJO_RESULT_OK) | 120 LOG_IF(ERROR, result != MOJO_RESULT_OK) |
| 122 << "MojoMain returned error (result: " << result << ")"; | 121 << "MojoMain returned error (result: " << result << ")"; |
| 123 return true; | 122 return true; |
| 124 } | 123 } |
| 125 | 124 |
| 126 } // namespace shell | 125 } // namespace shell |
| OLD | NEW |