A basic graphics package for the LPC4088 Display Module.

Dependents:   lpc4088_displaymodule_demo_sphere sampleGUI sampleEmptyGUI lpc4088_displaymodule_fs_aid ... more

Fork of DMBasicGUI by EmbeddedArtists AB

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Renderer.h Source File

Renderer.h

00001 /*
00002  *  Copyright 2014 Embedded Artists AB
00003  *
00004  *  Licensed under the Apache License, Version 2.0 (the "License");
00005  *  you may not use this file except in compliance with the License.
00006  *  You may obtain a copy of the License at
00007  *
00008  *    http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  *  Unless required by applicable law or agreed to in writing, software
00011  *  distributed under the License is distributed on an "AS IS" BASIS,
00012  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  *  See the License for the specific language governing permissions and
00014  *  limitations under the License.
00015  */
00016  
00017 #ifndef RENDERER_H
00018 #define RENDERER_H
00019 
00020 #include "rtos.h"
00021 #include "Display.h"
00022 
00023 /**
00024  * Renderer for the SlideShow engine.
00025  *
00026  * The renderer handles all (if more than one) running slideshows and
00027  * the layer(s) they are drawn on.
00028  *
00029  * For information on how to use the SlideShow and some examples see
00030  * https://developer.mbed.org/teams/Embedded-Artists/wiki/LPC4088DM-Using-the-SlideShow-Engine
00031  */
00032 class Renderer {
00033 public:
00034 
00035     Renderer();
00036     ~Renderer();
00037 
00038     /** Registers a part of the screen on a specific layer to be in use.
00039      *
00040      *  Returns a handle to pass when updating the framebuffer.
00041      *
00042      *  @param layer  0 is the bottom of the stack, higher number is on top
00043      *  @param xoff   top left corner of the drawing rectangle
00044      *  @param yoff   top left corner of the drawing rectangle
00045      *  @param width  width of the drawing rectangle
00046      *  @param height height of the drawing rectangle
00047      *
00048      *  @returns
00049      *       handle to pass to setFrameBuffer function
00050      *       0 on failure
00051      */
00052     uint32_t registerUser(int layer, int xoff, int yoff, int width, int height);
00053 
00054     /** Registers the entire screen on a specific layer to be in use.
00055      *
00056      *  Returns a handle to pass when updating the framebuffer.
00057      *
00058      *  @param layer  0 is the bottom of the stack, higher number is on top
00059      *
00060      *  @returns
00061      *       handle to pass to setFrameBuffer function
00062      *       0 on failure
00063      */
00064     uint32_t registerFullscreenUser(int layer);
00065 
00066     /** Removes a previously registered user
00067      *
00068      *  @param handle the handle from the registerUser() call
00069      */
00070     void unregisterUser(uint32_t handle);
00071 
00072     /** Informs the renderer that there is new data to render
00073      *
00074      * Blocks until the data has been registered. After that point the
00075      * data must not be modified until next call to setFramebuffer.
00076      *
00077      *  @param handle the handle from the registerUser() call
00078      *  @param data   the image data
00079      */
00080     void setFramebuffer(uint32_t handle, const uint16_t* data);
00081 
00082     /** Run the renderer
00083      *
00084      * Should be called from a high priority thread.
00085      */
00086     void render();
00087 
00088 private:
00089 
00090     enum Constants {
00091       MaxNumLayers = 10,
00092     };
00093 
00094     typedef uint16_t* image_t;
00095 
00096     typedef struct {
00097       bool used;
00098       int x0;
00099       int y0;
00100       int x1;
00101       int y1;
00102       int width;
00103       int clippedHeight;
00104       int zorder;
00105       int signalId;
00106       bool fullscreen;
00107       const uint16_t* newData;
00108       const uint16_t* activeData;
00109       uint16_t* tmp;
00110       Mutex* lock;
00111     } layerinfo_t;
00112 
00113     layerinfo_t layers[MaxNumLayers];
00114     layerinfo_t* order[MaxNumLayers];
00115 
00116     int numRegisteredLayers;
00117 
00118     osThreadId threadId;
00119     Mutex setupMutex;
00120 
00121     int screenWidth;
00122     int screenHeight;
00123     int screenPixels;
00124     int screenBytes;
00125     int activeBackBuffer;
00126 
00127     image_t ImageBackBuffer[2];
00128 
00129     Display* display;
00130 };
00131 
00132 #endif
00133 
00134 
00135