r9470 MarkieB - /branches/MarkieB/windows/windows/gui.c
by netsurf@semichrome.net
Author: MarkieB
Date: Thu Aug 27 03:26:55 2009
New Revision: 9470
URL: http://source.netsurf-browser.org?rev=9470&view=rev
Log:
double buffering working
Modified:
branches/MarkieB/windows/windows/gui.c
Modified: branches/MarkieB/windows/windows/gui.c
URL: http://source.netsurf-browser.org/branches/MarkieB/windows/windows/gui.c?...
==============================================================================
--- branches/MarkieB/windows/windows/gui.c (original)
+++ branches/MarkieB/windows/windows/gui.c Thu Aug 27 03:26:55 2009
@@ -87,6 +87,8 @@
HWND hscroll; /**< horizontal scrollbar handle */
HWND localhistory; /**< handle to local history window */
HMENU mainmenu; /**< the main menu */
+ HDC bufferdc; /**< the screen buffer */
+ HBITMAP bufferbm; /**< the buffer bitmap */
int width; /**< width of window */
int height; /**< height of drawing area */
int urlbarwidth; /**< width of url bar */
@@ -272,7 +274,6 @@
struct gui_window *w = window_list;
struct browser_window *bw;
struct content *c;
- HBITMAP bufferbm;
HDC hdc;
while (w != NULL) {
@@ -316,20 +317,12 @@
nsws_plot_set_scale(bw->scale);
doublebuffering = true;
- if (bufferdc != NULL) {
- bufferbm = SelectObject(bufferdc, bufferbm);
- DeleteDC(bufferdc);
- DeleteObject(bufferbm);
- }
- hdc = GetDC(current_hwnd);
- bufferdc = CreateCompatibleDC(hdc);
- if (bufferdc == NULL)
+ hdc = GetDC(w->main);
+
+ if ((w->bufferbm == NULL) || (w->bufferdc == NULL))
doublebuffering = false;
- if (doublebuffering) {
- bufferbm = CreateCompatibleBitmap(hdc, w->width,
- w->height + w->voffset);
- SelectObject(bufferdc, bufferbm);
- }
+ if (doublebuffering)
+ bufferdc = w->bufferdc;
content_redraw(c, -w->scrollx / w->bw->scale,
-w->scrolly / w->bw->scale,
w->width, w->height,
@@ -338,14 +331,12 @@
w->redraw.right,
w->redraw.bottom,
bw->scale, 0xFFFFFF);
- if (doublebuffering) {
+ if (doublebuffering)
/* blit buffer to screen */
- hdc = GetDC(current_hwnd);
BitBlt(hdc, 0, w->voffset, w->width, w->height,
bufferdc, 0, w->voffset,
SRCCOPY);
- }
- ReleaseDC(current_hwnd, hdc);
+ ReleaseDC(w->main, hdc);
doublebuffering = false;
w->requestscrolly = 0;
@@ -1084,9 +1075,19 @@
GetWindowRect(w->statusbar, &rstatus);
gui_window_get_scroll(w, &x, &y);
w->voffset = rtool.bottom - rtool.top;
- w->height = /* rmain.bottom */ HIWORD(lparam) - w->voffset - (rstatus.bottom -
+ w->height = HIWORD(lparam) - w->voffset - (rstatus.bottom -
rstatus.top);
- w->width = LOWORD(lparam) /* rmain.right */;
+ w->width = LOWORD(lparam);
+ HDC hdc = GetDC(hwnd);
+ if (w->bufferdc == NULL)
+ w->bufferdc = CreateCompatibleDC(hdc);
+ if (w->bufferbm != NULL) {
+ DeleteObject(w->bufferbm);
+ w->bufferbm = CreateCompatibleBitmap(hdc, w->width,
+ w->height + w->voffset);
+ SelectObject(w->bufferdc, w->bufferbm);
+ }
+ ReleaseDC(hwnd, hdc);
w->urlbarwidth = w->width - w->ntoolbuttons *
w->toolbuttondimension - 8;
if (w->bw) {
13 years, 6 months
r9469 MarkieB - /branches/MarkieB/windows/windows/gui.c
by netsurf@semichrome.net
Author: MarkieB
Date: Thu Aug 27 03:07:18 2009
New Revision: 9469
URL: http://source.netsurf-browser.org?rev=9469&view=rev
Log:
move window cleanly
Modified:
branches/MarkieB/windows/windows/gui.c
Modified: branches/MarkieB/windows/windows/gui.c
URL: http://source.netsurf-browser.org/branches/MarkieB/windows/windows/gui.c?...
==============================================================================
--- branches/MarkieB/windows/windows/gui.c (original)
+++ branches/MarkieB/windows/windows/gui.c Thu Aug 27 03:07:18 2009
@@ -272,33 +272,32 @@
struct gui_window *w = window_list;
struct browser_window *bw;
struct content *c;
-
+ HBITMAP bufferbm;
+ HDC hdc;
+
while (w != NULL) {
- bw = w->bw;
- c = bw->current_content;
-
- if ((!c) || (c->locked)) {
+ if ((w->redraw.right - w->redraw.left <= 0) ||
+ (w->redraw.bottom - w->redraw.top <= 0)) {
w = w->next;
continue;
}
+
+ bw = w->bw;
+ if (bw == NULL) {
+ w = w->next;
+ continue;
+ }
+
+ c = bw->current_content;
+
+ if ((c == NULL) || (c->locked)) {
+ w = w->next;
+ continue;
+ }
+ current_hwnd = w->main;
PostMessage(w->toolbar, WM_PAINT, 0, 0);
PostMessage(w->urlbar, WM_PAINT, 0, 0);
-/* if ((w->redraw.left < w->redraw.right) ||
- (w->redraw.top < w->redraw.bottom)) {
- HDC hdc = GetDC(w->main);
- LOGBRUSH lb = {BS_SOLID, 0xFFFFFFFF, 0};
- HPEN pen = ExtCreatePen(PS_GEOMETRIC, 1, &lb, 0, NULL);
- HGDIOBJ penbak = SelectObject(hdc, (HGDIOBJ)pen);
- HBRUSH brush = CreateSolidBrush(0xFFFFFFFF);
- HGDIOBJ brushbak = SelectObject(hdc, (HGDIOBJ) brush);
- Rectangle(hdc, 0, w->voffset, w->width,
- w->height + w->voffset);
- pen = SelectObject(hdc, penbak);
- brush = SelectObject(hdc, brushbak);
- DeleteObject(pen);
- DeleteObject(brush);
- }
-*/ w->scrolly += w->requestscrolly;
+ w->scrolly += w->requestscrolly;
w->scrollx += w->requestscrollx;
w->scrolly = MAX(w->scrolly, 0);
w->scrolly = MIN(w->scrolly, c->height * w->bw->scale
@@ -317,10 +316,12 @@
nsws_plot_set_scale(bw->scale);
doublebuffering = true;
- if (bufferdc != NULL)
+ if (bufferdc != NULL) {
+ bufferbm = SelectObject(bufferdc, bufferbm);
DeleteDC(bufferdc);
- HDC hdc = GetDC(current_hwnd);
- HBITMAP bufferbm;
+ DeleteObject(bufferbm);
+ }
+ hdc = GetDC(current_hwnd);
bufferdc = CreateCompatibleDC(hdc);
if (bufferdc == NULL)
doublebuffering = false;
@@ -329,7 +330,6 @@
w->height + w->voffset);
SelectObject(bufferdc, bufferbm);
}
- ReleaseDC(current_hwnd, hdc);
content_redraw(c, -w->scrollx / w->bw->scale,
-w->scrolly / w->bw->scale,
w->width, w->height,
@@ -339,14 +339,14 @@
w->redraw.bottom,
bw->scale, 0xFFFFFF);
if (doublebuffering) {
+ /* blit buffer to screen */
hdc = GetDC(current_hwnd);
BitBlt(hdc, 0, w->voffset, w->width, w->height,
bufferdc, 0, w->voffset,
SRCCOPY);
- DeleteObject(bufferbm);
- }
+ }
+ ReleaseDC(current_hwnd, hdc);
doublebuffering = false;
- /* blit buffer to screen */
w->requestscrolly = 0;
w->requestscrollx = 0;
@@ -1056,6 +1056,9 @@
w->redraw.top = MAX(ps.rcPaint.top - w->voffset, 0);
w->redraw.right = MIN(ps.rcPaint.right, w->width);
w->redraw.bottom = MIN(ps.rcPaint.bottom, w->height);
+ printf("paint %ld,%ld to %ld,%ld\n", w->redraw.left,
+ w->redraw.top, w->redraw.right,
+ w->redraw.bottom);
redraw();
EndPaint(hwnd, &ps);
return DefWindowProc(hwnd, msg, wparam, lparam);
@@ -1065,6 +1068,10 @@
PostMessage(w->toolbar, WM_PAINT, 0, 0);
PostMessage(w->urlbar, WM_PAINT, 0, 0);
return DefWindowProc(hwnd, msg, wparam, lparam);
+ break;
+ case WM_MOVE:
+ DefWindowProc(hwnd, msg, wparam, lparam);
+ gui_window_redraw_window(w);
break;
case WM_SIZE:
{
13 years, 6 months
r9468 MarkieB - in /branches/MarkieB/windows/windows: gui.c plot.c
by netsurf@semichrome.net
Author: MarkieB
Date: Thu Aug 27 01:35:33 2009
New Revision: 9468
URL: http://source.netsurf-browser.org?rev=9468&view=rev
Log:
proper handling of margins / edges / +1s etc
Modified:
branches/MarkieB/windows/windows/gui.c
branches/MarkieB/windows/windows/plot.c
Modified: branches/MarkieB/windows/windows/gui.c
URL: http://source.netsurf-browser.org/branches/MarkieB/windows/windows/gui.c?...
==============================================================================
--- branches/MarkieB/windows/windows/gui.c (original)
+++ branches/MarkieB/windows/windows/gui.c Thu Aug 27 01:35:33 2009
@@ -326,7 +326,7 @@
doublebuffering = false;
if (doublebuffering) {
bufferbm = CreateCompatibleBitmap(hdc, w->width,
- w->height);
+ w->height + w->voffset);
SelectObject(bufferdc, bufferbm);
}
ReleaseDC(current_hwnd, hdc);
@@ -1048,9 +1048,9 @@
/* 1 seems necessary */
w->height = r.bottom - w->voffset - (rstatus.bottom -
- rstatus.top);
-
- w->width = r.right;
+ rstatus.top) + 1;
+
+ w->width = r.right + 1;
w->redraw.left = MAX(ps.rcPaint.left, 0);
w->redraw.top = MAX(ps.rcPaint.top - w->voffset, 0);
Modified: branches/MarkieB/windows/windows/plot.c
URL: http://source.netsurf-browser.org/branches/MarkieB/windows/windows/plot.c...
==============================================================================
--- branches/MarkieB/windows/windows/plot.c (original)
+++ branches/MarkieB/windows/windows/plot.c Thu Aug 27 01:35:33 2009
@@ -58,12 +58,12 @@
static bool clip(int x0, int y0, int x1, int y1)
{
- int voffset = thumbnail ? 0 : gui_window_voffset(current_gui);
+ int voffset = (thumbnail ? 0 : gui_window_voffset(current_gui));
y0 += voffset;
y1 += voffset;
#if NSWS_PLOT_DEBUG
- LOG(("clip %d,%d to %d,%d", x0, y0, x1, y1));
+ LOG(("clip %d,%d to %d,%d thumbnail %d", x0, y0, x1, y1, thumbnail));
#endif
RECT *clip = gui_window_clip_rect(current_gui);
if (clip == NULL)
@@ -84,10 +84,11 @@
static bool line(int x0, int y0, int x1, int y1, const plot_style_t *style)
{
- y0 += thumbnail ? 0 : gui_window_voffset(current_gui);
- y1 += thumbnail ? 0 : gui_window_voffset(current_gui);
-#if NSWS_PLOT_DEBUG
- LOG(("ligne from %d,%d to %d,%d", x0, y0, x1, y1));
+ y0 += (thumbnail ? 0 : gui_window_voffset(current_gui));
+ y1 += (thumbnail ? 0 : gui_window_voffset(current_gui));
+#if NSWS_PLOT_DEBUG
+ LOG(("ligne from %d,%d to %d,%d thumbnail %d", x0, y0, x1, y1,
+ thumbnail));
#endif
RECT *clipr = gui_window_clip_rect(current_gui);
if (clipr == NULL)
@@ -157,10 +158,11 @@
y1 = MIN(y1, gui_window_height(current_gui));
}
- y0 += thumbnail ? 0 : gui_window_voffset(current_gui);
- y1 += thumbnail ? 0 : gui_window_voffset(current_gui);
+ y0 += (thumbnail ? 0 : gui_window_voffset(current_gui));
+ y1 += (thumbnail ? 0 : gui_window_voffset(current_gui));
#if NSWS_PLOT_DEBUG
- LOG(("rectangle from %d,%d to %d,%d", x0, y0, x1, y1));
+ LOG(("rectangle from %d,%d to %d,%d thumbnail %d", x0, y0, x1, y1,
+ thumbnail));
#endif
HDC hdc = doublebuffering ? bufferdc : GetDC(current_hwnd);
if (hdc == NULL) {
@@ -242,7 +244,7 @@
static bool polygon(const int *p, unsigned int n, const plot_style_t *style)
{
#if NSWS_PLOT_DEBUG
- LOG(("polygon %d points", n));
+ LOG(("polygon %d points thumbnail %d", n, thumbnail));
#endif
POINT points[n];
unsigned int i;
@@ -327,7 +329,7 @@
const plot_font_style_t *style)
{
#if NSWS_PLOT_DEBUG
- LOG(("words %s at %d,%d", text, x, y));
+ LOG(("words %s at %d,%d thumbnail %d", text, x, y, thumbnail));
#endif
HDC hdc = doublebuffering ? bufferdc : GetDC(current_hwnd);
if (hdc == NULL) {
@@ -355,7 +357,7 @@
fontbak = (HFONT) SelectObject(hdc, font);
GetTextExtentPoint(hdc, text, length, &s);
- y += thumbnail ? 0 : gui_window_voffset(current_gui);
+ y += (thumbnail ? 0 : gui_window_voffset(current_gui));
r.left = x;
r.top = y - (3 * s.cy) / 4;
r.right = x + s.cx;
@@ -392,9 +394,9 @@
static bool disc(int x, int y, int radius, const plot_style_t *style)
{
- y += thumbnail ? 0 : gui_window_voffset(current_gui);
-#if NSWS_PLOT_DEBUG
- LOG(("disc at %d,%d radius %d", x, y, radius));
+ y += (thumbnail ? 0 : gui_window_voffset(current_gui));
+#if NSWS_PLOT_DEBUG
+ LOG(("disc at %d,%d radius %d thumbnail %d", x, y, radius, thumbnail));
#endif
HDC hdc = doublebuffering ? bufferdc : GetDC(current_hwnd);
if (hdc == NULL) {
@@ -472,7 +474,7 @@
static bool arc(int x, int y, int radius, int angle1, int angle2,
const plot_style_t *style)
{
- y += thumbnail ? 0 : gui_window_voffset(current_gui);
+ y += (thumbnail ? 0 : gui_window_voffset(current_gui));
#if NSWS_PLOT_DEBUG
LOG(("arc centre %d,%d radius %d from %d to %d", x, y, radius,
angle1, angle2));
@@ -590,7 +592,7 @@
#endif
if (bitmap == NULL)
return false;
- int voffset = thumbnail ? 0 : gui_window_voffset(current_gui);
+ int voffset = (thumbnail ? 0 : gui_window_voffset(current_gui));
y += voffset;
HDC hdc = doublebuffering ? bufferdc : GetDC(current_hwnd);
if (hdc == NULL) {
13 years, 6 months
r9467 MarkieB - /branches/MarkieB/windows/windows/gui.c
by netsurf@semichrome.net
Author: MarkieB
Date: Thu Aug 27 01:10:12 2009
New Revision: 9467
URL: http://source.netsurf-browser.org?rev=9467&view=rev
Log:
double buffering
Modified:
branches/MarkieB/windows/windows/gui.c
Modified: branches/MarkieB/windows/windows/gui.c
URL: http://source.netsurf-browser.org/branches/MarkieB/windows/windows/gui.c?...
==============================================================================
--- branches/MarkieB/windows/windows/gui.c (original)
+++ branches/MarkieB/windows/windows/gui.c Thu Aug 27 01:10:12 2009
@@ -316,8 +316,8 @@
current_redraw_browser = bw;
nsws_plot_set_scale(bw->scale);
-/* doublebuffering = true;
-*/ if (bufferdc != NULL)
+ doublebuffering = true;
+ if (bufferdc != NULL)
DeleteDC(bufferdc);
HDC hdc = GetDC(current_hwnd);
HBITMAP bufferbm;
@@ -1720,48 +1720,11 @@
*/
void gui_window_set_scroll(struct gui_window *w, int sx, int sy)
{
- int blitfromtopleftx = 0, blitfromtoplefty = w->voffset,
- blittotopleftx = 0, blittotoplefty = w->voffset,
- nonvisright, nonvisleft, nonvistop, nonvisbottom;
w->requestscrollx = sx - w->scrollx;
w->requestscrolly = sy - w->scrolly;
if (w->bw->current_content == NULL)
return;
-
- if (w->requestscrollx > 0)
- blitfromtopleftx = w->requestscrollx;
- if (w->requestscrolly > 0)
- blitfromtoplefty = w->voffset + w->requestscrolly;
- if (w->requestscrollx < 0)
- blittotopleftx = -w->requestscrollx;
- if (w->requestscrolly < 0)
- blittotoplefty = w->voffset - w->requestscrolly;
-
- RECT rmain, rdesk;
- GetWindowRect(w->main, &rmain);
-/* BringWindowToTop(w->main);
-*/ SetWindowPos(w->main, HWND_TOPMOST, rmain.left, rmain.top,
- rmain.right - rmain.left, rmain.bottom - rmain.top, 0);
-
-/* ShowWindow(w->main, SW_SHOWNORMAL);
- WINDOWPOS wp = {w->main, HWND_TOPMOST, 0, 0, 0, 0,
- SWP_NOMOVE | SWP_NOSIZE};
- SendMessage(w->main, WM_WINDOWPOSCHANGED, 0, (LPARAM)&wp);
-*/
- HWND desktop = GetDesktopWindow();
- if (desktop == NULL) {
- warn_user("NoMemory", 0);
- return;
- }
- GetWindowRect(desktop, &rdesk);
- DeleteObject(desktop);
-
- nonvisright = MAX(0, rmain.right - rdesk.right);
- nonvisleft = MAX(0, rdesk.left - rmain.left);
- nonvistop = MAX(0, rdesk.top - rmain.top);
- nonvisbottom = MAX(0, rmain.bottom - rdesk.bottom);
-
SCROLLINFO si;
si.cbSize = sizeof(si);
@@ -1789,91 +1752,7 @@
HideCaret(w->main);
/* sample screen elements that are being moved */
- BITMAPINFO *bmi = (BITMAPINFO *) malloc(sizeof(BITMAPINFOHEADER) +
- ((w->width - abs(w->requestscrollx)) *
- (w->height - abs(w->requestscrolly)) * 4));
-
- if (bmi == NULL) {
- return;
- }
- HDC hdc = GetDC(current_hwnd);
- if (hdc == NULL) {
- warn_user("NoMemory", 0);
- return;
- }
- HDC Memhdc = CreateCompatibleDC(hdc);
- if (Memhdc == NULL) {
- warn_user("NoMemory", 0);
- return;
- }
- BITMAPINFOHEADER bmih;
- HBITMAP MemBMh = CreateCompatibleBitmap(
- hdc, w->width - abs(w->requestscrollx),
- w->height - abs(w->requestscrolly));
- if (MemBMh == NULL) {
- warn_user("NoMemory", 0);
- return;
- }
- BITMAP MemBM;
-
- /* save screen data */
- SelectObject(Memhdc, MemBMh);
-
- BitBlt(Memhdc, 0, 0, w->width - abs(w->requestscrollx),
- w->height - abs(w->requestscrolly),
- hdc, blitfromtopleftx, blitfromtoplefty, SRCCOPY);
-
- GetObject(MemBMh, sizeof(BITMAP), &MemBM);
-
- bmih.biSize = sizeof(bmih);
- bmih.biWidth = w->width - abs(w->requestscrollx);
- bmih.biHeight = w->height - abs(w->requestscrolly);
- bmih.biPlanes = 1;
- bmih.biBitCount = 32;
- bmih.biCompression = BI_RGB;
- bmih.biSizeImage = 4 * (w->height - abs(w->requestscrolly))
- * (w->width - abs(w->requestscrollx));
- bmih.biXPelsPerMeter = 3600; /* 100 dpi */
- bmih.biYPelsPerMeter = 3600;
- bmih.biClrUsed = 0;
- bmih.biClrImportant = 0;
- bmi->bmiHeader = bmih;
-
- GetDIBits(hdc, MemBMh, 0, w->height - abs(w->requestscrolly),
- bmi->bmiColors, bmi, DIB_RGB_COLORS);
-
- /* move memorized elements to new screen location */
- SetDIBitsToDevice(hdc, blittotopleftx, blittotoplefty,
- w->width - abs(w->requestscrollx),
- w->height - abs(w->requestscrolly),
- 0, 0, 0, w->height, (const void *) bmi->bmiColors,
- bmi, DIB_RGB_COLORS);
- SetCaretPos(p.x - w->requestscrollx, p.y - w->requestscrolly);
- ShowCaret(w->main);
-
- /* redraw new area from core */
- if (w->requestscrollx < 0)
- gui_window_redraw(w, 0, 0, (3 - w->requestscrollx)
- * w->bw->scale + nonvisleft, w->height);
- else if (w->requestscrollx > 0)
- gui_window_redraw(w, w->width - (w->requestscrollx + 3)
- * w->bw->scale - nonvisright, 0,
- w->width, w->height);
- else if (w->requestscrolly < 0)
- gui_window_redraw(w, 0, 0, w->width,
- (3 - w->requestscrolly ) * w->bw->scale +
- nonvistop);
- else if (w->requestscrolly > 0)
- gui_window_redraw(w, 0, w->height - (w->requestscrolly + 3) *
- w->bw->scale - nonvisbottom, w->width,
- w->height);
-/* SetWindowPos(w->main, HWND_NOTOPMOST, rmain.left, rmain.top,
- rmain.right - rmain.left, rmain.bottom - rmain.top, 0);
-*/
- free(bmi);
- DeleteObject(MemBMh);
- DeleteDC(Memhdc);
- ReleaseDC(current_hwnd, hdc);
+ gui_window_redraw_window(w);
}
void gui_window_scroll_visible(struct gui_window *w, int x0, int y0,
13 years, 6 months
r9466 MarkieB - in /branches/MarkieB/windows/windows: gui.c gui.h localhistory.c
by netsurf@semichrome.net
Author: MarkieB
Date: Thu Aug 27 00:42:33 2009
New Revision: 9466
URL: http://source.netsurf-browser.org?rev=9466&view=rev
Log:
local history window icos
Modified:
branches/MarkieB/windows/windows/gui.c
branches/MarkieB/windows/windows/gui.h
branches/MarkieB/windows/windows/localhistory.c
Modified: branches/MarkieB/windows/windows/gui.c
URL: http://source.netsurf-browser.org/branches/MarkieB/windows/windows/gui.c?...
==============================================================================
--- branches/MarkieB/windows/windows/gui.c (original)
+++ branches/MarkieB/windows/windows/gui.c Thu Aug 27 00:42:33 2009
@@ -60,8 +60,6 @@
char *quirks_stylesheet_url;
char *options_file_location;
-static int open_windows = 0;
-
struct gui_window *input_window = NULL;
struct gui_window *search_current_window;
struct gui_window *window_list = NULL;
@@ -70,6 +68,8 @@
FARPROC toolproc;
static char default_page[] = "http://www.netsurf-browser.org/welcome/";
+static HICON hIcon, hIconS;
+static int open_windows = 0;
#define NTOOLBUTTONS 5
#define NSWS_URL_ENTER (WM_USER)
@@ -330,7 +330,8 @@
SelectObject(bufferdc, bufferbm);
}
ReleaseDC(current_hwnd, hdc);
- content_redraw(c, -w->scrollx / w->bw->scale, -w->scrolly / w->bw->scale,
+ content_redraw(c, -w->scrollx / w->bw->scale,
+ -w->scrolly / w->bw->scale,
w->width, w->height,
w->redraw.left,
w->redraw.top,
@@ -1364,18 +1365,22 @@
*/
void nsws_window_set_ico(struct gui_window *w)
{
- HICON hIcon, hIconS;
char ico[PATH_MAX];
nsws_find_resource(ico, "NetSurf32.ico", "windows/res/NetSurf32.ico");
LOG(("setting ico as %s", ico));
hIcon = LoadImage(NULL, ico, IMAGE_ICON, 32, 32, LR_LOADFROMFILE);
- if (hIcon)
+ if (hIcon != NULL)
SendMessage(w->main, WM_SETICON, ICON_BIG, (LPARAM) hIcon);
nsws_find_resource(ico, "NetSurf16.ico", "windows/res/NetSurf16.ico");
LOG(("setting ico as %s", ico));
hIconS = LoadImage(NULL, ico, IMAGE_ICON, 16, 16, LR_LOADFROMFILE);
- if (hIconS)
+ if (hIconS != NULL)
SendMessage(w->main, WM_SETICON, ICON_SMALL, (LPARAM)hIconS);
+}
+
+HICON nsws_window_get_ico(bool large)
+{
+ return large ? hIcon : hIconS;
}
/**
Modified: branches/MarkieB/windows/windows/gui.h
URL: http://source.netsurf-browser.org/branches/MarkieB/windows/windows/gui.h?...
==============================================================================
--- branches/MarkieB/windows/windows/gui.h (original)
+++ branches/MarkieB/windows/windows/gui.h Thu Aug 27 00:42:33 2009
@@ -70,5 +70,6 @@
struct gui_window *gui_window_iterate(struct gui_window *);
struct browser_window *gui_window_browser_window(struct gui_window *);
struct nsws_pointers *nsws_get_pointers(void);
+HICON nsws_window_get_ico(bool);
#endif
Modified: branches/MarkieB/windows/windows/localhistory.c
URL: http://source.netsurf-browser.org/branches/MarkieB/windows/windows/localh...
==============================================================================
--- branches/MarkieB/windows/windows/localhistory.c (original)
+++ branches/MarkieB/windows/windows/localhistory.c Thu Aug 27 00:42:33 2009
@@ -49,7 +49,9 @@
WNDCLASSEX we;
HWND hwnd;
INITCOMMONCONTROLSEX icc;
-
+ HICON hIcon = nsws_window_get_ico(true);
+ HICON hIconS = nsws_window_get_ico(false);
+
icc.dwSize = sizeof(icc);
icc.dwICC = ICC_BAR_CLASSES | ICC_WIN95_CLASSES;
#if WINVER > 0x0501
@@ -63,12 +65,14 @@
we.cbClsExtra = 0;
we.cbWndExtra = 0;
we.hInstance = hinstance;
- we.hIcon = LoadIcon(NULL, IDI_APPLICATION);
+ we.hIcon = (hIcon == NULL) ?
+ LoadIcon(NULL, IDI_APPLICATION) : hIcon;
we.hCursor = LoadCursor(NULL, IDC_ARROW);
we.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
we.lpszMenuName = NULL;
we.lpszClassName = localhistorywindowclassname;
- we.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
+ we.hIconSm = (hIconS == NULL) ?
+ LoadIcon(NULL, IDI_APPLICATION) : hIconS;
RegisterClassEx(&we);
LOG(("creating local history window for hInstance %p", hinstance));
hwnd = CreateWindow(localhistorywindowclassname, "NetSurf History",
13 years, 6 months
r9465 MarkieB - in /branches/MarkieB/windows/windows: gui.c plot.c plot.h thumbnail.c
by netsurf@semichrome.net
Author: MarkieB
Date: Wed Aug 26 12:44:30 2009
New Revision: 9465
URL: http://source.netsurf-browser.org?rev=9465&view=rev
Log:
full colour thumbnails
Modified:
branches/MarkieB/windows/windows/gui.c
branches/MarkieB/windows/windows/plot.c
branches/MarkieB/windows/windows/plot.h
branches/MarkieB/windows/windows/thumbnail.c
Modified: branches/MarkieB/windows/windows/gui.c
URL: http://source.netsurf-browser.org/branches/MarkieB/windows/windows/gui.c?...
==============================================================================
--- branches/MarkieB/windows/windows/gui.c (original)
+++ branches/MarkieB/windows/windows/gui.c Wed Aug 26 12:44:30 2009
@@ -322,14 +322,14 @@
HDC hdc = GetDC(current_hwnd);
HBITMAP bufferbm;
bufferdc = CreateCompatibleDC(hdc);
- ReleaseDC(current_hwnd, hdc);
if (bufferdc == NULL)
doublebuffering = false;
if (doublebuffering) {
- bufferbm = CreateCompatibleBitmap(bufferdc,
- w->width, w->height);
+ bufferbm = CreateCompatibleBitmap(hdc, w->width,
+ w->height);
SelectObject(bufferdc, bufferbm);
}
+ ReleaseDC(current_hwnd, hdc);
content_redraw(c, -w->scrollx / w->bw->scale, -w->scrolly / w->bw->scale,
w->width, w->height,
w->redraw.left,
Modified: branches/MarkieB/windows/windows/plot.c
URL: http://source.netsurf-browser.org/branches/MarkieB/windows/windows/plot.c...
==============================================================================
--- branches/MarkieB/windows/windows/plot.c (original)
+++ branches/MarkieB/windows/windows/plot.c Wed Aug 26 12:44:30 2009
@@ -50,6 +50,7 @@
HWND current_hwnd;
struct gui_window *current_gui;
bool doublebuffering;
+bool thumbnail = false;
HDC bufferdc;
static float nsws_plot_scale = 1.0;
static RECT localhistory_clip;
@@ -57,7 +58,7 @@
static bool clip(int x0, int y0, int x1, int y1)
{
- int voffset = gui_window_voffset(current_gui);
+ int voffset = thumbnail ? 0 : gui_window_voffset(current_gui);
y0 += voffset;
y1 += voffset;
@@ -69,7 +70,7 @@
clip = &localhistory_clip;
x0 = MAX(x0, 0);
y0 = MAX(y0, voffset);
- if (current_gui != NULL) {
+ if (!((current_gui == NULL) || (thumbnail))) {
x1 = MIN(x1, gui_window_width(current_gui));
y1 = MIN(y1, gui_window_height(current_gui) + voffset);
}
@@ -83,8 +84,8 @@
static bool line(int x0, int y0, int x1, int y1, const plot_style_t *style)
{
- y0 += gui_window_voffset(current_gui);
- y1 += gui_window_voffset(current_gui);
+ y0 += thumbnail ? 0 : gui_window_voffset(current_gui);
+ y1 += thumbnail ? 0 : gui_window_voffset(current_gui);
#if NSWS_PLOT_DEBUG
LOG(("ligne from %d,%d to %d,%d", x0, y0, x1, y1));
#endif
@@ -151,13 +152,13 @@
y1++;
x0 = MAX(x0, 0);
y0 = MAX(y0, 0);
- if (current_gui != NULL) {
+ if (!((current_gui == NULL) || (thumbnail))) {
x1 = MIN(x1, gui_window_width(current_gui));
y1 = MIN(y1, gui_window_height(current_gui));
}
- y0 += gui_window_voffset(current_gui);
- y1 += gui_window_voffset(current_gui);
+ y0 += thumbnail ? 0 : gui_window_voffset(current_gui);
+ y1 += thumbnail ? 0 : gui_window_voffset(current_gui);
#if NSWS_PLOT_DEBUG
LOG(("rectangle from %d,%d to %d,%d", x0, y0, x1, y1));
#endif
@@ -289,21 +290,12 @@
ReleaseDC(current_hwnd, hdc);
return false;
}
- RECT r;
- r.left = gui_window_width(current_gui);
- r.top = gui_window_height(current_gui) +
- gui_window_voffset(current_gui);
- r.right = 0;
- r.bottom = 0;
SetPolyFillMode(hdc, WINDING);
for (i = 0; i < n; i++) {
points[i].x = (long) p[2 * i];
points[i].y = (long) (p[2 * i + 1]
- + gui_window_voffset(current_gui));
- r.left = MIN(r.left, points[i].x);
- r.top = MIN(r.top, points[i].y);
- r.right = MAX(r.right, points[i].x);
- r.bottom = MIN(r.bottom, points[i].y);
+ + (thumbnail ? 0 :
+ gui_window_voffset(current_gui)));
#if NSWS_PLOT_DEBUG
printf ("%ld,%ld ", points[i].x, points[i].y);
@@ -316,8 +308,7 @@
Polygon(hdc, points, n);
SelectClipRgn(hdc, NULL);
-/* ValidateRect(current_hwnd, &r);
-*/
+
pen = SelectObject(hdc, penbak);
brush = SelectObject(hdc, brushbak);
DeleteObject(clipregion);
@@ -364,7 +355,7 @@
fontbak = (HFONT) SelectObject(hdc, font);
GetTextExtentPoint(hdc, text, length, &s);
- y += gui_window_voffset(current_gui);
+ y += thumbnail ? 0 : gui_window_voffset(current_gui);
r.left = x;
r.top = y - (3 * s.cy) / 4;
r.right = x + s.cx;
@@ -401,7 +392,7 @@
static bool disc(int x, int y, int radius, const plot_style_t *style)
{
- y += gui_window_voffset(current_gui);
+ y += thumbnail ? 0 : gui_window_voffset(current_gui);
#if NSWS_PLOT_DEBUG
LOG(("disc at %d,%d radius %d", x, y, radius));
#endif
@@ -481,7 +472,7 @@
static bool arc(int x, int y, int radius, int angle1, int angle2,
const plot_style_t *style)
{
- y += gui_window_voffset(current_gui);
+ y += thumbnail ? 0 : gui_window_voffset(current_gui);
#if NSWS_PLOT_DEBUG
LOG(("arc centre %d,%d radius %d from %d to %d", x, y, radius,
angle1, angle2));
@@ -599,7 +590,7 @@
#endif
if (bitmap == NULL)
return false;
- int voffset = gui_window_voffset(current_gui);
+ int voffset = thumbnail ? 0 : gui_window_voffset(current_gui);
y += voffset;
HDC hdc = doublebuffering ? bufferdc : GetDC(current_hwnd);
if (hdc == NULL) {
Modified: branches/MarkieB/windows/windows/plot.h
URL: http://source.netsurf-browser.org/branches/MarkieB/windows/windows/plot.h...
==============================================================================
--- branches/MarkieB/windows/windows/plot.h (original)
+++ branches/MarkieB/windows/windows/plot.h Wed Aug 26 12:44:30 2009
@@ -23,6 +23,7 @@
extern struct gui_window *current_gui;
extern HDC bufferdc;
extern bool doublebuffering;
+extern bool thumbnail;
void nsws_plot_set_scale(float s);
float nsws_plot_get_scale(void);
Modified: branches/MarkieB/windows/windows/thumbnail.c
URL: http://source.netsurf-browser.org/branches/MarkieB/windows/windows/thumbn...
==============================================================================
--- branches/MarkieB/windows/windows/thumbnail.c (original)
+++ branches/MarkieB/windows/windows/thumbnail.c Wed Aug 26 12:44:30 2009
@@ -40,7 +40,6 @@
int width = MIN(content->width, 1024);
int height = MIN(content->height, 768);
int i;
- char temp;
uint8_t *pixdata;
HDC hdc, minidc;
HBITMAP bufferbm, minibm, minibm2;
@@ -73,7 +72,7 @@
return false;
}
- bufferbm = CreateCompatibleBitmap(bufferdc, width, height);
+ bufferbm = CreateCompatibleBitmap(hdc, width, height);
if (bufferbm == NULL) {
doublebuffering = false;
ReleaseDC(current_hwnd, hdc);
@@ -81,10 +80,12 @@
return false;
}
SelectObject(bufferdc, bufferbm);
+ thumbnail = true;
plot.rectangle(0, 0, width, height, plot_style_fill_white);
content_redraw(content, 0, 0, content->width, content->height, 0, 0,
width, height, 1.0, 0xFFFFFF);
-
+ thumbnail = false;
+
/* scale bufferbm to minibm */
minidc = CreateCompatibleDC(hdc);
@@ -95,24 +96,23 @@
free(bmi);
return false;
}
- ReleaseDC(current_hwnd, hdc);
- minibm = CreateCompatibleBitmap(minidc, bitmap->width, bitmap->height);
+ minibm = CreateCompatibleBitmap(hdc, bitmap->width, bitmap->height);
if (minibm == NULL) {
doublebuffering = false;
DeleteObject(bufferbm);
DeleteDC(minidc);
+ ReleaseDC(current_hwnd, hdc);
free(bmi);
return false;
}
+ ReleaseDC(current_hwnd, hdc);
SelectObject(minidc, minibm);
StretchBlt(minidc, 0, 0, bitmap->width, bitmap->height, bufferdc, 0, 0,
width, height, SRCCOPY);
-/* BitBlt(hdc, 100, 100, bitmap->width, bitmap->height, minidc, 0, 0,
- SRCCOPY);
-*/ minibm2 = CreateCompatibleBitmap(minidc, bitmap->width,
+ minibm2 = CreateCompatibleBitmap(minidc, bitmap->width,
bitmap->height);
if (minibm2 == NULL) {
doublebuffering = false;
@@ -130,20 +130,13 @@
pixdata = (uint8_t *)(bitmap->pixdata);
for (i = 0; i < bitmap->width * bitmap->height; i++) {
- temp = (bmi->bmiColors[i].rgbRed == 0x80) ? 0xFF : 0;
- bmi->bmiColors[i].rgbRed = temp;
- bmi->bmiColors[i].rgbGreen = temp;
- bmi->bmiColors[i].rgbBlue = temp;
pixdata[4 * i] = bmi->bmiColors[i].rgbRed;
- pixdata[4 * i + 1] = bmi->bmiColors[i].rgbBlue;
- pixdata[4 * i + 2] = bmi->bmiColors[i].rgbGreen;
+ pixdata[4 * i + 1] = bmi->bmiColors[i].rgbGreen;
+ pixdata[4 * i + 2] = bmi->bmiColors[i].rgbBlue;
pixdata[4 * i + 3] = 0xFF;
}
doublebuffering = false;
-/* SetDIBitsToDevice(hdc, 100, 100, bitmap->width, bitmap->height,
- 0, 0, 0, bitmap->height, (const void *) bmi->bmiColors,
- bmi, DIB_RGB_COLORS);
-*/
+
DeleteObject(bufferbm);
DeleteObject(minibm);
DeleteObject(minibm2);
13 years, 6 months
r9463 struggleyb - in /branches/struggleyb/libdom-html/src/html: html_element.c html_element.h html_link_element.c html_style_element.c
by netsurf@semichrome.net
Author: struggleyb
Date: Wed Aug 26 08:31:24 2009
New Revision: 9463
URL: http://source.netsurf-browser.org?rev=9463&view=rev
Log:
Add dom_html_element_set/get_bool_property, a more generic bool property accessor function.
Modified:
branches/struggleyb/libdom-html/src/html/html_element.c
branches/struggleyb/libdom-html/src/html/html_element.h
branches/struggleyb/libdom-html/src/html/html_link_element.c
branches/struggleyb/libdom-html/src/html/html_style_element.c
Modified: branches/struggleyb/libdom-html/src/html/html_element.c
URL: http://source.netsurf-browser.org/branches/struggleyb/libdom-html/src/htm...
==============================================================================
--- branches/struggleyb/libdom-html/src/html/html_element.c (original)
+++ branches/struggleyb/libdom-html/src/html/html_element.c Wed Aug 26 08:31:24 2009
@@ -46,23 +46,24 @@
/* Common functions */
/**
- * Get the disabled property
+ * Get the a bool property
*
- * \param ele The dom_html_element object
- * \param disabled The returned status
+ * \param ele The dom_html_element object
+ * \param name The name of the attribute
+ * \param len The length of ::name
+ * \param has The returned status
* \return DOM_NO_ERR on success, appropriate dom_exception on failure.
*/
-dom_exception dom_html_element_get_disabled(dom_html_element *ele,
- bool *disabled)
+dom_exception dom_html_element_get_bool_property(dom_html_element *ele,
+ const char *name, unsigned long len, bool *has)
{
- const char *name = "disabled";
dom_document *doc = dom_node_get_owner(ele);
dom_string *str = NULL;
dom_attr *a = NULL;
dom_exception err;
err = _dom_document_create_string(doc, (const uint8_t *) name,
- SLEN(name), &str);
+ len, &str);
if (err != DOM_NO_ERR)
goto fail;
@@ -71,9 +72,9 @@
goto cleanup1;
if (a != NULL) {
- *disabled = true;
+ *has = true;
} else {
- *disabled = false;
+ *has = false;
}
dom_node_unref(a);
@@ -86,23 +87,24 @@
}
/**
- * Set the disabled property
+ * Set a bool property
*
- * \param ele The dom_html_element object
- * \param disabled The status
+ * \param ele The dom_html_element object
+ * \param name The name of the attribute
+ * \param len The length of ::name
+ * \param has The status
* \return DOM_NO_ERR on success, appropriate dom_exception on failure.
*/
-dom_exception dom_html_element_set_disabled(dom_html_element *ele,
- bool disabled)
+dom_exception dom_html_element_set_bool_property(dom_html_element *ele,
+ const char *name, unsigned long len, bool has)
{
- const char *name = "disabled";
dom_document *doc = dom_node_get_owner(ele);
dom_string *str = NULL;
dom_attr *a = NULL;
dom_exception err;
err = _dom_document_create_string(doc, (const uint8_t *) name,
- SLEN(name), &str);
+ len, &str);
if (err != DOM_NO_ERR)
goto fail;
@@ -111,12 +113,12 @@
goto cleanup1;
dom_node *res = NULL;
- if (a != NULL && disabled == false) {
+ if (a != NULL && has == false) {
err = dom_element_remove_attribute_node(ele, a, &res);
if (err != DOM_NO_ERR)
goto cleanup2;
dom_node_unref(res);
- } else if (a == NULL && disabled == true) {
+ } else if (a == NULL && has == true) {
lwc_string *lstr = NULL;
lwc_context *ctx = _dom_document_get_intern_context(doc);
assert(ctx != NULL);
Modified: branches/struggleyb/libdom-html/src/html/html_element.h
URL: http://source.netsurf-browser.org/branches/struggleyb/libdom-html/src/htm...
==============================================================================
--- branches/struggleyb/libdom-html/src/html/html_element.h (original)
+++ branches/struggleyb/libdom-html/src/html/html_element.h Wed Aug 26 08:31:24 2009
@@ -36,10 +36,10 @@
struct dom_node_internal *old);
/* Some common functions used by all child classes */
-dom_exception dom_html_element_get_disabled(dom_html_element *ele,
- bool *disabled);
-dom_exception dom_html_element_set_disabled(dom_html_element *ele,
- bool disabled);
+dom_exception dom_html_element_get_bool_property(dom_html_element *ele,
+ const char *name, unsigned long len, bool *has);
+dom_exception dom_html_element_set_bool_property(dom_html_element *ele,
+ const char *name, unsigned long len, bool has);
#endif
Modified: branches/struggleyb/libdom-html/src/html/html_link_element.c
URL: http://source.netsurf-browser.org/branches/struggleyb/libdom-html/src/htm...
==============================================================================
--- branches/struggleyb/libdom-html/src/html/html_link_element.c (original)
+++ branches/struggleyb/libdom-html/src/html/html_link_element.c Wed Aug 26 08:31:24 2009
@@ -106,7 +106,8 @@
dom_exception dom_html_link_element_get_disabled(dom_html_link_element *ele,
bool *disabled)
{
- return dom_html_element_get_disabled(&ele->base, disabled);
+ return dom_html_element_get_bool_property(&ele->base, "disabled",
+ SLEN("disabled"), disabled);
}
/**
@@ -119,7 +120,8 @@
dom_exception dom_html_link_element_set_disabled(dom_html_link_element *ele,
bool disabled)
{
- return dom_html_element_set_disabled(&ele->base, disabled);
+ return dom_html_element_set_bool_property(&ele->base, "disabled",
+ SLEN("disabled"), disabled);
}
/*------------------------------------------------------------------------*/
Modified: branches/struggleyb/libdom-html/src/html/html_style_element.c
URL: http://source.netsurf-browser.org/branches/struggleyb/libdom-html/src/htm...
==============================================================================
--- branches/struggleyb/libdom-html/src/html/html_style_element.c (original)
+++ branches/struggleyb/libdom-html/src/html/html_style_element.c Wed Aug 26 08:31:24 2009
@@ -148,7 +148,8 @@
dom_exception dom_html_style_element_get_disabled(dom_html_style_element *ele,
bool *disabled)
{
- return dom_html_element_get_disabled(&ele->base, disabled);
+ return dom_html_element_get_bool_property(&ele->base, "disabled",
+ SLEN("disabled"), disabled);
}
/**
@@ -161,6 +162,7 @@
dom_exception dom_html_style_element_set_disabled(dom_html_style_element *ele,
bool disabled)
{
- return dom_html_element_set_disabled(&ele->base, disabled);
+ return dom_html_element_set_bool_property(&ele->base, "disabled",
+ SLEN("disabled"), disabled);
}
13 years, 6 months
r9462 MarkieB - in /branches/MarkieB/windows: desktop/history_core.c windows/bitmap.c windows/plot.c windows/thumbnail.c
by netsurf@semichrome.net
Author: MarkieB
Date: Wed Aug 26 08:10:05 2009
New Revision: 9462
URL: http://source.netsurf-browser.org?rev=9462&view=rev
Log:
working monochrome thumbnails
Modified:
branches/MarkieB/windows/desktop/history_core.c
branches/MarkieB/windows/windows/bitmap.c
branches/MarkieB/windows/windows/plot.c
branches/MarkieB/windows/windows/thumbnail.c
Modified: branches/MarkieB/windows/desktop/history_core.c
URL: http://source.netsurf-browser.org/branches/MarkieB/windows/desktop/histor...
==============================================================================
--- branches/MarkieB/windows/desktop/history_core.c (original)
+++ branches/MarkieB/windows/desktop/history_core.c Wed Aug 26 08:10:05 2009
@@ -629,9 +629,10 @@
int xoffset = x - x0;
int yoffset = y - y0;
plot_style_t pstyle_history_rect = {
- .stroke_type = PLOT_OP_TYPE_SOLID,
- .stroke_colour = c,
- .stroke_width = entry == history->current ? 2 : 1,
+ .stroke_type = PLOT_OP_TYPE_SOLID,
+ .stroke_colour = c,
+ .stroke_width = entry == history->current ? 2 : 1,
+ .fill_type = PLOT_OP_TYPE_NONE,
};
plot_font_style_t fstyle = *plot_style_font;
@@ -640,13 +641,15 @@
return false;
else
plot.clip(0, 0, history->width, history->height);
-
+
if (entry->bitmap == NULL)
LOG(("NULL bitmap"));
- if (!((entry->bitmap == NULL ) || (plot.bitmap(entry->x + xoffset,
+ else if (!(plot.bitmap(entry->x + xoffset,
entry->y + yoffset, WIDTH, HEIGHT,
- entry->bitmap, 0xffffff, 0))))
+ entry->bitmap, 0xffffff, 0))) {
return false;
+ }
+
if (!plot.rectangle(entry->x - 1 + xoffset,
entry->y - 1 + yoffset,
entry->x + xoffset + WIDTH,
Modified: branches/MarkieB/windows/windows/bitmap.c
URL: http://source.netsurf-browser.org/branches/MarkieB/windows/windows/bitmap...
==============================================================================
--- branches/MarkieB/windows/windows/bitmap.c (original)
+++ branches/MarkieB/windows/windows/bitmap.c Wed Aug 26 08:10:05 2009
@@ -50,7 +50,7 @@
LOG(("width %d, height %d, state %u",width,height,state));
bitmap = calloc(1 , sizeof(struct bitmap));
if (bitmap) {
- bitmap->pixdata = calloc(4, width * height);
+ bitmap->pixdata = calloc(width * height, 4);
if (bitmap->pixdata != NULL) {
bitmap->width = width;
bitmap->height = height;
Modified: branches/MarkieB/windows/windows/plot.c
URL: http://source.netsurf-browser.org/branches/MarkieB/windows/windows/plot.c...
==============================================================================
--- branches/MarkieB/windows/windows/plot.c (original)
+++ branches/MarkieB/windows/windows/plot.c Wed Aug 26 08:10:05 2009
@@ -180,6 +180,10 @@
(style->stroke_type == PLOT_OP_TYPE_NONE ? PS_NULL :
0)));
LOGBRUSH lb = {BS_SOLID, pencol, 0};
+ LOGBRUSH lb1 = {BS_SOLID, style->fill_colour, 0};
+ if (style->fill_type == PLOT_OP_TYPE_NONE)
+ lb1.lbStyle = BS_HOLLOW;
+
HPEN pen = ExtCreatePen(penstyle, style->stroke_width, &lb, 0, NULL);
if (pen == NULL) {
DeleteObject(clipregion);
@@ -193,8 +197,7 @@
ReleaseDC(current_hwnd, hdc);
return false;
}
- COLORREF brushcol = (DWORD)(style->fill_colour & 0xFFFFFFFF);
- HBRUSH brush = CreateSolidBrush(brushcol);
+ HBRUSH brush = CreateBrushIndirect(&lb1);
if (brush == NULL) {
DeleteObject(clipregion);
SelectObject(hdc, penbak);
Modified: branches/MarkieB/windows/windows/thumbnail.c
URL: http://source.netsurf-browser.org/branches/MarkieB/windows/windows/thumbn...
==============================================================================
--- branches/MarkieB/windows/windows/thumbnail.c (original)
+++ branches/MarkieB/windows/windows/thumbnail.c Wed Aug 26 08:10:05 2009
@@ -1,5 +1,5 @@
/*
- * Copyright 2008 Vincent Sanders <vince(a)kyllikki.org>
+ * Copyright 2009 Mark Benjamin <netsurf-browser.org.MarkBenjamin(a)dfgh.net>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
@@ -16,7 +16,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include "content/urldb.h"
#include "desktop/browser.h"
+#include "utils/log.h"
#include "windows/bitmap.h"
#include "windows/gui.h"
#include "windows/plot.h"
@@ -31,10 +33,15 @@
#endif
bool thumbnail_create(struct content *content, struct bitmap *bitmap,
- const char *url)
+ const char *url)
{
+ LOG(("creating thumbnail %p for url %s content %p", bitmap, url,
+ content));
int width = MIN(content->width, 1024);
int height = MIN(content->height, 768);
+ int i;
+ char temp;
+ uint8_t *pixdata;
HDC hdc, minidc;
HBITMAP bufferbm, minibm, minibm2;
BITMAPINFO *bmi = (BITMAPINFO *) malloc(sizeof(BITMAPINFOHEADER) +
@@ -42,7 +49,7 @@
BITMAPINFOHEADER bmih;
bmih.biSize = sizeof(bmih);
bmih.biWidth = bitmap->width;
- bmih.biHeight = bitmap->height;
+ bmih.biHeight = - bitmap->height;
bmih.biPlanes = 1;
bmih.biBitCount = 32;
bmih.biCompression = BI_RGB;
@@ -60,19 +67,21 @@
hdc = GetDC(current_hwnd);
bufferdc = CreateCompatibleDC(hdc);
- ReleaseDC(current_hwnd, hdc);
if ((bufferdc == NULL) || (bmi == NULL)) {
doublebuffering = false;
+ ReleaseDC(current_hwnd, hdc);
return false;
}
bufferbm = CreateCompatibleBitmap(bufferdc, width, height);
if (bufferbm == NULL) {
doublebuffering = false;
+ ReleaseDC(current_hwnd, hdc);
+ free(bmi);
return false;
}
SelectObject(bufferdc, bufferbm);
-
+ plot.rectangle(0, 0, width, height, plot_style_fill_white);
content_redraw(content, 0, 0, content->width, content->height, 0, 0,
width, height, 1.0, 0xFFFFFF);
@@ -82,14 +91,18 @@
if (minidc == NULL) {
doublebuffering = false;
DeleteObject(bufferbm);
+ ReleaseDC(current_hwnd, hdc);
+ free(bmi);
return false;
}
+ ReleaseDC(current_hwnd, hdc);
minibm = CreateCompatibleBitmap(minidc, bitmap->width, bitmap->height);
if (minibm == NULL) {
doublebuffering = false;
DeleteObject(bufferbm);
DeleteDC(minidc);
+ free(bmi);
return false;
}
@@ -97,27 +110,47 @@
StretchBlt(minidc, 0, 0, bitmap->width, bitmap->height, bufferdc, 0, 0,
width, height, SRCCOPY);
-
- minibm2 = CreateCompatibleBitmap(minidc, bitmap->width,
+/* BitBlt(hdc, 100, 100, bitmap->width, bitmap->height, minidc, 0, 0,
+ SRCCOPY);
+*/ minibm2 = CreateCompatibleBitmap(minidc, bitmap->width,
bitmap->height);
if (minibm2 == NULL) {
doublebuffering = false;
DeleteObject(bufferbm);
DeleteObject(minibm);
DeleteDC(minidc);
+ free(bmi);
return false;
}
SelectObject(minidc, minibm2);
+
+/* save data from minibm bmi */
+ GetDIBits(minidc, minibm, 0, 1 - bitmap->height,
+ bmi->bmiColors, bmi, DIB_RGB_COLORS);
-/* save data from minibm to bitmap->pixdata */
- GetDIBits(minidc, minibm, 0, bitmap->height - 1,
- (void *)bitmap->pixdata, bmi, DIB_RGB_COLORS);
-
-
+ pixdata = (uint8_t *)(bitmap->pixdata);
+ for (i = 0; i < bitmap->width * bitmap->height; i++) {
+ temp = (bmi->bmiColors[i].rgbRed == 0x80) ? 0xFF : 0;
+ bmi->bmiColors[i].rgbRed = temp;
+ bmi->bmiColors[i].rgbGreen = temp;
+ bmi->bmiColors[i].rgbBlue = temp;
+ pixdata[4 * i] = bmi->bmiColors[i].rgbRed;
+ pixdata[4 * i + 1] = bmi->bmiColors[i].rgbBlue;
+ pixdata[4 * i + 2] = bmi->bmiColors[i].rgbGreen;
+ pixdata[4 * i + 3] = 0xFF;
+ }
+ doublebuffering = false;
+/* SetDIBitsToDevice(hdc, 100, 100, bitmap->width, bitmap->height,
+ 0, 0, 0, bitmap->height, (const void *) bmi->bmiColors,
+ bmi, DIB_RGB_COLORS);
+*/
DeleteObject(bufferbm);
DeleteObject(minibm);
DeleteObject(minibm2);
DeleteDC(minidc);
+ free(bmi);
+ if (url)
+ urldb_set_thumbnail(url, bitmap);
doublebuffering = false;
return true;
13 years, 6 months
r9461 jmb - in /trunk/tools/buildsystem/makefiles: Makefile.tools Makefile.top
by netsurf@semichrome.net
Author: jmb
Date: Wed Aug 26 07:47:22 2009
New Revision: 9461
URL: http://source.netsurf-browser.org?rev=9461&view=rev
Log:
C++ support
Modified:
trunk/tools/buildsystem/makefiles/Makefile.tools
trunk/tools/buildsystem/makefiles/Makefile.top
Modified: trunk/tools/buildsystem/makefiles/Makefile.tools
URL: http://source.netsurf-browser.org/trunk/tools/buildsystem/makefiles/Makef...
==============================================================================
--- trunk/tools/buildsystem/makefiles/Makefile.tools (original)
+++ trunk/tools/buildsystem/makefiles/Makefile.tools Wed Aug 26 07:47:22 2009
@@ -13,7 +13,8 @@
# BUILD Type of build to perform:
# release - Release build (default)
# debug - Debug build
-# OPTCFLAGS Optional compiler flags for $(BUILD)
+# OPTCFLAGS Optional C compiler flags for $(BUILD)
+# OPTCXXFLAGS Optional C++ compiler flags for $(BUILD)
# OPTLDFLAGS Optional linker flags for $(BUILD)
# TARGET Target platform (defaults to host)
#
@@ -72,6 +73,7 @@
GCCSDK_INSTALL_ENV ?= <NSLibs$$Dir>
CC__ := gcc
+ CXX__ := g++
CMHG ?= cmunge
GENHTML ?= echo
LCOV ?= echo
@@ -89,6 +91,7 @@
AR__ := $(wildcard $(GCCSDK_INSTALL_CROSSBIN)/*ar)
CC__ := $(wildcard $(GCCSDK_INSTALL_CROSSBIN)/*gcc)
+ CXX__ := $(wildcard $(GCCSDK_INSTALL_CROSSBIN/*g++)
CMHG ?= PATH="$(GCCSDK_INSTALL_CROSSBIN):$(PATH)" $(GCCSDK_INSTALL_CROSSBIN)/cmunge
GENHTML ?= echo
LCOV ?= echo
@@ -106,6 +109,7 @@
endif
CFLAGS := $(CFLAGS) -mpoke-function-name -I$(GCCSDK_INSTALL_ENV)/include
+ CXXFLAGS := $(CXXFLAGS) -mpoke-function-name -I$(GCCSDK_INSTALL_ENV)/include
LDFLAGS := $(LDFLAGS) -L$(GCCSDK_INSTALL_ENV)/lib
CMHGFLAGS := -p -tgcc -32bit -apcs 3/32/nonreent/fpe2/noswst/nofpr/nofp
@@ -146,12 +150,14 @@
GCCSDK_INSTALL_ENV ?= /usr/local/mingw
CC__ := i586-mingw32msvc-gcc
+ CXX__ := i586-mingw32msvc-g++
AR__ := i586-mingw32msvc-ar
PKGCONFIG ?= $(GCCSDK_INSTALL_ENV)/bin/win-pkg-config
endif
CFLAGS := $(CFLAGS) -U__STRICT_ANSI__ -I$(GCCSDK_INSTALL_ENV)/include
+ CXXFLAGS := $(CXXFLAGS) -U__STRICT_ANSI__ -I$(GCCSDK_INSTALL_ENV)/include
LDFLAGS := $(LDFLAGS) -L$(GCCSDK_INSTALL_ENV)/lib
# Default prefix
@@ -172,6 +178,8 @@
HOST_CC ?= $(CC)
+HOST_CXX ?= $(CXX)
+
INSTALL ?= install
LCOV ?= lcov
@@ -201,8 +209,10 @@
ifeq ($(BUILD),release)
OPTCFLAGS ?= -DNDEBUG -O2
+ OPTCXXFLAGS ?= -DNDEBUG -O2
else
OPTCFLAGS ?= -g -O0
+ OPTCXXFLAGS ?= -g -O0
OPTLDFLAGS ?= -g
endif
@@ -213,9 +223,12 @@
ASFLAGS ?= -xassembler-with-cpp
CFLAGS := $(CFLAGS) $(OPTCFLAGS)
+CXXFLAGS := $(CXXFLAGS) $(OPTCXXFLAGS)
# Some attempt to sanitise TARGET and HOST when used as pre-defines
CFLAGS := $(CFLAGS) -DBUILD_TARGET_$(subst .,_,$(subst -,_,$(TARGET)))
+CXXFLAGS := $(CXXFLAGS) -DBUILD_TARGET_$(subst .,_,$(subst -,_,$(TARGET)))
CFLAGS := $(CFLAGS) -DBUILD_HOST_$(subst .,_,$(subst -,_,$(HOST)))
+CXXFLAGS := $(CXXFLAGS) -DBUILD_HOST_$(subst .,_,$(subst -,_,$(HOST)))
ASFLAGS := $(ASFLAGS) $(CFLAGS)
LDFLAGS := $(LDFLAGS) $(OPTLDFLAGS)
@@ -223,18 +236,22 @@
# Extensions for coverage target
ifeq ($(MAKECMDGOALS),coverage)
COVCFLAGS ?= -fprofile-arcs -ftest-coverage
+ COVCXXFLAGS ?= -fprofile-arcs -ftest-coverage
COVLDFLAGS ?= -lgcov
CFLAGS := $(CFLAGS) $(COVCFLAGS)
+ CXXFLAGS := $(CXXFLAGS) $(COVCXXFLAGS)
LDFLAGS := $(LDFLAGS) $(COVLDFLAGS)
endif
# Extensions for profile target
ifeq ($(MAKECMDGOALS),profile)
PROFCFLAGS ?= -pg
+ PROFCXXFLAGS ?= -pg
PROFLDFLAGS ?= -pg
CFLAGS := $(CFLAGS) $(PROFCFLAGS)
+ CXXFLAGS := $(CXXFLAGS) $(PROFCXXFLAGS)
LDFLAGS := $(LDFLAGS) $(PROFLDFLAGS)
endif
@@ -253,6 +270,7 @@
ifeq ($(COMPONENT_TYPE),lib-shared)
# Default CFLAGS/LDFLAGS for shared libraries
SHAREDCFLAGS ?= -fPIC -DPIC
+ SHAREDCXXFLAGS ?= -fPIC -DPIC
SHAREDLDFLAGS ?= -shared \
-Wl,-soname,$(SONAME)
SHAREDLDPATH ?= LD_LIBRARY_PATH="$(BUILDDIR):$(LD_LIBRARY_PATH)"
@@ -268,6 +286,7 @@
endif
CFLAGS := $(CFLAGS) -mmodule
+ CXXFLAGS := $(CXXFLAGS) -mmodule
LDFLAGS := $(LDFLAGS) -mmodule
endif
@@ -296,6 +315,13 @@
endif
endif
+# CXX
+ifeq ($(origin CXX),default)
+ ifdef CXX__
+ CXX := $(CXX__)
+ endif
+endif
+
# AR
ifeq ($(origin AR),default)
ifdef AR__
Modified: trunk/tools/buildsystem/makefiles/Makefile.top
URL: http://source.netsurf-browser.org/trunk/tools/buildsystem/makefiles/Makef...
==============================================================================
--- trunk/tools/buildsystem/makefiles/Makefile.top (original)
+++ trunk/tools/buildsystem/makefiles/Makefile.top Wed Aug 26 07:47:22 2009
@@ -31,9 +31,11 @@
#
# ARFLAGS Archiver flags for the current compilation
# CFLAGS C compiler flags for the current compilation
+# CXXFLAGS C++ compiler flags for the current compilation
# LDFLAGS Linker flags for the current compilation
#
# TESTCFLAGS Any test-specific CFLAGS
+# TESTCXXFLAGS Any test-specific CXXFLAGS
# TESTLDFLAGS Any test-specific LDFLAGS
#
# TESTRUNNER Test runner invocation command
@@ -168,11 +170,19 @@
# Calculate objects to build
OBJECTS := $(addprefix $(BUILDDIR)/,$(filter %.o, \
$(subst /,_,$(subst .c,.o,$(SOURCES))) \
+ $(subst /,_,$(subst .cpp,.o,$(SOURCES))) \
$(subst /,_,$(subst .cmhg,.o,$(SOURCES))) \
$(subst /,_,$(subst .s,.o,$(SOURCES)))))
bin_for_test = $(addprefix $(BUILDDIR)/,$(firstword $(subst :, ,$(ITEM))))
TEST_BINARIES := $(foreach ITEM,$(TEST_ITEMS),$(bin_for_test))
+
+# Determine if we're building any C++ sources
+ifneq ($(filter %.cpp,$(SOURCES)),)
+ CXX_IN_BUILD := yes
+else
+ CXX_IN_BUILD := no
+endif
# Determine the output filename
ifeq ($(findstring lib,$(COMPONENT_TYPE)),lib)
@@ -355,7 +365,11 @@
$(Q)$(AR) $(ARFLAGS) $@ $(OBJECTS)
else
$(VQ)$(ECHO) $(ECHOFLAGS) " LINK: $@"
+ ifeq ($(CXX_IN_BUILD),yes)
+ $(Q)$(CXX) -o $@ $(OBJECTS) $(LDFLAGS) $(SHAREDLDFLAGS)
+ else
$(Q)$(CC) -o $@ $(OBJECTS) $(LDFLAGS) $(SHAREDLDFLAGS)
+ endif
endif
###############################################################################
@@ -369,6 +383,15 @@
# C compiler can compile and dep simultaneously
define dep_c
+ ifeq ($$(findstring $$(BUILDDIR)/$2,$$(DEPFILES)),)
+ $$(BUILDDIR)/$2: $$(BUILDDIR)/stamp $1
+
+ DEPFILES += $$(BUILDDIR)/$2
+ endif
+
+ endef
+
+ define dep_cxx
ifeq ($$(findstring $$(BUILDDIR)/$2,$$(DEPFILES)),)
$$(BUILDDIR)/$2: $$(BUILDDIR)/stamp $1
@@ -387,11 +410,25 @@
endif
endef
+
+ define build_cxx
+ ifeq ($$(findstring $$(BUILDDIR)/$2,$$(BUILDFILES)),)
+ $$(BUILDDIR)/$2: $$(BUILDDIR)/stamp $1
+ $$(VQ)$$(ECHO) $$(ECHOFLAGS) " COMPILE: $1"
+ $$(Q)$$(CXX) -MMD -MP $$($3) -o $$@ -c $1
+
+ BUILDFILES += $$(BUILDDIR)/$2
+ endif
+
+ endef
else
ifeq ($(CC_CANNOT_DEP),yes)
# C compiler cannot calculate dependencies
define dep_c
+ endef
+
+ define dep_cxx
endef
define build_c
@@ -399,6 +436,17 @@
$$(BUILDDIR)/$2: $$(BUILDDIR)/stamp $1
$$(VQ)$$(ECHO) $$(ECHOFLAGS) " COMPILE: $1"
$$(Q)$$(CC) $$($3) -o $$@ -c $1
+
+ BUILDFILES += $$(BUILDDIR)/$2
+ endif
+
+ endef
+
+ define build_cxx
+ ifeq ($$(findstring $$(BUILDDIR)/$2,$$(BUILDFILES)),)
+ $$(BUILDDIR)/$2: $$(BUILDDIR)/stamp $1
+ $$(VQ)$$(ECHO) $$(ECHOFLAGS) " COMPILE: $1"
+ $$(Q)$$(CXX) $$($3) -o $$@ -c $1
BUILDFILES += $$(BUILDDIR)/$2
endif
@@ -421,11 +469,36 @@
endef
+ define dep_cxx
+ ifeq ($$(findstring $$(BUILDDIR)/$2,$$(DEPFILES)),)
+ $$(BUILDDIR)/$2: $$(BUILDDIR)/stamp $1
+ $$(VQ)$$(ECHO) $$(ECHOFLAGS) " DEP: $1"
+ $$(Q)$$(RM) $$(RMFLAGS) $($@)
+ $$(Q)$$(CXX) $$($3) -MM $1 > $$@.tmp
+ $$(Q)$$(SED) $$(SEDFLAGS) 's,^.*:,$$@ $$(@:.d=.o):,' < $$@.tmp > $$@
+ $$(Q)$$(RM) $$@.tmp
+
+ DEPFILES += $$(BUILDDIR)/$2
+ endif
+
+ endef
+
define build_c
ifeq ($$(findstring $$(BUILDDIR)/$2,$$(BUILDFILES)),)
$$(BUILDDIR)/$2: $$(BUILDDIR)/stamp $1
$$(VQ)$$(ECHO) $$(ECHOFLAGS) " COMPILE: $1"
$$(Q)$$(CC) $$($3) -o $$@ -c $1
+
+ BUILDFILES += $$(BUILDDIR)/$2
+ endif
+
+ endef
+
+ define build_cxx
+ ifeq ($$(findstring $$(BUILDDIR)/$2,$$(BUILDFILES)),)
+ $$(BUILDDIR)/$2: $$(BUILDDIR)/stamp $1
+ $$(VQ)$$(ECHO) $$(ECHOFLAGS) " COMPILE: $1"
+ $$(Q)$$(CXX) $$($3) -o $$@ -c $1
BUILDFILES += $$(BUILDDIR)/$2
endif
@@ -456,15 +529,21 @@
endef
BUILDCFLAGS = $(CFLAGS) $(SHAREDCFLAGS)
+BUILDCXXFLAGS = $(CXXFLAGS) $(SHAREDCXXFLAGS)
BUILDASFLAGS = $(ASFLAGS) $(SHAREDCFLAGS)
# Generate dependency rules
$(eval $(foreach SOURCE,$(filter %.c,$(SOURCES)), \
$(call dep_c,$(SOURCE),$(subst /,_,$(SOURCE:.c=.d)),BUILDCFLAGS)))
+$(eval $(foreach SOURCE,$(filter %.cpp,$(SOURCES)), \
+ $(call dep_cxx,$(SOURCE),$(subst /,_,$(SOURCE:.cpp=.d)),BUILDCXXFLAGS)))
# Generate compilation rules
$(eval $(foreach SOURCE,$(filter %.c,$(SOURCES)), \
$(call build_c,$(SOURCE),$(subst /,_,$(SOURCE:.c=.o)),BUILDCFLAGS)))
+
+$(eval $(foreach SOURCE,$(filter %.cpp,$(SOURCES)), \
+ $(call build_cxx,$(SOURCE),$(subst /,_,$(SOURCE:.cpp=.o)),BUILDCXXFLAGS)))
$(eval $(foreach SOURCE,$(filter %.cmhg,$(SOURCES)), \
$(call build_cmhg,$(SOURCE),$(subst /,_,$(SOURCE:.cmhg=.o)))))
@@ -480,12 +559,17 @@
endif
TESTCFLAGS += $(CFLAGS)
+ TESTCXXFLAGS += $(CXXFLAGS)
TESTLDFLAGS += $(LDFLAGS)
define link_test
$2: $($3) $1
$$(VQ)$$(ECHO) $$(ECHOFLAGS) " LINK: $2"
+ ifeq ($$(CXX_IN_BUILD),yes)
+ $$(Q)$$(CXX) -o $$@ $1 $$($4)
+ else
$$(Q)$$(CC) -o $$@ $1 $$($4)
+ endif
endef
@@ -498,8 +582,16 @@
$(call dep_c,$(SOURCE),$(subst /,_,$(SOURCE:.c=.d)),TESTCFLAGS))))
$(eval $(foreach ITEM,$(TEST_ITEMS), \
+ $(foreach SOURCE,$(filter %.cpp,$(srcs_for_test)), \
+ $(call dep_cxx,$(SOURCE),$(subst /,_,$(SOURCE:.cpp=.d)),TESTCXXFLAGS))))
+
+ $(eval $(foreach ITEM,$(TEST_ITEMS), \
$(foreach SOURCE,$(filter %.c,$(srcs_for_test)), \
$(call build_c,$(SOURCE),$(subst /,_,$(SOURCE:.c=.o)),TESTCFLAGS))))
+
+ $(eval $(foreach ITEM,$(TEST_ITEMS), \
+ $(foreach SOURCE,$(filter %.cpp,$(srcs_for_test)), \
+ $(call build_cxx,$(SOURCE),$(subst /,_,$(SOURCE:.cpp=.o)),TESTCXXFLAGS))))
$(eval $(foreach ITEM,$(TEST_ITEMS), \
$(call link_test,$(objs_for_test),$(bin_for_test),TESTLIB,TESTLDFLAGS)))
13 years, 6 months