mirror of
https://github.com/penpot/penpot.git
synced 2025-03-28 15:41:25 -05:00
wip: add common namespace and fix cpp errors
This commit is contained in:
parent
024a2ae848
commit
bc0fde68c7
7 changed files with 50 additions and 16 deletions
|
@ -7,7 +7,7 @@ all:
|
|||
# -sUSE_PTHREADS: Disables pthreads.
|
||||
# -sMAX_WEBGL_VERSION: Max WebGL set to 2
|
||||
# -sUSE_WEBGL2: Uses WebGL2 by default.
|
||||
emcc \
|
||||
em++ \
|
||||
-std=c++20 \
|
||||
-lembind \
|
||||
-fno-rtti \
|
||||
|
|
|
@ -3,10 +3,17 @@
|
|||
console.log("preamble", Renderer);
|
||||
Renderer.setCanvas = function setCanvas(canvas, attrs) {
|
||||
console.log("GL", GL);
|
||||
debugger
|
||||
const context = GL.createContext(canvas, attrs);
|
||||
if (!context) {
|
||||
throw new Error('Could not create a new WebGL context')
|
||||
}
|
||||
GL.makeContextCurrent(context);
|
||||
|
||||
// Emscripten does not enable this by default and Skia needs this
|
||||
// to handle certain GPU corner cases.
|
||||
GL.currentContext.GLctx.getExtension('WEBGL_debug_renderer_info');
|
||||
|
||||
console.log("setCanvas", canvas, attrs);
|
||||
const gr = this._MakeGrContext();
|
||||
console.log("gr", gr);
|
||||
|
|
|
@ -74,8 +74,7 @@
|
|||
[app.main.repo :as rp]
|
||||
[app.main.streams :as ms]
|
||||
[app.main.worker :as uw]
|
||||
[app.renderer.cpp :as renderer-cpp]
|
||||
[app.renderer.rs :as renderer-rs]
|
||||
[app.renderer :as renderer]
|
||||
[app.util.dom :as dom]
|
||||
[app.util.globals :as ug]
|
||||
[app.util.http :as http]
|
||||
|
@ -355,11 +354,6 @@
|
|||
(dcm/retrieve-comment-threads file-id)
|
||||
(fetch-bundle project-id file-id))
|
||||
|
||||
(when (contains? cf/flags :renderer-v2-cpp)
|
||||
(rx/of (renderer-cpp/init)))
|
||||
(when (contains? cf/flags :renderer-v2-rs)
|
||||
(rx/of (renderer-rs/init)))
|
||||
|
||||
(->> stream
|
||||
(rx/filter dch/commit?)
|
||||
(rx/map deref)
|
||||
|
|
|
@ -48,10 +48,10 @@
|
|||
[app.main.ui.workspace.viewport.utils :as utils]
|
||||
[app.main.ui.workspace.viewport.viewport-ref :refer [create-viewport-ref]]
|
||||
[app.main.ui.workspace.viewport.widgets :as widgets]
|
||||
[app.renderer.cpp :as renderer-cpp]
|
||||
[app.renderer.rs :as renderer-rs]
|
||||
[app.renderer :as renderer]
|
||||
[app.util.debug :as dbg]
|
||||
[beicon.v2.core :as rx]
|
||||
[promesa.core :as p]
|
||||
[rumext.v2 :as mf]))
|
||||
|
||||
;; --- Viewport
|
||||
|
@ -269,13 +269,13 @@
|
|||
|
||||
rule-area-size (/ rulers/ruler-area-size zoom)]
|
||||
|
||||
(mf/with-effect
|
||||
|
||||
(when (renderer/is-enabled?)
|
||||
(mf/with-effect
|
||||
[canvas-ref]
|
||||
(let [canvas (mf/ref-val canvas-ref)]
|
||||
(when (contains? cf/flags :renderer-v2-cpp)
|
||||
(renderer-cpp/set-canvas canvas))
|
||||
(when (contains? cf/flags :renderer-v2-rs)
|
||||
(renderer-rs/set-canvas canvas))))
|
||||
(p/then (renderer/init)
|
||||
#(renderer/set-canvas canvas)))))
|
||||
|
||||
(hooks/setup-dom-events zoom disable-paste in-viewport? workspace-read-only? drawing-tool drawing-path?)
|
||||
(hooks/setup-viewport-size vport viewport-ref)
|
||||
|
|
32
frontend/src/app/renderer.cljs
Normal file
32
frontend/src/app/renderer.cljs
Normal file
|
@ -0,0 +1,32 @@
|
|||
(ns app.renderer
|
||||
(:require
|
||||
[app.config :as cf]
|
||||
[app.renderer.cpp :as renderer-cpp]
|
||||
[app.renderer.rs :as renderer-rs]))
|
||||
|
||||
(defn is-enabled?
|
||||
[]
|
||||
(or (contains? cf/flags :renderer-v2-cpp)
|
||||
(contains? cf/flags :renderer-v2-rs)))
|
||||
|
||||
(defn init
|
||||
[]
|
||||
(cond
|
||||
;; CPP
|
||||
(contains? cf/flags :renderer-v2-cpp)
|
||||
(renderer-cpp/init)
|
||||
|
||||
;; Rust
|
||||
(contains? cf/flags :renderer-v2-rs)
|
||||
(renderer-rs/init)))
|
||||
|
||||
(defn set-canvas
|
||||
[canvas]
|
||||
(cond
|
||||
;; CPP
|
||||
(contains? cf/flags :renderer-v2-cpp)
|
||||
(renderer-cpp/set-canvas canvas)
|
||||
|
||||
;; Rust
|
||||
(contains? cf/flags :renderer-v2-rs)
|
||||
(renderer-rs/set-canvas canvas)))
|
|
@ -71,6 +71,7 @@ Module['ready'] = new Promise(function(resolve, reject) {
|
|||
console.log("preamble", Renderer);
|
||||
Renderer.setCanvas = function setCanvas(canvas, attrs) {
|
||||
console.log("GL", GL);
|
||||
debugger
|
||||
const context = GL.createContext(canvas, attrs);
|
||||
if (!context) {
|
||||
throw new Error('Could not create a new WebGL context')
|
||||
|
@ -212,13 +213,13 @@ if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
|
|||
scriptDirectory = '';
|
||||
}
|
||||
|
||||
scriptDirectory += 'renderer/cpp/';
|
||||
if (!(typeof window == 'object' || typeof importScripts == 'function')) throw new Error('not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)');
|
||||
|
||||
// Differentiate the Web Worker from the Node Worker case, as reading must
|
||||
// be done differently.
|
||||
{
|
||||
// include: web_or_worker_shell_read.js
|
||||
scriptDirectory += 'renderer/cpp/';
|
||||
|
||||
|
||||
read_ = (url) => {
|
||||
|
|
Loading…
Add table
Reference in a new issue