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

Side by Side Diff: webkit/glue/plugins/pepper_graphics_3d.cc

Issue 4310002: Make PPAPI headers compile with C compilers (gcc on Linux & Mac and MSVS on W... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « webkit/glue/plugins/pepper_graphics_2d.cc ('k') | webkit/glue/plugins/pepper_image_data.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "webkit/glue/plugins/pepper_graphics_3d.h" 5 #include "webkit/glue/plugins/pepper_graphics_3d.h"
6 6
7 #include "gpu/command_buffer/common/command_buffer.h" 7 #include "gpu/command_buffer/common/command_buffer.h"
8 #include "base/singleton.h" 8 #include "base/singleton.h"
9 #include "base/thread_local.h" 9 #include "base/thread_local.h"
10 #include "ppapi/c/dev/ppb_graphics_3d_dev.h" 10 #include "ppapi/c/dev/ppb_graphics_3d_dev.h"
11 #include "webkit/glue/plugins/pepper_common.h"
11 #include "webkit/glue/plugins/pepper_plugin_instance.h" 12 #include "webkit/glue/plugins/pepper_plugin_instance.h"
12 13
13 namespace pepper { 14 namespace pepper {
14 15
15 namespace { 16 namespace {
16 17
17 struct CurrentContextTag {}; 18 struct CurrentContextTag {};
18 typedef Singleton<base::ThreadLocalPointer<Graphics3D>, 19 typedef Singleton<base::ThreadLocalPointer<Graphics3D>,
19 DefaultSingletonTraits<base::ThreadLocalPointer<Graphics3D> >, 20 DefaultSingletonTraits<base::ThreadLocalPointer<Graphics3D> >,
20 CurrentContextTag> CurrentContextKey; 21 CurrentContextTag> CurrentContextKey;
21 22
22 // Size of the transfer buffer. 23 // Size of the transfer buffer.
23 enum { kTransferBufferSize = 512 * 1024 }; 24 enum { kTransferBufferSize = 512 * 1024 };
24 25
25 bool IsGraphics3D(PP_Resource resource) { 26 PP_Bool IsGraphics3D(PP_Resource resource) {
26 return !!Resource::GetAs<Graphics3D>(resource); 27 return BoolToPPBool(!!Resource::GetAs<Graphics3D>(resource));
27 } 28 }
28 29
29 bool GetConfigs(int32_t* configs, int32_t config_size, int32_t* num_config) { 30 PP_Bool GetConfigs(int32_t* configs, int32_t config_size, int32_t* num_config) {
30 // TODO(neb): Implement me! 31 // TODO(neb): Implement me!
31 return false; 32 return PP_FALSE;
32 } 33 }
33 34
34 bool ChooseConfig(const int32_t* attrib_list, int32_t* configs, 35 PP_Bool ChooseConfig(const int32_t* attrib_list, int32_t* configs,
35 int32_t config_size, int32_t* num_config) { 36 int32_t config_size, int32_t* num_config) {
36 // TODO(neb): Implement me! 37 // TODO(neb): Implement me!
37 return false; 38 return PP_FALSE;
38 } 39 }
39 40
40 bool GetConfigAttrib(int32_t config, int32_t attribute, int32_t* value) { 41 PP_Bool GetConfigAttrib(int32_t config, int32_t attribute, int32_t* value) {
41 // TODO(neb): Implement me! 42 // TODO(neb): Implement me!
42 return false; 43 return PP_FALSE;
43 } 44 }
44 45
45 const char* QueryString(int32_t name) { 46 const char* QueryString(int32_t name) {
46 switch (name) { 47 switch (name) {
47 case EGL_CLIENT_APIS: 48 case EGL_CLIENT_APIS:
48 return "OpenGL_ES"; 49 return "OpenGL_ES";
49 case EGL_EXTENSIONS: 50 case EGL_EXTENSIONS:
50 return ""; 51 return "";
51 case EGL_VENDOR: 52 case EGL_VENDOR:
52 return "Google"; 53 return "Google";
(...skipping 20 matching lines...) Expand all
73 } 74 }
74 75
75 return context->GetReference(); 76 return context->GetReference();
76 } 77 }
77 78
78 void* GetProcAddress(const char* name) { 79 void* GetProcAddress(const char* name) {
79 // TODO(neb): Implement me! 80 // TODO(neb): Implement me!
80 return NULL; 81 return NULL;
81 } 82 }
82 83
83 bool MakeCurrent(PP_Resource graphics3d) { 84 PP_Bool MakeCurrent(PP_Resource graphics3d) {
84 if (!graphics3d) { 85 if (!graphics3d) {
85 Graphics3D::ResetCurrent(); 86 Graphics3D::ResetCurrent();
86 return true; 87 return PP_TRUE;
87 } else { 88 } else {
88 scoped_refptr<Graphics3D> context(Resource::GetAs<Graphics3D>(graphics3d)); 89 scoped_refptr<Graphics3D> context(Resource::GetAs<Graphics3D>(graphics3d));
89 return context.get() && context->MakeCurrent(); 90 return BoolToPPBool(context.get() && context->MakeCurrent());
90 } 91 }
91 } 92 }
92 93
93 PP_Resource GetCurrentContext() { 94 PP_Resource GetCurrentContext() {
94 Graphics3D* currentContext = Graphics3D::GetCurrent(); 95 Graphics3D* currentContext = Graphics3D::GetCurrent();
95 return currentContext ? currentContext->GetReference() : 0; 96 return currentContext ? currentContext->GetReference() : 0;
96 } 97 }
97 98
98 bool SwapBuffers(PP_Resource graphics3d) { 99 PP_Bool SwapBuffers(PP_Resource graphics3d) {
99 scoped_refptr<Graphics3D> context(Resource::GetAs<Graphics3D>(graphics3d)); 100 scoped_refptr<Graphics3D> context(Resource::GetAs<Graphics3D>(graphics3d));
100 return context && context->SwapBuffers(); 101 return BoolToPPBool(context && context->SwapBuffers());
101 } 102 }
102 103
103 uint32_t GetError() { 104 uint32_t GetError() {
104 // TODO(neb): Figure out error checking. 105 // TODO(neb): Figure out error checking.
105 return PP_GRAPHICS_3D_ERROR_SUCCESS; 106 return PP_GRAPHICS_3D_ERROR_SUCCESS;
106 } 107 }
107 108
108 const PPB_Graphics3D_Dev ppb_graphics3d = { 109 const PPB_Graphics3D_Dev ppb_graphics3d = {
109 &IsGraphics3D, 110 &IsGraphics3D,
110 &GetConfigs, 111 &GetConfigs,
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 if (platform_context_.get()) { 248 if (platform_context_.get()) {
248 platform_context_->SetNotifyRepaintTask( 249 platform_context_->SetNotifyRepaintTask(
249 method_factory3d_.NewRunnableMethod(&Graphics3D::HandleRepaint, 250 method_factory3d_.NewRunnableMethod(&Graphics3D::HandleRepaint,
250 instance_id)); 251 instance_id));
251 } 252 }
252 } 253 }
253 } 254 }
254 255
255 } // namespace pepper 256 } // namespace pepper
256 257
OLDNEW
« no previous file with comments | « webkit/glue/plugins/pepper_graphics_2d.cc ('k') | webkit/glue/plugins/pepper_image_data.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698