summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.defaults4
-rw-r--r--cocoa/Makefile.target9
-rw-r--r--cocoa/NetSurf.xcodeproj/project.pbxproj4
-rw-r--r--cocoa/apple_image.h54
-rw-r--r--cocoa/apple_image.m117
-rw-r--r--content/content.c18
-rw-r--r--content/content_protected.h7
-rw-r--r--content/content_type.h3
-rw-r--r--render/box.c3
-rw-r--r--render/box_construct.c3
10 files changed, 213 insertions, 9 deletions
diff --git a/Makefile.defaults b/Makefile.defaults
index 6722494d1..effead2e7 100644
--- a/Makefile.defaults
+++ b/Makefile.defaults
@@ -373,9 +373,11 @@ ifeq ($(TARGET),cocoa)
NETSURF_USE_NSSVG := YES
NETSURF_USE_MNG := NO
+
+ NETSURF_USE_JPEG := NO
# Optimisation levels
- CFLAGS += -O2 -Wuninitialized
+ CFLAGS += -O2 -Wuninitialized -DWITH_APPLE_IMAGE
endif
diff --git a/cocoa/Makefile.target b/cocoa/Makefile.target
index 3b9915947..ee79b9c92 100644
--- a/cocoa/Makefile.target
+++ b/cocoa/Makefile.target
@@ -31,12 +31,6 @@
CFLAGS += -I/usr/include/libxml2
CFLAGS += -include cocoa/Prefix.pch
-ifneq ($(wildcard /opt/local*),)
- # libjpeg is there when installed from MacPort.
- LDFLAGS += -L/opt/local/lib
- CFLAGS += -I/opt/local/include
-endif
-
VERSION_FULL := $(shell sed -n '/\"/{s/.*"\(.*\)\".*/\1/;p;}' desktop/version.c)
VERSION_MAJ := $(shell sed -n '/_major/{s/.* = \([0-9]*\).*/\1/;p;}' desktop/version.c)
VERSION_MIN := $(shell sed -n '/_minor/{s/.* = \([0-9]*\).*/\1/;p;}' desktop/version.c)
@@ -96,7 +90,8 @@ S_COCOA := \
ArrowBox.m \
ArrowWindow.m \
BlackScroller.m \
- LocalHistoryController.m
+ LocalHistoryController.m \
+ apple_image.m
S_TABBAR := \
NSBezierPath_AMShading.m \
diff --git a/cocoa/NetSurf.xcodeproj/project.pbxproj b/cocoa/NetSurf.xcodeproj/project.pbxproj
index 1f3141526..eacc80a43 100644
--- a/cocoa/NetSurf.xcodeproj/project.pbxproj
+++ b/cocoa/NetSurf.xcodeproj/project.pbxproj
@@ -269,6 +269,8 @@
26B4E926130D36A90003B527 /* LocalHistoryPanel.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = LocalHistoryPanel.xib; sourceTree = "<group>"; };
26B4E928130D37E50003B527 /* LocalHistoryController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LocalHistoryController.h; sourceTree = "<group>"; };
26B4E929130D37E50003B527 /* LocalHistoryController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LocalHistoryController.m; sourceTree = "<group>"; };
+ 26BA25AB1321653200AEC1DA /* apple_image.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = apple_image.m; sourceTree = "<group>"; };
+ 26BA25AC1321653200AEC1DA /* apple_image.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = apple_image.h; sourceTree = "<group>"; };
26CDCEB312E702D8004FC66B /* NSBezierPath_AMShading.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSBezierPath_AMShading.h; sourceTree = "<group>"; };
26CDCEB412E702D8004FC66B /* NSBezierPath_AMShading.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NSBezierPath_AMShading.m; sourceTree = "<group>"; };
26CDCEB512E702D8004FC66B /* NSString_AITruncation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSString_AITruncation.h; sourceTree = "<group>"; };
@@ -583,6 +585,8 @@
265F303F12D6637E0048B600 /* Cocoa Frontend */ = {
isa = PBXGroup;
children = (
+ 26BA25AB1321653200AEC1DA /* apple_image.m */,
+ 26BA25AC1321653200AEC1DA /* apple_image.h */,
26CDD26512E74402004FC66B /* Browser */,
26CDD26712E74453004FC66B /* Download */,
26CDD26612E7441E004FC66B /* Views */,
diff --git a/cocoa/apple_image.h b/cocoa/apple_image.h
new file mode 100644
index 000000000..1611cf52a
--- /dev/null
+++ b/cocoa/apple_image.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2011 Sven Weidauer <sven.weidauer@gmail.com>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef _NETSURF_COCOA_APPLE_IMAGE_H_
+#define _NETSURF_COCOA_APPLE_IMAGE_H_
+
+#ifdef WITH_APPLE_IMAGE
+
+#ifdef WITH_JPEG
+#error "Don't define WITH_JPEG and WITH_APPLE_IMAGE"
+#endif
+
+#include "utils/config.h"
+#include "desktop/plot_style.h"
+
+struct bitmap;
+struct content;
+struct rect;
+
+struct content_apple_image_data {
+};
+
+bool apple_image_convert(struct content *c);
+void apple_image_destroy(struct content *c);
+
+bool apple_image_redraw(struct content *c, int x, int y,
+ int width, int height, const struct rect *clip,
+ float scale, colour background_colour);
+bool apple_image_redraw_tiled(struct content *c, int x, int y,
+ int width, int height, const struct rect *clip,
+ float scale, colour background_colour,
+ bool repeat_x, bool repeat_y);
+
+bool apple_image_clone(const struct content *old, struct content *new_content);
+
+#endif /* WITH_APPLE_IMAGE */
+
+#endif
diff --git a/cocoa/apple_image.m b/cocoa/apple_image.m
new file mode 100644
index 000000000..cdf3e537b
--- /dev/null
+++ b/cocoa/apple_image.m
@@ -0,0 +1,117 @@
+/*
+ * Copyright 2011 Sven Weidauer <sven.weidauer@gmail.com>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifdef WITH_APPLE_IMAGE
+
+#import "cocoa/apple_image.h"
+
+#include "utils/config.h"
+#include "content/content_protected.h"
+#include "image/bitmap.h"
+#include "desktop/plotters.h"
+
+/**
+ * Convert a CONTENT_APPLE_IMAGE for display.
+ */
+
+bool apple_image_convert(struct content *c)
+{
+ unsigned long size;
+ const char *bytes = content__get_source_data(c, &size);
+
+ NSData *data = [NSData dataWithBytesNoCopy: (char *)bytes length: size freeWhenDone: NO];
+ NSBitmapImageRep *image = [[NSBitmapImageRep imageRepWithData: data] retain];
+
+ if (image == nil) {
+ union content_msg_data msg_data;
+ msg_data.error = "cannot decode image";
+ content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
+ return false;
+ }
+
+ c->width = [image pixelsWide];
+ c->height = [image pixelsHigh];
+ c->bitmap = (void *)image;
+
+ char title[100];
+ snprintf( title, sizeof title, "Image (%dx%d)", c->width, c->height );
+ content__set_title(c, title );
+
+ content_set_ready(c);
+ content_set_done(c);
+ content_set_status(c, "");
+
+ return true;
+}
+
+
+void apple_image_destroy(struct content *c)
+{
+ [(id)c->bitmap release];
+ c->bitmap = NULL;
+}
+
+
+bool apple_image_clone(const struct content *old, struct content *new_content)
+{
+ if (old->status == CONTENT_STATUS_READY ||
+ old->status == CONTENT_STATUS_DONE) {
+ new_content->width = old->width;
+ new_content->height = old->height;
+ new_content->bitmap = (void *)[(id)old->bitmap retain];
+ }
+
+ return true;
+}
+
+
+/**
+ * Redraw a CONTENT_APPLE_IMAGE.
+ */
+
+bool apple_image_redraw(struct content *c, int x, int y,
+ int width, int height, const struct rect *clip,
+ float scale, colour background_colour)
+{
+ return plot.bitmap(x, y, width, height,
+ c->bitmap, background_colour, BITMAPF_NONE);
+}
+
+
+/**
+ * Redraw a CONTENT_APPLE_IMAGE with appropriate tiling.
+ */
+
+bool apple_image_redraw_tiled(struct content *c, int x, int y,
+ int width, int height, const struct rect *clip,
+ float scale, colour background_colour,
+ bool repeat_x, bool repeat_y)
+{
+ bitmap_flags_t flags = BITMAPF_NONE;
+
+ if (repeat_x)
+ flags |= BITMAPF_REPEAT_X;
+ if (repeat_y)
+ flags |= BITMAPF_REPEAT_Y;
+
+ return plot.bitmap(x, y, width, height,
+ c->bitmap, background_colour,
+ flags);
+}
+
+#endif /* WITH_APPLE_IMAGE */
diff --git a/content/content.c b/content/content.c
index cac5c97e7..41d922d62 100644
--- a/content/content.c
+++ b/content/content.c
@@ -83,6 +83,10 @@
#ifdef WITH_AMIGA_ICON
#include "amiga/icon.h"
#endif
+#ifdef WITH_APPLE_IMAGE
+#include "cocoa/apple_image.h"
+#endif
+
#include "utils/http.h"
#include "utils/log.h"
#include "utils/messages.h"
@@ -140,6 +144,10 @@ static const struct mime_entry mime_map[] = {
{"image/jpeg", CONTENT_JPEG},
{"image/jpg", CONTENT_JPEG},
#endif
+#ifdef WITH_APPLE_IMAGE
+ {"image/jpeg", CONTENT_APPLE_IMAGE},
+ {"image/jpg", CONTENT_APPLE_IMAGE},
+#endif
#ifdef WITH_MNG
{"image/mng", CONTENT_MNG},
#endif
@@ -149,6 +157,9 @@ static const struct mime_entry mime_map[] = {
#ifdef WITH_JPEG
{"image/pjpeg", CONTENT_JPEG},
#endif
+#ifdef WITH_APPLE_IMAGE
+ {"image/pjpeg", CONTENT_APPLE_IMAGE},
+#endif
#if defined(WITH_MNG) || defined(WITH_PNG)
{"image/png", CONTENT_PNG},
#endif
@@ -249,6 +260,9 @@ const char * const content_type_name[] = {
#ifdef WITH_AMIGA_ICON
"AMIGA_ICON",
#endif
+#ifdef WITH_APPLE_IMAGE
+ "APPLE_IMAGE",
+#endif
"OTHER",
"UNKNOWN"
};
@@ -385,6 +399,10 @@ static const struct handler_entry handler_map[] = {
0, amiga_icon_destroy, 0, 0, 0, amiga_icon_redraw, 0,
0, 0, amiga_icon_clone, false},
#endif
+#ifdef WITH_APPLE_IMAGE
+ {0, 0, apple_image_convert, 0, apple_image_destroy, 0, 0, 0,
+ apple_image_redraw, apple_image_redraw_tiled, 0, 0, apple_image_clone, false},
+#endif
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, false}
};
#define HANDLER_MAP_COUNT (sizeof(handler_map) / sizeof(handler_map[0]))
diff --git a/content/content_protected.h b/content/content_protected.h
index 38f381583..50ece50a5 100644
--- a/content/content_protected.h
+++ b/content/content_protected.h
@@ -81,7 +81,9 @@
#ifdef WITH_AMIGA_ICON
#include "amiga/icon.h"
#endif
-
+#ifdef WITH_APPLE_IMAGE
+#include "cocoa/apple_image.h"
+#endif
struct bitmap;
struct content;
@@ -159,6 +161,9 @@ struct content {
#ifdef WITH_AMIGA_ICON
struct content_amiga_icon_data amiga_icon;
#endif
+#ifdef WITH_APPLE_IMAGE
+ struct content_apple_image_data apple_image;
+#endif
} data;
/**< URL for refresh request, in standard form as from url_join. */
diff --git a/content/content_type.h b/content/content_type.h
index 9703c5616..0b086a599 100644
--- a/content/content_type.h
+++ b/content/content_type.h
@@ -74,6 +74,9 @@ typedef enum {
#ifdef WITH_AMIGA_ICON
CONTENT_AMIGA_ICON,
#endif
+#ifdef WITH_APPLE_IMAGE
+ CONTENT_APPLE_IMAGE,
+#endif
/* these must be the last two */
CONTENT_OTHER,
CONTENT_UNKNOWN /**< content-type not received yet */
diff --git a/render/box.c b/render/box.c
index 275079978..fa579aff8 100644
--- a/render/box.c
+++ b/render/box.c
@@ -1176,6 +1176,9 @@ bool box_duplicate_main_tree(struct box *box, struct content *c, int *count)
#if defined(WITH_NS_SVG) || defined(WITH_RSVG)
content_get_type(box->object) == CONTENT_SVG ||
#endif
+#ifdef WITH_APPLE_IMAGE
+ content_get_type(box->object) == CONTENT_APPLE_IMAGE ||
+#endif
false))
box->object = NULL;
diff --git a/render/box_construct.c b/render/box_construct.c
index d99e5deec..44fcb54b1 100644
--- a/render/box_construct.c
+++ b/render/box_construct.c
@@ -87,6 +87,9 @@ static const content_type image_types[] = {
#ifdef WITH_AMIGA_ICON
CONTENT_AMIGA_ICON,
#endif
+#ifdef WITH_APPLE_IMAGE
+ CONTENT_APPLE_IMAGE,
+#endif
CONTENT_UNKNOWN };
/* the strings are not important, since we just compare the pointers */