32 #include "cairoSurfaceImage.rcd" 33 #include "cairoSurfaceImage.xcd" 34 #include "renderNativeWindow.rcd" 35 #include "renderNativeWindow.xcd" 51 #define NTDDI_VERSION NTDDI_WINBLUE 52 #include <shellscalingapi.h> 57 ecolab::cairo::Colour RenderNativeWindow::backgroundColour{0.8,0.8,0.8,1};
72 RenderNativeWindow::~RenderNativeWindow()
74 minsky().nativeWindowsToRedraw.erase(
this);
80 const lock_guard lock(drawMutex);
84 surface.reset(
new NativeSurface(*
this));
89 void RenderNativeWindow::destroyFrame() {
90 const lock_guard lock(drawMutex);
94 void RenderNativeWindow::macOSXRedraw()
97 if (!winInfoPtr.get())
return;
98 winInfoPtr->requestRedraw();
103 void RenderNativeWindow::requestRedraw()
105 if (!winInfoPtr.get())
return;
107 minsky().nativeWindowsToRedraw.insert(
this);
111 void RenderNativeWindow::draw()
113 const lock_guard lock(drawMutex);
114 if (!winInfoPtr.get())
119 #ifdef FPS_PROFILING_ON 120 unsigned long t0_render_start = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count();
124 auto surfaceToDraw = winInfoPtr->getBufferSurface();
125 if (!surfaceToDraw)
return;
126 surfaceToDraw.swap(surface);
128 cairo_reset_clip(surface->cairo());
129 const ecolab::cairo::CairoSave cs(surface->cairo());
130 cairo_set_source_rgba(surface->cairo(), backgroundColour.r,backgroundColour.g,backgroundColour.b,backgroundColour.a);
131 cairo_rectangle(surface->cairo(), 0, 0, winInfoPtr->childWidth, winInfoPtr->childHeight);
132 cairo_fill(surface->cairo());
133 cairo_set_source_rgb(surface->cairo(), 0, 0, 0);
134 redraw(0, 0, winInfoPtr->childWidth, winInfoPtr->childHeight);
136 #ifdef FPS_PROFILING_ON 137 unsigned long t1_png_stream_start = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count();
140 #ifdef FPS_PROFILING_ON 141 unsigned long t2_window_copy_start = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count();
144 surfaceToDraw.swap(surface);
145 winInfoPtr->copyBufferToMain();
148 #ifdef FPS_PROFILING_ON 149 unsigned long t3_render_over = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count();
151 unsigned long windowCopyTime = t3_render_over - t2_window_copy_start;
152 unsigned long pngStreamWriteTime = t2_window_copy_start - t1_png_stream_start;
153 unsigned long totalTime = t3_render_over - t0_render_start;
155 cout <<
"Rendering Time (ms): " << totalTime <<
" (total) | " << windowCopyTime <<
" (window copy) | " << pngStreamWriteTime <<
" (png stream overhead) " << endl;
160 double RenderNativeWindow::scaleFactor()
163 DEVICE_SCALE_FACTOR scaleFactor;
164 GetScaleFactorForMonitor(MonitorFromPoint(POINT{0,0}, MONITOR_DEFAULTTOPRIMARY), &scaleFactor);
165 return int(scaleFactor)/100.0;
struct TCLcmd::trap::init_t init
CLASSDESC_ACCESS_EXPLICIT_INSTANTIATION(minsky::RenderNativeWindow)
Creation and access to the minskyTCL_obj object, which has code to record whenever Minsky's state cha...
std::string parentWindowId
RenderNativeWindow & renderNativeWindow
NativeSurface(RenderNativeWindow &r, cairo_surface_t *s=nullptr, int width=-1, int height=-1)
void requestRedraw() override