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

Side by Side Diff: experimental/c_salt/npapi/browser_3d_device.cc

Issue 10928195: First round of dead file removal (Closed) Base URL: https://github.com/samclegg/nativeclient-sdk.git@master
Patch Set: Created 8 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
OLDNEW
(Empty)
1 // Copyright 2010 The Native Client Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can
3 // be found in the LICENSE file.
4
5 #include "c_salt/npapi/browser_3d_device.h"
6
7 #include <nacl/npapi_extensions.h>
8
9 #include "c_salt/instance.h"
10 #include "c_salt/opengl_context.h"
11
12 NPDevice* NPN_AcquireDevice(NPP instance, NPDeviceID device);
13
14 namespace {
15 const int32_t kCommandBufferSize = 1024 * 1024;
16 } // namespace
17
18 namespace c_salt {
19
20 Browser3DDevice* CreateBrowser3DDevice(const Instance& instance) {
21 return new npapi::Browser3DDeviceNPAPI(instance);
22 }
23
24 namespace npapi {
25
26 Browser3DDeviceNPAPI::Browser3DDeviceNPAPI(const Instance& instance)
27 : instance_(instance), device3d_(NULL) {
28 std::memset(&context3d_, 0, sizeof(context3d_));
29 }
30
31 Browser3DDeviceNPAPI::~Browser3DDeviceNPAPI() {
32 DeleteBrowser3DContext();
33 device3d_ = NULL;
34 }
35
36 bool Browser3DDeviceNPAPI::AcquireBrowser3DDevice() {
37 if (is_valid())
38 return true;
39 device3d_ = NPN_AcquireDevice(instance_.npp_instance(), NPPepper3DDevice);
40 assert(device3d_);
41 return is_valid();
42 }
43
44 PGLContext Browser3DDeviceNPAPI::CreateBrowser3DContext(
45 OpenGLContext* context) {
46 NPDeviceContext3DConfig config;
47 config.commandBufferSize = kCommandBufferSize;
48 assert(device3d_);
49 context3d_.repaintCallback = RepaintCallback;
50 context3d_.user_data_ = context;
51 device3d_->initializeContext(instance_.npp_instance(),
52 &config,
53 &context3d_);
54 return pglCreateContext(instance_.npp_instance(), device3d_, &context3d_);
55 }
56
57 void Browser3DDeviceNPAPI::DeleteBrowser3DContext() {
58 PGLBoolean success = device3d_->destroyContext(instance_.npp_instance(),
59 &context3d_);
60 assert(PGL_TRUE == success);
61 std::memset(&context3d_, 0, sizeof(context3d_));
62 }
63
64 void Browser3DDeviceNPAPI::RepaintCallback(NPP /* npp NOTUSED */,
65 NPDeviceContext3D* native_context) {
66 assert(native_context);
67 DeviceContext3DExt* context =
68 static_cast<DeviceContext3DExt*>(native_context);
69 OpenGLContext* opengl_context = context->user_data_;
70 assert(opengl_context);
71 if (opengl_context)
72 opengl_context->RenderContext();
73 }
74 } // namespace npapi
75 } // namespace c_salt
OLDNEW
« no previous file with comments | « experimental/c_salt/npapi/browser_3d_device.h ('k') | experimental/c_salt/npapi/browser_binding.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698