Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Updated to new version of Berkelium

- better rendering using two callbacks
- added delegate for external host callbacks
  • Loading branch information...
commit 4a72b124edbf1354be5e54cfb9c08ec5a7c5b486 1 parent 7faf3f1
Jeroen Dierckx authored
Showing with 932 additions and 213 deletions.
  1. BIN  berkelium/bin/berkelium.dll
  2. BIN  berkelium/bin/berkelium.exe
  3. BIN  berkelium/bin/glut_demo.exe
  4. BIN  berkelium/bin/glut_input.exe
  5. BIN  berkelium/bin/locales/en-US.dll
  6. BIN  berkelium/bin/ppmrender.exe
  7. BIN  berkelium/bin/resources.pak
  8. BIN  berkelium/bin/themes/default.dll
  9. +31 −3 berkelium/include/berkelium/Berkelium.hpp
  10. +26 −3 berkelium/include/berkelium/Context.hpp
  11. +5 −0 berkelium/include/berkelium/Cursor.hpp
  12. +18 −8 berkelium/include/berkelium/Rect.hpp
  13. +2 −3 berkelium/include/berkelium/Singleton.hpp
  14. +134 −0 berkelium/include/berkelium/WeakString.hpp
  15. +18 −0 berkelium/include/berkelium/Widget.hpp
  16. +110 −31 berkelium/include/berkelium/Window.hpp
  17. +278 −65 berkelium/include/berkelium/WindowDelegate.hpp
  18. BIN  berkelium/lib/berkelium.lib
  19. +1 −1  berkelium/readme.txt
  20. +47 −20 src/UnityBerkeliumPlugin.cpp
  21. +143 −24 src/UnityBerkeliumWindow.cpp
  22. +39 −16 src/UnityBerkeliumWindow.h
  23. +2 −0  src/global.h
  24. +78 −39 test-project/Assets/Plugins/UnityBerkelium.cs
  25. BIN  test-project/Assets/Plugins/UnityBerkeliumPlugin.dll
