Mercurial > hg > orthanc-stone
comparison Framework/Viewport/SdlViewport.cpp @ 909:7a7e4e1f558f
SdlCairo resizable
author | Alain Mazy <alain@mazy.be> |
---|---|
date | Thu, 18 Jul 2019 09:41:10 +0200 |
parents | 722ee73e6ba2 |
children | 1091b2adeb5a |
comparison
equal
deleted
inserted
replaced
908:2f16ad9d30ad | 909:7a7e4e1f558f |
---|---|
54 bool allowDpiScaling) : | 54 bool allowDpiScaling) : |
55 SdlViewport(title), | 55 SdlViewport(title), |
56 window_(title, width, height, false /* enable OpenGL */, allowDpiScaling), | 56 window_(title, width, height, false /* enable OpenGL */, allowDpiScaling), |
57 compositor_(GetScene(), width, height) | 57 compositor_(GetScene(), width, height) |
58 { | 58 { |
59 static const uint32_t rmask = 0x00ff0000; | 59 UpdateSdlSurfaceSize(width, height); |
60 static const uint32_t gmask = 0x0000ff00; | |
61 static const uint32_t bmask = 0x000000ff; | |
62 | |
63 sdlSurface_ = SDL_CreateRGBSurfaceFrom((void*)(compositor_.GetCanvas().GetBuffer()), width, height, 32, | |
64 compositor_.GetCanvas().GetPitch(), rmask, gmask, bmask, 0); | |
65 if (!sdlSurface_) | |
66 { | |
67 LOG(ERROR) << "Cannot create a SDL surface from a Cairo surface"; | |
68 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); | |
69 } | |
70 } | 60 } |
71 | 61 |
72 | 62 |
73 SdlCairoViewport::~SdlCairoViewport() | 63 SdlCairoViewport::~SdlCairoViewport() |
74 { | 64 { |
83 { | 73 { |
84 GetCompositor().Refresh(); | 74 GetCompositor().Refresh(); |
85 window_.Render(sdlSurface_); | 75 window_.Render(sdlSurface_); |
86 } | 76 } |
87 | 77 |
78 void SdlCairoViewport::UpdateSize(unsigned int width, | |
79 unsigned int height) | |
80 { | |
81 compositor_.UpdateSize(width, height); | |
82 UpdateSdlSurfaceSize(width, height); | |
83 Refresh(); | |
84 } | |
85 | |
86 | |
87 void SdlCairoViewport::UpdateSdlSurfaceSize(unsigned int width, | |
88 unsigned int height) | |
89 { | |
90 static const uint32_t rmask = 0x00ff0000; | |
91 static const uint32_t gmask = 0x0000ff00; | |
92 static const uint32_t bmask = 0x000000ff; | |
93 | |
94 sdlSurface_ = SDL_CreateRGBSurfaceFrom((void*)(compositor_.GetCanvas().GetBuffer()), width, height, 32, | |
95 compositor_.GetCanvas().GetPitch(), rmask, gmask, bmask, 0); | |
96 if (!sdlSurface_) | |
97 { | |
98 LOG(ERROR) << "Cannot create a SDL surface from a Cairo surface"; | |
99 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); | |
100 } | |
101 } | |
102 | |
88 } | 103 } |