diff --git a/DesktopEditor/doctrenderer/docbuilder_p.cpp b/DesktopEditor/doctrenderer/docbuilder_p.cpp index d732f206bc..fd7069c5b6 100644 --- a/DesktopEditor/doctrenderer/docbuilder_p.cpp +++ b/DesktopEditor/doctrenderer/docbuilder_p.cpp @@ -58,7 +58,7 @@ CV8RealTimeWorker::CV8RealTimeWorker(NSDoctRenderer::CDocBuilder* pBuilder) { m_nFileType = -1; - m_isolate = CV8Worker::getInitializer()->CreateNew(); + m_isolate = v8::Isolate::GetCurrent(); // CV8Worker::getInitializer()->CreateNew(); m_isolate_scope = new v8::Isolate::Scope(m_isolate); m_isolate_locker = new v8::Locker(m_isolate); @@ -933,12 +933,12 @@ namespace NSDoctRenderer void CDocBuilder::Initialize() { - CV8Worker::Initialize(); + // CV8Worker::Initialize(); } void CDocBuilder::Dispose() { - CV8Worker::Dispose(); + // CV8Worker::Dispose(); } void CDocBuilder::WriteData(const wchar_t* path, const wchar_t* value, const bool& append) diff --git a/DesktopEditor/doctrenderer/doctrenderer.cpp b/DesktopEditor/doctrenderer/doctrenderer.cpp index 215a0d3bd5..2b67c672ba 100644 --- a/DesktopEditor/doctrenderer/doctrenderer.cpp +++ b/DesktopEditor/doctrenderer/doctrenderer.cpp @@ -741,7 +741,7 @@ namespace NSDoctRenderer LOGGER_SPEED_START bool bIsBreak = false; - v8::Isolate* isolate = CV8Worker::getInitializer()->CreateNew(); + v8::Isolate* isolate = v8::Isolate::GetCurrent(); // CV8Worker::getInitializer()->CreateNew(); if (true) { v8::Isolate::Scope isolate_cope(isolate); diff --git a/DesktopEditor/doctrenderer/js_internal/embed/GraphicsEmbed.h b/DesktopEditor/doctrenderer/js_internal/embed/GraphicsEmbed.h index 78fdbdf533..10818af08a 100644 --- a/DesktopEditor/doctrenderer/js_internal/embed/GraphicsEmbed.h +++ b/DesktopEditor/doctrenderer/js_internal/embed/GraphicsEmbed.h @@ -119,6 +119,7 @@ public: JSSmart DrawPolygon(JSSmart oPath, JSSmart lineWidth, JSSmart shift); JSSmart DrawFootnoteRect(JSSmart x, JSSmart y, JSSmart w, JSSmart h); + static void CreateNativeGraphics(const v8::FunctionCallbackInfo& args); static void CreateObjectInContext(const std::string& name, JSSmart context); }; diff --git a/DesktopEditor/doctrenderer/js_internal/embed/v8/v8_Graphics.cpp b/DesktopEditor/doctrenderer/js_internal/embed/v8/v8_Graphics.cpp index 82de8a93bb..1123bf9e80 100644 --- a/DesktopEditor/doctrenderer/js_internal/embed/v8/v8_Graphics.cpp +++ b/DesktopEditor/doctrenderer/js_internal/embed/v8/v8_Graphics.cpp @@ -322,26 +322,26 @@ namespace NSGraphics return handle_scope.Escape(result); } +} - void CreateNativeGraphics(const v8::FunctionCallbackInfo& args) - { - v8::Isolate* isolate = args.GetIsolate(); - v8::HandleScope scope(isolate); +void CGraphicsEmbed::CreateNativeGraphics(const v8::FunctionCallbackInfo& args) +{ + v8::Isolate* isolate = args.GetIsolate(); + v8::HandleScope scope(isolate); - v8::Handle GraphicsTemplate = NSGraphics::CreateGraphicsTemplate(isolate); - CGraphicsEmbed* pGraphics = new CGraphicsEmbed(); + v8::Handle GraphicsTemplate = NSGraphics::CreateGraphicsTemplate(isolate); + CGraphicsEmbed* pGraphics = new CGraphicsEmbed(); - v8::Local obj = GraphicsTemplate->NewInstance(isolate->GetCurrentContext()).ToLocalChecked(); - obj->SetInternalField(0, v8::External::New(CV8Worker::GetCurrent(), pGraphics)); + v8::Local obj = GraphicsTemplate->NewInstance(isolate->GetCurrentContext()).ToLocalChecked(); + obj->SetInternalField(0, v8::External::New(CV8Worker::GetCurrent(), pGraphics)); - args.GetReturnValue().Set(obj); - } + args.GetReturnValue().Set(obj); } void CGraphicsEmbed::CreateObjectInContext(const std::string& name, JSSmart context) { v8::Isolate* current = CV8Worker::GetCurrent(); - context->m_internal->m_global->Set(current, name.c_str(), v8::FunctionTemplate::New(current, NSGraphics::CreateNativeGraphics)); + context->m_internal->m_global->Set(current, name.c_str(), v8::FunctionTemplate::New(current, CreateNativeGraphics)); } /* diff --git a/DesktopEditor/doctrenderer/nativecontrol.cpp b/DesktopEditor/doctrenderer/nativecontrol.cpp index 963f5bf3cf..dfe67540a0 100644 --- a/DesktopEditor/doctrenderer/nativecontrol.cpp +++ b/DesktopEditor/doctrenderer/nativecontrol.cpp @@ -621,6 +621,7 @@ v8::Handle CreateNativeControlTemplateBuilder(v8::Isolate* i } // -------------------------- +/* void CV8Worker::Initialize() { if (NULL == m_pInitializer) @@ -644,5 +645,5 @@ CV8Initializer* CV8Worker::getInitializer() return CV8Worker::m_pInitializer; } -CV8Initializer* CV8Worker::m_pInitializer = NULL; +CV8Initializer* CV8Worker::m_pInitializer = NULL;*/ // -------------------------- diff --git a/DesktopEditor/doctrenderer/nativecontrol.h b/DesktopEditor/doctrenderer/nativecontrol.h index b925cb244c..294d920b2c 100644 --- a/DesktopEditor/doctrenderer/nativecontrol.h +++ b/DesktopEditor/doctrenderer/nativecontrol.h @@ -1257,6 +1257,7 @@ public: } }; +/* class CV8Worker { private: @@ -1271,6 +1272,7 @@ public: static CV8Initializer* getInitializer(); }; +*/ bool Doct_renderer_SaveFile_ForBuilder(int nFormat, const std::wstring& strDstFile, CNativeControl* pNative, diff --git a/Test/Applications/V8CanvasContext/V8CanvasContext.cpp b/Test/Applications/V8CanvasContext/V8CanvasContext.cpp index 6058c3aa3f..c6509a4fce 100644 --- a/Test/Applications/V8CanvasContext/V8CanvasContext.cpp +++ b/Test/Applications/V8CanvasContext/V8CanvasContext.cpp @@ -2,8 +2,9 @@ #include #include "V8CanvasContext.h" -#include "../../../Common/3dParty/v8/v8/include/v8.h" -#include "../../../Common/3dParty/v8/v8/include/libplatform/libplatform.h" +#include "v8.h" +#include "libplatform/libplatform.h" +#include "../../../DesktopEditor/doctrenderer/js_internal/embed/GraphicsEmbed.h" #include "../../../DesktopEditor/common/File.h" #include "../../../DesktopEditor/common/Types.h" @@ -129,7 +130,7 @@ HRESULT CV8CanvasContext::Run(const std::wstring& sPath) v8::Handle global = v8::ObjectTemplate::New(isolate); global->Set(isolate, "User", v8::FunctionTemplate::New(isolate, CreateUser)); - global->Set(isolate, "CGraphics", v8::FunctionTemplate::New(isolate, CreateGraphics)); + global->Set(isolate, "CGraphics", v8::FunctionTemplate::New(isolate, CGraphicsEmbed::CreateNativeGraphics)); v8::Local context = v8::Context::New(isolate, NULL, global); v8::Context::Scope context_scope(context); diff --git a/Test/Applications/V8CanvasContext/V8CanvasContext.h b/Test/Applications/V8CanvasContext/V8CanvasContext.h index cdcbb772d2..5c87ede6dd 100644 --- a/Test/Applications/V8CanvasContext/V8CanvasContext.h +++ b/Test/Applications/V8CanvasContext/V8CanvasContext.h @@ -4,10 +4,10 @@ #include #include "../../../DesktopEditor/common/Types.h" -#include "../../../Common/3dParty/v8/v8/include/v8.h" -#include "../../../Common/3dParty/v8/v8/include/libplatform/libplatform.h" +#include "v8.h" +#include "libplatform/libplatform.h" -#include "../../../DesktopEditor/doctrenderer/jsgraphics/graphics_wrapper.h" +#include "../../../DesktopEditor/doctrenderer/js_internal/embed/GraphicsEmbed.h" #ifndef V8CANVASCONTEXT_USE_DYNAMIC_LIBRARY #define V8CANVASCONTEXT_DECL_EXPORT diff --git a/Test/Applications/V8CanvasContext/V8CanvasContext_test.pro b/Test/Applications/V8CanvasContext/V8CanvasContext_test.pro index 57abe08655..d40759ef06 100644 --- a/Test/Applications/V8CanvasContext/V8CanvasContext_test.pro +++ b/Test/Applications/V8CanvasContext/V8CanvasContext_test.pro @@ -5,6 +5,7 @@ TARGET = V8CanvasContext_Test TEMPLATE = app CONFIG += console CONFIG -= app_bundle +CONFIG += core_static_link_libstd DEFINES += V8CANVASCONTEXT_USE_DYNAMIC_LIBRARY @@ -13,15 +14,11 @@ PWD_ROOT_DIR = $$PWD include($$CORE_ROOT_DIR/Common/base.pri) include($$CORE_ROOT_DIR/Common/3dParty/v8/v8.pri) -ADD_DEPENDENCY(kernel, UnicodeConverter, graphics) +ADD_DEPENDENCY(kernel, UnicodeConverter, graphics, doctrenderer) -HEADERS += V8CanvasContext.h \ - $$CORE_ROOT_DIR/DesktopEditor/doctrenderer/jsgraphics/graphics.h \ - $$CORE_ROOT_DIR/DesktopEditor/doctrenderer/jsgraphics/graphics_wrapper.h +HEADERS += V8CanvasContext.h SOURCES += main.cpp \ - V8CanvasContext.cpp \ - $$CORE_ROOT_DIR/DesktopEditor/doctrenderer/jsgraphics/graphics.cpp \ - $$CORE_ROOT_DIR/DesktopEditor/doctrenderer/jsgraphics/graphics_wrapper.cpp \ + V8CanvasContext.cpp DESTDIR = $$PWD/build/$$CORE_BUILDS_PLATFORM_PREFIX