- fixed alpha bitmap drawing
- fixed polygon drawing - newstyle throbber, loosely copied from the gtk one. svn path=/trunk/netsurf/; revision=4259
@ -97,8 +97,10 @@ static inline void nsbeos_rgba_to_bgra(void *src, void *dst, int width, int heig
|
|||||||
to[x].g = from[x].g;
|
to[x].g = from[x].g;
|
||||||
to[x].r = from[x].r;
|
to[x].r = from[x].r;
|
||||||
to[x].a = from[x].a;
|
to[x].a = from[x].a;
|
||||||
|
/*
|
||||||
if (from[x].a == 0)
|
if (from[x].a == 0)
|
||||||
*(rgb_color *)&to[x] = B_TRANSPARENT_32_BIT;
|
*(rgb_color *)&to[x] = B_TRANSPARENT_32_BIT;
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
from += rowstride;
|
from += rowstride;
|
||||||
to += rowstride;
|
to += rowstride;
|
||||||
@ -168,7 +170,7 @@ bool bitmap_test_opaque(struct bitmap *bitmap)
|
|||||||
{
|
{
|
||||||
assert(bitmap);
|
assert(bitmap);
|
||||||
/* todo: test if bitmap as opaque */
|
/* todo: test if bitmap as opaque */
|
||||||
return bitmap->opaque;
|
return false;//bitmap->opaque;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -181,7 +183,7 @@ bool bitmap_get_opaque(struct bitmap *bitmap)
|
|||||||
{
|
{
|
||||||
assert(bitmap);
|
assert(bitmap);
|
||||||
/* todo: get whether bitmap is opaque */
|
/* todo: get whether bitmap is opaque */
|
||||||
return bitmap->opaque;
|
return false;//bitmap->opaque;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -334,8 +334,38 @@ void gui_init(int argc, char** argv)
|
|||||||
|
|
||||||
//nsbeos_completion_init();
|
//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");
|
find_resource(buf, "throbber.gif", "./beos/res/throbber.gif");
|
||||||
nsbeos_throbber_initialise(buf);
|
nsbeos_throbber_initialise_from_gif(buf);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (nsbeos_throbber == NULL)
|
if (nsbeos_throbber == NULL)
|
||||||
die("Unable to load throbber image.\n");
|
die("Unable to load throbber image.\n");
|
||||||
|
|
||||||
|
@ -107,6 +107,9 @@ const struct plotter_table nsbeos_plotters = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark - implementation
|
||||||
|
|
||||||
|
|
||||||
BView *nsbeos_current_gc(void)
|
BView *nsbeos_current_gc(void)
|
||||||
{
|
{
|
||||||
return current_view;
|
return current_view;
|
||||||
@ -158,9 +161,14 @@ bool nsbeos_plot_rectangle(int x0, int y0, int width, int height,
|
|||||||
|
|
||||||
nsbeos_set_colour(c);
|
nsbeos_set_colour(c);
|
||||||
|
|
||||||
|
float pensize = view->PenSize();
|
||||||
|
view->SetPenSize(line_width);
|
||||||
|
|
||||||
BRect rect(x0, y0, x0 + width - 1, y0 + height - 1);
|
BRect rect(x0, y0, x0 + width - 1, y0 + height - 1);
|
||||||
view->StrokeRect(rect, pat);
|
view->StrokeRect(rect, pat);
|
||||||
|
|
||||||
|
view->SetPenSize(pensize);
|
||||||
|
|
||||||
//nsbeos_current_gc_unlock();
|
//nsbeos_current_gc_unlock();
|
||||||
|
|
||||||
#if 0 /* GTK */
|
#if 0 /* GTK */
|
||||||
@ -200,10 +208,15 @@ bool nsbeos_plot_line(int x0, int y0, int x1, int y1, int width,
|
|||||||
|
|
||||||
nsbeos_set_colour(c);
|
nsbeos_set_colour(c);
|
||||||
|
|
||||||
|
float pensize = view->PenSize();
|
||||||
|
view->SetPenSize(width);
|
||||||
|
|
||||||
BPoint start(x0, y0);
|
BPoint start(x0, y0);
|
||||||
BPoint end(x1, y1);
|
BPoint end(x1, y1);
|
||||||
view->StrokeLine(start, end, pat);
|
view->StrokeLine(start, end, pat);
|
||||||
|
|
||||||
|
view->SetPenSize(pensize);
|
||||||
|
|
||||||
//nsbeos_current_gc_unlock();
|
//nsbeos_current_gc_unlock();
|
||||||
|
|
||||||
#if 0 /* GTK */
|
#if 0 /* GTK */
|
||||||
@ -236,8 +249,20 @@ bool nsbeos_plot_polygon(int *p, unsigned int n, colour fill)
|
|||||||
return false;
|
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);
|
view->BeginLineArray(n);
|
||||||
|
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
@ -247,6 +272,7 @@ bool nsbeos_plot_polygon(int *p, unsigned int n, colour fill)
|
|||||||
}
|
}
|
||||||
|
|
||||||
view->EndLineArray();
|
view->EndLineArray();
|
||||||
|
#endif
|
||||||
|
|
||||||
//nsbeos_current_gc_unlock();
|
//nsbeos_current_gc_unlock();
|
||||||
|
|
||||||
@ -467,21 +493,29 @@ static bool nsbeos_plot_bbitmap(int x, int y, int width, int height,
|
|||||||
}
|
}
|
||||||
|
|
||||||
drawing_mode oldmode = view->DrawingMode();
|
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,
|
// XXX DrawBitmap() resamples if rect doesn't match,
|
||||||
// but doesn't do any filtering
|
// but doesn't do any filtering
|
||||||
// XXX: use Zeta API if available ?
|
// XXX: use Zeta API if available ?
|
||||||
|
|
||||||
BRect rect(x, y, x + width - 1, y + height - 1);
|
BRect rect(x, y, x + width - 1, y + height - 1);
|
||||||
|
/*
|
||||||
rgb_color old = view->LowColor();
|
rgb_color old = view->LowColor();
|
||||||
if (bg != TRANSPARENT) {
|
if (bg != TRANSPARENT) {
|
||||||
view->SetLowColor(nsbeos_rgb_colour(bg));
|
view->SetLowColor(nsbeos_rgb_colour(bg));
|
||||||
view->FillRect(rect, B_SOLID_LOW);
|
view->FillRect(rect, B_SOLID_LOW);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
view->DrawBitmap(b, rect);
|
view->DrawBitmap(b, rect);
|
||||||
// maybe not needed?
|
// maybe not needed?
|
||||||
view->SetLowColor(old);
|
//view->SetLowColor(old);
|
||||||
|
view->SetBlendingMode(alpha, func);
|
||||||
view->SetDrawingMode(oldmode);
|
view->SetDrawingMode(oldmode);
|
||||||
|
|
||||||
//nsbeos_current_gc_unlock();
|
//nsbeos_current_gc_unlock();
|
||||||
|
@ -527,6 +527,7 @@ void nsbeos_scaffolding_dispatch_event(nsbeos_scaffolding *scaffold, BMessage *m
|
|||||||
url = data;
|
url = data;
|
||||||
} else
|
} else
|
||||||
url << path.Path();
|
url << path.Path();
|
||||||
|
|
||||||
browser_window_go(bw, url.String(), 0, true);
|
browser_window_go(bw, url.String(), 0, true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1303,7 +1304,8 @@ nsbeos_scaffolding *nsbeos_new_scaffolding(struct gui_window *toplevel)
|
|||||||
toolbar->AddChild(g->throbber);
|
toolbar->AddChild(g->throbber);
|
||||||
g->throbber->SetViewColor(toolbar->ViewColor());
|
g->throbber->SetViewColor(toolbar->ViewColor());
|
||||||
g->throbber->SetLowColor(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. */
|
/* set up the throbber. */
|
||||||
g->throbber->SetBitmap(nsbeos_throbber->framedata[0]);
|
g->throbber->SetBitmap(nsbeos_throbber->framedata[0]);
|
||||||
g->throb_frame = 0;
|
g->throb_frame = 0;
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include "utils/log.h"
|
#include "utils/log.h"
|
||||||
#include "image/gifread.h"
|
#include "image/gifread.h"
|
||||||
@ -25,9 +26,85 @@ extern "C" {
|
|||||||
#include "beos/beos_throbber.h"
|
#include "beos/beos_throbber.h"
|
||||||
#include "beos/beos_bitmap.h"
|
#include "beos/beos_bitmap.h"
|
||||||
|
|
||||||
|
#include <File.h>
|
||||||
|
#include <TranslationUtils.h>
|
||||||
|
|
||||||
struct nsbeos_throbber *nsbeos_throbber = NULL;
|
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
|
/* disect the GIF provided by filename in *fn into a series of
|
||||||
* BBitmap for use later.
|
* BBitmap for use later.
|
||||||
|
@ -29,7 +29,8 @@ struct nsbeos_throbber
|
|||||||
|
|
||||||
extern struct nsbeos_throbber *nsbeos_throbber;
|
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);
|
void nsbeos_throbber_finalise(void);
|
||||||
|
|
||||||
#endif /* __BEOS_THROBBER_H__ */
|
#endif /* __BEOS_THROBBER_H__ */
|
||||||
|
Before Width: | Height: | Size: 5.1 KiB |
BIN
beos/res/throbber/throbber0.png
Normal file
After Width: | Height: | Size: 521 B |
BIN
beos/res/throbber/throbber1.png
Normal file
After Width: | Height: | Size: 820 B |
BIN
beos/res/throbber/throbber2.png
Normal file
After Width: | Height: | Size: 812 B |
BIN
beos/res/throbber/throbber3.png
Normal file
After Width: | Height: | Size: 826 B |
BIN
beos/res/throbber/throbber4.png
Normal file
After Width: | Height: | Size: 818 B |
BIN
beos/res/throbber/throbber5.png
Normal file
After Width: | Height: | Size: 815 B |
BIN
beos/res/throbber/throbber6.png
Normal file
After Width: | Height: | Size: 839 B |
BIN
beos/res/throbber/throbber7.png
Normal file
After Width: | Height: | Size: 811 B |
BIN
beos/res/throbber/throbber8.png
Normal file
After Width: | Height: | Size: 833 B |