Mercurial > hg > orthanc-stone
comparison Framework/Viewport/SdlViewport.cpp @ 1307:8a28a9bf8876 broker
ViewportController now gets a ref to its parent viewport for proper lock usage
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Wed, 04 Mar 2020 10:07:37 +0100 |
parents | 7ec8fea061b9 |
children | 3d26447ddd28 |
comparison
equal
deleted
inserted
replaced
1306:fef1ec42a7db | 1307:8a28a9bf8876 |
---|---|
46 } | 46 } |
47 | 47 |
48 compositor_.reset(compositor); | 48 compositor_.reset(compositor); |
49 } | 49 } |
50 | 50 |
51 | |
52 SdlViewport::SdlViewport() : | 51 SdlViewport::SdlViewport() : |
53 controller_(new ViewportController) | 52 controller_(new ViewportController(*this)) |
54 { | 53 { |
55 refreshEvent_ = SDL_RegisterEvents(1); | 54 refreshEvent_ = SDL_RegisterEvents(1); |
56 | 55 |
57 if (refreshEvent_ == static_cast<uint32_t>(-1)) | 56 if (refreshEvent_ == static_cast<uint32_t>(-1)) |
58 { | 57 { |
59 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); | 58 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); |
60 } | 59 } |
61 } | 60 } |
62 | 61 |
62 SdlViewport::SdlViewport(boost::weak_ptr<UndoStack> undoStackW) : | |
63 controller_(new ViewportController(*this,undoStackW)) | |
64 { | |
65 refreshEvent_ = SDL_RegisterEvents(1); | |
66 | |
67 if (refreshEvent_ == static_cast<uint32_t>(-1)) | |
68 { | |
69 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); | |
70 } | |
71 } | |
63 | 72 |
64 void SdlViewport::SendRefreshEvent() | 73 void SdlViewport::SendRefreshEvent() |
65 { | 74 { |
66 SDL_Event event; | 75 SDL_Event event; |
67 SDL_memset(&event, 0, sizeof(event)); | 76 SDL_memset(&event, 0, sizeof(event)); |
77 context_(title, width, height, allowDpiScaling) | 86 context_(title, width, height, allowDpiScaling) |
78 { | 87 { |
79 AcquireCompositor(new OpenGLCompositor(context_)); // (*) | 88 AcquireCompositor(new OpenGLCompositor(context_)); // (*) |
80 } | 89 } |
81 | 90 |
91 SdlOpenGLViewport::SdlOpenGLViewport(const char* title, | |
92 boost::weak_ptr<UndoStack> undoStackW, | |
93 unsigned int width, | |
94 unsigned int height, | |
95 bool allowDpiScaling) : | |
96 SdlViewport(undoStackW), | |
97 context_(title, width, height, allowDpiScaling) | |
98 { | |
99 AcquireCompositor(new OpenGLCompositor(context_)); // (*) | |
100 } | |
82 | 101 |
83 SdlOpenGLViewport::~SdlOpenGLViewport() | 102 SdlOpenGLViewport::~SdlOpenGLViewport() |
84 { | 103 { |
85 // Make sure that the "OpenGLCompositor" is destroyed BEFORE the | 104 // Make sure that the "OpenGLCompositor" is destroyed BEFORE the |
86 // "OpenGLContext" it references (*) | 105 // "OpenGLContext" it references (*) |