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
=== modified file 'plugin/BrowserNode.cpp'
--- plugin/BrowserNode.cpp 2014-02-09 11:42:34 +0000
+++ plugin/BrowserNode.cpp 2014-09-25 06:09:12 +0000
@@ -7,11 +7,14 @@
77
8#include "../../player/Player.h"8#include "../../player/Player.h"
9#include "../../player/MouseEvent.h"9#include "../../player/MouseEvent.h"
10#include "../../player/SDLDisplayEngine.h"10//#include "../../player/SDLDisplayEngine.h"
11#include "../../graphics/GLContextManager.h"
1112
12#include "../../base/Logger.h"13#include "../../base/Logger.h"
13#include "../../graphics/OGLHelper.h"14#include "../../graphics/OGLHelper.h"
14#include "../../wrapper/WrapHelper.h"15#include "../../wrapper/WrapHelper.h"
16#include "../../wrapper/raw_constructor.hpp"
17
15#include <berkelium/Berkelium.hpp>18#include <berkelium/Berkelium.hpp>
16#include <berkelium/Window.hpp>19#include <berkelium/Window.hpp>
17#include <berkelium/WindowDelegate.hpp>20#include <berkelium/WindowDelegate.hpp>
@@ -47,7 +50,7 @@
47 m_pBerkeliumWindow = Berkelium::Window::create(context);50 m_pBerkeliumWindow = Berkelium::Window::create(context);
48 m_pBerkeliumWindow->resize(0, 0);51 m_pBerkeliumWindow->resize(0, 0);
49 context->destroy();52 context->destroy();
50 preprerender();53// preprerender();
51 Player::get()->registerPreRenderListener(this);54 Player::get()->registerPreRenderListener(this);
52}55}
5356
@@ -58,6 +61,55 @@
58 m_pBerkeliumWindow->destroy();61 m_pBerkeliumWindow->destroy();
59}62}
60bool isFinishLoading = false;63bool isFinishLoading = false;
64
65void BrowserNode::connectDisplay()
66{
67 RasterNode::connectDisplay();
68 createSurface();
69}
70
71void BrowserNode::connect(CanvasPtr pCanvas)
72{
73 RasterNode::connect(pCanvas);
74}
75
76void BrowserNode::disconnect(bool bKill)
77{
78 RasterNode::disconnect(bKill);
79}
80
81void BrowserNode::createSurface()
82{
83 setViewport(-32767, -32767, -32767, -32767);
84 m_bCreated = true;
85 m_LastSize = getSize();
86 if (m_XOffset < 0) {
87 m_XOffset = 0;
88 }
89 if (m_YOffset < 0) {
90 m_YOffset = 0;
91 }
92 int x = m_XOffset/100 * getWidth();
93 int y = m_YOffset/100 * getHeight();
94 IntPoint offset(x, y);
95 IntPoint size(getWidth(), getHeight());
96
97 m_pBerkeliumWindow->resize(getWidth() + offset.x, getHeight() + offset.y);
98 m_pBerkeliumWindow->setDelegate(this);
99
100 allocateBuffer(size, offset);
101 bool bMipmap = getMaterial().getUseMipmaps();
102
103 PixelFormat pf = R8G8B8A8;
104 pTexture = GLContextManager::get()->createTexture(size, pf, bMipmap);
105 getSurface()->create(pf, pTexture);
106
107 newSurface();
108
109 // Version 1.8 of libAVG works with Bitmaps and not with memory buffers anymore. So we nee$
110 m_RenderBitmapPtr = BitmapPtr( new Bitmap( m_LastSize , pf ) );
111}
112
61void BrowserNode::onPaint(Berkelium::Window* pWindow, const unsigned char *pBitmapIn,113void BrowserNode::onPaint(Berkelium::Window* pWindow, const unsigned char *pBitmapIn,
62 const Berkelium::Rect &bitmapRect, size_t numCopyRects, 114 const Berkelium::Rect &bitmapRect, size_t numCopyRects,
63 const Berkelium::Rect *pCopyRects, int dx, int dy,115 const Berkelium::Rect *pCopyRects, int dx, int dy,
@@ -80,37 +132,12 @@
80 }132 }
81}133}
82134
83void BrowserNode::preprerender()
84{
85 if (!m_bCreated || getSize() != m_LastSize) {
86 m_bCreated = true;
87 m_LastSize = getSize();
88 if (m_XOffset < 0) {
89 m_XOffset = 0;
90 }
91 if (m_YOffset < 0) {
92 m_YOffset = 0;
93 }
94 int x = m_XOffset/100 * getWidth();
95 int y = m_YOffset/100 * getHeight();
96 IntPoint offset(x, y);
97 IntPoint size(getWidth(), getHeight());
98 m_pBerkeliumWindow->resize(getWidth() + offset.x, getHeight() + offset.y);
99 m_pBerkeliumWindow->setDelegate(this);
100
101 allocateBuffer(size, offset);
102 bool bMipmap = getMaterial().getUseMipmaps();
103 GLTexturePtr pTexture = GLTexturePtr(new GLTexture(size, R8G8B8A8, bMipmap));
104 pTexture->enableStreaming();
105 getSurface()->create(R8G8B8A8,pTexture);
106 newSurface();
107 }
108135
109}
110void BrowserNode::preRender(const VertexArrayPtr& pVA, bool bIsParentActive,136void BrowserNode::preRender(const VertexArrayPtr& pVA, bool bIsParentActive,
111 float parentEffectiveOpacity)137 float parentEffectiveOpacity)
112{138{
113if (!m_bCreated || getSize() != m_LastSize) {139if (!m_bCreated || getSize() != m_LastSize) {
140 setViewport(-32767, -32767, -32767, -32767);
114 m_bCreated = true;141 m_bCreated = true;
115 m_LastSize = getSize();142 m_LastSize = getSize();
116 if (m_XOffset < 0) {143 if (m_XOffset < 0) {
@@ -128,28 +155,37 @@
128 155
129 allocateBuffer(size, offset);156 allocateBuffer(size, offset);
130 bool bMipmap = getMaterial().getUseMipmaps();157 bool bMipmap = getMaterial().getUseMipmaps();
131 GLTexturePtr pTexture = GLTexturePtr(new GLTexture(size, R8G8B8A8, bMipmap));158
132 pTexture->enableStreaming();159 PixelFormat pf = R8G8B8A8;
133 getSurface()->create(R8G8B8A8,pTexture);160 pTexture = GLContextManager::get()->createTexture(size, pf, bMipmap);
134 newSurface();161 getSurface()->create(pf, pTexture);
162
163 // Version 1.8 of libAVG works with Bitmaps and not with memory buffers anymore. So we nee$
164 m_RenderBitmapPtr = BitmapPtr( new Bitmap( m_LastSize , pf ) );
165
135 }166 }
136 RasterNode::preRender(pVA, bIsParentActive, parentEffectiveOpacity);167 RasterNode::preRender(pVA, bIsParentActive, parentEffectiveOpacity);
168
169 if (isVisible()) {
170 if (isDirty()){
171 m_RenderBitmapPtr->setPixels(getBuffer());
172 GLContextManager::get()->scheduleTexUpload(pTexture, m_RenderBitmapPtr);
173 cleanDirtyFlag();
174 }
175
176 scheduleFXRender();
177 }
178
137 calcVertexArray(pVA);179 calcVertexArray(pVA);
138}180}
139181
182
140static ProfilingZoneID pzid("BrowserNode::render");183static ProfilingZoneID pzid("BrowserNode::render");
141184
142185
143void BrowserNode::render()186void BrowserNode::render()
144{187{
145ScopeTimer Timer(pzid);188 ScopeTimer Timer(pzid);
146 if (isDirty()){
147 GLTexturePtr pTexture = getSurface()->getTex();
148 BitmapPtr pBmp = pTexture->lockStreamingBmp();
149 memcpy(pBmp->getPixels(), getBuffer(), getBufferLength());
150 cleanDirtyFlag();
151 pTexture->unlockStreamingBmp(true);
152 }
153 blt32(getTransform(), getSize(), getEffectiveOpacity(), getBlendMode());189 blt32(getTransform(), getSize(), getEffectiveOpacity(), getBlendMode());
154}190}
155191
@@ -327,6 +363,8 @@
327 return m_bPainted;363 return m_bPainted;
328}364}
329365
366char browserNodeName[] = "browser";
367
330void BrowserNode::registerType()368void BrowserNode::registerType()
331{369{
332 avg::TypeDefinition def = avg::TypeDefinition("browser", "rasternode",370 avg::TypeDefinition def = avg::TypeDefinition("browser", "rasternode",
@@ -346,6 +384,12 @@
346 avg::TypeRegistry::get()->registerType(def, allowedParentNodeNames);384 avg::TypeRegistry::get()->registerType(def, allowedParentNodeNames);
347}385}
348386
387void BrowserNode::renderFX()
388{
389 RasterNode::renderFX(getSize(), Pixel32(255, 255, 255, 255), false);
390}
391
392
349}393}
350394
351using namespace avg;395using namespace avg;
@@ -354,6 +398,7 @@
354{398{
355 // TODO: add docstrings for all methods399 // TODO: add docstrings for all methods
356 class_<BrowserNode, bases<RasterNode>, boost::noncopyable>("BrowserNode", no_init)400 class_<BrowserNode, bases<RasterNode>, boost::noncopyable>("BrowserNode", no_init)
401 .def("__init__", raw_constructor(createNode<browserNodeName>))
357 .def("loadUrl", &BrowserNode::loadUrl)402 .def("loadUrl", &BrowserNode::loadUrl)
358 .def("refresh", &BrowserNode::refresh)403 .def("refresh", &BrowserNode::refresh)
359 .def("zoom", &BrowserNode::zoom)404 .def("zoom", &BrowserNode::zoom)
360405
=== modified file 'plugin/BrowserNode.h'
--- plugin/BrowserNode.h 2014-02-08 15:51:12 +0000
+++ plugin/BrowserNode.h 2014-09-25 06:09:12 +0000
@@ -33,9 +33,15 @@
33 BrowserNode(const ArgList& Args);33 BrowserNode(const ArgList& Args);
34 virtual ~BrowserNode();34 virtual ~BrowserNode();
3535
36 virtual void connectDisplay();
37 virtual void connect(CanvasPtr pCanvas);
38 virtual void disconnect(bool bKill);
39 void createSurface();
40
36 virtual void preRender(const VertexArrayPtr& pVA, bool bIsParentActive,41 virtual void preRender(const VertexArrayPtr& pVA, bool bIsParentActive,
37 float parentEffectiveOpacity);42 float parentEffectiveOpacity);
38 virtual void render();43 virtual void render();
44 virtual void renderFX();
3945
40 virtual bool handleEvent(EventPtr pEvent);46 virtual bool handleEvent(EventPtr pEvent);
41 // IPreRenderListener47 // IPreRenderListener
@@ -76,6 +82,8 @@
76 float m_YOffset;82 float m_YOffset;
77 bool m_bEventHandler;83 bool m_bEventHandler;
78 bool m_bPainted;84 bool m_bPainted;
85 MCTexturePtr pTexture;
86 BitmapPtr m_RenderBitmapPtr;
79};87};
8088
81}89}
8290
=== modified file 'plugin/Makefile.am'
--- plugin/Makefile.am 2014-02-16 10:22:03 +0000
+++ plugin/Makefile.am 2014-09-25 06:09:12 +0000
@@ -1,5 +1,5 @@
11
2INCLUDES = -I. -I../player \2AM_CPPFLAGS = -I. -I../player \
3 @XML2_CFLAGS@ @PTHREAD_CFLAGS@ @PANGOFT2_CFLAGS@ @PYTHON_CPPFLAGS@ @DC1394_2_CFLAGS@3 @XML2_CFLAGS@ @PTHREAD_CFLAGS@ @PANGOFT2_CFLAGS@ @PYTHON_CPPFLAGS@ @DC1394_2_CFLAGS@
44
5ALL_H =5ALL_H =
@@ -9,11 +9,11 @@
9 EXTRA_LDFLAGS=-read_only_relocs suppress9 EXTRA_LDFLAGS=-read_only_relocs suppress
10else10else
11 XGL_LIBS = -lXxf86vm11 XGL_LIBS = -lXxf86vm
12 EXTRA_LDFLAGS=-XCClinker liblibberkelium.so -XCClinker ../../wrapper/.libs/avg.so12 EXTRA_LDFLAGS=-XCClinker ../../wrapper/.libs/avg.so
13endif13endif
1414
15ALL_GL_LIBS = @GL_LIBS@ @SDL_LIBS@ $(XGL_LIBS)15ALL_GL_LIBS = @GL_LIBS@ @SDL_LIBS@ $(XGL_LIBS)
1616
17pkgpyexec_LTLIBRARIES = libbrowsernode.la17pkgpyexec_LTLIBRARIES = libbrowsernode.la
18libbrowsernode_la_SOURCES = BrowserNode.cpp BerkeliumDelegate.cpp18libbrowsernode_la_SOURCES = BrowserNode.cpp
19libbrowsernode_la_LDFLAGS = $(EXTRA_LDFLAGS) -module -lberkeliumwrapper19libbrowsernode_la_LDFLAGS = -lberkelium_delegate $(EXTRA_LDFLAGS) -module

Subscribers

People subscribed via source and target branches