Merge lp:~browsernode-team/browsernode/libAVG1.8.2 into lp:browsernode

Proposed by Michel van der Breggen
Status: Merged
Merged at revision: 8
Proposed branch: lp:~browsernode-team/browsernode/libAVG1.8.2
Merge into: lp:browsernode
Diff against target: 259 lines (+98/-45)
3 files modified
plugin/BrowserNode.cpp (+86/-41)
plugin/BrowserNode.h (+8/-0)
plugin/Makefile.am (+4/-4)
To merge this branch: bzr merge lp:~browsernode-team/browsernode/libAVG1.8.2
Reviewer Review Type Date Requested Status
Andrea Approve
Review via email: mp+235902@code.launchpad.net

Description of the change

Updated BrowserNode.cpp and Browsernode.h to incorporate the new multicontext system used within libAVG 1.8.2

To post a comment you must log in.
Revision history for this message
Andrea (magnetto-andrea) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugin/BrowserNode.cpp'
2--- plugin/BrowserNode.cpp 2014-02-09 11:42:34 +0000
3+++ plugin/BrowserNode.cpp 2014-09-25 06:09:12 +0000
4@@ -7,11 +7,14 @@
5
6 #include "../../player/Player.h"
7 #include "../../player/MouseEvent.h"
8-#include "../../player/SDLDisplayEngine.h"
9+//#include "../../player/SDLDisplayEngine.h"
10+#include "../../graphics/GLContextManager.h"
11
12 #include "../../base/Logger.h"
13 #include "../../graphics/OGLHelper.h"
14 #include "../../wrapper/WrapHelper.h"
15+#include "../../wrapper/raw_constructor.hpp"
16+
17 #include <berkelium/Berkelium.hpp>
18 #include <berkelium/Window.hpp>
19 #include <berkelium/WindowDelegate.hpp>
20@@ -47,7 +50,7 @@
21 m_pBerkeliumWindow = Berkelium::Window::create(context);
22 m_pBerkeliumWindow->resize(0, 0);
23 context->destroy();
24- preprerender();
25+// preprerender();
26 Player::get()->registerPreRenderListener(this);
27 }
28
29@@ -58,6 +61,55 @@
30 m_pBerkeliumWindow->destroy();
31 }
32 bool isFinishLoading = false;
33+
34+void BrowserNode::connectDisplay()
35+{
36+ RasterNode::connectDisplay();
37+ createSurface();
38+}
39+
40+void BrowserNode::connect(CanvasPtr pCanvas)
41+{
42+ RasterNode::connect(pCanvas);
43+}
44+
45+void BrowserNode::disconnect(bool bKill)
46+{
47+ RasterNode::disconnect(bKill);
48+}
49+
50+void BrowserNode::createSurface()
51+{
52+ setViewport(-32767, -32767, -32767, -32767);
53+ m_bCreated = true;
54+ m_LastSize = getSize();
55+ if (m_XOffset < 0) {
56+ m_XOffset = 0;
57+ }
58+ if (m_YOffset < 0) {
59+ m_YOffset = 0;
60+ }
61+ int x = m_XOffset/100 * getWidth();
62+ int y = m_YOffset/100 * getHeight();
63+ IntPoint offset(x, y);
64+ IntPoint size(getWidth(), getHeight());
65+
66+ m_pBerkeliumWindow->resize(getWidth() + offset.x, getHeight() + offset.y);
67+ m_pBerkeliumWindow->setDelegate(this);
68+
69+ allocateBuffer(size, offset);
70+ bool bMipmap = getMaterial().getUseMipmaps();
71+
72+ PixelFormat pf = R8G8B8A8;
73+ pTexture = GLContextManager::get()->createTexture(size, pf, bMipmap);
74+ getSurface()->create(pf, pTexture);
75+
76+ newSurface();
77+
78+ // Version 1.8 of libAVG works with Bitmaps and not with memory buffers anymore. So we nee$
79+ m_RenderBitmapPtr = BitmapPtr( new Bitmap( m_LastSize , pf ) );
80+}
81+
82 void BrowserNode::onPaint(Berkelium::Window* pWindow, const unsigned char *pBitmapIn,
83 const Berkelium::Rect &bitmapRect, size_t numCopyRects,
84 const Berkelium::Rect *pCopyRects, int dx, int dy,
85@@ -80,37 +132,12 @@
86 }
87 }
88
89-void BrowserNode::preprerender()
90-{
91- if (!m_bCreated || getSize() != m_LastSize) {
92- m_bCreated = true;
93- m_LastSize = getSize();
94- if (m_XOffset < 0) {
95- m_XOffset = 0;
96- }
97- if (m_YOffset < 0) {
98- m_YOffset = 0;
99- }
100- int x = m_XOffset/100 * getWidth();
101- int y = m_YOffset/100 * getHeight();
102- IntPoint offset(x, y);
103- IntPoint size(getWidth(), getHeight());
104- m_pBerkeliumWindow->resize(getWidth() + offset.x, getHeight() + offset.y);
105- m_pBerkeliumWindow->setDelegate(this);
106-
107- allocateBuffer(size, offset);
108- bool bMipmap = getMaterial().getUseMipmaps();
109- GLTexturePtr pTexture = GLTexturePtr(new GLTexture(size, R8G8B8A8, bMipmap));
110- pTexture->enableStreaming();
111- getSurface()->create(R8G8B8A8,pTexture);
112- newSurface();
113- }
114
115-}
116 void BrowserNode::preRender(const VertexArrayPtr& pVA, bool bIsParentActive,
117 float parentEffectiveOpacity)
118 {
119 if (!m_bCreated || getSize() != m_LastSize) {
120+ setViewport(-32767, -32767, -32767, -32767);
121 m_bCreated = true;
122 m_LastSize = getSize();
123 if (m_XOffset < 0) {
124@@ -128,28 +155,37 @@
125
126 allocateBuffer(size, offset);
127 bool bMipmap = getMaterial().getUseMipmaps();
128- GLTexturePtr pTexture = GLTexturePtr(new GLTexture(size, R8G8B8A8, bMipmap));
129- pTexture->enableStreaming();
130- getSurface()->create(R8G8B8A8,pTexture);
131- newSurface();
132+
133+ PixelFormat pf = R8G8B8A8;
134+ pTexture = GLContextManager::get()->createTexture(size, pf, bMipmap);
135+ getSurface()->create(pf, pTexture);
136+
137+ // Version 1.8 of libAVG works with Bitmaps and not with memory buffers anymore. So we nee$
138+ m_RenderBitmapPtr = BitmapPtr( new Bitmap( m_LastSize , pf ) );
139+
140 }
141- RasterNode::preRender(pVA, bIsParentActive, parentEffectiveOpacity);
142+ RasterNode::preRender(pVA, bIsParentActive, parentEffectiveOpacity);
143+
144+ if (isVisible()) {
145+ if (isDirty()){
146+ m_RenderBitmapPtr->setPixels(getBuffer());
147+ GLContextManager::get()->scheduleTexUpload(pTexture, m_RenderBitmapPtr);
148+ cleanDirtyFlag();
149+ }
150+
151+ scheduleFXRender();
152+ }
153+
154 calcVertexArray(pVA);
155 }
156
157+
158 static ProfilingZoneID pzid("BrowserNode::render");
159
160
161 void BrowserNode::render()
162 {
163-ScopeTimer Timer(pzid);
164- if (isDirty()){
165- GLTexturePtr pTexture = getSurface()->getTex();
166- BitmapPtr pBmp = pTexture->lockStreamingBmp();
167- memcpy(pBmp->getPixels(), getBuffer(), getBufferLength());
168- cleanDirtyFlag();
169- pTexture->unlockStreamingBmp(true);
170- }
171+ ScopeTimer Timer(pzid);
172 blt32(getTransform(), getSize(), getEffectiveOpacity(), getBlendMode());
173 }
174
175@@ -327,6 +363,8 @@
176 return m_bPainted;
177 }
178
179+char browserNodeName[] = "browser";
180+
181 void BrowserNode::registerType()
182 {
183 avg::TypeDefinition def = avg::TypeDefinition("browser", "rasternode",
184@@ -346,6 +384,12 @@
185 avg::TypeRegistry::get()->registerType(def, allowedParentNodeNames);
186 }
187
188+void BrowserNode::renderFX()
189+{
190+ RasterNode::renderFX(getSize(), Pixel32(255, 255, 255, 255), false);
191+}
192+
193+
194 }
195
196 using namespace avg;
197@@ -354,6 +398,7 @@
198 {
199 // TODO: add docstrings for all methods
200 class_<BrowserNode, bases<RasterNode>, boost::noncopyable>("BrowserNode", no_init)
201+ .def("__init__", raw_constructor(createNode<browserNodeName>))
202 .def("loadUrl", &BrowserNode::loadUrl)
203 .def("refresh", &BrowserNode::refresh)
204 .def("zoom", &BrowserNode::zoom)
205
206=== modified file 'plugin/BrowserNode.h'
207--- plugin/BrowserNode.h 2014-02-08 15:51:12 +0000
208+++ plugin/BrowserNode.h 2014-09-25 06:09:12 +0000
209@@ -33,9 +33,15 @@
210 BrowserNode(const ArgList& Args);
211 virtual ~BrowserNode();
212
213+ virtual void connectDisplay();
214+ virtual void connect(CanvasPtr pCanvas);
215+ virtual void disconnect(bool bKill);
216+ void createSurface();
217+
218 virtual void preRender(const VertexArrayPtr& pVA, bool bIsParentActive,
219 float parentEffectiveOpacity);
220 virtual void render();
221+ virtual void renderFX();
222
223 virtual bool handleEvent(EventPtr pEvent);
224 // IPreRenderListener
225@@ -76,6 +82,8 @@
226 float m_YOffset;
227 bool m_bEventHandler;
228 bool m_bPainted;
229+ MCTexturePtr pTexture;
230+ BitmapPtr m_RenderBitmapPtr;
231 };
232
233 }
234
235=== modified file 'plugin/Makefile.am'
236--- plugin/Makefile.am 2014-02-16 10:22:03 +0000
237+++ plugin/Makefile.am 2014-09-25 06:09:12 +0000
238@@ -1,5 +1,5 @@
239
240-INCLUDES = -I. -I../player \
241+AM_CPPFLAGS = -I. -I../player \
242 @XML2_CFLAGS@ @PTHREAD_CFLAGS@ @PANGOFT2_CFLAGS@ @PYTHON_CPPFLAGS@ @DC1394_2_CFLAGS@
243
244 ALL_H =
245@@ -9,11 +9,11 @@
246 EXTRA_LDFLAGS=-read_only_relocs suppress
247 else
248 XGL_LIBS = -lXxf86vm
249- EXTRA_LDFLAGS=-XCClinker liblibberkelium.so -XCClinker ../../wrapper/.libs/avg.so
250+ EXTRA_LDFLAGS=-XCClinker ../../wrapper/.libs/avg.so
251 endif
252
253 ALL_GL_LIBS = @GL_LIBS@ @SDL_LIBS@ $(XGL_LIBS)
254
255 pkgpyexec_LTLIBRARIES = libbrowsernode.la
256-libbrowsernode_la_SOURCES = BrowserNode.cpp BerkeliumDelegate.cpp
257-libbrowsernode_la_LDFLAGS = $(EXTRA_LDFLAGS) -module -lberkeliumwrapper
258+libbrowsernode_la_SOURCES = BrowserNode.cpp
259+libbrowsernode_la_LDFLAGS = -lberkelium_delegate $(EXTRA_LDFLAGS) -module

Subscribers

People subscribed via source and target branches