Project

General

Profile

SO3Engine
SO3EmbeddedWebNavigatorRenderHandler.h
Go to the documentation of this file.
1/*
2-----------------------------------------------------------------------------
3This source file is part of OpenSpace3D
4For the latest info, see http://www.openspace3d.com
5
6Copyright (c) 2011 I-maginer
7
8This program is free software; you can redistribute it and/or modify it under
9the terms of the GNU Lesser General Public License as published by the Free Software
10Foundation; either version 2 of the License, or (at your option) any later
11version.
12
13This program is distributed in the hope that it will be useful, but WITHOUT
14ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
16
17You should have received a copy of the GNU Lesser General Public License along with
18this program; if not, write to the Free Software Foundation, Inc., 59 Temple
19Place - Suite 330, Boston, MA 02111-1307, USA, or go to
20http://www.gnu.org/copyleft/lesser.txt
21-----------------------------------------------------------------------------
22*/
23
24#ifndef _SCOL_EMBEDDED_WEB_NAVIGATOR_RENDER_HANDLER_
25#define _SCOL_EMBEDDED_WEB_NAVIGATOR_RENDER_HANDLER_
26
27#include <thread>
28#include <shared_mutex>
30#if SO3_WEB_NAVIGATOR_BUILD == 1
31#include "include/cef_render_handler.h"
32#include "include/cef_task.h"
33//#include "cef.h"
34
35namespace SO3
36{
37 namespace EmbeddedWebNavigator
38 {
39
40class WebNavigatorRenderHandler : public CefRenderHandler,
42{
43public:
44protected:
45private:
46 std::shared_mutex offscreenBufferCriticalSection;
47 bool isOffscreen;
48 unsigned char* offscreenBuffer;
49 size_t offscreenBufferMemorySize;
50 unsigned char* offscreenPopupBuffer;
51 CefRect offscreenPopupRect;
52 unsigned int offscreenBuffer_width;
53 unsigned int offscreenBuffer_height;
54 bool bufferContentChanged;
55
56public:
60 WebNavigatorRenderHandler(CefRefPtr<WebNavigatorClient>& parentWebNavigatorClientInstance, const ScolWindowHandle& scolMainWindow, bool offscreen);
61
66
69 unsigned char* GetOffscreenBuffer();
70
73 unsigned char* GetOffscreenPopupBuffer();
74
78
81 unsigned int GetOffscreenBufferWidth();
82
85 unsigned int GetOffscreenBufferHeight();
86
91
95 bool BlitOffscreenBitmap(unsigned char* dest, int destWidth, int destHeight, int destBytesPerPixel, int destBitsPerLine);
96
100 bool BlitOffscreenAlphaBitmap(unsigned char* destColor, unsigned char* destAlpha, int destWidth, int destHeight, int destColorBytesPerPixel, int destColorBitsPerLine);
101
104 bool BlitOffscreenTexture(Ogre::TexturePtr& ogreTexture, bool forceUpdate);
105
108 bool CheckPixelAlpha(int posX, int posY, float transparentTresholdColor);
109
113 virtual bool GetViewRect(CefRefPtr<CefBrowser> browser, CefRect& rect);
114
118 virtual void OnPopupShow(CefRefPtr<CefBrowser> browser, bool show) OVERRIDE;
119
123 virtual void OnPopupSize(CefRefPtr<CefBrowser> browser, const CefRect& rect) OVERRIDE;
124
128 virtual void OnPaint(CefRefPtr<CefBrowser> browser, CefRenderHandler::PaintElementType type, const CefRenderHandler::RectList& dirtyRects, const void* buffer, int width, int height) OVERRIDE;
129
133 virtual void OnCursorChange(CefRefPtr<CefBrowser> browser, CefCursorHandle cursor, CursorType type, const CefCursorInfo& custom_cursor_info) OVERRIDE;
134
138 virtual void _Cleanup();
139protected:
140 //Include the default reference counting implementation.
142
143 // Include the default locking implementation.
145private:
150
154 void SetRGB(CefRefPtr<CefBrowser> browser, int width, int height, const void* src, const RectList& dirtyRects);
155
159 void SetBufferSize(int width, int height);
160
164 void ConvertToRGBA(const unsigned char* src, unsigned char* dst, const RectList& dirtyRects, int renderSizeWidth, int renderSizeHeight);
165};
166
167 }
168}
169
170#endif
171#endif
virtual void OnPopupShow(CefRefPtr< CefBrowser > browser, bool show) OVERRIDE
virtual bool GetViewRect(CefRefPtr< CefBrowser > browser, CefRect &rect)
virtual void OnCursorChange(CefRefPtr< CefBrowser > browser, CefCursorHandle cursor, CursorType type, const CefCursorInfo &custom_cursor_info) OVERRIDE
virtual void OnPaint(CefRefPtr< CefBrowser > browser, CefRenderHandler::PaintElementType type, const CefRenderHandler::RectList &dirtyRects, const void *buffer, int width, int height) OVERRIDE
bool BlitOffscreenTexture(Ogre::TexturePtr &ogreTexture, bool forceUpdate)
bool BlitOffscreenBitmap(unsigned char *dest, int destWidth, int destHeight, int destBytesPerPixel, int destBitsPerLine)
virtual void OnPopupSize(CefRefPtr< CefBrowser > browser, const CefRect &rect) OVERRIDE
bool CheckPixelAlpha(int posX, int posY, float transparentTresholdColor)
bool BlitOffscreenAlphaBitmap(unsigned char *destColor, unsigned char *destAlpha, int destWidth, int destHeight, int destColorBytesPerPixel, int destColorBitsPerLine)