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

Side by Side Diff: o3d/gpu_plugin/gpu_plugin_object.cc

Issue 194049: Implemented shared memory as an NPObject. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 3 months 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
OLDNEW
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/np_utils/np_utils.h"
9 #include "o3d/gpu_plugin/gpu_plugin_object.h" 9 #include "o3d/gpu_plugin/gpu_plugin_object.h"
10 10
11 namespace o3d { 11 namespace o3d {
12 namespace gpu_plugin { 12 namespace gpu_plugin {
13 13
14 namespace { 14 namespace {
15 const int32 kCommandBufferSize = 1024; 15 const int32 kCommandBufferSize = 1024;
16 } // namespace anonymous 16 } // namespace anonymous
17 17
18 const NPUTF8 GPUPluginObject::kPluginType[] = 18 const NPUTF8 GPUPluginObject::kPluginType[] =
19 "application/vnd.google.chrome.gpu-plugin"; 19 "application/vnd.google.chrome.gpu-plugin";
20 20
21 GPUPluginObject::GPUPluginObject(NPP npp) 21 GPUPluginObject::GPUPluginObject(NPP npp)
22 : npp_(npp), 22 : npp_(npp),
23 status_(CREATED), 23 status_(CREATED) {
24 shared_memory_(NULL) {
25 memset(&window_, 0, sizeof(window_)); 24 memset(&window_, 0, sizeof(window_));
26 } 25 }
27 26
28 NPError GPUPluginObject::New(NPMIMEType plugin_type, 27 NPError GPUPluginObject::New(NPMIMEType plugin_type,
29 int16 argc, 28 int16 argc,
30 char* argn[], 29 char* argn[],
31 char* argv[], 30 char* argv[],
32 NPSavedData* saved) { 31 NPSavedData* saved) {
33 if (status_ != CREATED) 32 if (status_ != CREATED)
34 return NPERR_GENERIC_ERROR; 33 return NPERR_GENERIC_ERROR;
(...skipping 18 matching lines...) Expand all
53 } 52 }
54 53
55 int16 GPUPluginObject::HandleEvent(NPEvent* event) { 54 int16 GPUPluginObject::HandleEvent(NPEvent* event) {
56 return 0; 55 return 0;
57 } 56 }
58 57
59 NPError GPUPluginObject::Destroy(NPSavedData** saved) { 58 NPError GPUPluginObject::Destroy(NPSavedData** saved) {
60 if (status_ != INITIALIZED) 59 if (status_ != INITIALIZED)
61 return NPERR_GENERIC_ERROR; 60 return NPERR_GENERIC_ERROR;
62 61
63 if (shared_memory_) {
64 NPBrowser::get()->UnmapSharedMemory(npp_, shared_memory_);
65 }
66
67 command_buffer_object_ = NPObjectPointer<CommandBuffer>(); 62 command_buffer_object_ = NPObjectPointer<CommandBuffer>();
68 63
69 status_ = DESTROYED; 64 status_ = DESTROYED;
70 65
71 return NPERR_NO_ERROR; 66 return NPERR_NO_ERROR;
72 } 67 }
73 68
74 void GPUPluginObject::Release() { 69 void GPUPluginObject::Release() {
75 DCHECK(status_ != INITIALIZED); 70 DCHECK(status_ != INITIALIZED);
76 NPBrowser::get()->ReleaseObject(this); 71 NPBrowser::get()->ReleaseObject(this);
(...skipping 11 matching lines...) Expand all
88 command_buffer_object_ = NPCreateObject<CommandBuffer>(npp_); 83 command_buffer_object_ = NPCreateObject<CommandBuffer>(npp_);
89 if (!command_buffer_object_->Initialize(kCommandBufferSize)) { 84 if (!command_buffer_object_->Initialize(kCommandBufferSize)) {
90 command_buffer_object_ = NPObjectPointer<CommandBuffer>(); 85 command_buffer_object_ = NPObjectPointer<CommandBuffer>();
91 } 86 }
92 87
93 return command_buffer_object_; 88 return command_buffer_object_;
94 } 89 }
95 90
96 } // namespace gpu_plugin 91 } // namespace gpu_plugin
97 } // namespace o3d 92 } // namespace o3d
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698