29 #include "RESTProcess_base.h" 33 #include "cairoSurfaceImage.rcd" 34 #include "cairoSurfaceImage.xcd" 35 #include "renderNativeWindow.rcd" 36 #include "renderNativeWindow.xcd" 53 #define NTDDI_VERSION NTDDI_WINBLUE 54 #include <shellscalingapi.h> 59 ecolab::cairo::Colour RenderNativeWindow::backgroundColour{0.8,0.8,0.8,1};
74 RenderNativeWindow::~RenderNativeWindow()
76 minsky().nativeWindowsToRedraw.erase(
this);
82 const lock_guard lock(drawMutex);
86 surface.reset(
new NativeSurface(*
this));
91 void RenderNativeWindow::destroyFrame() {
92 const lock_guard lock(drawMutex);
106 void RenderNativeWindow::requestRedraw()
108 if (!winInfoPtr.get())
return;
109 minsky().nativeWindowsToRedraw.insert(
this);
113 void RenderNativeWindow::draw()
115 const lock_guard lock(drawMutex);
116 if (!winInfoPtr.get())
121 #ifdef FPS_PROFILING_ON 122 unsigned long t0_render_start = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count();
126 auto surfaceToDraw = winInfoPtr->getBufferSurface();
127 if (!surfaceToDraw)
return;
128 surfaceToDraw.swap(surface);
130 cairo_reset_clip(surface->cairo());
131 const ecolab::cairo::CairoSave cs(surface->cairo());
132 cairo_set_source_rgba(surface->cairo(), backgroundColour.r,backgroundColour.g,backgroundColour.b,backgroundColour.a);
133 cairo_rectangle(surface->cairo(), 0, 0, winInfoPtr->childWidth, winInfoPtr->childHeight);
134 cairo_fill(surface->cairo());
135 cairo_set_source_rgb(surface->cairo(), 0, 0, 0);
136 redraw(0, 0, winInfoPtr->childWidth, winInfoPtr->childHeight);
138 #ifdef FPS_PROFILING_ON 139 unsigned long t1_png_stream_start = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count();
142 #ifdef FPS_PROFILING_ON 143 unsigned long t2_window_copy_start = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count();
146 surfaceToDraw.swap(surface);
147 winInfoPtr->copyBufferToMain();
150 #ifdef FPS_PROFILING_ON 151 unsigned long t3_render_over = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count();
153 unsigned long windowCopyTime = t3_render_over - t2_window_copy_start;
154 unsigned long pngStreamWriteTime = t2_window_copy_start - t1_png_stream_start;
155 unsigned long totalTime = t3_render_over - t0_render_start;
157 cout <<
"Rendering Time (ms): " << totalTime <<
" (total) | " << windowCopyTime <<
" (window copy) | " << pngStreamWriteTime <<
" (png stream overhead) " << endl;
162 double RenderNativeWindow::scaleFactor()
165 DEVICE_SCALE_FACTOR scaleFactor;
166 GetScaleFactorForMonitor(MonitorFromPoint(POINT{0,0}, MONITOR_DEFAULTTOPRIMARY), &scaleFactor);
167 return int(scaleFactor)/100.0;
classdesc::Exclude< std::shared_ptr< WindowInformation > > winInfoPtr
CLASSDESC_ACCESS_EXPLICIT_INSTANTIATION(minsky::RenderNativeWindow)
void macOSXRedraw(RenderNativeWindow &window, const std::shared_ptr< std::lock_guard< std::mutex >> &lock)
std::string parentWindowId
RenderNativeWindow & renderNativeWindow
NativeSurface(RenderNativeWindow &r, cairo_surface_t *s=nullptr, int width=-1, int height=-1)
void requestRedraw() override