View
BIN  berkelium/bin/berkelium.dll
Binary file not shown
View
BIN  berkelium/bin/berkelium.exe
Binary file not shown
View
BIN  berkelium/bin/glut_demo.exe
Binary file not shown
View
BIN  berkelium/bin/glut_input.exe
Binary file not shown
View
BIN  berkelium/bin/locales/en-US.dll
Binary file not shown
View
BIN  berkelium/bin/ppmrender.exe
Binary file not shown
View
BIN  berkelium/bin/resources.pak
Binary file not shown
View
BIN  berkelium/bin/themes/default.dll
Binary file not shown
View
34 berkelium/include/berkelium/Berkelium.hpp
@@ -33,6 +33,7 @@
#ifndef _BERKELIUM_HPP_
#define _BERKELIUM_HPP_
#include "berkelium/Platform.hpp"
+#include "berkelium/WeakString.hpp"
namespace sandbox {
class BrokerServices;
class TargetServices;
@@ -42,12 +43,22 @@ enum DepEnforcement;
}
namespace Berkelium {
+/** May be implemented to handle global errors gracefully.
+ */
+class BERKELIUM_EXPORT ErrorDelegate {
+public:
+ virtual ~ErrorDelegate() {}
+};
+
/* TODO: Allow forkedProcessHook to be called without requiring the
library to be initialized/in memory (unless this is a sub-process).
i.e. an inline function that first searches for "--type=" in argv,
then uses dlopen or GetProcAddress.
*/
+/** Called by child processes.
+ * Should only ever be called from subprocess.cpp (berkelium.exe).
+ */
#ifdef _WIN32
void BERKELIUM_EXPORT forkedProcessHook(
sandbox::BrokerServices* (*ptrGetBrokerServices)(),
@@ -57,12 +68,29 @@ void BERKELIUM_EXPORT forkedProcessHook(
void BERKELIUM_EXPORT forkedProcessHook(int argc, char **argv);
#endif
-void BERKELIUM_EXPORT init();
+/** Iniitialize berkelium's global object.
+ * \param homeDirectory Just like Chrome's --user-data-dir command line flag.
+ * If homeDirectory is null or empty, creates a temporary data directory.
+ */
+void BERKELIUM_EXPORT init(FileString homeDirectory);
+
+/** Destroys Berkelium and attempts to free as much memory as possible.
+ * Note: You must destroy all Window and Context objects before calling
+ * Berkelium::destroy()!
+ */
void BERKELIUM_EXPORT destroy();
-void BERKELIUM_EXPORT update();
+void BERKELIUM_EXPORT setErrorHandler(ErrorDelegate * errorHandler);
-int BERKELIUM_EXPORT renderToBuffer(char *buffer, int width, int height);
+/** Runs the message loop until all pending messages are processed.
+ * Must be called from the same thread as all other Berkelium functions,
+ * usually your program's main (UI) thread.
+ * For now, you have to poll to receive updates without blocking indefinitely.
+ *
+ * Your WindowDelegate's should only receive callbacks synchronously with
+ * this call to update.
+ */
+void BERKELIUM_EXPORT update();
}
View
29 berkelium/include/berkelium/Context.hpp
@@ -39,16 +39,39 @@ class BrowsingInstance;
namespace Berkelium {
class ContextImpl;
+/** A context holds onto a reference counted profile object.
+ * The Window class calls clone() on a context, so you can safely
+ * destroy a Context after making all the Windows you want.
+ *
+ * No functions currently exist for this object.
+ */
class BERKELIUM_EXPORT Context {
protected:
Context();
public:
+ /** Creates an all-new context with no shared state and a refcount of 1.
+ */
+ static Context* create();
+
+ /** Deletes this Context object, which decrements the refcount for the
+ * underlying context data.
+ */
+ void destroy();
+ /** Deprecated destructor
+ * \deprecated destroy()
+ */
virtual ~Context();
- virtual Context* clone()const=0;
- virtual ContextImpl *getImpl()=0;
- virtual const ContextImpl *getImpl()const=0;
+
+ /** Returns a new Context object which increments the refcount of
+ * the internal context information. Called by Window::create.
+ */
+ virtual Context* clone() const = 0;
+
+
+ virtual ContextImpl* getImpl() = 0;
+ virtual const ContextImpl* getImpl() const = 0;
};
}
View
5 berkelium/include/berkelium/Cursor.hpp
@@ -36,6 +36,7 @@
#include "berkelium/Platform.hpp"
#if BERKELIUM_PLATFORM == PLATFORM_WINDOWS
+#include <windows.h>
#elif BERKELIUM_PLATFORM == PLATFORM_LINUX
// FIXME this really only works for toolkit == gtk
// We use alternate definitions since we can't properly forward
@@ -64,6 +65,7 @@ class WindowImpl;
class BERKELIUM_EXPORT Cursor {
public:
#if BERKELIUM_PLATFORM == PLATFORM_WINDOWS
+ HCURSOR GetCursor() const;
#elif BERKELIUM_PLATFORM == PLATFORM_LINUX
GdkCursorEnum GetCursorType() const;
GdkCursorPtr GetCustomCursor() const;
@@ -77,6 +79,9 @@ class BERKELIUM_EXPORT Cursor {
Cursor(); // Non-copyable
#if BERKELIUM_PLATFORM == PLATFORM_WINDOWS
+ Cursor(const HCURSOR handle);
+
+ HCURSOR mHandle;
#elif BERKELIUM_PLATFORM == PLATFORM_LINUX
Cursor(const GdkCursorEnum& _type, GdkCursorPtr _cursor);
View
26 berkelium/include/berkelium/Rect.hpp
@@ -36,19 +36,29 @@
namespace Berkelium {
struct Rect {
- int mTop;
int mLeft;
+ int mTop;
int mWidth;
int mHeight;
- int top() const { return mTop; }
- int left() const { return mLeft; }
- int width() const { return mWidth; }
- int height() const { return mHeight; }
- int right() const { return mLeft + mWidth; }
- int bottom() const { return mTop + mHeight; }
+ inline int y() const { return mTop; }
+ inline int x() const { return mLeft; }
+ inline int top() const { return mTop; }
+ inline int left() const { return mLeft; }
+ inline int width() const { return mWidth; }
+ inline int height() const { return mHeight; }
+ inline int right() const { return mLeft + mWidth; }
+ inline int bottom() const { return mTop + mHeight; }
+
+ template <class T>
+ inline void setFromRect(const T&sourceRect) {
+ mLeft = sourceRect.x();
+ mTop = sourceRect.y();
+ mWidth = sourceRect.width();
+ mHeight = sourceRect.height();
+ }
- bool contains(int x, int y) const {
+ inline bool contains(int x, int y) const {
return (x >= left() && x < right() &&
y >= top() && y < bottom());
}
View
5 berkelium/include/berkelium/Singleton.hpp
@@ -38,10 +38,9 @@ namespace Berkelium {
template <class T> class AutoSingleton {
static std::auto_ptr<T>sInstance;
public:
- static T&getSingleton() {
+ static T& getSingleton() {
if (sInstance.get()==NULL) {
- std::auto_ptr<T> tmp(new T);
- sInstance = tmp;
+ throw std::exception();
}
return *static_cast<T*>(sInstance.get());
}
View
134 berkelium/include/berkelium/WeakString.hpp
@@ -0,0 +1,134 @@
+/* Berkelium - Embedded Chromium
+ * SafeString.hpp
+ *
+ * Copyright (c) 2009, Patrick Reiter Horn
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Sirikata nor the names of its contributors may
+ * be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
+ * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _BERKELIUM_WEAK_STRING_HPP_
+#define _BERKELIUM_WEAK_STRING_HPP_
+
+#include "berkelium/Platform.hpp"
+
+namespace Berkelium {
+
+// Simple POD string class. Data must be owned by caller.
+template <class CharType>
+struct WeakString {
+ const CharType* mData;
+ size_t mLength;
+
+ typedef CharType Type;
+
+ inline const CharType* data() const {
+ return mData;
+ }
+
+ inline size_t length() const {
+ return mLength;
+ }
+
+ inline size_t size() const {
+ return mLength;
+ }
+
+ template <class StrType>
+ inline StrType& get(StrType& ret) const {
+ if (!mData || !mLength) {
+ ret = StrType();
+ }
+ ret = StrType(mData, mLength);
+ return ret;
+ }
+
+ template <class StrType>
+ inline StrType get() const {
+ if (!mData || !mLength) {
+ return StrType();
+ }
+ return StrType(mData, mLength);
+ }
+
+ template <class StrType>
+ inline static WeakString<CharType> point_to(const StrType&input) {
+ WeakString<CharType> ret;
+ ret.mData = input.data();
+ ret.mLength = input.length();
+ return ret;
+ }
+
+ inline static WeakString<CharType> point_to(const CharType*input_data,
+ size_t input_length) {
+ WeakString<CharType> ret;
+ ret.mData = input_data;
+ ret.mLength = input_length;
+ return ret;
+ }
+
+ inline static WeakString<CharType> empty() {
+ WeakString<CharType> ret;
+ ret.mData = NULL;
+ ret.mLength = 0;
+ return ret;
+ }
+};
+
+template <class StrType, class CharType>
+inline StrType &operator+(const StrType&lhs, WeakString<CharType>&rhs) {
+ StrType temp;
+ return lhs + rhs.get(temp);
+}
+
+template <class StrType, class CharType>
+inline StrType &operator+=(StrType&lhs, WeakString<CharType>&rhs) {
+ StrType temp;
+ return lhs += rhs.get(temp);
+}
+
+template <class OstreamType, class CharType>
+inline OstreamType &operator<< (OstreamType&lhs, WeakString<CharType>&rhs) {
+ size_t length = rhs.length();
+ const CharType *data = rhs.data();
+ for (size_t i = 0; i < length; i++) {
+ lhs << data[i];
+ }
+ return lhs;
+}
+
+typedef WeakString<char> URLString;
+typedef WeakString<wchar_t> WideString;
+
+#if BERKELIUM_PLATFORM == PLATFORM_WINDOWS
+typedef WeakString<wchar_t> FileString;
+#else
+typedef WeakString<char> FileString;
+#endif
+
+}
+
+#endif
View
18 berkelium/include/berkelium/Widget.hpp
@@ -37,12 +37,30 @@
namespace Berkelium {
+/** A widget is a rectangular canvas which can be painted to. A Widget
+ * maintains its own focus state, and can accept input just like a Window.
+ * Widgets have very limited use in practice--mostly just dropdowns.
+ */
class BERKELIUM_EXPORT Widget {
public:
+ /** Deprecated virtual destructor.
+ * \deprecated Use the safer destroy() method instead.
+ */
virtual ~Widget() {}
+ /** Safe destructor for widget. Should clean up all resources.
+ * Note: WindowDelegate::onWidgetDestroyed will be called synchronously.
+ */
+ void destroy(); // defined in src/RenderWidget.cpp
+
+ /** Gets a unique id for this widget.
+ * \returns the widget's routing id
+ */
+ virtual int getId() const = 0;
+
virtual void focus()=0;
virtual void unfocus()=0;
+ virtual bool hasFocus() const = 0;
virtual void mouseMoved(int xPos, int yPos)=0;
virtual void mouseButton(unsigned int buttonID, bool down)=0;
View
141 berkelium/include/berkelium/Window.hpp
@@ -35,6 +35,7 @@
#include <vector>
+#include "berkelium/WeakString.hpp"
#include "berkelium/Context.hpp"
#include "berkelium/Rect.hpp"
@@ -73,28 +74,35 @@ class BERKELIUM_EXPORT Window {
/** Construct a completely uninitialized Window -- it will have no backing
* renderer or delegate and use a new Context.
*/
- Window();
+ Window ();
/** Construct a Window which uses the specified Context for rendering.
* \param otherContext an existing rendering Context to use
*/
Window (const Context*otherContext);
public:
- /** Create a new Window with all default properties -- a zero sized window
- * and a default local web page.
- */
- static Window* create();
/** Create a new Window with all default properties which uses an existing
* Context for rendering. It will be zero sized and use a default local
* web page.
- * \param otherContext an existing context to use for rendering
+ * \param context an existing context to use for rendering
* \returns a new Window or NULL on failure
*/
- static Window* create(const Context&otherContext);
+ static Window* create (const Context * context);
+
+ /** Deletes this window object.
+ */
+ void destroy();
+ /** Deprecated virtual destructor.
+ * \deprecated Use destroy() to avoid interference from custom allocators.
+ */
virtual ~Window();
- virtual Widget* getWidget() const=0; // could return NULL.
+ /** A Window should have a root widget object, unless the window crashed
+ * or has never been navigated.
+ * If such a widget exists, returns non-null.
+ */
+ virtual Widget* getWidget() const=0;
/** Get the rendering context for this Window. */
inline Context *getContext() const {
@@ -110,30 +118,26 @@ class BERKELIUM_EXPORT Window {
mDelegate = delegate;
}
- void appendWidget(Widget *wid) {
- mWidgets.push_back(wid);
- }
- void removeWidget(Widget *wid) {
- for (WidgetList::iterator it = mWidgets.begin();
- it != backEnd();
- ++it)
- {
- if (*it == wid) {
- mWidgets.erase(it);
- return;
- }
- }
- }
+ /** loop from the backmost (usually obscured) widget to the
+ * frontmost (focused) widget.
+ */
BackToFrontIter backIter() const {
return mWidgets.begin();
}
+
+ /** Corresponding end() to compare against the backIter. */
BackToFrontIter backEnd() const {
return mWidgets.end();
}
+ /** loop from the frontmost (focused) widget to the
+ * backmost (usually obscured) widget.
+ */
FrontToBackIter frontIter() const {
return mWidgets.rbegin();
}
+
+ /** Corresponding end() to compare against the frontIter. */
FrontToBackIter frontEnd() const {
return mWidgets.rend();
}
@@ -148,9 +152,25 @@ class BERKELIUM_EXPORT Window {
*/
Widget *getWidgetAtPoint(int xPos, int yPos, bool returnRootIfOutside=false) const;
+ /** Gets an id for this window.
+ * \returns the RenderView's unique routing id.
+ */
+ virtual int getId() const = 0;
+
+ /** Sets the transparency flag for this Window. Note that the buffer will
+ * be BGRA regardless of transparency, but if the window is not set as
+ * transparent, the alpha channel should always be 1.
+ * Transparency defaults to false and must be enabled on each Window.
+ * \param istrans Whether to enable a transparent background.
+ */
virtual void setTransparent(bool istrans)=0;
+ /** Set the topmost Widget for this Window as focused.
+ */
virtual void focus()=0;
+
+ /** Blurs all widgets on this Window.
+ */
virtual void unfocus()=0;
/** Inject a mouse movement event into the Window at the specified position.
@@ -186,34 +206,76 @@ class BERKELIUM_EXPORT Window {
virtual void keyEvent(bool pressed, int mods, int vk_code, int scancode)=0;
- /** Resize the Window.
+ /** Resize the Window. You should receive an onPaint message as an
+ * acknowledgement.
* \param width the new width
* \param height the new height
*/
virtual void resize(int width, int height)=0;
+ /** Changes the zoom level of the page in fixed increments (same as
+ * Ctrl--, Ctrl-0, and Ctrl-+ in most browsers.
+ * \param mode -1 to zoom out, 0 to reset zoom, 1 to zoom in
+ */
+ virtual void adjustZoom (int mode)=0;
+
/** Execute Javascript in the context of the Window. This is equivalent to
* executing Javascript in the address bar of a regular browser. The
* javascript is copied so the caller retains ownership of the string.
* \param javascript pointer to a string containing Javascript code
- * \param javascriptLength length of the Javascript string
*/
- virtual void executeJavascript(const wchar_t* javascript, size_t javascriptLength)=0;
+ virtual void executeJavascript (WideString javascript) = 0;
+
+ /** Insert the given text as a STYLE element at the beginning of the
+ * document.
+ * \param css Stylesheet content to insert.
+ * \param elementId Can be empty, but if specified then it is used
+ * as the id for the newly inserted element (replacing an existing one
+ * with the same id, if any).
+ */
+ virtual void insertCSS (WideString css, WideString elementId) = 0;
- /** Request navigation to a URL. The URL string is copied so the caller
- * retains ownership of the string.
- * \param url pointer to an ASCII string containing a URL
- * \param urlLength the length of the URL string
+ /** Request navigation to a URL. Depending on the url, this might not
+ * cause an actual navigation.
+ * \param url URLString pointer to an ASCII URL.
+ */
+ virtual bool navigateTo(URLString url)=0;
+
+ /**
+ * Request navigation to a URL. The URL string is copied so the caller
+ * retains ownership of the string.
+ * \deprecated Use navigateTo(URLString) instead
+ * \param url pointer to an ASCII string containing a URL
+ * \param url_length the length of the URL string
*/
- virtual bool navigateTo(const char *url, size_t urlLength)=0;
+ inline bool navigateTo(const char *url, size_t url_length) {
+ return navigateTo(URLString::point_to(url,url_length));
+ }
/** Request that the page be reloaded. */
- virtual void refresh()=0;
+ virtual void refresh() = 0;
+
+ /** Stop ongoing navigations. */
+ virtual void stop() = 0;
+
+ /** Goes back by one history item. */
+ virtual void goBack() = 0;
+
+ /** Goes forward by one history item. */
+ virtual void goForward() = 0;
+
+ /** True if you can go back at all (if back button should be enabled). */
+ virtual bool canGoBack() const = 0;
+
+ /** True if you can go forward (if forwrad button should be enabled). */
+ virtual bool canGoForward() const = 0;
/** Cut the currently selected data to the clipboard. */
virtual void cut()=0;
+
/** Copy the currently selected data to the clipboard. */
virtual void copy()=0;
+
/** Paste the current clipboard contents to the current cursoor position in
* the Window.
*/
@@ -221,6 +283,7 @@ class BERKELIUM_EXPORT Window {
/** Request the last action be undone. */
virtual void undo()=0;
+
/** Request the last undone action be reperformed. */
virtual void redo()=0;
@@ -231,6 +294,22 @@ class BERKELIUM_EXPORT Window {
virtual void selectAll()=0;
protected:
+ void appendWidget(Widget *wid) {
+ mWidgets.push_back(wid);
+ }
+ void removeWidget(Widget *wid) {
+ for (WidgetList::iterator it = mWidgets.begin();
+ it != backEnd();
+ ++it)
+ {
+ if (*it == wid) {
+ mWidgets.erase(it);
+ return;
+ }
+ }
+ }
+
+protected:
Context *mContext;
WindowDelegate *mDelegate;
View
343 berkelium/include/berkelium/WindowDelegate.hpp
@@ -33,18 +33,18 @@
#ifndef _BERKELIUM_WINDOW_DELEGATE_HPP_
#define _BERKELIUM_WINDOW_DELEGATE_HPP_
-#include <vector>
+#include "berkelium/WeakString.hpp"
namespace Berkelium {
class WindowImpl;
class Widget;
class Window;
-
-class RenderWidget; // FIXME: private interface.
-
class Cursor;
+/**
+ * Holds parameters for the onContextMenu delegate method.
+ */
struct ContextMenuEventArgs {
enum MediaType {
MediaTypeNone,
@@ -67,118 +67,331 @@ struct ContextMenuEventArgs {
int mouseX, mouseY;
- const wchar_t * linkUrl, * srcUrl, * pageUrl, * frameUrl, * selectedText;
- size_t linkUrlLength, srcUrlLength, pageUrlLength, frameUrlLength, selectedTextLength;
+ URLString linkUrl, srcUrl, pageUrl, frameUrl;
+ WideString selectedText;
bool isEditable;
int editFlags;
};
+/**
+ * Override WindowDelegate methods to intercept events from a render view.
+ */
class BERKELIUM_EXPORT WindowDelegate {
public:
+ /**
+ * Virtual destructor is not necessary--Berkelium will not delete a
+ * WindowDelegate.
+ */
virtual ~WindowDelegate() {}
- // DidStartProvisionalLoadForFrame
- // DidRedirectProvisionalLoad
- virtual void onAddressBarChanged(Window *win, const char* newURL, size_t newURLSize) {}
-
- // DidStartProvisionalLoadForFrame
- virtual void onStartLoading(Window *win, const char *newURL, size_t newURLSize) {}
- // DocumentLoadedInFrame
+ /**
+ * The URL associated with this page has changed. This is similar to
+ * onStartLoading, but may also be called if the hash part of the url
+ * changes.
+ *
+ * \param win Window instance that fired this event.
+ * \param newURL URL to display or store.
+ */
+ virtual void onAddressBarChanged(Window *win, URLString newURL) {}
+ /**
+ * Indicates whether the main page has started navigating to a new URL.
+ * \note See onLoadingStateChanged for deciding to show a loading message.
+ *
+ * \param win Window instance that fired this event.
+ * \param newURL URL of the currently-loading page for the main frame.
+ */
+ virtual void onStartLoading(Window *win, URLString newURL) {}
+ /**
+ * A page has loaded without error.
+ *
+ * \param win Window instance that fired this event.
+ */
virtual void onLoad(Window *win) {}
- virtual void onLoadError(Window *win, const char* error, size_t errorLength) {}
-
- virtual void onBeforeUnload(Window *win, bool *proceed) {}
- virtual void onCancelUnload(Window *win) {}
-
+ /**
+ * A worker has crashed. No info is provided yet to the callback.
+ *
+ * \param win Window instance that fired this event.
+ */
+ virtual void onCrashedWorker(Window *win) {}
+ /**
+ * Plugin with a given name has crashed. There's currently no way to
+ * restart it, aside from maybe reloading the page that uses it.
+ *
+ * \param win Window instance that fired this event.
+ * \param pluginName Name reported by the plugin..
+ */
+ virtual void onCrashedPlugin(Window *win, WideString pluginName) {}
+ /**
+ * Encountered an error while loading a page, and might not finish loading.
+ *
+ * \param win Window instance that fired this event.
+ * \param url URL that encountered the error.
+ * \param errorCode Some enumeration? errno? net error code?
+ * \param isMainFrame True if the error happened for the main page,
+ * If false, it may have happened in an iframe (or XHR?).
+ */
+ virtual void onProvisionalLoadError(Window *win, URLString url,
+ int errorCode, bool isMainFrame) {}
+ /**
+ * Display a javascript message (Maybe an error?) or console.log.
+ *
+ * \param win Window instance that fired this event.
+ * \param message String contents of the log message.
+ * \param sourceId Javascript file or other source sending the message.
+ * \param line_no Line number, useful for debugging.
+ */
+ virtual void onConsoleMessage(Window *win, WideString message,
+ WideString sourceId, int line_no) {}
+ /**
+ * Synchronously display an alert box (OK), confirm (OK, CANCEL), or a
+ * prompt (Input). If prompt, optionally return a string in value.
+ *
+ * \param win Window instance that fired this event.
+ * \param message Alert message
+ * \param defaultValue What to display in a text field if this is prompt.
+ * \param url Originator (script? or page?) of the alert box.
+ * \param flags enum? What type of alert/confirm/prompt.
+ * \param success True if the OK button, false if CANCEL.
+ * \param value Allocated (strdup is easiest) return, default empty/null.
+ */
+ virtual void onScriptAlert(Window *win, WideString message,
+ WideString defaultValue, URLString url,
+ int flags, bool &success, WideString &value) {}
+ /**
+ * Frees resources from the most recent onScriptAlert call, if necessary.
+ * Guaranteed to be called within the span of the same update() call, so
+ * the WindowDelegate can safely use a variable to hold the string instance
+ * while waiting to free it.
+ *
+ * \param lastValue A value to pass to the appropriate free method.
+ */
+ virtual void freeLastScriptAlert(WideString lastValue) {}
+ /**
+ * A navigation has been requested but not yet started.
+ * I'm not sure yet if this gets called for frames.
+ *
+ * \param win Window instance that fired this event.
+ * \param newUrl URL which wants to load.
+ * \param referrer Page which initiated the request.
+ * \param isNewWindow The request will result in a popup if not cancelled.
+ If true and not cancelled, expect a onCreatedWindow callback soon.
+ * \param cancelDefaultAction Put true into this value to cancel.
+ * For example, if you don't want a new window, call win->navigate.
+ */
+ virtual void onNavigationRequested(Window *win, URLString newUrl,
+ URLString referrer, bool isNewWindow,
+ bool &cancelDefaultAction) {}
+ /**
+ * Notifies if a page is loading.
+ * This callback is only useful for deciding whether to show a loading
+ * indicator, for example a spinning widget or maybe a capital letter
+ * being bombarded by meteors.
+ * \note This may happen at different times from onStartLoading.
+ *
+ * \param win Window instance that fired this event.
+ * \param isLoading true if loading has started, false if stopped.
+ */
+ virtual void onLoadingStateChanged(Window *win, bool isLoading) {}
+ /**
+ * Window's title has changed. This is usually the contents of title,
+ * however some pages may dynamically change document.title.
+ * Additionally, may be a default title (e.g. a URL) if the page has none.
+ *
+ * \param win Window instance that fired this event.
+ * \param title Page title, should be the same as document.title.
+ */
+ virtual void onTitleChanged(Window *win, WideString title) {}
+ /**
+ * Display a tooltip at the mouse cursor position.
+ * There's no notification for destroying the tooltip afaik
+ *
+ * \param win Window instance that fired this event.
+ * \param text Text on the tooltip.
+ */
+ virtual void onTooltipChanged(Window *win, WideString text) {}
+
+ /**
+ * A renderer instance crashed. Applications can't currently do anything
+ * to handle this aside from recreating the Window object.
+ *
+ * \param win Window instance that fired this event.
+ */
virtual void onCrashed(Window *win) {}
+ /**
+ * A renderer instance is hung. You can use this to display the Window in
+ * a greyed out state, and offer the user a choice to kill the Window.
+ *
+ * \param win Window instance that fired this event.
+ */
virtual void onUnresponsive(Window *win) {}
+ /**
+ * Renderer instance is back to normal. Reset the color and close dialogs.
+ *
+ * \param win Window instance that fired this event.
+ */
virtual void onResponsive(Window *win) {}
- struct Data {
- const char *message;
- size_t length;
- };
- virtual void onChromeSend(
- Window *win,
- Data message,
- const Data* content,
- size_t numContents) {}
-
- virtual void onCreatedWindow(Window *win, Window *newWindow) {}
+ /**
+ * Javascript has sent an externalHost message to this WindowDelegate.
+ * To send a message from javascript call, for example: <code>
+ * window.externalHost.postMessage("message", "urn:uuid:0000-...")
+ * </code>
+ * \param win Window instance that fired this event.
+ * \param message Full contents of message sent by javascript.
+ * \param origin Origin header of page sending the request. Use this
+ * if you want to restrict messages to trusted pages.
+ * \param target A URI Specified by the page. Can be in a custum or urn
+ * format if that is useful.
+ */
+ virtual void onExternalHost(
+ Window *win,
+ WideString message,
+ URLString origin,
+ URLString target) {}
+
+ /**
+ * A new window has already been created. You are now expected to hold
+ * onto the instance and be responsible for deleting it.
+ *
+ * \param win Window instance that fired this event.
+ * \param newWindow New Berkelium window object to keep track of.
+ * You may optionally destroy the window if you don't want it.
+ * \param initialRect Coordinates and size that the window is requesting.
+ * Use them as a recommendataion, but it's fine to call resize(),
+ * and x/y coords should be ignored if doing off-screen rendering.
+ */
+ virtual void onCreatedWindow(Window *win, Window *newWindow,
+ const Rect &initialRect) {}
+
+ /**
+ * The window is being painted. You need to synchronously copy the buffer
+ * into application (video) memory before returning.
+ *
+ * \param win Window instance that fired this event.
+ * \param sourceBuffer BGRA buffer with width/height of sourceBufferRect.
+ * \param sourceBufferRect Rect containing the buffer.
+ * \param numCopyRects Length of copyRects.
+ * \param copyRects Array of valid+changed rectangles of sourceBuffer.
+ * Anything not in copyRects is usually garbage data.
+ * While these must lie within sourceBufferRect to make sense,
+ * they are not relative to sourceBufferRect.
+ * \param dx If non-zero, the area of the page specified by scrollRect has
+ * been scrolled horizontally.
+ * \param dy If non-zero, the area of the page specified by scrollRect has
+ * been scrolled vertically.
+ * \param scrollRect Area of the page to scroll. Only valid if dx&&dy.
+ */
virtual void onPaint(
Window *win,
const unsigned char *sourceBuffer,
- const Rect &rect,
+ const Rect &sourceBufferRect,
+ size_t numCopyRects,
+ const Rect *copyRects,
int dx, int dy,
const Rect &scrollRect) {}
- /** Linux only. uses an OpenGL texture.
- * If not using OpenGL, each srcRect will get its own call to 'onPaint'
- * It should be possible to paint plugins directly onto the canvas.
- * If this is not possible, then plugins may be created as widgets with
- * a negative z-index (i.e. below anything else on the screen).
-
- virtual void onPaintPluginTexture(
- Window *win,
- void* sourceGLTexture,
- const std::vector<Rect> srcRects, // relative to destRect
- const Rect &destRect)=0;
- */
-////////// WIDGET FUNCTIONS //////////
+ /**
+ * A widget is a rectangle to display on top of the page, e.g. a context
+ * menu or a dropdown.
+ *
+ * \param win Window which is gaining a new widget object
+ * \param newWidget Widget object to optionally hold onto.
+ * \param zIndex Sorting value to compare to other Widget's.
+ */
virtual void onWidgetCreated(Window *win, Widget *newWidget, int zIndex) {}
- virtual void onWidgetDestroyed(Window *win, Widget *newWidget) {}
-
- // Will be called before the first call to paint.
+ /**
+ * Called by Widget::destroy(), in its destructor. This widget will be
+ * removed from the Window's list of widgets when this function returns.
+ *
+ * \param win Window which is losing this widget object.
+ * \param wid Widget this event is for.
+ */
+ virtual void onWidgetDestroyed(Window *win, Widget *wid) {}
+
+ /**
+ * Widget has changed size, Usually only happens once after creating.
+ *
+ * \param win Window which is losing this widget object.
+ * \param wid Widget this event is for.
+ * \param newWidth Width of widget texture.
+ * \param newHeight Height of widget texture.
+ */
virtual void onWidgetResize(
Window *win,
Widget *wid,
int newWidth,
int newHeight) {}
- // Never called for the main window.
+ /**
+ * Widget has moved, Usually only happens once after creating.
+ * While these coordinates may be ignored, the position usually corresponds
+ * to some click event or the mouse coordinates.
+ *
+ * \param win Window which is losing this widget object.
+ * \param wid Widget this event is for.
+ * \param newX Left coordinate relative to Window.
+ * \param newY Top coordinate relative to Window.
+ */
virtual void onWidgetMove(
Window *win,
Widget *wid,
int newX,
int newY) {}
+ /**
+ * A widget overlay has been painted.
+ *
+ * \see onPaint
+ * \param win Window instance that fired this event.
+ * \param wid Widget this event is for
+ * \param sourceBuffer raw buffer.
+ * \param sourceBufferRect Rect containing the buffer.
+ * \param numCopyRects Length of copyRects.
+ * \param copyRects Array of valid+changed rectangles of sourceBuffer.
+ * \param dx delta-x scroll
+ * \param dy delta-y scroll
+ * \param scrollRect Area of the page to scroll. Only valid if dx&&dy.
+ */
virtual void onWidgetPaint(
Window *win,
Widget *wid,
const unsigned char *sourceBuffer,
- const Rect &rect,
+ const Rect &sourceBufferRect,
+ size_t numCopyRects,
+ const Rect *copyRects,
int dx, int dy,
const Rect &scrollRect) {}
- /** Invoked when the Window requests that the mouse cursor be updated. */
- virtual void onCursorUpdated(const Cursor& newCursor) {}
-
- virtual void onShowContextMenu(Window *win, const ContextMenuEventArgs& args) {}
+ /**
+ * Invoked when the Window requests that the mouse cursor be updated.
+ * \param win Window instance that fired this event.
+ * \param newCursor Platform-specific cursor handle to pass to the
+ * appropriate system API.
+ * \see Berkelium::Cursor
+ */
+ virtual void onCursorUpdated(Window *win, const Cursor& newCursor) {}
+
+ /**
+ * Notification that the user has brought up a context menu. Chrome doesn't
+ * specify the exact set of context menu items--implementors are free to
+ * choose other menu items to display.
+ * \param win Window instance that fired this event.
+ * \param args Guidelines on what menu items to include or not include.
+ */
+ virtual void onShowContextMenu(Window *win,
+ const ContextMenuEventArgs& args) {}
/**************************
Might want messages for:
-- ShowContextMenu(const ContextMenuParams& params);
- StartDragging(const WebDropData& drop_data,
WebKit::WebDragOperationsMask allowed_ops);
- UpdateDragCursor(WebKit::WebDragOperation operation);
- TakeFocus(bool reverse)
-
-- Renderer[Un]Responsive
-
-- RequestOpenURL
-- DocumentAvailableInMainFrame
-- DidStartLoading
-- DidStopLoading
- Close
- UpdateTargetURL
-- UpdateTitle
- UpdateEncoding
-- UpdateState????
-- DidNavigate
-
- Also, may want API to bind javascript functions.
**************************/
};
View
BIN  berkelium/lib/berkelium.lib
Binary file not shown
View
2  berkelium/readme.txt
@@ -1 +1 @@
-Downloaded and unpacked from http://github.com/downloads/sirikata/berkelium/berkelium_49000_vc9_2010-06-20.7z
+Downloaded and unpacked from http://github.com/downloads/sirikata/berkelium/berkelium-win32-beta-2010-08-01.7z
View
67 src/UnityBerkeliumPlugin.cpp
@@ -22,7 +22,13 @@ static WindowMap windows;
UnityBerkeliumWindow *getWindow(int id)
{
WindowMap::const_iterator it = windows.find(id);
- return (it == windows.end()) ? 0 : it->second;
+ if(it == windows.end())
+ {
+ cerr << "Warning: no berkelium window found with ID " << id << "!" << endl;
+ return 0;
+ }
+
+ return it->second;
}
@@ -34,11 +40,13 @@ PLUGIN_API void Berkelium_init()
{
if(refCount == 0)
{
- // Initialize the Berkelium engine
- Berkelium::init();
-
// Redirect stderr to log file
::freopen(logFilename, "w", stderr);
+
+ // Initialize the Berkelium engine
+ cerr << "First reference to Berkelium initialized: initializing the library" << endl;
+ Berkelium::init(Berkelium::FileString::empty());
+ cerr << "... done initializing Berkelium" << endl;
}
++refCount;
@@ -50,6 +58,8 @@ PLUGIN_API void Berkelium_destroy()
if(refCount == 0)
{
+ cerr << "Last reference to Berkelium destroyed: destroying the library" << endl;
+
// Destroy the windows that still exist
for(WindowMap::iterator it = windows.begin(); it != windows.end(); ++it)
delete it->second;
@@ -57,6 +67,7 @@ PLUGIN_API void Berkelium_destroy()
// Close the berkelium backend
Berkelium::destroy();
+ cerr << "... done destroying Berkelium" << endl;
// Close the log file
fclose(stderr);
@@ -75,7 +86,7 @@ PLUGIN_API void Berkelium_update()
* Window-specific functions *
****************************/
-PLUGIN_API bool Berkelium_Window_create(int uniqueID, float *colors, bool transparency, int width, int height, char *url, UnityBerkeliumWindow::PaintFunc paintFunc)
+PLUGIN_API bool Berkelium_Window_create(int uniqueID, float *colors, bool transparency, int width, int height, char *url)
{
if(windows.find(uniqueID) != windows.end())
{
@@ -83,7 +94,7 @@ PLUGIN_API bool Berkelium_Window_create(int uniqueID, float *colors, bool transp
return false;
}
- UnityBerkeliumWindow *pWindow = new UnityBerkeliumWindow(uniqueID, colors, transparency, width, height, url, paintFunc);
+ UnityBerkeliumWindow *pWindow = new UnityBerkeliumWindow(uniqueID, colors, transparency, width, height, url);
cerr << "Berkelium window created: " << pWindow << " (size=" << width << ", " << height << "; url=" << url << ")" << endl;
windows[uniqueID] = pWindow;
@@ -98,9 +109,18 @@ PLUGIN_API void Berkelium_Window_destroy(int windowID)
{
delete it->second;
windows.erase(it);
+
+ cerr << "Berkelium window destroyed: " << windowID << endl;
}
}
+PLUGIN_API void Berkelium_Window_setPaintFunctions(int windowID, UnityBerkeliumWindow::SetPixelsFunc setPixelsFunc, UnityBerkeliumWindow::ApplyTextureFunc applyTextureFunc)
+{
+ UnityBerkeliumWindow *pWindow = getWindow(windowID);
+ if(pWindow)
+ pWindow->setPaintFunctions(setPixelsFunc, applyTextureFunc);
+}
+
// Note: we need this function because I can't get parameters in function pointers to work properly
PLUGIN_API Berkelium::Rect Berkelium_Window_getLastDirtyRect(int windowID)
{
@@ -109,8 +129,6 @@ PLUGIN_API Berkelium::Rect Berkelium_Window_getLastDirtyRect(int windowID)
UnityBerkeliumWindow *pWindow = getWindow(windowID);
if(pWindow)
result = pWindow->getLastDirtyRect();
- else
- cerr << "Warning: no berkelium window found with ID " << windowID << "!" << endl;
return result;
}
@@ -120,8 +138,6 @@ PLUGIN_API void Berkelium_Window_mouseDown(int windowID, int button)
UnityBerkeliumWindow *pWindow = getWindow(windowID);
if(pWindow)
pWindow->getBerkeliumWindow()->mouseButton(button, true);
- else
- cerr << "Warning: no berkelium window found with ID " << windowID << "!" << endl;
}
PLUGIN_API void Berkelium_Window_mouseUp(int windowID, int button)
@@ -129,8 +145,6 @@ PLUGIN_API void Berkelium_Window_mouseUp(int windowID, int button)
UnityBerkeliumWindow *pWindow = getWindow(windowID);
if(pWindow)
pWindow->getBerkeliumWindow()->mouseButton(button, false);
- else
- cerr << "Warning: no berkelium window found with ID " << windowID << "!" << endl;
}
PLUGIN_API void Berkelium_Window_mouseMove(int windowID, int x, int y)
@@ -138,8 +152,6 @@ PLUGIN_API void Berkelium_Window_mouseMove(int windowID, int x, int y)
UnityBerkeliumWindow *pWindow = getWindow(windowID);
if(pWindow)
pWindow->getBerkeliumWindow()->mouseMoved(x, y);
- else
- cerr << "Warning: no berkelium window found with ID " << windowID << "!" << endl;
}
PLUGIN_API void Berkelium_Window_textEvent(int windowID, wchar_t c)
@@ -147,8 +159,6 @@ PLUGIN_API void Berkelium_Window_textEvent(int windowID, wchar_t c)
UnityBerkeliumWindow *pWindow = getWindow(windowID);
if(pWindow)
pWindow->getBerkeliumWindow()->textEvent(&c, 1);
- else
- cerr << "Warning: no berkelium window found with ID " << windowID << "!" << endl;
}
PLUGIN_API void Berkelium_Window_keyEvent(int windowID, bool pressed, int mods, int vk_code, int scancode)
@@ -156,10 +166,11 @@ PLUGIN_API void Berkelium_Window_keyEvent(int windowID, bool pressed, int mods,
UnityBerkeliumWindow *pWindow = getWindow(windowID);
if(pWindow)
pWindow->getBerkeliumWindow()->keyEvent(pressed, mods, vk_code, scancode);
- else
- cerr << "Warning: no berkelium window found with ID " << windowID << "!" << endl;
}
+
+//-- Javascript functionality --//
+
/// Thanks to agentdm
PLUGIN_API void Berkelium_Window_executeJavascript(int windowID, char* javaScript)
{
@@ -177,7 +188,23 @@ PLUGIN_API void Berkelium_Window_executeJavascript(int windowID, char* javaScrip
std::wcerr << "Javascript converted: " << wctStrJScript << endl;
if(pWindow)
- pWindow->getBerkeliumWindow()->executeJavascript(wctStrJScript, scriptLength);
+ pWindow->getBerkeliumWindow()->executeJavascript(Berkelium::WideString::point_to(wctStrJScript, scriptLength));
+}
+
+
+PLUGIN_API void Berkelium_Window_setExternalHostCallback(int windowID, UnityBerkeliumWindow::ExternalHostFunc callback)
+{
+ UnityBerkeliumWindow *pWindow = getWindow(windowID);
+ if(pWindow)
+ pWindow->setExternalHostCallback(callback);
+}
+
+// TEMP This should be a parameter in the callback function
+PLUGIN_API const wchar_t *Berkelium_Window_getLastExternalHostMessage(int windowID)
+{
+ UnityBerkeliumWindow *pWindow = getWindow(windowID);
+ if(pWindow)
+ return pWindow->getLastExternalHostMessage().c_str();
else
- cerr << "Warning: no berkelium window found with ID " << windowID << "!" << endl;
+ return L"";
}
View
167 src/UnityBerkeliumWindow.cpp
@@ -14,13 +14,17 @@
* Constructors and destructor *
******************************/
-UnityBerkeliumWindow::UnityBerkeliumWindow(int uniqueID, float *buffer, bool transparency, int width, int height, const string &url, PaintFunc paintFunc)
-: m_id(uniqueID), m_buffer(buffer), m_transparency(transparency), m_width(width), m_height(height), m_url(url), m_paintFunc(paintFunc)
+UnityBerkeliumWindow::UnityBerkeliumWindow(int uniqueID, float *buffer, bool transparency, int width, int height, const string &url)
+: m_id(uniqueID), m_buffer(buffer), m_transparency(transparency), m_width(width), m_height(height), m_url(url)
+, m_setPixelsFunc(0), m_applyTextureFunc(0), m_externalHostFunc(0)
{
assert(m_buffer);
assert(width > 0 && height > 0);
- m_pWindow = Berkelium::Window::create();
+ Berkelium::Context *pContext = Berkelium::Context::create();
+ m_pWindow = Berkelium::Window::create(pContext);
+ delete pContext;
+
m_pWindow->setDelegate(this);
m_pWindow->setTransparent(transparency);
m_pWindow->resize(width, height);
@@ -37,11 +41,23 @@ UnityBerkeliumWindow::~UnityBerkeliumWindow()
* Other functions *
******************/
+void UnityBerkeliumWindow::setPaintFunctions(SetPixelsFunc setPixelsFunc, ApplyTextureFunc applyTextureFunc)
+{
+ m_setPixelsFunc = setPixelsFunc;
+ m_applyTextureFunc = applyTextureFunc;
+}
+
+void UnityBerkeliumWindow::setExternalHostCallback(ExternalHostFunc callback)
+{
+ m_externalHostFunc = callback;
+}
+
/**************************************
* Berkelium::WindowDelegate functions *
**************************************/
+#if 0
void UnityBerkeliumWindow::onPaint(Berkelium::Window *pWindow, const unsigned char *sourceBuffer, const Berkelium::Rect &rect, int dx, int dy, const Berkelium::Rect &scrollRect)
{
#ifdef DEBUG
@@ -132,15 +148,18 @@ void UnityBerkeliumWindow::onPaint(Berkelium::Window *pWindow, const unsigned ch
m_lastDirtyRect = rect;
m_paintFunc(/*rect.left(), rect.top(), rect.width(), rect.height()*/);
}
+#endif
-void UnityBerkeliumWindow::onAddressBarChanged(Berkelium::Window *win, const char* newURL, size_t newURLSize)
+void UnityBerkeliumWindow::onAddressBarChanged(Berkelium::Window *win, Berkelium::URLString newURL)
{
cerr << "[UnityBerkeliumWindow] onAddressBarChanged called (window: " << win << ")" << endl;
+ cerr << " newURL: " << newURL << endl;
}
-void UnityBerkeliumWindow::onStartLoading(Berkelium::Window *win, const char *newURL, size_t newURLSize)
+void UnityBerkeliumWindow::onStartLoading(Berkelium::Window *win, Berkelium::URLString newURL)
{
cerr << "[UnityBerkeliumWindow] onStartLoading called (window: " << win << ")" << endl;
+ cerr << " newURL: " << newURL << endl;
}
void UnityBerkeliumWindow::onLoad(Berkelium::Window *win)
@@ -148,19 +167,72 @@ void UnityBerkeliumWindow::onLoad(Berkelium::Window *win)
cerr << "[UnityBerkeliumWindow] onLoad called (window: " << win << ")" << endl;
}
-void UnityBerkeliumWindow::onLoadError(Berkelium::Window *win, const char* error, size_t errorLength)
+void UnityBerkeliumWindow::onCrashedWorker(Berkelium::Window *win)
+{
+ cerr << "[UnityBerkeliumWindow] onCrashedWorker called (window: " << win << ")" << endl;
+}
+
+void UnityBerkeliumWindow::onCrashedPlugin(Berkelium::Window *win, Berkelium::WideString pluginName)
+{
+ cerr << "[UnityBerkeliumWindow] onCrashedPlugin called (window: " << win << ")" << endl;
+ wcerr << " pluginName: " << pluginName << endl;
+}
+
+void UnityBerkeliumWindow::onProvisionalLoadError(Berkelium::Window *win, Berkelium::URLString url, int errorCode, bool isMainFrame)
+{
+ cerr << "[UnityBerkeliumWindow] onProvisionalLoadError called (window: " << win << ")" << endl;
+ cerr << " url: " << url << endl;
+ cerr << " errorCode: " << errorCode << endl;
+ cerr << " isMainFrame: " << (isMainFrame ? "yes" : "no") << endl;
+}
+
+void UnityBerkeliumWindow::onConsoleMessage(Berkelium::Window *win, Berkelium::WideString message, Berkelium::WideString sourceId, int line_no)
+{
+ cerr << "[UnityBerkeliumWindow] onConsoleMessage called (window: " << win << ")" << endl;
+ wcerr << " message: " << message << endl;
+ wcerr << " sourceId: " << sourceId << endl;
+ cerr << " line_no: " << line_no << endl;
+}
+
+void UnityBerkeliumWindow::onScriptAlert(Berkelium::Window *win, Berkelium::WideString message, Berkelium::WideString defaultValue, Berkelium::URLString url, int flags, bool &success, Berkelium::WideString &value)
+{
+ cerr << "[UnityBerkeliumWindow] onScriptAlert called (window: " << win << ")" << endl;
+ wcerr << " message: " << message << endl;
+ wcerr << " defaultValue: " << defaultValue << endl;
+ cerr << " url: " << url << endl;
+ cerr << " flags: " << flags << endl;
+}
+
+void UnityBerkeliumWindow::freeLastScriptAlert(Berkelium::WideString lastValue)
+{
+ cerr << "[UnityBerkeliumWindow] freeLastScriptAlert called (lastValue: " << lastValue << ")" << endl;
+ wcerr << " lastValue: " << lastValue << endl;
+}
+
+void UnityBerkeliumWindow::onNavigationRequested(Berkelium::Window *win, Berkelium::URLString newUrl, Berkelium::URLString referrer, bool isNewWindow, bool &cancelDefaultAction)
{
- cerr << "[UnityBerkeliumWindow] onLoadError called (window: " << win << ")" << endl;
+ cerr << "[UnityBerkeliumWindow] onNavigationRequested called (window: " << win << ")" << endl;
+ cerr << " newUrl: " << newUrl << endl;
+ cerr << " referrer: " << referrer << endl;
+ cerr << " isNewWindow: " << (isNewWindow ? "yes" : "no") << endl;
}
-void UnityBerkeliumWindow::onBeforeUnload(Berkelium::Window *win, bool *proceed)
+void UnityBerkeliumWindow::onLoadingStateChanged(Berkelium::Window *win, bool isLoading)
{
- cerr << "[UnityBerkeliumWindow] onBeforeUnload called (window: " << win << ")" << endl;
+ cerr << "[UnityBerkeliumWindow] onLoadingStateChanged called (window: " << win << ")" << endl;
+ cerr << " isLoading: " << (isLoading? "yes" : "no") << endl;
}
-void UnityBerkeliumWindow::onCancelUnload(Berkelium::Window *win)
+void UnityBerkeliumWindow::onTitleChanged(Berkelium::Window *win, Berkelium::WideString title)
{
- cerr << "[UnityBerkeliumWindow] onCancelUnload called (window: " << win << ")" << endl;
+ cerr << "[UnityBerkeliumWindow] onTitleChanged called (window: " << win << ")" << endl;
+ wcerr << " title: " << title << endl;
+}
+
+void UnityBerkeliumWindow::onTooltipChanged(Berkelium::Window *win, Berkelium::WideString text)
+{
+ cerr << "[UnityBerkeliumWindow] onTooltipChanged called (window: " << win << ")" << endl;
+ wcerr << " tetx: " << text << endl;
}
void UnityBerkeliumWindow::onCrashed(Berkelium::Window *win)
@@ -178,44 +250,88 @@ void UnityBerkeliumWindow::onResponsive(Berkelium::Window *win)
cerr << "[UnityBerkeliumWindow] onResponsive called (window: " << win << ")" << endl;
}
-void UnityBerkeliumWindow::onChromeSend(Berkelium::Window *win, Data message, const Data* content, size_t numContents)
+void UnityBerkeliumWindow::onExternalHost(Berkelium::Window *win, Berkelium::WideString message, Berkelium::URLString origin, Berkelium::URLString target)
{
- cerr << "[UnityBerkeliumWindow] onChromeSend called (window: " << win << ")" << endl;
+ cerr << "[UnityBerkeliumWindow] onExternalHost called (window: " << win << ")" << endl;
+ wcerr << " message: " << message << endl;
+ cerr << " origin: " << origin << endl;
+ cerr << " target: " << target << endl;
+
+ if(m_externalHostFunc)
+ {
+ m_lastExternalHostMessage = std::wstring(message.data(), message.length());
+ m_externalHostFunc(/*message.data()*/);
+ }
}
-void UnityBerkeliumWindow::onCreatedWindow(Berkelium::Window *win, Berkelium::Window *newWindow)
+void UnityBerkeliumWindow::onCreatedWindow(Berkelium::Window *win, Berkelium::Window *newWindow, const Berkelium::Rect &initialRect)
{
cerr << "[UnityBerkeliumWindow] onCreatedWindow called (window: " << win << ")" << endl;
}
+void UnityBerkeliumWindow::onPaint(Berkelium::Window *win, const unsigned char *sourceBuffer, const Berkelium::Rect &sourceBufferRect, size_t numCopyRects, const Berkelium::Rect *copyRects, int dx, int dy, const Berkelium::Rect &scrollRect)
+{
+#ifdef DEBUG
+ cerr << "[UnityBerkeliumWindow] onPaint called (window: " << win << ")" << endl;
+ cerr << " sourceBuffer: " << (void *) sourceBuffer << endl;
+ cerr << " sourceBufferRect: (left=" << sourceBufferRect.left() << ", width=" << sourceBufferRect.width() << ", top=" << sourceBufferRect.top() << ", height=" << sourceBufferRect.height() << ")" << endl;
+ cerr << " num dirty rects: " << numCopyRects << endl;
+ for(size_t i = 0; i < numCopyRects; ++i)
+ cerr << " rect " << i << ": (left=" << copyRects[i].left() << ", width=" << copyRects[i].width() << ", top=" << copyRects[i].top() << ", height=" << copyRects[i].height() << ")" << endl;
+#endif
+
+ //! @todo Handle Scrolling
+ if(dx != 0 || dy != 0)
+ {
+ }
+
+ // Apply the dirty rectangles
+ for(size_t i = 0; i < numCopyRects; ++i)
+ {
+ convertColors(copyRects[i], sourceBuffer);
+ m_lastDirtyRect = copyRects[i];
+
+ if(m_setPixelsFunc)
+ m_setPixelsFunc(/*rect.left(), rect.top(), rect.width(), rect.height()*/);
+ }
+
+ // Call the paint callback
+ if(m_applyTextureFunc)
+ m_applyTextureFunc();
+}
+
void UnityBerkeliumWindow::onWidgetCreated(Berkelium::Window *win, Berkelium::Widget *newWidget, int zIndex)
{
- cerr << "[UnityBerkeliumWindow] onWidgetCreated called (widget: " << newWidget << ")" << endl;
+ cerr << "[UnityBerkeliumWindow] onWidgetCreated called (window: " << win << ")" << endl;
}
-void UnityBerkeliumWindow::onWidgetDestroyed(Berkelium::Window *win, Berkelium::Widget *newWidget)
+void UnityBerkeliumWindow::onWidgetDestroyed(Berkelium::Window *win, Berkelium::Widget *wid)
{
- cerr << "[UnityBerkeliumWindow] onWidgetDestroyed called (widget: " << newWidget << ")" << endl;
+ cerr << "[UnityBerkeliumWindow] onWidgetDestroyed called (window: " << win << ")" << endl;
}
-void UnityBerkeliumWindow::onWidgetResize(Berkelium::Window *win, Berkelium::Widget *wid, int newWidth,int newHeight)
+void UnityBerkeliumWindow::onWidgetResize(Berkelium::Window *win, Berkelium::Widget *wid, int newWidth, int newHeight)
{
- cerr << "[UnityBerkeliumWindow] onWidgetResize called (widget: " << wid << ")" << endl;
+ cerr << "[UnityBerkeliumWindow] onWidgetResize called (window: " << win << ")" << endl;
}
void UnityBerkeliumWindow::onWidgetMove(Berkelium::Window *win, Berkelium::Widget *wid, int newX, int newY)
{
- cerr << "[UnityBerkeliumWindow] onWidgetMove called (widget: " << wid << ")" << endl;
+ cerr << "[UnityBerkeliumWindow] onWidgetMove called (window: " << win << ")" << endl;
}
-void UnityBerkeliumWindow::onWidgetPaint(Berkelium::Window *win, Berkelium::Widget *wid, const unsigned char *sourceBuffer, const Berkelium::Rect &rect,int dx, int dy, const Berkelium::Rect &scrollRect)
+void UnityBerkeliumWindow::onWidgetPaint(Berkelium::Window *win, Berkelium::Widget *wid, const unsigned char *sourceBuffer, const Berkelium::Rect &sourceBufferRect, size_t numCopyRects, const Berkelium::Rect *copyRects, int dx, int dy, const Berkelium::Rect &scrollRect)
{
- cerr << "[UnityBerkeliumWindow] onWidgetPaint called (widget: " << wid << ")" << endl;
+#ifdef DEBUG
+ cerr << "[UnityBerkeliumWindow] onWidgetPaint called (window: " << win << ")" << endl;
+#endif
}
-void UnityBerkeliumWindow::onCursorUpdated(const Berkelium::Cursor& newCursor)
+void UnityBerkeliumWindow::onCursorUpdated(Berkelium::Window *win, const Berkelium::Cursor& newCursor)
{
- cerr << "[UnityBerkeliumWindow] onCursorUpdated called" << endl;
+#ifdef DEBUG
+ cerr << "[UnityBerkeliumWindow] onCursorUpdated called (window: " << win << ")" << endl;
+#endif
}
void UnityBerkeliumWindow::onShowContextMenu(Berkelium::Window *win, const Berkelium::ContextMenuEventArgs& args)
@@ -235,7 +351,10 @@ void UnityBerkeliumWindow::convertColors(const Berkelium::Rect &rect, const unsi
{
for(int y = rect.top(); y < rect.bottom(); ++y)
{
+ // We copy to the beginning of the buffer
+ // (because we can't change the start address of the buffer we provide the Unity .SetPixels function
int idx = (y - rect.top()) * rect.width() + (x - rect.left());
+ //int idx = y * rect.width() + x;
m_buffer[idx * 4 + 0] = sourceBuffer[idx * 4 + 2] / 255.0f; // R
m_buffer[idx * 4 + 1] = sourceBuffer[idx * 4 + 1] / 255.0f; // G
View
55 src/UnityBerkeliumWindow.h
@@ -14,6 +14,7 @@
#include <berkelium/Berkelium.hpp>
#include <berkelium/Window.hpp>
#include <berkelium/WindowDelegate.hpp>
+#include <vector>
/** Class Description */
class UnityBerkeliumWindow: Berkelium::WindowDelegate
@@ -21,39 +22,57 @@ class UnityBerkeliumWindow: Berkelium::WindowDelegate
public:
// The callback function that is called when a paint event occurs
// Note: Unity crashes when providing a struct or more than two standard parameters
- //typedef void (*PaintFunc)(Berkelium::Rect);
- typedef void (*PaintFunc)(/*int left, int top, int width, int height*/);
+ //typedef void (*SetPixelsFunc)(Berkelium::Rect);
+ typedef void (*SetPixelsFunc)(/*int left, int top, int width, int height*/);
+ typedef void (*ApplyTextureFunc)();
+
+ // The callback function that is called from a javascript externalHost call
+ typedef void (*ExternalHostFunc)(/*const wchar_t *message*/);
// Constructors and destructor
- UnityBerkeliumWindow(int uniqueID, float *buffer, bool transparency, int width, int height, const string &url, PaintFunc paintFunc);
+ UnityBerkeliumWindow(int uniqueID, float *buffer, bool transparency, int width, int height, const string &url);
virtual ~UnityBerkeliumWindow();
// Information
Berkelium::Window *getBerkeliumWindow() const { return m_pWindow; }
+ // Callbacks
+ void setPaintFunctions(SetPixelsFunc setPixelsFunc, ApplyTextureFunc applyTextureFunc);
+ void setExternalHostCallback(ExternalHostFunc callback);
+
// Current paint info
const Berkelium::Rect &getLastDirtyRect() const { return m_lastDirtyRect; }
+ // Last external host message
+ const std::wstring &getLastExternalHostMessage() const { return m_lastExternalHostMessage; }
+
protected:
// Berkelium::WindowDelegate functions
- virtual void onPaint(Berkelium::Window *pWindow, const unsigned char *sourceBuffer, const Berkelium::Rect &rect, int dx, int dy, const Berkelium::Rect &scrollRect);
- virtual void onAddressBarChanged(Berkelium::Window *win, const char* newURL, size_t newURLSize);
- virtual void onStartLoading(Berkelium::Window *win, const char *newURL, size_t newURLSize);
+ virtual void onAddressBarChanged(Berkelium::Window *win, Berkelium::URLString newURL);
+ virtual void onStartLoading(Berkelium::Window *win, Berkelium::URLString newURL);
virtual void onLoad(Berkelium::Window *win);
- virtual void onLoadError(Berkelium::Window *win, const char* error, size_t errorLength);
- virtual void onBeforeUnload(Berkelium::Window *win, bool *proceed);
- virtual void onCancelUnload(Berkelium::Window *win);
+ virtual void onCrashedWorker(Berkelium::Window *win);
+ virtual void onCrashedPlugin(Berkelium::Window *win, Berkelium::WideString pluginName);
+ virtual void onProvisionalLoadError(Berkelium::Window *win, Berkelium::URLString url, int errorCode, bool isMainFrame);
+ virtual void onConsoleMessage(Berkelium::Window *win, Berkelium::WideString message, Berkelium::WideString sourceId, int line_no);
+ virtual void onScriptAlert(Berkelium::Window *win, Berkelium::WideString message, Berkelium::WideString defaultValue, Berkelium::URLString url, int flags, bool &success, Berkelium::WideString &value);
+ virtual void freeLastScriptAlert(Berkelium::WideString lastValue);
+ virtual void onNavigationRequested(Berkelium::Window *win, Berkelium::URLString newUrl, Berkelium::URLString referrer, bool isNewWindow, bool &cancelDefaultAction);
+ virtual void onLoadingStateChanged(Berkelium::Window *win, bool isLoading);
+ virtual void onTitleChanged(Berkelium::Window *win, Berkelium::WideString title);
+ virtual void onTooltipChanged(Berkelium::Window *win, Berkelium::WideString text);
virtual void onCrashed(Berkelium::Window *win);
virtual void onUnresponsive(Berkelium::Window *win);
virtual void onResponsive(Berkelium::Window *win);
- virtual void onChromeSend(Berkelium::Window *win, Data message, const Data* content, size_t numContents);
- virtual void onCreatedWindow(Berkelium::Window *win, Berkelium::Window *newWindow);
+ virtual void onExternalHost(Berkelium::Window *win, Berkelium::WideString message, Berkelium::URLString origin, Berkelium::URLString target);
+ virtual void onCreatedWindow(Berkelium::Window *win, Berkelium::Window *newWindow, const Berkelium::Rect &initialRect);
+ virtual void onPaint(Berkelium::Window *win, const unsigned char *sourceBuffer, const Berkelium::Rect &sourceBufferRect, size_t numCopyRects, const Berkelium::Rect *copyRects, int dx, int dy, const Berkelium::Rect &scrollRect);
virtual void onWidgetCreated(Berkelium::Window *win, Berkelium::Widget *newWidget, int zIndex);
- virtual void onWidgetDestroyed(Berkelium::Window *win, Berkelium::Widget *newWidget);
- virtual void onWidgetResize(Berkelium::Window *win, Berkelium::Widget *wid, int newWidth,int newHeight);
+ virtual void onWidgetDestroyed(Berkelium::Window *win, Berkelium::Widget *wid);
+ virtual void onWidgetResize(Berkelium::Window *win, Berkelium::Widget *wid, int newWidth, int newHeight);
virtual void onWidgetMove(Berkelium::Window *win, Berkelium::Widget *wid, int newX, int newY);
- virtual void onWidgetPaint(Berkelium::Window *win, Berkelium::Widget *wid, const unsigned char *sourceBuffer, const Berkelium::Rect &rect,int dx, int dy, const Berkelium::Rect &scrollRect);
- virtual void onCursorUpdated(const Berkelium::Cursor& newCursor);
+ virtual void onWidgetPaint(Berkelium::Window *win, Berkelium::Widget *wid, const unsigned char *sourceBuffer, const Berkelium::Rect &sourceBufferRect, size_t numCopyRects, const Berkelium::Rect *copyRects, int dx, int dy, const Berkelium::Rect &scrollRect);
+ virtual void onCursorUpdated(Berkelium::Window *win, const Berkelium::Cursor& newCursor);
virtual void onShowContextMenu(Berkelium::Window *win, const Berkelium::ContextMenuEventArgs& args);
// Protected functions
@@ -67,8 +86,12 @@ class UnityBerkeliumWindow: Berkelium::WindowDelegate
int m_width, m_height;
string m_url;
- PaintFunc m_paintFunc;
+ SetPixelsFunc m_setPixelsFunc;
+ ApplyTextureFunc m_applyTextureFunc;
Berkelium::Rect m_lastDirtyRect;
+
+ ExternalHostFunc m_externalHostFunc;
+ std::wstring m_lastExternalHostMessage;
};
#endif // UNITYBERKELIUMWINDOW_H
View
2  src/global.h
@@ -44,6 +44,8 @@ using std::cout;
using std::cin;
using std::cerr;
using std::endl;
+using std::wcout;
+using std::wcerr;
#include <cassert>
View
117 test-project/Assets/Plugins/UnityBerkelium.cs
@@ -23,18 +23,26 @@ public class UnityBerkelium : MonoBehaviour {
private GCHandle m_PixelsHandle;
private int m_TextureID;
- // A rectangle
+ // A rectangle (same structure as the Berkelium Rect)
struct Rect
{
- public int top, left;
+ public int left, top;
public int width, height;
}
// The delegate that is called when there is a dirty rectangle
// Note: Unity crashes when using a struct or more than two parameters
- //delegate void PaintFunc(Rect rect);
- delegate void PaintFunc(/*int left, int top, int width, int height*/);
- private PaintFunc m_paintFunc;
+ //delegate void SetPixelsFunc(Rect rect);
+ delegate void SetPixelsFunc(/*int left, int top, int width, int height*/);
+ private SetPixelsFunc m_setPixelsFunc;
+
+ // The delgate that is called when all dirty rectangles can be applied
+ delegate void ApplyTextureFunc();
+ private ApplyTextureFunc m_applyTextureFunc;
+
+ // The delegate that is called when javascript calls to Unity
+ delegate void ExternalHostFunc(/*string message*/);
+ private ExternalHostFunc m_externalHostFunc;
// Imported functions
[DllImport ("UnityBerkeliumPlugin")]
@@ -47,12 +55,15 @@ struct Rect
private static extern void Berkelium_update();
[DllImport ("UnityBerkeliumPlugin")]
- private static extern int Berkelium_Window_create(int windowID, IntPtr colors, bool transparency, int width, int height, string url, PaintFunc paintFunc);
+ private static extern int Berkelium_Window_create(int windowID, IntPtr colors, bool transparency, int width, int height, string url);
[DllImport ("UnityBerkeliumPlugin")]
private static extern void Berkelium_Window_destroy(int windowID);
[DllImport ("UnityBerkeliumPlugin")]
+ private static extern void Berkelium_Window_setPaintFunctions(int windowID, SetPixelsFunc setPixelsFunc, ApplyTextureFunc applyTextureFunc);
+
+ [DllImport ("UnityBerkeliumPlugin")]
private static extern Rect Berkelium_Window_getLastDirtyRect(int windowID);
[DllImport ("UnityBerkeliumPlugin")]
@@ -73,21 +84,27 @@ struct Rect
[DllImport ("UnityBerkeliumPlugin")]
private static extern void Berkelium_Window_executeJavascript(int windowID, string javascript);
- void Start () {
-
+ [DllImport ("UnityBerkeliumPlugin")]
+ private static extern void Berkelium_Window_setExternalHostCallback(int windowID, ExternalHostFunc callback);
+
+ [DllImport ("UnityBerkeliumPlugin")]
+ private static extern IntPtr Berkelium_Window_getLastExternalHostMessage(int windowID);
+
+ void Start ()
+ {
// Initialize Berkelium
Berkelium_init();
- // Create the texture that will represent the website (with optional transparency and without mipmaps)
+ // Create the texture that will represent the website (with optional transparency and without mipmaps)
TextureFormat texFormat = transparency ? TextureFormat.ARGB32 : TextureFormat.RGB24;
- m_Texture = new Texture2D (width, height, texFormat, false);
-
- // Create the pixel array for the plugin to write into at startup
- m_Pixels = m_Texture.GetPixels (0);
- // "pin" the array in memory, so we can pass direct pointer to it's data to the plugin,
- // without costly marshaling of array of structures.
- m_PixelsHandle = GCHandle.Alloc(m_Pixels, GCHandleType.Pinned);
-
+ m_Texture = new Texture2D (width, height, texFormat, false);
+
+ // Create the pixel array for the plugin to write into at startup
+ m_Pixels = m_Texture.GetPixels (0);
+ // "pin" the array in memory, so we can pass direct pointer to it's data to the plugin,
+ // without costly marshaling of array of structures.
+ m_PixelsHandle = GCHandle.Alloc(m_Pixels, GCHandleType.Pinned);
+
// Save the texture ID
m_TextureID = m_Texture.GetInstanceID();
@@ -95,10 +112,10 @@ struct Rect
m_Texture.filterMode = FilterMode.Trilinear;
m_Texture.anisoLevel = 2;
- // Assign texture to the renderer
- if (renderer)
+ // Assign texture to the renderer
+ if (renderer)
{
- renderer.material.mainTexture = m_Texture;
+ renderer.material.mainTexture = m_Texture;
// Transparency?
if(transparency)
@@ -109,33 +126,49 @@ struct Rect
// The texture has to be flipped
renderer.material.mainTextureScale = new Vector2(1,-1);
}
- // or gui texture
- else if (GetComponent(typeof(GUITexture)))
- {
- GUITexture gui = GetComponent(typeof(GUITexture)) as GUITexture;
- gui.texture = m_Texture;
- }
- else
- {
- Debug.Log("Game object has no renderer or gui texture to assign the generated texture to!");
- }
-
- // Paint callback
- m_paintFunc = new PaintFunc(this.Paint);
+ // or gui texture
+ else if (GetComponent(typeof(GUITexture)))
+ {
+ GUITexture gui = GetComponent(typeof(GUITexture)) as GUITexture;
+ gui.texture = m_Texture;
+ }
+ else
+ {
+ Debug.Log("Game object has no renderer or gui texture to assign the generated texture to!");
+ }
// Create new web window
- Berkelium_Window_create(m_TextureID, m_PixelsHandle.AddrOfPinnedObject(), transparency, width,height, url, m_paintFunc);
+ Berkelium_Window_create(m_TextureID, m_PixelsHandle.AddrOfPinnedObject(), transparency, width,height, url);
print("Created new web window: " + m_TextureID);
+
+ // Paint callbacks
+ m_setPixelsFunc = new SetPixelsFunc(this.SetPixels);
+ m_applyTextureFunc = new ApplyTextureFunc(this.ApplyTexture);
+ Berkelium_Window_setPaintFunctions(m_TextureID, m_setPixelsFunc, m_applyTextureFunc);
+
+ // Set the external host callback (for calling Unity functions from javascript)
+ m_externalHostFunc = new ExternalHostFunc(this.onExternalHost);
+ Berkelium_Window_setExternalHostCallback(m_TextureID, m_externalHostFunc);
}
- void Paint(/*int left, int top, int width, int height*/)
+ void SetPixels(/*int left, int top, int width, int height*/)
{
Rect rect = Berkelium_Window_getLastDirtyRect(m_TextureID);
-
//print("Painting rect: (" + rect.left + ", " + rect.top + ", " + rect.width + ", " + rect.height + ")");
m_Texture.SetPixels(rect.left, rect.top, rect.width, rect.height, m_Pixels, 0);
+ }
+
+ void ApplyTexture()
+ {
+ //print("Applying texture");
m_Texture.Apply();
}
+
+ void onExternalHost(/*string message*/)
+ {
+ string message = Marshal.PtrToStringUni(Berkelium_Window_getLastExternalHostMessage(m_TextureID));
+ print("Message from javascript: " + message);
+ }
void OnDisable() {
// Destroy the web window
@@ -148,9 +181,8 @@ void Paint(/*int left, int top, int width, int height*/)
Berkelium_destroy();
}
- // Now we can simply call UpdateTexture which gets routed directly into the plugin
- void Update () {
-
+ void Update ()
+ {
// Update Berkelium
// TODO This only has to be done once in stead of per object
Berkelium_update();
@@ -238,6 +270,13 @@ void OnGUI()
Berkelium_Window_keyEvent(m_TextureID, pressed, mods, vk_code, scancode);
print("Key event: " + pressed + ", " + Event.current.keyCode);*/
}
+
+ // A button to test javascript execution
+ /*if(GUI.Button(Rect(10,10,150,100), "Execute Javascript"))
+ {
+ print("Executing Javascript");
+ Berkelium_Window_executeJavascript(m_TextureID, "callMeBack()");
+ }*/
}
int convertKeyCode(KeyCode keyCode)
View
BIN  test-project/Assets/Plugins/UnityBerkeliumPlugin.dll
Binary file not shown
Please sign in to comment.
Something went wrong with that request. Please try again.