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

Side by Side Diff: gpu/gpu_plugin/gpu_plugin_object.h

Issue 465040: Added CommandBufferClient, CommandBufferStub and some IPC messages.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years 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 | « gpu/gpu_plugin/gpu_plugin.cc ('k') | gpu/gpu_plugin/gpu_plugin_object.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef GPU_GPU_PLUGIN_GPU_PLUGIN_OBJECT_H_
6 #define GPU_GPU_PLUGIN_GPU_PLUGIN_OBJECT_H_
7
8 #include <string>
9
10 #include "base/ref_counted.h"
11 #include "base/thread.h"
12 #include "gpu/command_buffer/common/command_buffer.h"
13 #include "gpu/command_buffer/service/gpu_processor.h"
14 #include "gpu/np_utils/default_np_object.h"
15 #include "gpu/np_utils/np_dispatcher.h"
16 #include "gpu/np_utils/np_headers.h"
17 #include "gpu/np_utils/np_plugin_object.h"
18 #include "gpu/np_utils/np_utils.h"
19
20 namespace gpu_plugin {
21
22 // The scriptable object for the GPU plugin.
23 class GPUPluginObject : public np_utils::DefaultNPObject<NPObject>,
24 public np_utils::PluginObject {
25 public:
26 static const int32 kCommandBufferSize = 1024 * 1024;
27
28 enum Status {
29 // In the state of waiting for the named function to be called to continue
30 // the initialization sequence.
31 kWaitingForNew,
32 kWaitingForSetWindow,
33 kWaitingForOpenCommandBuffer,
34
35 // Initialization either succeeded or failed.
36 kInitializationSuccessful,
37 kInitializationFailed,
38
39 // Destroy has now been called and the plugin object cannot be used.
40 kDestroyed,
41 };
42
43 static const NPUTF8 kPluginType[];
44
45 explicit GPUPluginObject(NPP npp);
46
47 virtual NPError New(NPMIMEType plugin_type,
48 int16 argc,
49 char* argn[],
50 char* argv[],
51 NPSavedData* saved);
52
53 virtual NPError SetWindow(NPWindow* new_window);
54 const NPWindow& GetWindow() { return window_; }
55
56 virtual int16 HandleEvent(NPEvent* event);
57
58 virtual NPError Destroy(NPSavedData** saved);
59
60 virtual void Release();
61
62 virtual NPObject* GetScriptableNPObject();
63
64 // Returns the current initialization status. See Status enum.
65 int32 GetStatus() {
66 return status_;
67 }
68
69 // Get the width of the plugin window.
70 int32 GetWidth() {
71 return window_.width;
72 }
73
74 // Get the height of the plugin window.
75 int32 GetHeight() {
76 return window_.height;
77 }
78
79 // Set the object that receives notifications of GPU plugin object events
80 // such as resize and keyboard and mouse input.
81 void SetEventSync(np_utils::NPObjectPointer<NPObject> event_sync) {
82 event_sync_ = event_sync;
83 }
84
85 np_utils::NPObjectPointer<NPObject> GetEventSync() {
86 return event_sync_;
87 }
88
89 // Initializes and returns the command buffer object. Returns NULL if the
90 // command buffer cannot be initialized, for example if the plugin does not
91 // yet have a window handle.
92 command_buffer::CommandBuffer* OpenCommandBuffer();
93
94 // Set the status for testing.
95 void set_status(Status status) {
96 status_ = status;
97 }
98
99 // Replace the default command buffer for testing. Takes ownership.
100 void set_command_buffer(command_buffer::CommandBuffer*
101 command_buffer) {
102 command_buffer_.reset(command_buffer);
103 }
104
105 // Replace the default GPU processor for testing.
106 void set_gpu_processor(
107 const scoped_refptr<command_buffer::GPUProcessor>& processor) {
108 processor_ = processor;
109 }
110
111 NP_UTILS_BEGIN_DISPATCHER_CHAIN(GPUPluginObject, DefaultNPObject<NPObject>)
112 NP_UTILS_DISPATCHER(GetStatus, int32())
113 NP_UTILS_DISPATCHER(GetWidth, int32())
114 NP_UTILS_DISPATCHER(GetHeight, int32())
115 NP_UTILS_DISPATCHER(SetEventSync,
116 void(np_utils::NPObjectPointer<NPObject> sync))
117 NP_UTILS_DISPATCHER(GetEventSync, np_utils::NPObjectPointer<NPObject>())
118 NP_UTILS_END_DISPATCHER_CHAIN
119
120 private:
121 NPError PlatformSpecificSetWindow(NPWindow* new_window);
122
123 NPP npp_;
124 Status status_;
125 NPWindow window_;
126 scoped_ptr<command_buffer::CommandBuffer> command_buffer_;
127 scoped_refptr<command_buffer::GPUProcessor> processor_;
128 np_utils::NPObjectPointer<NPObject> event_sync_;
129 };
130
131 } // namespace gpu_plugin
132
133 #endif // GPU_GPU_PLUGIN_GPU_PLUGIN_OBJECT_H_
OLDNEW
« no previous file with comments | « gpu/gpu_plugin/gpu_plugin.cc ('k') | gpu/gpu_plugin/gpu_plugin_object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698