Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of DMBasicGUI by
SlideShow/Renderer.h@15:a68bb30ab95e, 2015-03-09 (annotated)
- Committer:
- embeddedartists
- Date:
- Mon Mar 09 11:08:43 2015 +0100
- Revision:
- 15:a68bb30ab95e
- Parent:
- 14:647b1896ed84
- More documentation fixes
- Improved interface for the Renderer class by removing setRenderThread()
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| embeddedartists | 13:bff2288c2c61 | 1 | /* |
| embeddedartists | 13:bff2288c2c61 | 2 | * Copyright 2014 Embedded Artists AB |
| embeddedartists | 13:bff2288c2c61 | 3 | * |
| embeddedartists | 13:bff2288c2c61 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| embeddedartists | 13:bff2288c2c61 | 5 | * you may not use this file except in compliance with the License. |
| embeddedartists | 13:bff2288c2c61 | 6 | * You may obtain a copy of the License at |
| embeddedartists | 13:bff2288c2c61 | 7 | * |
| embeddedartists | 13:bff2288c2c61 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| embeddedartists | 13:bff2288c2c61 | 9 | * |
| embeddedartists | 13:bff2288c2c61 | 10 | * Unless required by applicable law or agreed to in writing, software |
| embeddedartists | 13:bff2288c2c61 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| embeddedartists | 13:bff2288c2c61 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| embeddedartists | 13:bff2288c2c61 | 13 | * See the License for the specific language governing permissions and |
| embeddedartists | 13:bff2288c2c61 | 14 | * limitations under the License. |
| embeddedartists | 13:bff2288c2c61 | 15 | */ |
| embeddedartists | 13:bff2288c2c61 | 16 | |
| embeddedartists | 5:f4de114c31c3 | 17 | #ifndef RENDERER_H |
| embeddedartists | 5:f4de114c31c3 | 18 | #define RENDERER_H |
| embeddedartists | 5:f4de114c31c3 | 19 | |
| embeddedartists | 5:f4de114c31c3 | 20 | #include "rtos.h" |
| embeddedartists | 5:f4de114c31c3 | 21 | #include "Display.h" |
| embeddedartists | 5:f4de114c31c3 | 22 | |
| embeddedartists | 14:647b1896ed84 | 23 | /** |
| embeddedartists | 14:647b1896ed84 | 24 | * Renderer for the SlideShow engine. |
| embeddedartists | 14:647b1896ed84 | 25 | * |
| embeddedartists | 14:647b1896ed84 | 26 | * The renderer handles all (if more than one) running slideshows and |
| embeddedartists | 14:647b1896ed84 | 27 | * the layer(s) they are drawn on. |
| embeddedartists | 14:647b1896ed84 | 28 | * |
| embeddedartists | 14:647b1896ed84 | 29 | * For information on how to use the SlideShow and some examples see |
| embeddedartists | 14:647b1896ed84 | 30 | * https://developer.mbed.org/teams/Embedded-Artists/wiki/LPC4088DM-Using-the-SlideShow-Engine |
| embeddedartists | 14:647b1896ed84 | 31 | */ |
| embeddedartists | 5:f4de114c31c3 | 32 | class Renderer { |
| embeddedartists | 5:f4de114c31c3 | 33 | public: |
| embeddedartists | 5:f4de114c31c3 | 34 | |
| embeddedartists | 13:bff2288c2c61 | 35 | Renderer(); |
| embeddedartists | 5:f4de114c31c3 | 36 | ~Renderer(); |
| embeddedartists | 5:f4de114c31c3 | 37 | |
| embeddedartists | 15:a68bb30ab95e | 38 | /** Registers a part of the screen on a specific layer to be in use. |
| embeddedartists | 5:f4de114c31c3 | 39 | * |
| embeddedartists | 5:f4de114c31c3 | 40 | * Returns a handle to pass when updating the framebuffer. |
| embeddedartists | 5:f4de114c31c3 | 41 | * |
| embeddedartists | 5:f4de114c31c3 | 42 | * @param layer 0 is the bottom of the stack, higher number is on top |
| embeddedartists | 5:f4de114c31c3 | 43 | * @param xoff top left corner of the drawing rectangle |
| embeddedartists | 5:f4de114c31c3 | 44 | * @param yoff top left corner of the drawing rectangle |
| embeddedartists | 5:f4de114c31c3 | 45 | * @param width width of the drawing rectangle |
| embeddedartists | 5:f4de114c31c3 | 46 | * @param height height of the drawing rectangle |
| embeddedartists | 5:f4de114c31c3 | 47 | * |
| embeddedartists | 5:f4de114c31c3 | 48 | * @returns |
| embeddedartists | 5:f4de114c31c3 | 49 | * handle to pass to setFrameBuffer function |
| embeddedartists | 5:f4de114c31c3 | 50 | * 0 on failure |
| embeddedartists | 5:f4de114c31c3 | 51 | */ |
| embeddedartists | 5:f4de114c31c3 | 52 | uint32_t registerUser(int layer, int xoff, int yoff, int width, int height); |
| embeddedartists | 15:a68bb30ab95e | 53 | |
| embeddedartists | 15:a68bb30ab95e | 54 | /** Registers the entire screen on a specific layer to be in use. |
| embeddedartists | 15:a68bb30ab95e | 55 | * |
| embeddedartists | 15:a68bb30ab95e | 56 | * Returns a handle to pass when updating the framebuffer. |
| embeddedartists | 15:a68bb30ab95e | 57 | * |
| embeddedartists | 15:a68bb30ab95e | 58 | * @param layer 0 is the bottom of the stack, higher number is on top |
| embeddedartists | 15:a68bb30ab95e | 59 | * |
| embeddedartists | 15:a68bb30ab95e | 60 | * @returns |
| embeddedartists | 15:a68bb30ab95e | 61 | * handle to pass to setFrameBuffer function |
| embeddedartists | 15:a68bb30ab95e | 62 | * 0 on failure |
| embeddedartists | 15:a68bb30ab95e | 63 | */ |
| embeddedartists | 5:f4de114c31c3 | 64 | uint32_t registerFullscreenUser(int layer); |
| embeddedartists | 5:f4de114c31c3 | 65 | |
| embeddedartists | 15:a68bb30ab95e | 66 | /** Removes a previously registered user |
| embeddedartists | 5:f4de114c31c3 | 67 | * |
| embeddedartists | 15:a68bb30ab95e | 68 | * @param handle the handle from the registerUser() call |
| embeddedartists | 5:f4de114c31c3 | 69 | */ |
| embeddedartists | 5:f4de114c31c3 | 70 | void unregisterUser(uint32_t handle); |
| embeddedartists | 5:f4de114c31c3 | 71 | |
| embeddedartists | 15:a68bb30ab95e | 72 | /** Informs the renderer that there is new data to render |
| embeddedartists | 5:f4de114c31c3 | 73 | * |
| embeddedartists | 15:a68bb30ab95e | 74 | * Blocks until the data has been registered. After that point the |
| embeddedartists | 15:a68bb30ab95e | 75 | * data must not be modified until next call to setFramebuffer. |
| embeddedartists | 5:f4de114c31c3 | 76 | * |
| embeddedartists | 15:a68bb30ab95e | 77 | * @param handle the handle from the registerUser() call |
| embeddedartists | 5:f4de114c31c3 | 78 | * @param data the image data |
| embeddedartists | 5:f4de114c31c3 | 79 | */ |
| embeddedartists | 5:f4de114c31c3 | 80 | void setFramebuffer(uint32_t handle, const uint16_t* data); |
| embeddedartists | 5:f4de114c31c3 | 81 | |
| embeddedartists | 5:f4de114c31c3 | 82 | /** Run the renderer |
| embeddedartists | 5:f4de114c31c3 | 83 | * |
| embeddedartists | 5:f4de114c31c3 | 84 | * Should be called from a high priority thread. |
| embeddedartists | 5:f4de114c31c3 | 85 | */ |
| embeddedartists | 5:f4de114c31c3 | 86 | void render(); |
| embeddedartists | 5:f4de114c31c3 | 87 | |
| embeddedartists | 5:f4de114c31c3 | 88 | private: |
| embeddedartists | 5:f4de114c31c3 | 89 | |
| embeddedartists | 5:f4de114c31c3 | 90 | enum Constants { |
| embeddedartists | 5:f4de114c31c3 | 91 | MaxNumLayers = 10, |
| embeddedartists | 5:f4de114c31c3 | 92 | }; |
| embeddedartists | 5:f4de114c31c3 | 93 | |
| embeddedartists | 5:f4de114c31c3 | 94 | typedef uint16_t* image_t; |
| embeddedartists | 5:f4de114c31c3 | 95 | |
| embeddedartists | 5:f4de114c31c3 | 96 | typedef struct { |
| embeddedartists | 5:f4de114c31c3 | 97 | bool used; |
| embeddedartists | 5:f4de114c31c3 | 98 | int x0; |
| embeddedartists | 5:f4de114c31c3 | 99 | int y0; |
| embeddedartists | 5:f4de114c31c3 | 100 | int x1; |
| embeddedartists | 5:f4de114c31c3 | 101 | int y1; |
| embeddedartists | 5:f4de114c31c3 | 102 | int width; |
| embeddedartists | 5:f4de114c31c3 | 103 | int clippedHeight; |
| embeddedartists | 5:f4de114c31c3 | 104 | int zorder; |
| embeddedartists | 5:f4de114c31c3 | 105 | int signalId; |
| embeddedartists | 5:f4de114c31c3 | 106 | bool fullscreen; |
| embeddedartists | 5:f4de114c31c3 | 107 | const uint16_t* newData; |
| embeddedartists | 5:f4de114c31c3 | 108 | const uint16_t* activeData; |
| embeddedartists | 5:f4de114c31c3 | 109 | uint16_t* tmp; |
| embeddedartists | 5:f4de114c31c3 | 110 | Mutex* lock; |
| embeddedartists | 5:f4de114c31c3 | 111 | } layerinfo_t; |
| embeddedartists | 5:f4de114c31c3 | 112 | |
| embeddedartists | 5:f4de114c31c3 | 113 | layerinfo_t layers[MaxNumLayers]; |
| embeddedartists | 5:f4de114c31c3 | 114 | layerinfo_t* order[MaxNumLayers]; |
| embeddedartists | 5:f4de114c31c3 | 115 | |
| embeddedartists | 5:f4de114c31c3 | 116 | int numRegisteredLayers; |
| embeddedartists | 5:f4de114c31c3 | 117 | |
| embeddedartists | 15:a68bb30ab95e | 118 | osThreadId threadId; |
| embeddedartists | 5:f4de114c31c3 | 119 | Mutex setupMutex; |
| embeddedartists | 5:f4de114c31c3 | 120 | |
| embeddedartists | 5:f4de114c31c3 | 121 | int screenWidth; |
| embeddedartists | 5:f4de114c31c3 | 122 | int screenHeight; |
| embeddedartists | 5:f4de114c31c3 | 123 | int screenPixels; |
| embeddedartists | 5:f4de114c31c3 | 124 | int screenBytes; |
| embeddedartists | 5:f4de114c31c3 | 125 | int activeBackBuffer; |
| embeddedartists | 5:f4de114c31c3 | 126 | |
| embeddedartists | 5:f4de114c31c3 | 127 | image_t ImageBackBuffer[2]; |
| embeddedartists | 5:f4de114c31c3 | 128 | |
| embeddedartists | 5:f4de114c31c3 | 129 | Display* display; |
| embeddedartists | 5:f4de114c31c3 | 130 | }; |
| embeddedartists | 5:f4de114c31c3 | 131 | |
| embeddedartists | 5:f4de114c31c3 | 132 | #endif |
| embeddedartists | 5:f4de114c31c3 | 133 | |
| embeddedartists | 5:f4de114c31c3 | 134 | |
| embeddedartists | 5:f4de114c31c3 | 135 |
