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

Unified Diff: native_client_sdk/src/libraries/ppapi_simple/ppapi_simple_main2d.cc

Issue 15011003: ppapi_simple (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Restore images Created 7 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: native_client_sdk/src/libraries/ppapi_simple/ppapi_simple_main2d.cc
diff --git a/native_client_sdk/src/libraries/ppapi_simple/ppapi_simple_main2d.cc b/native_client_sdk/src/libraries/ppapi_simple/ppapi_simple_main2d.cc
new file mode 100644
index 0000000000000000000000000000000000000000..7a57fdbf6d745a07284fab79991fea47c78fe632
--- /dev/null
+++ b/native_client_sdk/src/libraries/ppapi_simple/ppapi_simple_main2d.cc
@@ -0,0 +1,56 @@
+/* Copyright (c) 2012 The Chromium Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "ppapi/c/pp_instance.h"
+#include "ppapi/c/pp_module.h"
+
+
+#include "ppapi_simple/ppapi_simple_instance2d.h"
+#include "ppapi_simple/ppapi_simple_main2d.h"
+
+
+PP_Bool PSUpdate2DContext(PSEvent* event, PS2DContext_t* context) {
+ PP_Bool updated = PP_FALSE;
+ // Process all view updates to keep context bound
+ if (event->type_ == PS_VIEW_EVENT) {
+ struct PP_Rect rect;
+ int32_t width;
+ int32_t height;
+ if (g_Context.ctx_) {
+ g_pCore->ReleaseResource(g_Context.ctx_);
+ g_Context.ctx_ = 0;
binji 2013/05/23 18:06:49 what is g_Context?
+ }
+
+ g_pView->GetRect(event->resource_, &rect);
+ width = rect.size.width;
+ height = rect.size.height;
+
+ if (width != g_Context.size_.width || height != g_Context.size_.height) {
+ updated = true;
binji 2013/05/23 18:06:49 PP_TRUE
+ }
+
+ if (width != g_Context.size_.width || height != g_Context.size_.height ||
binji 2013/05/23 18:06:49 why not set updated in this block? isn't it update
+ !g_Context.bound_) {
+ g_Context.ctx_ =
+ g_pGraphics2D->Create(PSGetInstanceId(), &rect.size, PP_TRUE);
+ g_Context.bound_ =
+ g_pInstance->BindGraphics(PSGetInstanceId(), g_Context.ctx_);
+ g_Context.size_ = rect.size;
+ }
+ }
+ return updated;
+}
+
+
+void PSEnableRender(int enable) {
+ PSInstance* pInst = PSInstance::GetInstance();
+ pInst->EnableRender(enable != 0);
binji 2013/05/23 18:06:49 not implemented anywhere
+};
+
+void* PSCreateMain2D(PP_Instance inst, PSMain2DCfg_t* cfg, const char* argv[]) {
+ PSInstance2D* pInst = new PSInstance2D(inst, cfg, argv);
+ return pInst;
+}
+

Powered by Google App Engine
This is Rietveld 408576698