Skip to content

Commit

Permalink
[DEV] Enable support of render driver with hardware acceleration
Browse files Browse the repository at this point in the history
  • Loading branch information
BoubacarDiene committed Jan 21, 2021
1 parent 2f67d94 commit 980857e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
1 change: 1 addition & 0 deletions doc/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- Bug fixes
- Additional unit tests
- Now possible to test the application inside the docker container
- Allow to use render drivers with hardware acceleration
```

## v1.3
Expand Down
2 changes: 1 addition & 1 deletion doc/HOWTO.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
- In below sections, <x.y> has to be replaced with the current version of the binary.
- Another path to Main.xml config file can be specified using -f option\
```
E.g.: $ ./out/mmstreamer/bin/mmstreamer-<x.y> -f /tmp/Main.xml
E.g.: ./out/mmstreamer/bin/mmstreamer-<x.y> -f /tmp/Main.xml
```
- In case a "bitsPerPixel" different from the active framebuffer's depth is specified in Graphics.xml, mmstreamer will try to change depth. To make it work, "root" permission is required (E.g. Run mmstreamer as root)
- If mmstreamer failed to start, please, see [TROUBLESHOOT](TROUBLESHOOT.md)
Expand Down
20 changes: 11 additions & 9 deletions src/graphics/drawers/Drawer2.c
Original file line number Diff line number Diff line change
Expand Up @@ -1323,7 +1323,8 @@ static enum drawer_error_e initWindowAndRenderer_f(struct drawer_s *obj, enum gf
;
}

// Create window
// Create a window usable with OpenGL context
windowFlags |= SDL_WINDOW_OPENGL;
*window = SDL_CreateWindow(windowCaption, windowPos.x, windowPos.y,
windowPos.w, windowPos.h, windowFlags);
if (!(*window)) {
Expand All @@ -1338,23 +1339,24 @@ static enum drawer_error_e initWindowAndRenderer_f(struct drawer_s *obj, enum gf
}

// Create renderer
// FIXME : Make renderer work with HW acceleration (SDL_RENDERER_ACCELERATED)
// The issue is that the UI becomes weird once one starts playing with
// some buttons.
// - A render driver that supports HW acceleration is used when available
// - Otherwise a render driver supporting software fallback is selected
//
// Once fixed, replace
// uint32_t rendererFlags = SDL_RENDERER_TARGETTEXTURE|SDL_RENDERER_SOFTWARE;
// with
// uint32_t rendererFlags = SDL_RENDERER_TARGETTEXTURE;
// IMPORTANT: Note that the created window must be usable with OpenGL context
// i.e SDL_WINDOW_OPENGL is set. If not, you might experiment an
// issue (artifacts, weird UI) which seems to be reproducible when
// "opengles2" has been selected as the render driver (rather than
// "opengl" or "software" for example).
SDL_RendererInfo renderDriverInfo;
uint32_t rendererFlags = SDL_RENDERER_TARGETTEXTURE|SDL_RENDERER_SOFTWARE;
uint32_t rendererFlags = SDL_RENDERER_TARGETTEXTURE;
int32_t nbRenderDrivers = SDL_GetNumRenderDrivers(), index = 0;
while (index < nbRenderDrivers) {
if (SDL_GetRenderDriverInfo(index, &renderDriverInfo) == 0) {
if (((renderDriverInfo.flags & rendererFlags) == rendererFlags)
&& ((renderDriverInfo.flags & SDL_RENDERER_ACCELERATED) == SDL_RENDERER_ACCELERATED)) {
Logd("Using render driver with HW acceleration: %s", renderDriverInfo.name);
rendererFlags |= SDL_RENDERER_ACCELERATED;
SDL_SetHint(SDL_HINT_RENDER_DRIVER, renderDriverInfo.name);
break;
}
}
Expand Down

0 comments on commit 980857e

Please sign in to comment.