Browse Source

Merge pull request #769 from AtomicGameEngine/JME-ATOMIC-IPCWEBVIEWUPDATES

Improved IPC performance for larger messages, WebView now supports transparency
JoshEngebretson 9 years ago
parent
commit
e023200a4e

+ 2 - 2
Build/CMake/Modules/AtomicWindows.cmake

@@ -31,8 +31,8 @@ endif()
 
 # removes dependency on D3DCompiler dll for Atomic Direct3D9 builds which don't require it
 # (binaries that never initialize the Direct3D9 graphics subsystem)
-if (NOT ATOMIC_D3DCOMPILER_DISABLE AND NOT ATOMIC_UWEBKIT)
-  add_definitions(-DATOMIC_D3DCOMPILER_ENABLED)
+if (ATOMIC_D3D9SHADERCOMPILER_DISABLE)
+  add_definitions(-DATOMIC_D3D9SHADERCOMPILER_DISABLE)
 endif()
 
 

+ 2 - 2
Source/Atomic/Graphics/Direct3D9/D3D9ShaderVariation.cpp

@@ -31,7 +31,7 @@
 #include "../../IO/Log.h"
 #include "../../Resource/ResourceCache.h"
 
-#ifdef ATOMIC_D3DCOMPILER_ENABLED
+#ifndef ATOMIC_D3D9SHADERCOMPILER_DISABLE
 #include <d3dcompiler.h>
 #endif
 
@@ -224,7 +224,7 @@ bool ShaderVariation::LoadByteCode(PODVector<unsigned>& byteCode, const String&
 bool ShaderVariation::Compile(PODVector<unsigned>& byteCode)
 {
 
-#ifndef ATOMIC_D3DCOMPILER_ENABLED
+#ifdef ATOMIC_D3D9SHADERCOMPILER_DISABLE
     return false;
 #else
     const String& sourceCode = owner_->GetSourceCode(type_);

+ 1 - 1
Source/Atomic/IPC/IPCUnix.h

@@ -60,7 +60,7 @@ private:
 
 class PipeTransport : public PipeUnix {
 public:
-    static const size_t kBufferSz = 4096;
+    static const size_t kBufferSz = 1024 * 1024;
 
     bool Send(const void* buf, size_t sz) {
         return Write(buf, sz);

+ 4 - 2
Source/Atomic/IPC/IPCWindows.cpp

@@ -40,7 +40,9 @@ namespace Atomic
 {
 
 static const wchar_t kPipePrefix[] = L"\\\\.\\pipe\\";
-static const int kPipeBufferSz = 4 * 1024;
+// start with 1 megabyte of buffer, this will grow if a request exceeds this size
+// however, it will block during resize
+static const int kPipeBufferSz = ATOMIC_WINDOWS_IPC_BUFFER_SIZE;
 static LONG g_pipe_seq = 0;
 
 HANDLE PipePair::OpenPipeServer(const wchar_t* name, bool read)
@@ -213,7 +215,7 @@ void PipeWin::ReaderThread::ThreadFunction()
             continue;
 
         DWORD bytesRead = 0;
-        if (TRUE == ::ReadFile(pipeWin_->pipeRead_, &buf_[0], 4096, &bytesRead, NULL))
+        if (TRUE == ::ReadFile(pipeWin_->pipeRead_, &buf_[0], ATOMIC_WINDOWS_IPC_BUFFER_SIZE, &bytesRead, NULL))
         {
             readSize_ = (unsigned) bytesRead;
         }

+ 5 - 2
Source/Atomic/IPC/IPCWindows.h

@@ -32,6 +32,8 @@
 namespace Atomic
 {
 
+#define ATOMIC_WINDOWS_IPC_BUFFER_SIZE 1048576
+
 class PipePair {
 
 public:
@@ -75,7 +77,7 @@ private:
 
         ReaderThread(PipeWin* pipeWin) : pipeWin_(pipeWin), readSize_(0)
         {
-            buf_.Resize(4096);
+            buf_.Resize(ATOMIC_WINDOWS_IPC_BUFFER_SIZE);
         }
 
         void Kill();
@@ -97,7 +99,8 @@ private:
 
 class PipeTransport : public PipeWin {
 public:
-    static const size_t kBufferSz = 4096;
+
+    static const size_t kBufferSz = ATOMIC_WINDOWS_IPC_BUFFER_SIZE;
 
     bool Send(const void* buf, size_t sz) {
         return Write(buf, sz);

+ 6 - 0
Source/AtomicWebView/Internal/WebAppBrowser.cpp

@@ -35,9 +35,15 @@ WebAppBrowser::WebAppBrowser()
 
 void WebAppBrowser::OnBeforeCommandLineProcessing(const CefString& process_type, CefRefPtr<CefCommandLine> command_line)
 {
+
+    // media stream support
     command_line->AppendSwitch("--enable-media-stream");
     command_line->AppendSwitch("--enable-usermedia-screen-capturing");
 
+    // transparency support
+    command_line->AppendSwitch("--off-screen-rendering-enabled");
+    command_line->AppendSwitch("--transparent-painting-enabled");
+
     CefApp::OnBeforeCommandLineProcessing(process_type, command_line);
 }
 

+ 6 - 3
Source/AtomicWebView/WebBrowserHost.cpp

@@ -118,17 +118,20 @@ WebBrowserHost::WebBrowserHost(Context* context) : Object (context)
 
 
     // IMPORTANT: See flags being set in implementation of void WebAppBrowser::OnBeforeCommandLineProcessing
-    // these include "--enable-media-stream", "--enable-usermedia-screen-capturing"
+    // these include "--enable-media-stream", "--enable-usermedia-screen-capturing", "--off-screen-rendering-enabled", "--transparent-painting-enabled"
 
 #ifdef ATOMIC_PLATFORM_LINUX
-    static const char* _argv[3] = { "AtomicWebView", "--disable-setuid-sandbox", "--off-screen-rendering-enabled" };
+    static const char* _argv[3] = { "AtomicWebView", "--disable-setuid-sandbox" };
     CefMainArgs args(3, (char**) &_argv);
 #else
     CefMainArgs args;
 #endif
 
     CefSettings settings;
-    settings.windowless_rendering_enabled = true;
+    settings.windowless_rendering_enabled = 1;
+
+    // default background is white, add a setting
+    // settings.background_color = 0;
 
     if (productVersion_.Length())
     {

+ 4 - 3
Source/AtomicWebView/WebClient.cpp

@@ -347,7 +347,8 @@ public:
         browserSettings.universal_access_from_file_urls = STATE_ENABLED;
 
         windowInfo.width = width;
-        windowInfo.height = height;
+        windowInfo.height = height;        
+        windowInfo.transparent_painting_enabled = 1;
 
         Graphics* graphics = webClient_->GetSubsystem<Graphics>();
 
@@ -365,7 +366,7 @@ public:
 #endif
 
 #ifdef ATOMIC_PLATFORM_WINDOWS
-                windowInfo.SetAsWindowless(info.info.win.window, false);
+                windowInfo.SetAsWindowless(info.info.win.window, /*transparent*/ true);
 #endif
             }
 
@@ -374,7 +375,7 @@ public:
         {
 #ifndef ATOMIC_PLATFORM_LINUX
             // headless
-            windowInfo.SetAsWindowless(nullptr, false);
+            windowInfo.SetAsWindowless(nullptr, true);
 #endif
         }