Author: mmu_man
Date: Tue Jun 3 20:53:20 2008
New Revision: 4259
URL:
http://source.netsurf-browser.org?rev=4259&view=rev
Log:
- fixed alpha bitmap drawing
- fixed polygon drawing
- newstyle throbber, loosely copied from the gtk one.
Added:
trunk/netsurf/beos/res/throbber/
trunk/netsurf/beos/res/throbber/throbber0.png (with props)
trunk/netsurf/beos/res/throbber/throbber1.png (with props)
trunk/netsurf/beos/res/throbber/throbber2.png (with props)
trunk/netsurf/beos/res/throbber/throbber3.png (with props)
trunk/netsurf/beos/res/throbber/throbber4.png (with props)
trunk/netsurf/beos/res/throbber/throbber5.png (with props)
trunk/netsurf/beos/res/throbber/throbber6.png (with props)
trunk/netsurf/beos/res/throbber/throbber7.png (with props)
trunk/netsurf/beos/res/throbber/throbber8.png (with props)
Removed:
trunk/netsurf/beos/res/throbber.gif
Modified:
trunk/netsurf/beos/beos_bitmap.cpp
trunk/netsurf/beos/beos_gui.cpp
trunk/netsurf/beos/beos_plotters.cpp
trunk/netsurf/beos/beos_scaffolding.cpp
trunk/netsurf/beos/beos_throbber.cpp
trunk/netsurf/beos/beos_throbber.h
Modified: trunk/netsurf/beos/beos_bitmap.cpp
URL:
http://source.netsurf-browser.org/trunk/netsurf/beos/beos_bitmap.cpp?rev=...
==============================================================================
--- trunk/netsurf/beos/beos_bitmap.cpp (original)
+++ trunk/netsurf/beos/beos_bitmap.cpp Tue Jun 3 20:53:20 2008
@@ -97,8 +97,10 @@
to[x].g = from[x].g;
to[x].r = from[x].r;
to[x].a = from[x].a;
+ /*
if (from[x].a == 0)
*(rgb_color *)&to[x] = B_TRANSPARENT_32_BIT;
+ */
}
from += rowstride;
to += rowstride;
@@ -168,7 +170,7 @@
{
assert(bitmap);
/* todo: test if bitmap as opaque */
- return bitmap->opaque;
+ return false;//bitmap->opaque;
}
@@ -181,7 +183,7 @@
{
assert(bitmap);
/* todo: get whether bitmap is opaque */
- return bitmap->opaque;
+ return false;//bitmap->opaque;
}
Modified: trunk/netsurf/beos/beos_gui.cpp
URL:
http://source.netsurf-browser.org/trunk/netsurf/beos/beos_gui.cpp?rev=425...
==============================================================================
--- trunk/netsurf/beos/beos_gui.cpp (original)
+++ trunk/netsurf/beos/beos_gui.cpp Tue Jun 3 20:53:20 2008
@@ -334,8 +334,38 @@
//nsbeos_completion_init();
+
+ /* This is an ugly hack to just get the new-style throbber going.
+ * It, along with the PNG throbber loader, need making more generic.
+ */
+ {
+#define STROF(n) #n
+#define FIND_THROB(n) find_resource(filenames[(n)], \
+ "throbber/throbber" STROF(n) ".png", \
+ "./beos/res/throbber/throbber" STROF(n) ".png")
+ char filenames[9][PATH_MAX];
+ FIND_THROB(0);
+ FIND_THROB(1);
+ FIND_THROB(2);
+ FIND_THROB(3);
+ FIND_THROB(4);
+ FIND_THROB(5);
+ FIND_THROB(6);
+ FIND_THROB(7);
+ FIND_THROB(8);
+ nsbeos_throbber_initialise_from_png(9,
+ filenames[0], filenames[1], filenames[2], filenames[3],
+ filenames[4], filenames[5], filenames[6], filenames[7],
+ filenames[8]);
+#undef FIND_THROB
+#undef STROF
+ }
+
+#if 0
find_resource(buf, "throbber.gif", "./beos/res/throbber.gif");
- nsbeos_throbber_initialise(buf);
+ nsbeos_throbber_initialise_from_gif(buf);
+#endif
+
if (nsbeos_throbber == NULL)
die("Unable to load throbber image.\n");
Modified: trunk/netsurf/beos/beos_plotters.cpp
URL:
http://source.netsurf-browser.org/trunk/netsurf/beos/beos_plotters.cpp?re...
==============================================================================
--- trunk/netsurf/beos/beos_plotters.cpp (original)
+++ trunk/netsurf/beos/beos_plotters.cpp Tue Jun 3 20:53:20 2008
@@ -107,6 +107,9 @@
};
+// #pragma mark - implementation
+
+
BView *nsbeos_current_gc(void)
{
return current_view;
@@ -158,8 +161,13 @@
nsbeos_set_colour(c);
+ float pensize = view->PenSize();
+ view->SetPenSize(line_width);
+
BRect rect(x0, y0, x0 + width - 1, y0 + height - 1);
view->StrokeRect(rect, pat);
+
+ view->SetPenSize(pensize);
//nsbeos_current_gc_unlock();
@@ -200,9 +208,14 @@
nsbeos_set_colour(c);
+ float pensize = view->PenSize();
+ view->SetPenSize(width);
+
BPoint start(x0, y0);
BPoint end(x1, y1);
view->StrokeLine(start, end, pat);
+
+ view->SetPenSize(pensize);
//nsbeos_current_gc_unlock();
@@ -236,8 +249,20 @@
return false;
}
- rgb_color color = nsbeos_rgb_colour(fill);
-
+ nsbeos_set_colour(fill);
+
+ BPoint points[n];
+
+ for (i = 0; i < n; i++) {
+ points[i] = BPoint(p[2 * i], p[2 * i + 1]);
+ }
+
+ if (fill == TRANSPARENT)
+ view->StrokePolygon(points, (int32)n);
+ else
+ view->FillPolygon(points, (int32)n);
+
+#if 0
view->BeginLineArray(n);
for (i = 0; i < n; i++) {
@@ -247,6 +272,7 @@
}
view->EndLineArray();
+#endif
//nsbeos_current_gc_unlock();
@@ -467,21 +493,29 @@
}
drawing_mode oldmode = view->DrawingMode();
- view->SetDrawingMode(B_OP_OVER);
+ source_alpha alpha;
+ alpha_function func;
+ view->GetBlendingMode(&alpha, &func);
+ //view->SetDrawingMode(B_OP_OVER);
+ view->SetDrawingMode(B_OP_ALPHA);
+ view->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY);
// XXX DrawBitmap() resamples if rect doesn't match,
// but doesn't do any filtering
// XXX: use Zeta API if available ?
BRect rect(x, y, x + width - 1, y + height - 1);
+ /*
rgb_color old = view->LowColor();
if (bg != TRANSPARENT) {
view->SetLowColor(nsbeos_rgb_colour(bg));
view->FillRect(rect, B_SOLID_LOW);
}
+ */
view->DrawBitmap(b, rect);
// maybe not needed?
- view->SetLowColor(old);
+ //view->SetLowColor(old);
+ view->SetBlendingMode(alpha, func);
view->SetDrawingMode(oldmode);
//nsbeos_current_gc_unlock();
Modified: trunk/netsurf/beos/beos_scaffolding.cpp
URL:
http://source.netsurf-browser.org/trunk/netsurf/beos/beos_scaffolding.cpp...
==============================================================================
--- trunk/netsurf/beos/beos_scaffolding.cpp (original)
+++ trunk/netsurf/beos/beos_scaffolding.cpp Tue Jun 3 20:53:20 2008
@@ -527,6 +527,7 @@
url = data;
} else
url << path.Path();
+
browser_window_go(bw, url.String(), 0, true);
break;
}
@@ -1303,7 +1304,8 @@
toolbar->AddChild(g->throbber);
g->throbber->SetViewColor(toolbar->ViewColor());
g->throbber->SetLowColor(toolbar->ViewColor());
- g->throbber->SetDrawingMode(B_OP_OVER);
+ g->throbber->SetDrawingMode(B_OP_ALPHA);
+ g->throbber->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY);
/* set up the throbber. */
g->throbber->SetBitmap(nsbeos_throbber->framedata[0]);
g->throb_frame = 0;
Modified: trunk/netsurf/beos/beos_throbber.cpp
URL:
http://source.netsurf-browser.org/trunk/netsurf/beos/beos_throbber.cpp?re...
==============================================================================
--- trunk/netsurf/beos/beos_throbber.cpp (original)
+++ trunk/netsurf/beos/beos_throbber.cpp Tue Jun 3 20:53:20 2008
@@ -18,6 +18,7 @@
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
extern "C" {
#include "utils/log.h"
#include "image/gifread.h"
@@ -25,9 +26,85 @@
#include "beos/beos_throbber.h"
#include "beos/beos_bitmap.h"
+#include <File.h>
+#include <TranslationUtils.h>
+
struct nsbeos_throbber *nsbeos_throbber = NULL;
-bool nsbeos_throbber_initialise(const char *fn)
+/**
+ * Creates the throbber using a PNG for each frame. The number of frames must
+ * be at least two. The first frame is the inactive frame, others are the
+ * active frames.
+ *
+ * \param frames The number of frames. Must be at least two.
+ * \param ... Filenames of PNGs containing frames.
+ * \return true on success.
+ */
+bool nsbeos_throbber_initialise_from_png(const int frames, ...)
+{
+ va_list filenames;
+ status_t err;
+ struct nsbeos_throbber *throb; /**< structure we generate */
+ bool errors_when_loading = false; /**< true if a frame failed */
+
+ if (frames < 2) {
+ /* we need at least two frames - one for idle, one for active */
+ LOG(("Insufficent number of frames in throbber animation!"));
+ LOG(("(called with %d frames, where 2 is a minimum.)",
+ frames));
+ return false;
+ }
+
+ throb = (struct nsbeos_throbber *)malloc(sizeof(throb));
+ throb->nframes = frames;
+ throb->framedata = (BBitmap **)malloc(sizeof(BBitmap *) * throb->nframes);
+
+ va_start(filenames, frames);
+
+ for (int i = 0; i < frames; i++) {
+ const char *fn = va_arg(filenames, const char *);
+ BFile file(fn, B_READ_ONLY);
+ throb->framedata[i] = NULL;
+ err = file.InitCheck();
+ if (err < B_OK) {
+ LOG(("Error when loading %s: %s", fn, strerror(err)));
+ errors_when_loading = true;
+ continue;
+ }
+ throb->framedata[i] = BTranslationUtils::GetBitmap(&file);
+ if (throb->framedata[i] == NULL) {
+ LOG(("Error when loading %s: GetBitmap() returned NULL", fn));
+ errors_when_loading = true;
+ }
+ }
+
+ va_end(filenames);
+
+ if (errors_when_loading == true) {
+ for (int i = 0; i < frames; i++) {
+ delete throb->framedata[i];
+ }
+
+ free(throb->framedata);
+ free(throb);
+
+ return false;
+ }
+
+ nsbeos_throbber = throb;
+
+ return true;
+}
+
+/**
+ * Creates the throbber using a single GIF, using the first frame as the
+ * inactive throbber, and the others for the active animation. The GIF must
+ * therefor have at least two frames.
+ *
+ * \param fn Filename of GIF to use. It must have at least two frames.
+ * \return true on success.
+ */
+bool nsbeos_throbber_initialise_from_gif(const char *fn)
{
/* disect the GIF provided by filename in *fn into a series of
* BBitmap for use later.
Modified: trunk/netsurf/beos/beos_throbber.h
URL:
http://source.netsurf-browser.org/trunk/netsurf/beos/beos_throbber.h?rev=...
==============================================================================
--- trunk/netsurf/beos/beos_throbber.h (original)
+++ trunk/netsurf/beos/beos_throbber.h Tue Jun 3 20:53:20 2008
@@ -29,7 +29,8 @@
extern struct nsbeos_throbber *nsbeos_throbber;
-bool nsbeos_throbber_initialise(const char *fn);
+bool nsbeos_throbber_initialise_from_gif(const char *fn);
+bool nsbeos_throbber_initialise_from_png(const int frames, ...);
void nsbeos_throbber_finalise(void);
#endif /* __BEOS_THROBBER_H__ */
Removed: trunk/netsurf/beos/res/throbber.gif
URL:
http://source.netsurf-browser.org/trunk/netsurf/beos/res/throbber.gif?rev...
==============================================================================
Binary file - no diff available.
Added: trunk/netsurf/beos/res/throbber/throbber0.png
URL:
http://source.netsurf-browser.org/trunk/netsurf/beos/res/throbber/throbbe...
==============================================================================
Binary file - no diff available.
Propchange: trunk/netsurf/beos/res/throbber/throbber0.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: trunk/netsurf/beos/res/throbber/throbber1.png
URL:
http://source.netsurf-browser.org/trunk/netsurf/beos/res/throbber/throbbe...
==============================================================================
Binary file - no diff available.
Propchange: trunk/netsurf/beos/res/throbber/throbber1.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: trunk/netsurf/beos/res/throbber/throbber2.png
URL:
http://source.netsurf-browser.org/trunk/netsurf/beos/res/throbber/throbbe...
==============================================================================
Binary file - no diff available.
Propchange: trunk/netsurf/beos/res/throbber/throbber2.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: trunk/netsurf/beos/res/throbber/throbber3.png
URL:
http://source.netsurf-browser.org/trunk/netsurf/beos/res/throbber/throbbe...
==============================================================================
Binary file - no diff available.
Propchange: trunk/netsurf/beos/res/throbber/throbber3.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: trunk/netsurf/beos/res/throbber/throbber4.png
URL:
http://source.netsurf-browser.org/trunk/netsurf/beos/res/throbber/throbbe...
==============================================================================
Binary file - no diff available.
Propchange: trunk/netsurf/beos/res/throbber/throbber4.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: trunk/netsurf/beos/res/throbber/throbber5.png
URL:
http://source.netsurf-browser.org/trunk/netsurf/beos/res/throbber/throbbe...
==============================================================================
Binary file - no diff available.
Propchange: trunk/netsurf/beos/res/throbber/throbber5.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: trunk/netsurf/beos/res/throbber/throbber6.png
URL:
http://source.netsurf-browser.org/trunk/netsurf/beos/res/throbber/throbbe...
==============================================================================
Binary file - no diff available.
Propchange: trunk/netsurf/beos/res/throbber/throbber6.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: trunk/netsurf/beos/res/throbber/throbber7.png
URL:
http://source.netsurf-browser.org/trunk/netsurf/beos/res/throbber/throbbe...
==============================================================================
Binary file - no diff available.
Propchange: trunk/netsurf/beos/res/throbber/throbber7.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: trunk/netsurf/beos/res/throbber/throbber8.png
URL:
http://source.netsurf-browser.org/trunk/netsurf/beos/res/throbber/throbbe...
==============================================================================
Binary file - no diff available.
Propchange: trunk/netsurf/beos/res/throbber/throbber8.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream