OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 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 | 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 <stdlib.h> | 5 #include <stdlib.h> |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "o3d/gpu_plugin/np_utils/np_utils.h" |
8 #include "o3d/gpu_plugin/gpu_plugin_object.h" | 9 #include "o3d/gpu_plugin/gpu_plugin_object.h" |
9 | 10 |
10 namespace o3d { | 11 namespace o3d { |
11 namespace gpu_plugin { | 12 namespace gpu_plugin { |
12 | 13 |
13 namespace { | 14 namespace { |
14 const int32 kCommandBufferSize = 1024; | 15 const int32 kCommandBufferSize = 1024; |
15 } // namespace anonymous | 16 } // namespace anonymous |
16 | 17 |
17 const NPUTF8 GPUPluginObject::kPluginType[] = | 18 const NPUTF8 GPUPluginObject::kPluginType[] = |
18 "application/vnd.google.chrome.gpu-plugin"; | 19 "application/vnd.google.chrome.gpu-plugin"; |
19 | 20 |
20 GPUPluginObject::GPUPluginObject(NPP npp) | 21 GPUPluginObject::GPUPluginObject(NPP npp) |
21 : DispatchedNPObject(npp), | 22 : npp_(npp), |
22 status_(CREATED), | 23 status_(CREATED), |
23 shared_memory_(NULL) { | 24 shared_memory_(NULL) { |
24 memset(&window_, 0, sizeof(window_)); | 25 memset(&window_, 0, sizeof(window_)); |
25 } | 26 } |
26 | 27 |
27 NPError GPUPluginObject::New(NPMIMEType plugin_type, | 28 NPError GPUPluginObject::New(NPMIMEType plugin_type, |
28 int16 argc, | 29 int16 argc, |
29 char* argn[], | 30 char* argn[], |
30 char* argv[], | 31 char* argv[], |
31 NPSavedData* saved) { | 32 NPSavedData* saved) { |
(...skipping 21 matching lines...) Expand all Loading... |
53 | 54 |
54 int16 GPUPluginObject::HandleEvent(NPEvent* event) { | 55 int16 GPUPluginObject::HandleEvent(NPEvent* event) { |
55 return 0; | 56 return 0; |
56 } | 57 } |
57 | 58 |
58 NPError GPUPluginObject::Destroy(NPSavedData** saved) { | 59 NPError GPUPluginObject::Destroy(NPSavedData** saved) { |
59 if (status_ != INITIALIZED) | 60 if (status_ != INITIALIZED) |
60 return NPERR_GENERIC_ERROR; | 61 return NPERR_GENERIC_ERROR; |
61 | 62 |
62 if (shared_memory_) { | 63 if (shared_memory_) { |
63 NPBrowser::get()->UnmapSharedMemory(npp(), shared_memory_); | 64 NPBrowser::get()->UnmapSharedMemory(npp_, shared_memory_); |
64 } | 65 } |
65 | 66 |
66 command_buffer_object_ = NPObjectPointer<CommandBuffer>(); | 67 command_buffer_object_ = NPObjectPointer<CommandBuffer>(); |
67 | 68 |
68 status_ = DESTROYED; | 69 status_ = DESTROYED; |
69 | 70 |
70 return NPERR_NO_ERROR; | 71 return NPERR_NO_ERROR; |
71 } | 72 } |
72 | 73 |
73 void GPUPluginObject::Release() { | 74 void GPUPluginObject::Release() { |
74 DCHECK(status_ != INITIALIZED); | 75 DCHECK(status_ != INITIALIZED); |
75 NPBrowser::get()->ReleaseObject(this); | 76 NPBrowser::get()->ReleaseObject(this); |
76 } | 77 } |
77 | 78 |
78 NPObject*GPUPluginObject::GetScriptableNPObject() { | 79 NPObject*GPUPluginObject::GetScriptableNPObject() { |
79 NPBrowser::get()->RetainObject(this); | 80 NPBrowser::get()->RetainObject(this); |
80 return this; | 81 return this; |
81 } | 82 } |
82 | 83 |
83 NPObjectPointer<NPObject> GPUPluginObject::OpenCommandBuffer() { | 84 NPObjectPointer<NPObject> GPUPluginObject::OpenCommandBuffer() { |
84 if (command_buffer_object_.Get()) | 85 if (command_buffer_object_.Get()) |
85 return command_buffer_object_; | 86 return command_buffer_object_; |
86 | 87 |
87 command_buffer_object_ = NPCreateObject<CommandBuffer>(npp()); | 88 command_buffer_object_ = NPCreateObject<CommandBuffer>(npp_); |
88 if (!command_buffer_object_->Initialize(kCommandBufferSize)) { | 89 if (!command_buffer_object_->Initialize(kCommandBufferSize)) { |
89 command_buffer_object_ = NPObjectPointer<CommandBuffer>(); | 90 command_buffer_object_ = NPObjectPointer<CommandBuffer>(); |
90 } | 91 } |
91 | 92 |
92 return command_buffer_object_; | 93 return command_buffer_object_; |
93 } | 94 } |
94 | 95 |
95 } // namespace gpu_plugin | 96 } // namespace gpu_plugin |
96 } // namespace o3d | 97 } // namespace o3d |
OLD | NEW |