libdom: branch master updated. release/0.4.1-14-g6f9b1a5
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/libdom.git/shortlog/6f9b1a501fa8b95ba0befc...
...commit http://git.netsurf-browser.org/libdom.git/commit/6f9b1a501fa8b95ba0befc9f...
...tree http://git.netsurf-browser.org/libdom.git/tree/6f9b1a501fa8b95ba0befc9f3e...
The branch, master has been updated
via 6f9b1a501fa8b95ba0befc9f3eea815f2ba4035d (commit)
via fc079b52cb5b91347983c0523c59a4ba268ef561 (commit)
from 7595126d25277f09f9a0fb3769407428d3862402 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/libdom.git/commit/?id=6f9b1a501fa8b95ba0be...
commit 6f9b1a501fa8b95ba0befc9f3eea815f2ba4035d
Author: Michael Drake <michael.drake(a)codethink.co.uk>
Commit: Michael Drake <michael.drake(a)codethink.co.uk>
Example: Convert to use DOM walk API.
diff --git a/examples/dom-structure-dump.c b/examples/dom-structure-dump.c
index c719903..2cdc7c5 100644
--- a/examples/dom-structure-dump.c
+++ b/examples/dom-structure-dump.c
@@ -44,6 +44,7 @@
#include <string.h>
#include <dom/dom.h>
+#include <dom/walk.h>
#include <dom/bindings/hubbub/parser.h>
@@ -181,6 +182,12 @@ bool dump_dom_element_attribute(dom_node *node, char *attribute)
return true;
}
+static inline void dump_indent(int depth)
+{
+ for (int i = 0; i < depth; i++) {
+ printf(" ");
+ }
+}
/**
* Print a line in a DOM structure dump for an element
@@ -189,25 +196,13 @@ bool dump_dom_element_attribute(dom_node *node, char *attribute)
* \param depth The node's depth
* \return true on success, or false on error
*/
-bool dump_dom_element(dom_node *node, int depth)
+bool dump_dom_element(dom_node *node, int depth, bool close)
{
dom_exception exc;
dom_string *node_name = NULL;
- dom_node_type type;
- int i;
const char *string;
size_t length;
- /* Only interested in element nodes */
- exc = dom_node_get_node_type(node, &type);
- if (exc != DOM_NO_ERR) {
- printf("Exception raised for node_get_node_type\n");
- return false;
- } else if (type != DOM_ELEMENT_NODE) {
- /* Nothing to print */
- return true;
- }
-
/* Get element name */
exc = dom_node_get_node_name(node, &node_name);
if (exc != DOM_NO_ERR) {
@@ -215,48 +210,84 @@ bool dump_dom_element(dom_node *node, int depth)
return false;
} else if (node_name == NULL) {
printf("Broken: root_name == NULL\n");
- return false;
+ return false;
}
/* Print ASCII tree structure for current node */
- if (depth > 0) {
- for (i = 0; i < depth; i++) {
- printf("| ");
- }
- printf("+-");
- }
+ dump_indent(depth);
/* Get string data and print element name */
string = dom_string_data(node_name);
length = dom_string_byte_length(node_name);
- printf("[%.*s]", (int)length, string);
-
- if (length == 5 && strncmp(string, "title", 5) == 0) {
- /* Title tag, gather the title */
- dom_string *str;
- exc = dom_node_get_text_content(node, &str);
- if (exc == DOM_NO_ERR && str != NULL) {
- printf(" $%.*s$", (int)dom_string_byte_length(str),
- dom_string_data(str));
- dom_string_unref(str);
- }
- }
- /* Finished with the node_name dom_string */
+ /* TODO: Some elements don't have close tags; only print close tags for
+ * those that do. */
+ printf("<%s%.*s", close ? "/" : "", (int)length, string);
+
dom_string_unref(node_name);
- /* Print the element's id & class, if it has them */
- if (dump_dom_element_attribute(node, "id") == false ||
- dump_dom_element_attribute(node, "class") == false) {
- /* Error occured */
- printf("\n");
- return false;
+ if (!close) {
+ if (length == 5 && strncmp(string, "title", 5) == 0) {
+ /* Title tag, gather the title */
+ dom_string *s;
+ exc = dom_node_get_text_content(node, &s);
+ if (exc == DOM_NO_ERR && s != NULL) {
+ printf(" $%.*s$",
+ (int)dom_string_byte_length(s),
+ dom_string_data(s));
+ dom_string_unref(s);
+ }
+ }
+
+ /* Print the element's id & class, if it has them */
+ if (dump_dom_element_attribute(node, "id") == false ||
+ dump_dom_element_attribute(node, "class") == false) {
+ /* Error occured */
+ printf(">\n");
+ return false;
+ }
}
- printf("\n");
+ printf(">\n");
return true;
}
+/**
+ * Structure dump callback for DOM walker.
+ */
+enum dom_walk_cmd dump_dom_structure__cb(
+ enum dom_walk_stage stage,
+ dom_node_type type,
+ dom_node *node,
+ void *ctx)
+{
+ int *depth = ctx;
+
+ switch (type) {
+ case DOM_ELEMENT_NODE:
+ switch (stage) {
+ case DOM_WALK_STAGE_ENTER:
+ (*depth)++;
+ if (!dump_dom_element(node, *depth, false)) {
+ return DOM_WALK_CMD_ABORT;
+ }
+ break;
+
+ case DOM_WALK_STAGE_LEAVE:
+ if (!dump_dom_element(node, *depth, true)) {
+ return DOM_WALK_CMD_ABORT;
+ }
+ (*depth)--;
+ break;
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ return DOM_WALK_CMD_CONTINUE;
+}
/**
* Walk though a DOM (sub)tree, in depth first order, printing DOM structure.
@@ -267,46 +298,20 @@ bool dump_dom_element(dom_node *node, int depth)
bool dump_dom_structure(dom_node *node, int depth)
{
dom_exception exc;
- dom_node *child;
- /* Print this node's entry */
- if (dump_dom_element(node, depth) == false) {
- /* There was an error; return */
+ if (!dump_dom_element(node, depth, false)) {
return false;
}
- /* Get the node's first child */
- exc = dom_node_get_first_child(node, &child);
+ exc = libdom_treewalk(DOM_WALK_ENABLE_ALL,
+ dump_dom_structure__cb,
+ node, &depth);
if (exc != DOM_NO_ERR) {
- printf("Exception raised for node_get_first_child\n");
return false;
- } else if (child != NULL) {
- /* node has children; decend to children's depth */
- depth++;
-
- /* Loop though all node's children */
- do {
- dom_node *next_child;
-
- /* Visit node's descendents */
- if (dump_dom_structure(child, depth) == false) {
- /* There was an error; return */
- dom_node_unref(child);
- return false;
- }
-
- /* Go to next sibling */
- exc = dom_node_get_next_sibling(child, &next_child);
- if (exc != DOM_NO_ERR) {
- printf("Exception raised for "
- "node_get_next_sibling\n");
- dom_node_unref(child);
- return false;
- }
+ }
- dom_node_unref(child);
- child = next_child;
- } while (child != NULL); /* No more children */
+ if (!dump_dom_element(node, depth, true)) {
+ return false;
}
return true;
commitdiff http://git.netsurf-browser.org/libdom.git/commit/?id=fc079b52cb5b91347983...
commit fc079b52cb5b91347983c0523c59a4ba268ef561
Author: Michael Drake <michael.drake(a)codethink.co.uk>
Commit: Michael Drake <michael.drake(a)codethink.co.uk>
Add DOM tree walker functionality.
diff --git a/Makefile b/Makefile
index 4b82106..8d9df61 100644
--- a/Makefile
+++ b/Makefile
@@ -56,7 +56,7 @@ include $(NSBUILD)/Makefile.top
# Extra installation rules
Is := include/dom
I := /$(INCLUDEDIR)/dom
-INSTALL_ITEMS := $(INSTALL_ITEMS) $(I):$(Is)/dom.h;$(Is)/functypes.h;$(Is)/inttypes.h
+INSTALL_ITEMS := $(INSTALL_ITEMS) $(I):$(Is)/dom.h;$(Is)/functypes.h;$(Is)/inttypes.h;$(Is)/walk.h
Is := include/dom/core
I := /$(INCLUDEDIR)/dom/core
diff --git a/include/dom/walk.h b/include/dom/walk.h
new file mode 100644
index 0000000..0cd3fd0
--- /dev/null
+++ b/include/dom/walk.h
@@ -0,0 +1,65 @@
+/*
+ * This file is part of libdom.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2021 Michael Drake <tlsa(a)netsurf-browser.org>
+ */
+
+/** \file
+ * This is an API for walking a loaded DOM.
+ */
+
+#ifndef dom_walk_h_
+#define dom_walk_h_
+
+enum dom_walk_stage {
+ DOM_WALK_STAGE_ENTER,
+ DOM_WALK_STAGE_LEAVE,
+};
+
+enum dom_walk_enable {
+ DOM_WALK_ENABLE_ENTER = (1 << DOM_WALK_STAGE_ENTER),
+ DOM_WALK_ENABLE_LEAVE = (1 << DOM_WALK_STAGE_LEAVE),
+ DOM_WALK_ENABLE_ALL = DOM_WALK_ENABLE_ENTER | DOM_WALK_ENABLE_LEAVE,
+};
+
+enum dom_walk_cmd {
+ DOM_WALK_CMD_CONTINUE, /**< Continue the tree walk. */
+ DOM_WALK_CMD_ABORT, /**< Early termination of the tree walk. */
+ DOM_WALK_CMD_SKIP, /**< Skip children (only for \ref DOM_WALK_ENABLE_ENTER). */
+};
+
+/**
+ * DOM walking callback.
+ *
+ * Client callback for DOM walk.
+ *
+ * \param[in] stage Whether the \ref node is being entered or left.
+ * \param[in] node The node being walked. Client must take ref itself.
+ * \param[in] type The node type.
+ * \param[in] ctx Client private data.
+ * \return Tree walking client command.
+ */
+typedef enum dom_walk_cmd (*dom_walk_cb)(
+ enum dom_walk_stage stage,
+ dom_node_type type,
+ dom_node *node,
+ void *ctx);
+
+
+/**
+ * Walk a DOM subtree.
+ *
+ * \param[in] mask Mask of stages to enable callback for.
+ * \param[in] cb The client callback function.
+ * \param[in] root Node to start walk from.
+ * \param[in] ctx The client's private data.
+ * \return false for early termination of walk, true otherwise.
+ */
+dom_exception libdom_treewalk(
+ enum dom_walk_enable mask,
+ dom_walk_cb cb,
+ dom_node *root,
+ void *ctx);
+
+#endif
diff --git a/src/utils/Makefile b/src/utils/Makefile
index 4bb586f..f891b6e 100644
--- a/src/utils/Makefile
+++ b/src/utils/Makefile
@@ -1,4 +1,4 @@
# Sources
-DIR_SOURCES := namespace.c hashtable.c character_valid.c validate.c
+DIR_SOURCES := namespace.c hashtable.c character_valid.c validate.c walk.c
include $(NSBUILD)/Makefile.subdir
diff --git a/src/utils/walk.c b/src/utils/walk.c
new file mode 100644
index 0000000..20314f3
--- /dev/null
+++ b/src/utils/walk.c
@@ -0,0 +1,130 @@
+/*
+ * This file is part of libdom.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2021 Michael Drake <tlsa(a)netsurf-browser.org>
+ */
+
+/** \file
+ * This is an API for walking a loaded DOM.
+ */
+
+#include <dom/dom.h>
+#include <dom/walk.h>
+
+/**
+ * Wrapper for calling client callback.
+ *
+ * \param[in] mask Mask of stages to enable callback for.
+ * \param[in] stage Whether the \ref node is being entered or left.
+ * \param[in] node The node being walked.
+ * \param[in] cb The client callback function.
+ * \param[in] ctx The client's private data.
+ * \param[out] cmd_out Walk instruction from client.
+ * \return false for early termination of walk, true otherwise.
+ */
+static inline dom_exception dom_walk__cb(
+ enum dom_walk_enable mask,
+ enum dom_walk_stage stage,
+ dom_node *node,
+ dom_walk_cb cb,
+ void *ctx,
+ enum dom_walk_cmd *cmd_out)
+{
+ if ((1 << stage) & mask) {
+ dom_node_type type;
+ dom_exception exc;
+
+ exc = dom_node_get_node_type(node, &type);
+ if (exc != DOM_NO_ERR) {
+ return exc;
+ }
+
+ *cmd_out = cb(stage, type, node, ctx);
+ }
+
+ return DOM_NO_ERR;
+}
+
+/* exported interface documented in include/dom/walk.h */
+dom_exception libdom_treewalk(
+ enum dom_walk_enable mask,
+ dom_walk_cb cb,
+ dom_node *root,
+ void *ctx)
+{
+ dom_node *node;
+ dom_exception exc;
+ enum dom_walk_cmd cmd = DOM_WALK_CMD_CONTINUE;
+
+ node = dom_node_ref(root);
+
+ while (cmd != DOM_WALK_CMD_ABORT) {
+ dom_node *next = NULL;
+
+ if (cmd != DOM_WALK_CMD_SKIP) {
+ exc = dom_node_get_first_child(node, &next);
+ if (exc != DOM_NO_ERR) {
+ dom_node_unref(node);
+ break;
+ }
+ }
+
+ if (next != NULL) {
+ dom_node_unref(node);
+ node = next;
+ } else {
+ /* No children; siblings & ancestor's siblings */
+ while (node != root) {
+ exc = dom_walk__cb(mask, DOM_WALK_STAGE_LEAVE,
+ node, cb, ctx, &cmd);
+ if (exc != DOM_NO_ERR ||
+ cmd == DOM_WALK_CMD_ABORT) {
+ dom_node_unref(node);
+ return exc;
+ }
+
+ exc = dom_node_get_next_sibling(node, &next);
+ if (exc != DOM_NO_ERR) {
+ dom_node_unref(node);
+ node = NULL;
+ break;
+ }
+
+ if (next != NULL) {
+ /* Found next sibling. */
+ break;
+ }
+
+ exc = dom_node_get_parent_node(node, &next);
+ if (exc != DOM_NO_ERR) {
+ dom_node_unref(node);
+ return exc;
+ }
+
+ dom_node_unref(node);
+ node = next;
+ }
+
+ if (node == root) {
+ break;
+ }
+
+ dom_node_unref(node);
+ node = next;
+ }
+
+ assert(node != NULL);
+ assert(node != root);
+
+ exc = dom_walk__cb(mask, DOM_WALK_STAGE_ENTER, node,
+ cb, ctx, &cmd);
+ if (exc != DOM_NO_ERR) {
+ return exc;
+ }
+ }
+
+ dom_node_unref(node);
+
+ return DOM_NO_ERR;
+}
-----------------------------------------------------------------------
Summary of changes:
Makefile | 2 +-
examples/dom-structure-dump.c | 151 +++++++++++++++++++++--------------------
include/dom/walk.h | 65 ++++++++++++++++++
src/utils/Makefile | 2 +-
src/utils/walk.c | 130 +++++++++++++++++++++++++++++++++++
5 files changed, 275 insertions(+), 75 deletions(-)
create mode 100644 include/dom/walk.h
create mode 100644 src/utils/walk.c
diff --git a/Makefile b/Makefile
index 4b82106..8d9df61 100644
--- a/Makefile
+++ b/Makefile
@@ -56,7 +56,7 @@ include $(NSBUILD)/Makefile.top
# Extra installation rules
Is := include/dom
I := /$(INCLUDEDIR)/dom
-INSTALL_ITEMS := $(INSTALL_ITEMS) $(I):$(Is)/dom.h;$(Is)/functypes.h;$(Is)/inttypes.h
+INSTALL_ITEMS := $(INSTALL_ITEMS) $(I):$(Is)/dom.h;$(Is)/functypes.h;$(Is)/inttypes.h;$(Is)/walk.h
Is := include/dom/core
I := /$(INCLUDEDIR)/dom/core
diff --git a/examples/dom-structure-dump.c b/examples/dom-structure-dump.c
index c719903..2cdc7c5 100644
--- a/examples/dom-structure-dump.c
+++ b/examples/dom-structure-dump.c
@@ -44,6 +44,7 @@
#include <string.h>
#include <dom/dom.h>
+#include <dom/walk.h>
#include <dom/bindings/hubbub/parser.h>
@@ -181,6 +182,12 @@ bool dump_dom_element_attribute(dom_node *node, char *attribute)
return true;
}
+static inline void dump_indent(int depth)
+{
+ for (int i = 0; i < depth; i++) {
+ printf(" ");
+ }
+}
/**
* Print a line in a DOM structure dump for an element
@@ -189,25 +196,13 @@ bool dump_dom_element_attribute(dom_node *node, char *attribute)
* \param depth The node's depth
* \return true on success, or false on error
*/
-bool dump_dom_element(dom_node *node, int depth)
+bool dump_dom_element(dom_node *node, int depth, bool close)
{
dom_exception exc;
dom_string *node_name = NULL;
- dom_node_type type;
- int i;
const char *string;
size_t length;
- /* Only interested in element nodes */
- exc = dom_node_get_node_type(node, &type);
- if (exc != DOM_NO_ERR) {
- printf("Exception raised for node_get_node_type\n");
- return false;
- } else if (type != DOM_ELEMENT_NODE) {
- /* Nothing to print */
- return true;
- }
-
/* Get element name */
exc = dom_node_get_node_name(node, &node_name);
if (exc != DOM_NO_ERR) {
@@ -215,48 +210,84 @@ bool dump_dom_element(dom_node *node, int depth)
return false;
} else if (node_name == NULL) {
printf("Broken: root_name == NULL\n");
- return false;
+ return false;
}
/* Print ASCII tree structure for current node */
- if (depth > 0) {
- for (i = 0; i < depth; i++) {
- printf("| ");
- }
- printf("+-");
- }
+ dump_indent(depth);
/* Get string data and print element name */
string = dom_string_data(node_name);
length = dom_string_byte_length(node_name);
- printf("[%.*s]", (int)length, string);
-
- if (length == 5 && strncmp(string, "title", 5) == 0) {
- /* Title tag, gather the title */
- dom_string *str;
- exc = dom_node_get_text_content(node, &str);
- if (exc == DOM_NO_ERR && str != NULL) {
- printf(" $%.*s$", (int)dom_string_byte_length(str),
- dom_string_data(str));
- dom_string_unref(str);
- }
- }
- /* Finished with the node_name dom_string */
+ /* TODO: Some elements don't have close tags; only print close tags for
+ * those that do. */
+ printf("<%s%.*s", close ? "/" : "", (int)length, string);
+
dom_string_unref(node_name);
- /* Print the element's id & class, if it has them */
- if (dump_dom_element_attribute(node, "id") == false ||
- dump_dom_element_attribute(node, "class") == false) {
- /* Error occured */
- printf("\n");
- return false;
+ if (!close) {
+ if (length == 5 && strncmp(string, "title", 5) == 0) {
+ /* Title tag, gather the title */
+ dom_string *s;
+ exc = dom_node_get_text_content(node, &s);
+ if (exc == DOM_NO_ERR && s != NULL) {
+ printf(" $%.*s$",
+ (int)dom_string_byte_length(s),
+ dom_string_data(s));
+ dom_string_unref(s);
+ }
+ }
+
+ /* Print the element's id & class, if it has them */
+ if (dump_dom_element_attribute(node, "id") == false ||
+ dump_dom_element_attribute(node, "class") == false) {
+ /* Error occured */
+ printf(">\n");
+ return false;
+ }
}
- printf("\n");
+ printf(">\n");
return true;
}
+/**
+ * Structure dump callback for DOM walker.
+ */
+enum dom_walk_cmd dump_dom_structure__cb(
+ enum dom_walk_stage stage,
+ dom_node_type type,
+ dom_node *node,
+ void *ctx)
+{
+ int *depth = ctx;
+
+ switch (type) {
+ case DOM_ELEMENT_NODE:
+ switch (stage) {
+ case DOM_WALK_STAGE_ENTER:
+ (*depth)++;
+ if (!dump_dom_element(node, *depth, false)) {
+ return DOM_WALK_CMD_ABORT;
+ }
+ break;
+
+ case DOM_WALK_STAGE_LEAVE:
+ if (!dump_dom_element(node, *depth, true)) {
+ return DOM_WALK_CMD_ABORT;
+ }
+ (*depth)--;
+ break;
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ return DOM_WALK_CMD_CONTINUE;
+}
/**
* Walk though a DOM (sub)tree, in depth first order, printing DOM structure.
@@ -267,46 +298,20 @@ bool dump_dom_element(dom_node *node, int depth)
bool dump_dom_structure(dom_node *node, int depth)
{
dom_exception exc;
- dom_node *child;
- /* Print this node's entry */
- if (dump_dom_element(node, depth) == false) {
- /* There was an error; return */
+ if (!dump_dom_element(node, depth, false)) {
return false;
}
- /* Get the node's first child */
- exc = dom_node_get_first_child(node, &child);
+ exc = libdom_treewalk(DOM_WALK_ENABLE_ALL,
+ dump_dom_structure__cb,
+ node, &depth);
if (exc != DOM_NO_ERR) {
- printf("Exception raised for node_get_first_child\n");
return false;
- } else if (child != NULL) {
- /* node has children; decend to children's depth */
- depth++;
-
- /* Loop though all node's children */
- do {
- dom_node *next_child;
-
- /* Visit node's descendents */
- if (dump_dom_structure(child, depth) == false) {
- /* There was an error; return */
- dom_node_unref(child);
- return false;
- }
-
- /* Go to next sibling */
- exc = dom_node_get_next_sibling(child, &next_child);
- if (exc != DOM_NO_ERR) {
- printf("Exception raised for "
- "node_get_next_sibling\n");
- dom_node_unref(child);
- return false;
- }
+ }
- dom_node_unref(child);
- child = next_child;
- } while (child != NULL); /* No more children */
+ if (!dump_dom_element(node, depth, true)) {
+ return false;
}
return true;
diff --git a/include/dom/walk.h b/include/dom/walk.h
new file mode 100644
index 0000000..0cd3fd0
--- /dev/null
+++ b/include/dom/walk.h
@@ -0,0 +1,65 @@
+/*
+ * This file is part of libdom.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2021 Michael Drake <tlsa(a)netsurf-browser.org>
+ */
+
+/** \file
+ * This is an API for walking a loaded DOM.
+ */
+
+#ifndef dom_walk_h_
+#define dom_walk_h_
+
+enum dom_walk_stage {
+ DOM_WALK_STAGE_ENTER,
+ DOM_WALK_STAGE_LEAVE,
+};
+
+enum dom_walk_enable {
+ DOM_WALK_ENABLE_ENTER = (1 << DOM_WALK_STAGE_ENTER),
+ DOM_WALK_ENABLE_LEAVE = (1 << DOM_WALK_STAGE_LEAVE),
+ DOM_WALK_ENABLE_ALL = DOM_WALK_ENABLE_ENTER | DOM_WALK_ENABLE_LEAVE,
+};
+
+enum dom_walk_cmd {
+ DOM_WALK_CMD_CONTINUE, /**< Continue the tree walk. */
+ DOM_WALK_CMD_ABORT, /**< Early termination of the tree walk. */
+ DOM_WALK_CMD_SKIP, /**< Skip children (only for \ref DOM_WALK_ENABLE_ENTER). */
+};
+
+/**
+ * DOM walking callback.
+ *
+ * Client callback for DOM walk.
+ *
+ * \param[in] stage Whether the \ref node is being entered or left.
+ * \param[in] node The node being walked. Client must take ref itself.
+ * \param[in] type The node type.
+ * \param[in] ctx Client private data.
+ * \return Tree walking client command.
+ */
+typedef enum dom_walk_cmd (*dom_walk_cb)(
+ enum dom_walk_stage stage,
+ dom_node_type type,
+ dom_node *node,
+ void *ctx);
+
+
+/**
+ * Walk a DOM subtree.
+ *
+ * \param[in] mask Mask of stages to enable callback for.
+ * \param[in] cb The client callback function.
+ * \param[in] root Node to start walk from.
+ * \param[in] ctx The client's private data.
+ * \return false for early termination of walk, true otherwise.
+ */
+dom_exception libdom_treewalk(
+ enum dom_walk_enable mask,
+ dom_walk_cb cb,
+ dom_node *root,
+ void *ctx);
+
+#endif
diff --git a/src/utils/Makefile b/src/utils/Makefile
index 4bb586f..f891b6e 100644
--- a/src/utils/Makefile
+++ b/src/utils/Makefile
@@ -1,4 +1,4 @@
# Sources
-DIR_SOURCES := namespace.c hashtable.c character_valid.c validate.c
+DIR_SOURCES := namespace.c hashtable.c character_valid.c validate.c walk.c
include $(NSBUILD)/Makefile.subdir
diff --git a/src/utils/walk.c b/src/utils/walk.c
new file mode 100644
index 0000000..20314f3
--- /dev/null
+++ b/src/utils/walk.c
@@ -0,0 +1,130 @@
+/*
+ * This file is part of libdom.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2021 Michael Drake <tlsa(a)netsurf-browser.org>
+ */
+
+/** \file
+ * This is an API for walking a loaded DOM.
+ */
+
+#include <dom/dom.h>
+#include <dom/walk.h>
+
+/**
+ * Wrapper for calling client callback.
+ *
+ * \param[in] mask Mask of stages to enable callback for.
+ * \param[in] stage Whether the \ref node is being entered or left.
+ * \param[in] node The node being walked.
+ * \param[in] cb The client callback function.
+ * \param[in] ctx The client's private data.
+ * \param[out] cmd_out Walk instruction from client.
+ * \return false for early termination of walk, true otherwise.
+ */
+static inline dom_exception dom_walk__cb(
+ enum dom_walk_enable mask,
+ enum dom_walk_stage stage,
+ dom_node *node,
+ dom_walk_cb cb,
+ void *ctx,
+ enum dom_walk_cmd *cmd_out)
+{
+ if ((1 << stage) & mask) {
+ dom_node_type type;
+ dom_exception exc;
+
+ exc = dom_node_get_node_type(node, &type);
+ if (exc != DOM_NO_ERR) {
+ return exc;
+ }
+
+ *cmd_out = cb(stage, type, node, ctx);
+ }
+
+ return DOM_NO_ERR;
+}
+
+/* exported interface documented in include/dom/walk.h */
+dom_exception libdom_treewalk(
+ enum dom_walk_enable mask,
+ dom_walk_cb cb,
+ dom_node *root,
+ void *ctx)
+{
+ dom_node *node;
+ dom_exception exc;
+ enum dom_walk_cmd cmd = DOM_WALK_CMD_CONTINUE;
+
+ node = dom_node_ref(root);
+
+ while (cmd != DOM_WALK_CMD_ABORT) {
+ dom_node *next = NULL;
+
+ if (cmd != DOM_WALK_CMD_SKIP) {
+ exc = dom_node_get_first_child(node, &next);
+ if (exc != DOM_NO_ERR) {
+ dom_node_unref(node);
+ break;
+ }
+ }
+
+ if (next != NULL) {
+ dom_node_unref(node);
+ node = next;
+ } else {
+ /* No children; siblings & ancestor's siblings */
+ while (node != root) {
+ exc = dom_walk__cb(mask, DOM_WALK_STAGE_LEAVE,
+ node, cb, ctx, &cmd);
+ if (exc != DOM_NO_ERR ||
+ cmd == DOM_WALK_CMD_ABORT) {
+ dom_node_unref(node);
+ return exc;
+ }
+
+ exc = dom_node_get_next_sibling(node, &next);
+ if (exc != DOM_NO_ERR) {
+ dom_node_unref(node);
+ node = NULL;
+ break;
+ }
+
+ if (next != NULL) {
+ /* Found next sibling. */
+ break;
+ }
+
+ exc = dom_node_get_parent_node(node, &next);
+ if (exc != DOM_NO_ERR) {
+ dom_node_unref(node);
+ return exc;
+ }
+
+ dom_node_unref(node);
+ node = next;
+ }
+
+ if (node == root) {
+ break;
+ }
+
+ dom_node_unref(node);
+ node = next;
+ }
+
+ assert(node != NULL);
+ assert(node != root);
+
+ exc = dom_walk__cb(mask, DOM_WALK_STAGE_ENTER, node,
+ cb, ctx, &cmd);
+ if (exc != DOM_NO_ERR) {
+ return exc;
+ }
+ }
+
+ dom_node_unref(node);
+
+ return DOM_NO_ERR;
+}
--
Document Object Model library
2 years, 3 months
netsurf: branch master updated. release/3.10-150-g5a6bb39
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/5a6bb392184decd72779e...
...commit http://git.netsurf-browser.org/netsurf.git/commit/5a6bb392184decd72779ea9...
...tree http://git.netsurf-browser.org/netsurf.git/tree/5a6bb392184decd72779ea93c...
The branch, master has been updated
via 5a6bb392184decd72779ea93c4e0ecc492b3d77f (commit)
from 793f514220c15c6bb1b0db31bf0b6d0cfea0fc7b (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=5a6bb392184decd7277...
commit 5a6bb392184decd72779ea93c4e0ecc492b3d77f
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Revert "Amiga: do not force 32-bit bitmaps"
This reverts commit 793f514220c15c6bb1b0db31bf0b6d0cfea0fc7b.
diff --git a/frontends/amiga/bitmap.c b/frontends/amiga/bitmap.c
index 97e537c..e160f93 100644
--- a/frontends/amiga/bitmap.c
+++ b/frontends/amiga/bitmap.c
@@ -750,7 +750,7 @@ static nserror bitmap_render(struct bitmap *bitmap, struct hlcache_handle *conte
plot_height = ((plot_width * bitmap->height) + (bitmap->width / 2)) /
bitmap->width;
- bm_globals = ami_plot_ra_alloc(bitmap->width, bitmap->height, false);
+ bm_globals = ami_plot_ra_alloc(bitmap->width, bitmap->height, true, false);
ami_clearclipreg(bm_globals);
struct redraw_context ctx = {
diff --git a/frontends/amiga/corewindow.c b/frontends/amiga/corewindow.c
index 8898829..bfb0eb2 100644
--- a/frontends/amiga/corewindow.c
+++ b/frontends/amiga/corewindow.c
@@ -939,7 +939,7 @@ nserror ami_corewindow_init(struct ami_corewindow *ami_cw)
ami_cw->dragging = false;
/* allocate drawing area etc */
- ami_cw->gg = ami_plot_ra_alloc(100, 100, true); // force tiles to save memory
+ ami_cw->gg = ami_plot_ra_alloc(100, 100, false, true); // force tiles to save memory
ami_cw->deferred_rects = NewObjList();
ami_cw->deferred_rects_pool = ami_memory_itempool_create(sizeof(struct rect));
diff --git a/frontends/amiga/gui.c b/frontends/amiga/gui.c
index be5bca4..8eb34fb 100644
--- a/frontends/amiga/gui.c
+++ b/frontends/amiga/gui.c
@@ -1321,7 +1321,7 @@ static void ami_openscreen(void)
static void ami_openscreenfirst(void)
{
ami_openscreen();
- if(browserglob == NULL) browserglob = ami_plot_ra_alloc(0, 0, false);
+ if(browserglob == NULL) browserglob = ami_plot_ra_alloc(0, 0, false, false);
ami_theme_throbber_setup();
}
diff --git a/frontends/amiga/plotters.c b/frontends/amiga/plotters.c
index 68e682b..fe1e58f 100644
--- a/frontends/amiga/plotters.c
+++ b/frontends/amiga/plotters.c
@@ -110,7 +110,7 @@ static bool palette_mapped = true; /* palette-mapped state for the screen */
*/
#define AREA_SIZE 25000
-struct gui_globals *ami_plot_ra_alloc(ULONG width, ULONG height, bool alloc_pen_list)
+struct gui_globals *ami_plot_ra_alloc(ULONG width, ULONG height, bool force32bit, bool alloc_pen_list)
{
/* init shared bitmaps */
int depth = 32;
@@ -119,16 +119,16 @@ struct gui_globals *ami_plot_ra_alloc(ULONG width, ULONG height, bool alloc_pen_
struct gui_globals *gg = malloc(sizeof(struct gui_globals));
- depth = GetBitMapAttr(scrn->RastPort.BitMap, BMA_DEPTH);
+ if(force32bit == false) depth = GetBitMapAttr(scrn->RastPort.BitMap, BMA_DEPTH);
NSLOG(netsurf, INFO, "Screen depth = %d", depth);
#ifdef __amigaos4__
if(depth < 16) {
gg->palette_mapped = true;
- palette_mapped = true;
+ if(force32bit == false) palette_mapped = true;
} else {
gg->palette_mapped = false;
- palette_mapped = false;
+ if(force32bit == false) palette_mapped = false;
}
#else
/* Friend BitMaps are weird.
@@ -141,15 +141,15 @@ struct gui_globals *ami_plot_ra_alloc(ULONG width, ULONG height, bool alloc_pen_
} else {
/* Force friend BitMaps on for obvious RTG screens under OS3.
* If we get a bit smarter about this we can lose the user option. */
- if(depth > 8) friend = scrn->RastPort.BitMap;
+ if((depth > 8) && (force32bit == false)) friend = scrn->RastPort.BitMap;
}
if(depth < 16) {
gg->palette_mapped = true;
- palette_mapped = true;
+ if(force32bit == false) palette_mapped = true;
} else {
gg->palette_mapped = false;
- palette_mapped = false;
+ if(force32bit == false) palette_mapped = false;
}
#endif
@@ -177,7 +177,7 @@ struct gui_globals *ami_plot_ra_alloc(ULONG width, ULONG height, bool alloc_pen_
* \todo use friend BitMaps but avoid CompositeTags() at non-32-bit
* as that seems to be the cause of the problems.
*/
- if(depth >= 24) friend = scrn->RastPort.BitMap;
+ if((depth >= 24) && (force32bit == false)) friend = scrn->RastPort.BitMap;
#endif
gg->bm = ami_rtg_allocbitmap(width, height, 32, 0, friend, RGBFB_A8R8G8B8);
}
diff --git a/frontends/amiga/plotters.h b/frontends/amiga/plotters.h
index 8fadbe2..9425923 100644
--- a/frontends/amiga/plotters.h
+++ b/frontends/amiga/plotters.h
@@ -37,10 +37,11 @@ bool ami_plot_screen_is_palettemapped(void);
* Alloc a plotter render area
* \param width of render bitmap
* \param height of render bitmap
+ * \param force32bit allocate a 32-bit bitmap even if this does not match the screen
* \param alloc_pen_list set to false to use own pen list (eg. if multiple pen lists will be required)
* \returns pointer to render area
*/
-struct gui_globals *ami_plot_ra_alloc(ULONG width, ULONG height, bool alloc_pen_list);
+struct gui_globals *ami_plot_ra_alloc(ULONG width, ULONG height, bool force32bit, bool alloc_pen_list);
/**
* Free a plotter render area
diff --git a/frontends/amiga/print.c b/frontends/amiga/print.c
index 4624bd6..97c70b9 100644
--- a/frontends/amiga/print.c
+++ b/frontends/amiga/print.c
@@ -500,7 +500,7 @@ bool ami_print_begin(struct print_settings *ps)
{
ami_print_info.gg = ami_plot_ra_alloc(ami_print_info.PED->ped_MaxXDots,
ami_print_info.PED->ped_MaxYDots,
- false);
+ true, false);
if(!ami_print_info.gg) return false;
ami_print_info.page = 0;
-----------------------------------------------------------------------
Summary of changes:
frontends/amiga/bitmap.c | 2 +-
frontends/amiga/corewindow.c | 2 +-
frontends/amiga/gui.c | 2 +-
frontends/amiga/plotters.c | 16 ++++++++--------
frontends/amiga/plotters.h | 3 ++-
frontends/amiga/print.c | 2 +-
6 files changed, 14 insertions(+), 13 deletions(-)
diff --git a/frontends/amiga/bitmap.c b/frontends/amiga/bitmap.c
index 97e537c..e160f93 100644
--- a/frontends/amiga/bitmap.c
+++ b/frontends/amiga/bitmap.c
@@ -750,7 +750,7 @@ static nserror bitmap_render(struct bitmap *bitmap, struct hlcache_handle *conte
plot_height = ((plot_width * bitmap->height) + (bitmap->width / 2)) /
bitmap->width;
- bm_globals = ami_plot_ra_alloc(bitmap->width, bitmap->height, false);
+ bm_globals = ami_plot_ra_alloc(bitmap->width, bitmap->height, true, false);
ami_clearclipreg(bm_globals);
struct redraw_context ctx = {
diff --git a/frontends/amiga/corewindow.c b/frontends/amiga/corewindow.c
index 8898829..bfb0eb2 100644
--- a/frontends/amiga/corewindow.c
+++ b/frontends/amiga/corewindow.c
@@ -939,7 +939,7 @@ nserror ami_corewindow_init(struct ami_corewindow *ami_cw)
ami_cw->dragging = false;
/* allocate drawing area etc */
- ami_cw->gg = ami_plot_ra_alloc(100, 100, true); // force tiles to save memory
+ ami_cw->gg = ami_plot_ra_alloc(100, 100, false, true); // force tiles to save memory
ami_cw->deferred_rects = NewObjList();
ami_cw->deferred_rects_pool = ami_memory_itempool_create(sizeof(struct rect));
diff --git a/frontends/amiga/gui.c b/frontends/amiga/gui.c
index be5bca4..8eb34fb 100644
--- a/frontends/amiga/gui.c
+++ b/frontends/amiga/gui.c
@@ -1321,7 +1321,7 @@ static void ami_openscreen(void)
static void ami_openscreenfirst(void)
{
ami_openscreen();
- if(browserglob == NULL) browserglob = ami_plot_ra_alloc(0, 0, false);
+ if(browserglob == NULL) browserglob = ami_plot_ra_alloc(0, 0, false, false);
ami_theme_throbber_setup();
}
diff --git a/frontends/amiga/plotters.c b/frontends/amiga/plotters.c
index 68e682b..fe1e58f 100644
--- a/frontends/amiga/plotters.c
+++ b/frontends/amiga/plotters.c
@@ -110,7 +110,7 @@ static bool palette_mapped = true; /* palette-mapped state for the screen */
*/
#define AREA_SIZE 25000
-struct gui_globals *ami_plot_ra_alloc(ULONG width, ULONG height, bool alloc_pen_list)
+struct gui_globals *ami_plot_ra_alloc(ULONG width, ULONG height, bool force32bit, bool alloc_pen_list)
{
/* init shared bitmaps */
int depth = 32;
@@ -119,16 +119,16 @@ struct gui_globals *ami_plot_ra_alloc(ULONG width, ULONG height, bool alloc_pen_
struct gui_globals *gg = malloc(sizeof(struct gui_globals));
- depth = GetBitMapAttr(scrn->RastPort.BitMap, BMA_DEPTH);
+ if(force32bit == false) depth = GetBitMapAttr(scrn->RastPort.BitMap, BMA_DEPTH);
NSLOG(netsurf, INFO, "Screen depth = %d", depth);
#ifdef __amigaos4__
if(depth < 16) {
gg->palette_mapped = true;
- palette_mapped = true;
+ if(force32bit == false) palette_mapped = true;
} else {
gg->palette_mapped = false;
- palette_mapped = false;
+ if(force32bit == false) palette_mapped = false;
}
#else
/* Friend BitMaps are weird.
@@ -141,15 +141,15 @@ struct gui_globals *ami_plot_ra_alloc(ULONG width, ULONG height, bool alloc_pen_
} else {
/* Force friend BitMaps on for obvious RTG screens under OS3.
* If we get a bit smarter about this we can lose the user option. */
- if(depth > 8) friend = scrn->RastPort.BitMap;
+ if((depth > 8) && (force32bit == false)) friend = scrn->RastPort.BitMap;
}
if(depth < 16) {
gg->palette_mapped = true;
- palette_mapped = true;
+ if(force32bit == false) palette_mapped = true;
} else {
gg->palette_mapped = false;
- palette_mapped = false;
+ if(force32bit == false) palette_mapped = false;
}
#endif
@@ -177,7 +177,7 @@ struct gui_globals *ami_plot_ra_alloc(ULONG width, ULONG height, bool alloc_pen_
* \todo use friend BitMaps but avoid CompositeTags() at non-32-bit
* as that seems to be the cause of the problems.
*/
- if(depth >= 24) friend = scrn->RastPort.BitMap;
+ if((depth >= 24) && (force32bit == false)) friend = scrn->RastPort.BitMap;
#endif
gg->bm = ami_rtg_allocbitmap(width, height, 32, 0, friend, RGBFB_A8R8G8B8);
}
diff --git a/frontends/amiga/plotters.h b/frontends/amiga/plotters.h
index 8fadbe2..9425923 100644
--- a/frontends/amiga/plotters.h
+++ b/frontends/amiga/plotters.h
@@ -37,10 +37,11 @@ bool ami_plot_screen_is_palettemapped(void);
* Alloc a plotter render area
* \param width of render bitmap
* \param height of render bitmap
+ * \param force32bit allocate a 32-bit bitmap even if this does not match the screen
* \param alloc_pen_list set to false to use own pen list (eg. if multiple pen lists will be required)
* \returns pointer to render area
*/
-struct gui_globals *ami_plot_ra_alloc(ULONG width, ULONG height, bool alloc_pen_list);
+struct gui_globals *ami_plot_ra_alloc(ULONG width, ULONG height, bool force32bit, bool alloc_pen_list);
/**
* Free a plotter render area
diff --git a/frontends/amiga/print.c b/frontends/amiga/print.c
index 4624bd6..97c70b9 100644
--- a/frontends/amiga/print.c
+++ b/frontends/amiga/print.c
@@ -500,7 +500,7 @@ bool ami_print_begin(struct print_settings *ps)
{
ami_print_info.gg = ami_plot_ra_alloc(ami_print_info.PED->ped_MaxXDots,
ami_print_info.PED->ped_MaxYDots,
- false);
+ true, false);
if(!ami_print_info.gg) return false;
ami_print_info.page = 0;
--
NetSurf Browser
2 years, 3 months
netsurf: branch master updated. release/3.10-149-g793f514
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/793f514220c15c6bb1b0d...
...commit http://git.netsurf-browser.org/netsurf.git/commit/793f514220c15c6bb1b0db3...
...tree http://git.netsurf-browser.org/netsurf.git/tree/793f514220c15c6bb1b0db31b...
The branch, master has been updated
via 793f514220c15c6bb1b0db31bf0b6d0cfea0fc7b (commit)
from 474fd81bf685714a4596350c679a1f08d2b00390 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=793f514220c15c6bb1b...
commit 793f514220c15c6bb1b0db31bf0b6d0cfea0fc7b
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Amiga: do not force 32-bit bitmaps
This appears to be unnecessary
diff --git a/frontends/amiga/bitmap.c b/frontends/amiga/bitmap.c
index e160f93..97e537c 100644
--- a/frontends/amiga/bitmap.c
+++ b/frontends/amiga/bitmap.c
@@ -750,7 +750,7 @@ static nserror bitmap_render(struct bitmap *bitmap, struct hlcache_handle *conte
plot_height = ((plot_width * bitmap->height) + (bitmap->width / 2)) /
bitmap->width;
- bm_globals = ami_plot_ra_alloc(bitmap->width, bitmap->height, true, false);
+ bm_globals = ami_plot_ra_alloc(bitmap->width, bitmap->height, false);
ami_clearclipreg(bm_globals);
struct redraw_context ctx = {
diff --git a/frontends/amiga/corewindow.c b/frontends/amiga/corewindow.c
index bfb0eb2..8898829 100644
--- a/frontends/amiga/corewindow.c
+++ b/frontends/amiga/corewindow.c
@@ -939,7 +939,7 @@ nserror ami_corewindow_init(struct ami_corewindow *ami_cw)
ami_cw->dragging = false;
/* allocate drawing area etc */
- ami_cw->gg = ami_plot_ra_alloc(100, 100, false, true); // force tiles to save memory
+ ami_cw->gg = ami_plot_ra_alloc(100, 100, true); // force tiles to save memory
ami_cw->deferred_rects = NewObjList();
ami_cw->deferred_rects_pool = ami_memory_itempool_create(sizeof(struct rect));
diff --git a/frontends/amiga/gui.c b/frontends/amiga/gui.c
index 8eb34fb..be5bca4 100644
--- a/frontends/amiga/gui.c
+++ b/frontends/amiga/gui.c
@@ -1321,7 +1321,7 @@ static void ami_openscreen(void)
static void ami_openscreenfirst(void)
{
ami_openscreen();
- if(browserglob == NULL) browserglob = ami_plot_ra_alloc(0, 0, false, false);
+ if(browserglob == NULL) browserglob = ami_plot_ra_alloc(0, 0, false);
ami_theme_throbber_setup();
}
diff --git a/frontends/amiga/plotters.c b/frontends/amiga/plotters.c
index fe1e58f..68e682b 100644
--- a/frontends/amiga/plotters.c
+++ b/frontends/amiga/plotters.c
@@ -110,7 +110,7 @@ static bool palette_mapped = true; /* palette-mapped state for the screen */
*/
#define AREA_SIZE 25000
-struct gui_globals *ami_plot_ra_alloc(ULONG width, ULONG height, bool force32bit, bool alloc_pen_list)
+struct gui_globals *ami_plot_ra_alloc(ULONG width, ULONG height, bool alloc_pen_list)
{
/* init shared bitmaps */
int depth = 32;
@@ -119,16 +119,16 @@ struct gui_globals *ami_plot_ra_alloc(ULONG width, ULONG height, bool force32bit
struct gui_globals *gg = malloc(sizeof(struct gui_globals));
- if(force32bit == false) depth = GetBitMapAttr(scrn->RastPort.BitMap, BMA_DEPTH);
+ depth = GetBitMapAttr(scrn->RastPort.BitMap, BMA_DEPTH);
NSLOG(netsurf, INFO, "Screen depth = %d", depth);
#ifdef __amigaos4__
if(depth < 16) {
gg->palette_mapped = true;
- if(force32bit == false) palette_mapped = true;
+ palette_mapped = true;
} else {
gg->palette_mapped = false;
- if(force32bit == false) palette_mapped = false;
+ palette_mapped = false;
}
#else
/* Friend BitMaps are weird.
@@ -141,15 +141,15 @@ struct gui_globals *ami_plot_ra_alloc(ULONG width, ULONG height, bool force32bit
} else {
/* Force friend BitMaps on for obvious RTG screens under OS3.
* If we get a bit smarter about this we can lose the user option. */
- if((depth > 8) && (force32bit == false)) friend = scrn->RastPort.BitMap;
+ if(depth > 8) friend = scrn->RastPort.BitMap;
}
if(depth < 16) {
gg->palette_mapped = true;
- if(force32bit == false) palette_mapped = true;
+ palette_mapped = true;
} else {
gg->palette_mapped = false;
- if(force32bit == false) palette_mapped = false;
+ palette_mapped = false;
}
#endif
@@ -177,7 +177,7 @@ struct gui_globals *ami_plot_ra_alloc(ULONG width, ULONG height, bool force32bit
* \todo use friend BitMaps but avoid CompositeTags() at non-32-bit
* as that seems to be the cause of the problems.
*/
- if((depth >= 24) && (force32bit == false)) friend = scrn->RastPort.BitMap;
+ if(depth >= 24) friend = scrn->RastPort.BitMap;
#endif
gg->bm = ami_rtg_allocbitmap(width, height, 32, 0, friend, RGBFB_A8R8G8B8);
}
diff --git a/frontends/amiga/plotters.h b/frontends/amiga/plotters.h
index 9425923..8fadbe2 100644
--- a/frontends/amiga/plotters.h
+++ b/frontends/amiga/plotters.h
@@ -37,11 +37,10 @@ bool ami_plot_screen_is_palettemapped(void);
* Alloc a plotter render area
* \param width of render bitmap
* \param height of render bitmap
- * \param force32bit allocate a 32-bit bitmap even if this does not match the screen
* \param alloc_pen_list set to false to use own pen list (eg. if multiple pen lists will be required)
* \returns pointer to render area
*/
-struct gui_globals *ami_plot_ra_alloc(ULONG width, ULONG height, bool force32bit, bool alloc_pen_list);
+struct gui_globals *ami_plot_ra_alloc(ULONG width, ULONG height, bool alloc_pen_list);
/**
* Free a plotter render area
diff --git a/frontends/amiga/print.c b/frontends/amiga/print.c
index 97c70b9..4624bd6 100644
--- a/frontends/amiga/print.c
+++ b/frontends/amiga/print.c
@@ -500,7 +500,7 @@ bool ami_print_begin(struct print_settings *ps)
{
ami_print_info.gg = ami_plot_ra_alloc(ami_print_info.PED->ped_MaxXDots,
ami_print_info.PED->ped_MaxYDots,
- true, false);
+ false);
if(!ami_print_info.gg) return false;
ami_print_info.page = 0;
-----------------------------------------------------------------------
Summary of changes:
frontends/amiga/bitmap.c | 2 +-
frontends/amiga/corewindow.c | 2 +-
frontends/amiga/gui.c | 2 +-
frontends/amiga/plotters.c | 16 ++++++++--------
frontends/amiga/plotters.h | 3 +--
frontends/amiga/print.c | 2 +-
6 files changed, 13 insertions(+), 14 deletions(-)
diff --git a/frontends/amiga/bitmap.c b/frontends/amiga/bitmap.c
index e160f93..97e537c 100644
--- a/frontends/amiga/bitmap.c
+++ b/frontends/amiga/bitmap.c
@@ -750,7 +750,7 @@ static nserror bitmap_render(struct bitmap *bitmap, struct hlcache_handle *conte
plot_height = ((plot_width * bitmap->height) + (bitmap->width / 2)) /
bitmap->width;
- bm_globals = ami_plot_ra_alloc(bitmap->width, bitmap->height, true, false);
+ bm_globals = ami_plot_ra_alloc(bitmap->width, bitmap->height, false);
ami_clearclipreg(bm_globals);
struct redraw_context ctx = {
diff --git a/frontends/amiga/corewindow.c b/frontends/amiga/corewindow.c
index bfb0eb2..8898829 100644
--- a/frontends/amiga/corewindow.c
+++ b/frontends/amiga/corewindow.c
@@ -939,7 +939,7 @@ nserror ami_corewindow_init(struct ami_corewindow *ami_cw)
ami_cw->dragging = false;
/* allocate drawing area etc */
- ami_cw->gg = ami_plot_ra_alloc(100, 100, false, true); // force tiles to save memory
+ ami_cw->gg = ami_plot_ra_alloc(100, 100, true); // force tiles to save memory
ami_cw->deferred_rects = NewObjList();
ami_cw->deferred_rects_pool = ami_memory_itempool_create(sizeof(struct rect));
diff --git a/frontends/amiga/gui.c b/frontends/amiga/gui.c
index 8eb34fb..be5bca4 100644
--- a/frontends/amiga/gui.c
+++ b/frontends/amiga/gui.c
@@ -1321,7 +1321,7 @@ static void ami_openscreen(void)
static void ami_openscreenfirst(void)
{
ami_openscreen();
- if(browserglob == NULL) browserglob = ami_plot_ra_alloc(0, 0, false, false);
+ if(browserglob == NULL) browserglob = ami_plot_ra_alloc(0, 0, false);
ami_theme_throbber_setup();
}
diff --git a/frontends/amiga/plotters.c b/frontends/amiga/plotters.c
index fe1e58f..68e682b 100644
--- a/frontends/amiga/plotters.c
+++ b/frontends/amiga/plotters.c
@@ -110,7 +110,7 @@ static bool palette_mapped = true; /* palette-mapped state for the screen */
*/
#define AREA_SIZE 25000
-struct gui_globals *ami_plot_ra_alloc(ULONG width, ULONG height, bool force32bit, bool alloc_pen_list)
+struct gui_globals *ami_plot_ra_alloc(ULONG width, ULONG height, bool alloc_pen_list)
{
/* init shared bitmaps */
int depth = 32;
@@ -119,16 +119,16 @@ struct gui_globals *ami_plot_ra_alloc(ULONG width, ULONG height, bool force32bit
struct gui_globals *gg = malloc(sizeof(struct gui_globals));
- if(force32bit == false) depth = GetBitMapAttr(scrn->RastPort.BitMap, BMA_DEPTH);
+ depth = GetBitMapAttr(scrn->RastPort.BitMap, BMA_DEPTH);
NSLOG(netsurf, INFO, "Screen depth = %d", depth);
#ifdef __amigaos4__
if(depth < 16) {
gg->palette_mapped = true;
- if(force32bit == false) palette_mapped = true;
+ palette_mapped = true;
} else {
gg->palette_mapped = false;
- if(force32bit == false) palette_mapped = false;
+ palette_mapped = false;
}
#else
/* Friend BitMaps are weird.
@@ -141,15 +141,15 @@ struct gui_globals *ami_plot_ra_alloc(ULONG width, ULONG height, bool force32bit
} else {
/* Force friend BitMaps on for obvious RTG screens under OS3.
* If we get a bit smarter about this we can lose the user option. */
- if((depth > 8) && (force32bit == false)) friend = scrn->RastPort.BitMap;
+ if(depth > 8) friend = scrn->RastPort.BitMap;
}
if(depth < 16) {
gg->palette_mapped = true;
- if(force32bit == false) palette_mapped = true;
+ palette_mapped = true;
} else {
gg->palette_mapped = false;
- if(force32bit == false) palette_mapped = false;
+ palette_mapped = false;
}
#endif
@@ -177,7 +177,7 @@ struct gui_globals *ami_plot_ra_alloc(ULONG width, ULONG height, bool force32bit
* \todo use friend BitMaps but avoid CompositeTags() at non-32-bit
* as that seems to be the cause of the problems.
*/
- if((depth >= 24) && (force32bit == false)) friend = scrn->RastPort.BitMap;
+ if(depth >= 24) friend = scrn->RastPort.BitMap;
#endif
gg->bm = ami_rtg_allocbitmap(width, height, 32, 0, friend, RGBFB_A8R8G8B8);
}
diff --git a/frontends/amiga/plotters.h b/frontends/amiga/plotters.h
index 9425923..8fadbe2 100644
--- a/frontends/amiga/plotters.h
+++ b/frontends/amiga/plotters.h
@@ -37,11 +37,10 @@ bool ami_plot_screen_is_palettemapped(void);
* Alloc a plotter render area
* \param width of render bitmap
* \param height of render bitmap
- * \param force32bit allocate a 32-bit bitmap even if this does not match the screen
* \param alloc_pen_list set to false to use own pen list (eg. if multiple pen lists will be required)
* \returns pointer to render area
*/
-struct gui_globals *ami_plot_ra_alloc(ULONG width, ULONG height, bool force32bit, bool alloc_pen_list);
+struct gui_globals *ami_plot_ra_alloc(ULONG width, ULONG height, bool alloc_pen_list);
/**
* Free a plotter render area
diff --git a/frontends/amiga/print.c b/frontends/amiga/print.c
index 97c70b9..4624bd6 100644
--- a/frontends/amiga/print.c
+++ b/frontends/amiga/print.c
@@ -500,7 +500,7 @@ bool ami_print_begin(struct print_settings *ps)
{
ami_print_info.gg = ami_plot_ra_alloc(ami_print_info.PED->ped_MaxXDots,
ami_print_info.PED->ped_MaxYDots,
- true, false);
+ false);
if(!ami_print_info.gg) return false;
ami_print_info.page = 0;
--
NetSurf Browser
2 years, 3 months
libdom: branch master updated. release/0.4.1-12-g7595126
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/libdom.git/shortlog/7595126d25277f09f9a0fb...
...commit http://git.netsurf-browser.org/libdom.git/commit/7595126d25277f09f9a0fb37...
...tree http://git.netsurf-browser.org/libdom.git/tree/7595126d25277f09f9a0fb3769...
The branch, master has been updated
via 7595126d25277f09f9a0fb3769407428d3862402 (commit)
via c81f7ac01a3b7950749290855041a74517d4513e (commit)
from 77c29208368a77524e24a419238529edeec82c4d (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/libdom.git/commit/?id=7595126d25277f09f9a0...
commit 7595126d25277f09f9a0fb3769407428d3862402
Author: Michael Drake <michael.drake(a)codethink.co.uk>
Commit: Michael Drake <michael.drake(a)codethink.co.uk>
Example: Clean up LWC string table.
All leaks squashed.
diff --git a/examples/dom-structure-dump.c b/examples/dom-structure-dump.c
index b36bac2..c719903 100644
--- a/examples/dom-structure-dump.c
+++ b/examples/dom-structure-dump.c
@@ -312,6 +312,15 @@ bool dump_dom_structure(dom_node *node, int depth)
return true;
}
+/* LWC leak callback */
+void sd__fini_lwc_callback(lwc_string *str, void *pw)
+{
+ (void)(pw);
+
+ fprintf(stderr, "Leaked string: %.*s\n",
+ (int)lwc_string_length(str),
+ lwc_string_data(str));
+}
/**
* Main entry point from OS.
@@ -355,6 +364,7 @@ int main(int argc, char **argv)
dom_node_unref(doc);
dom_namespace_finalise();
+ lwc_iterate_strings(sd__fini_lwc_callback, NULL);
return EXIT_SUCCESS;
}
commitdiff http://git.netsurf-browser.org/libdom.git/commit/?id=c81f7ac01a3b79507492...
commit c81f7ac01a3b7950749290855041a74517d4513e
Author: Michael Drake <michael.drake(a)codethink.co.uk>
Commit: Michael Drake <michael.drake(a)codethink.co.uk>
Example: Finalise namespaces.
diff --git a/examples/dom-structure-dump.c b/examples/dom-structure-dump.c
index 4ce7670..b36bac2 100644
--- a/examples/dom-structure-dump.c
+++ b/examples/dom-structure-dump.c
@@ -354,6 +354,7 @@ int main(int argc, char **argv)
/* Finished with the dom_document */
dom_node_unref(doc);
+ dom_namespace_finalise();
return EXIT_SUCCESS;
}
-----------------------------------------------------------------------
Summary of changes:
examples/dom-structure-dump.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/examples/dom-structure-dump.c b/examples/dom-structure-dump.c
index 4ce7670..c719903 100644
--- a/examples/dom-structure-dump.c
+++ b/examples/dom-structure-dump.c
@@ -312,6 +312,15 @@ bool dump_dom_structure(dom_node *node, int depth)
return true;
}
+/* LWC leak callback */
+void sd__fini_lwc_callback(lwc_string *str, void *pw)
+{
+ (void)(pw);
+
+ fprintf(stderr, "Leaked string: %.*s\n",
+ (int)lwc_string_length(str),
+ lwc_string_data(str));
+}
/**
* Main entry point from OS.
@@ -354,6 +363,8 @@ int main(int argc, char **argv)
/* Finished with the dom_document */
dom_node_unref(doc);
+ dom_namespace_finalise();
+ lwc_iterate_strings(sd__fini_lwc_callback, NULL);
return EXIT_SUCCESS;
}
--
Document Object Model library
2 years, 3 months
netsurf: branch master updated. release/3.10-148-g474fd81
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/474fd81bf685714a45963...
...commit http://git.netsurf-browser.org/netsurf.git/commit/474fd81bf685714a4596350...
...tree http://git.netsurf-browser.org/netsurf.git/tree/474fd81bf685714a4596350c6...
The branch, master has been updated
via 474fd81bf685714a4596350c679a1f08d2b00390 (commit)
from d39ae4a10239481a9bf7eb8c9d6688f1e1e7cf39 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=474fd81bf685714a459...
commit 474fd81bf685714a4596350c679a1f08d2b00390
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Amiga: report correct depth
diff --git a/frontends/amiga/rtg.c b/frontends/amiga/rtg.c
index 5e1cac2..8618c0a 100644
--- a/frontends/amiga/rtg.c
+++ b/frontends/amiga/rtg.c
@@ -26,9 +26,6 @@ struct BitMap *ami_rtg_allocbitmap(ULONG width, ULONG height, ULONG depth,
ULONG flags, struct BitMap *friend, RGBFTYPE format)
{
if(P96Base == NULL) {
-#ifndef __amigaos4__
- if(depth > 8) depth = 8;
-#endif
return AllocBitMap(width, height, depth, flags, friend);
} else {
return p96AllocBitMap(width, height, depth, flags, friend, format);
-----------------------------------------------------------------------
Summary of changes:
frontends/amiga/rtg.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/frontends/amiga/rtg.c b/frontends/amiga/rtg.c
index 5e1cac2..8618c0a 100644
--- a/frontends/amiga/rtg.c
+++ b/frontends/amiga/rtg.c
@@ -26,9 +26,6 @@ struct BitMap *ami_rtg_allocbitmap(ULONG width, ULONG height, ULONG depth,
ULONG flags, struct BitMap *friend, RGBFTYPE format)
{
if(P96Base == NULL) {
-#ifndef __amigaos4__
- if(depth > 8) depth = 8;
-#endif
return AllocBitMap(width, height, depth, flags, friend);
} else {
return p96AllocBitMap(width, height, depth, flags, friend, format);
--
NetSurf Browser
2 years, 3 months
netsurf: branch master updated. release/3.10-147-gd39ae4a
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/d39ae4a10239481a9bf7e...
...commit http://git.netsurf-browser.org/netsurf.git/commit/d39ae4a10239481a9bf7eb8...
...tree http://git.netsurf-browser.org/netsurf.git/tree/d39ae4a10239481a9bf7eb8c9...
The branch, master has been updated
via d39ae4a10239481a9bf7eb8c9d6688f1e1e7cf39 (commit)
from 407e20578ff0b8c2b3fa534f82b4cf139e914ee0 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=d39ae4a10239481a9bf...
commit d39ae4a10239481a9bf7eb8c9d6688f1e1e7cf39
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
AMIGA: Use RTG calls on OS3
Enabled for experimentation
diff --git a/frontends/amiga/plotters.c b/frontends/amiga/plotters.c
index 215c5eb..fe1e58f 100644
--- a/frontends/amiga/plotters.c
+++ b/frontends/amiga/plotters.c
@@ -144,16 +144,13 @@ struct gui_globals *ami_plot_ra_alloc(ULONG width, ULONG height, bool force32bit
if((depth > 8) && (force32bit == false)) friend = scrn->RastPort.BitMap;
}
- /* OS3 is locked to using palette-mapped display even on RTG.
- * To change this, comment out the below and build with the similar OS4 lines above.
- * Various bits of RTG code are OS4-only and OS3 versions will need to be written,
- * however a brief test reveals a negative performance benefit, so this lock to a
- * palette-mapped display is most likely permanent.
- */
-#warning OS3 locked to palette-mapped modes
- gg->palette_mapped = true;
- palette_mapped = true;
- if(depth > 8) depth = 8;
+ if(depth < 16) {
+ gg->palette_mapped = true;
+ if(force32bit == false) palette_mapped = true;
+ } else {
+ gg->palette_mapped = false;
+ if(force32bit == false) palette_mapped = false;
+ }
#endif
/* Probably need to fix this next line */
-----------------------------------------------------------------------
Summary of changes:
frontends/amiga/plotters.c | 17 +++++++----------
1 file changed, 7 insertions(+), 10 deletions(-)
diff --git a/frontends/amiga/plotters.c b/frontends/amiga/plotters.c
index 215c5eb..fe1e58f 100644
--- a/frontends/amiga/plotters.c
+++ b/frontends/amiga/plotters.c
@@ -144,16 +144,13 @@ struct gui_globals *ami_plot_ra_alloc(ULONG width, ULONG height, bool force32bit
if((depth > 8) && (force32bit == false)) friend = scrn->RastPort.BitMap;
}
- /* OS3 is locked to using palette-mapped display even on RTG.
- * To change this, comment out the below and build with the similar OS4 lines above.
- * Various bits of RTG code are OS4-only and OS3 versions will need to be written,
- * however a brief test reveals a negative performance benefit, so this lock to a
- * palette-mapped display is most likely permanent.
- */
-#warning OS3 locked to palette-mapped modes
- gg->palette_mapped = true;
- palette_mapped = true;
- if(depth > 8) depth = 8;
+ if(depth < 16) {
+ gg->palette_mapped = true;
+ if(force32bit == false) palette_mapped = true;
+ } else {
+ gg->palette_mapped = false;
+ if(force32bit == false) palette_mapped = false;
+ }
#endif
/* Probably need to fix this next line */
--
NetSurf Browser
2 years, 3 months
netsurf: branch master updated. release/3.10-146-g407e205
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/407e20578ff0b8c2b3fa5...
...commit http://git.netsurf-browser.org/netsurf.git/commit/407e20578ff0b8c2b3fa534...
...tree http://git.netsurf-browser.org/netsurf.git/tree/407e20578ff0b8c2b3fa534f8...
The branch, master has been updated
via 407e20578ff0b8c2b3fa534f82b4cf139e914ee0 (commit)
from 9f3d0126503d0f22ffa6cd3d0d9d907d8d400595 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=407e20578ff0b8c2b3f...
commit 407e20578ff0b8c2b3fa534f82b4cf139e914ee0
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
RISC OS: GUI: Clean up alpha sprite support test.
diff --git a/frontends/riscos/gui.c b/frontends/riscos/gui.c
index 3f2a212..f9268ca 100644
--- a/frontends/riscos/gui.c
+++ b/frontends/riscos/gui.c
@@ -1112,9 +1112,11 @@ static void ro_gui_check_resolvers(void)
}
/**
- * Set global variable for whether the OS version supports alpha channels.
+ * Determine whether the OS version supports alpha channels.
+ *
+ * \return true iff alpha channels are supported, false otherwise.
*/
-static void ro_gui__check_os_alpha_sprites(void)
+static bool ro_gui__os_alpha_sprites_supported(void)
{
os_error *error;
int var_val;
@@ -1126,17 +1128,10 @@ static void ro_gui__check_os_alpha_sprites(void)
if (error) {
NSLOG(netsurf, ERROR, "xos_read_mode_variable: 0x%x: %s",
error->errnum, error->errmess);
- return;
- }
-
- if (var_val == (1 << 15)) {
- os_alpha_sprite_supported = true;
- } else {
- os_alpha_sprite_supported = false;
+ return false;
}
- NSLOG(netsurf, INFO, "OS supports alpha sprites: %s (%i)",
- os_alpha_sprite_supported ? "yes" : "no", var_val);
+ return (var_val == (1 << 15));
}
/**
@@ -1179,7 +1174,10 @@ static nserror gui_init(int argc, char** argv)
* (remember that it's preferable to check for specific features
* being present) */
xos_byte(osbyte_IN_KEY, 0, 0xff, &os_version, NULL);
- ro_gui__check_os_alpha_sprites();
+
+ os_alpha_sprite_supported = ro_gui__os_alpha_sprites_supported();
+ NSLOG(netsurf, INFO, "OS supports alpha sprites: %s",
+ os_alpha_sprite_supported ? "yes" : "no");
/* the first release version of the A9home OS is incapable of
plotting patterned lines (presumably a fault in the hw acceleration) */
-----------------------------------------------------------------------
Summary of changes:
frontends/riscos/gui.c | 22 ++++++++++------------
1 file changed, 10 insertions(+), 12 deletions(-)
diff --git a/frontends/riscos/gui.c b/frontends/riscos/gui.c
index 3f2a212..f9268ca 100644
--- a/frontends/riscos/gui.c
+++ b/frontends/riscos/gui.c
@@ -1112,9 +1112,11 @@ static void ro_gui_check_resolvers(void)
}
/**
- * Set global variable for whether the OS version supports alpha channels.
+ * Determine whether the OS version supports alpha channels.
+ *
+ * \return true iff alpha channels are supported, false otherwise.
*/
-static void ro_gui__check_os_alpha_sprites(void)
+static bool ro_gui__os_alpha_sprites_supported(void)
{
os_error *error;
int var_val;
@@ -1126,17 +1128,10 @@ static void ro_gui__check_os_alpha_sprites(void)
if (error) {
NSLOG(netsurf, ERROR, "xos_read_mode_variable: 0x%x: %s",
error->errnum, error->errmess);
- return;
- }
-
- if (var_val == (1 << 15)) {
- os_alpha_sprite_supported = true;
- } else {
- os_alpha_sprite_supported = false;
+ return false;
}
- NSLOG(netsurf, INFO, "OS supports alpha sprites: %s (%i)",
- os_alpha_sprite_supported ? "yes" : "no", var_val);
+ return (var_val == (1 << 15));
}
/**
@@ -1179,7 +1174,10 @@ static nserror gui_init(int argc, char** argv)
* (remember that it's preferable to check for specific features
* being present) */
xos_byte(osbyte_IN_KEY, 0, 0xff, &os_version, NULL);
- ro_gui__check_os_alpha_sprites();
+
+ os_alpha_sprite_supported = ro_gui__os_alpha_sprites_supported();
+ NSLOG(netsurf, INFO, "OS supports alpha sprites: %s",
+ os_alpha_sprite_supported ? "yes" : "no");
/* the first release version of the A9home OS is incapable of
plotting patterned lines (presumably a fault in the hw acceleration) */
--
NetSurf Browser
2 years, 3 months
netsurf: branch master updated. release/3.10-145-g9f3d012
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/9f3d0126503d0f22ffa6c...
...commit http://git.netsurf-browser.org/netsurf.git/commit/9f3d0126503d0f22ffa6cd3...
...tree http://git.netsurf-browser.org/netsurf.git/tree/9f3d0126503d0f22ffa6cd3d0...
The branch, master has been updated
via 9f3d0126503d0f22ffa6cd3d0d9d907d8d400595 (commit)
via 287e5e89b56c688bfc67bd742b386c68506c6e40 (commit)
via d58f893c57711fd353f33404418f54a824b1c304 (commit)
via e177254db462891236454a262afc8f1f7a31eaf8 (commit)
via 4b15a49bde7343c707263c7ee1d73be07a0bf060 (commit)
via b65abe987c4611bbd514c921a90f1800abb1c4b0 (commit)
from fa64d91d12c94c9aa230cd231b1d2e16054b41f2 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=9f3d0126503d0f22ffa...
commit 9f3d0126503d0f22ffa6cd3d0d9d907d8d400595
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
RISC OS: Image: Tinct workaround: Use OS alpha sprite rendering.
If NetSurf is configured to use OS for image rendering, and the
OS supports Alpha sprites, avoid going via Tinct completely.
Going via Tinct loses the alpha channel. However, with this
workaround, we lose Tinct's pretiling optimisation for tiling
tiny sprites.
diff --git a/frontends/riscos/image.c b/frontends/riscos/image.c
index 83653ba..0bad948 100644
--- a/frontends/riscos/image.c
+++ b/frontends/riscos/image.c
@@ -168,6 +168,27 @@ static bool image_redraw_os(osspriteop_id header, int x, int y, int req_width,
}
/**
+ * Override a sprite's mode.
+ *
+ * Only replaces mode if existing mode matches \ref old.
+ *
+ * \param[in] area The sprite area containing the sprite.
+ * \param[in] old Existing sprite mode to check for.
+ * \param[in] new Sprite mode to set if existing mode is expected.
+ */
+static inline void image__override_sprite_mode(
+ osspriteop_area *area,
+ os_mode old,
+ os_mode new)
+{
+ osspriteop_header *sprite = (osspriteop_header *)(area + 1);
+
+ if (sprite->mode == old) {
+ sprite->mode = new;
+ }
+}
+
+/**
* Plot an image at the given coordinates using the method specified
*
* \param area The sprite area containing the sprite
@@ -190,6 +211,8 @@ bool image_redraw(osspriteop_area *area, int x, int y, int req_width,
bool repeatx, bool repeaty, bool background, image_type type)
{
unsigned int tinct_options;
+ bool tinct_avoid = false;
+ bool res = false;
/* failed decompression/loading can result in no image being present */
if (!area)
@@ -203,28 +226,57 @@ bool image_redraw(osspriteop_area *area, int x, int y, int req_width,
height *= 2;
tinct_options = background ? nsoption_int(plot_bg_quality) :
nsoption_int(plot_fg_quality);
+
+ if (os_alpha_sprite_supported) {
+ /* Ideally Tinct would be updated to understand that modern OS
+ * versions can cope with alpha channels, and we could continue
+ * to pass to Tinct. The main drawback of fully avoiding Tinct
+ * is that we lose the optimisation for tiling tiny bitmaps.
+ */
+ if (tinct_options & tinct_USE_OS_SPRITE_OP) {
+ type = IMAGE_PLOT_OS;
+ tinct_avoid = true;
+ }
+ }
+
switch (type) {
case IMAGE_PLOT_TINCT_ALPHA:
- return image_redraw_tinct(header, x, y,
+ res = image_redraw_tinct(header, x, y,
req_width, req_height,
width, height,
background_colour,
repeatx, repeaty, true,
tinct_options);
+ break;
+
case IMAGE_PLOT_TINCT_OPAQUE:
- return image_redraw_tinct(header, x, y,
+ res = image_redraw_tinct(header, x, y,
req_width, req_height,
width, height,
background_colour,
repeatx, repeaty, false,
tinct_options);
+ break;
+
case IMAGE_PLOT_OS:
- return image_redraw_os(header, x, y, req_width,
+ if (tinct_avoid) {
+ image__override_sprite_mode(area,
+ tinct_SPRITE_MODE,
+ alpha_SPRITE_MODE);
+ }
+ res = image_redraw_os(header, x, y, req_width,
req_height, width, height,
repeatx | repeaty);
+ if (tinct_avoid) {
+ image__override_sprite_mode(area,
+ alpha_SPRITE_MODE,
+ tinct_SPRITE_MODE);
+ }
+ break;
+
default:
break;
}
- return false;
+ return res;
}
diff --git a/frontends/riscos/tinct.h b/frontends/riscos/tinct.h
index e02dcde..2931372 100644
--- a/frontends/riscos/tinct.h
+++ b/frontends/riscos/tinct.h
@@ -148,7 +148,16 @@
*/
#define tinct_BACKGROUND_SHIFT 0x08
-/* Sprite mode
-*/
+/* Sprite mode tinct
+ *
+ * Mode is: 32bpp 8:8:8:8 XXBBGGRR mode (a RISC OS 3.5+ type)
+ * We put alpha in the unused XX channel and Tinct treats it as alpha.
+ */
#define tinct_SPRITE_MODE (os_mode)0x301680b5
+
+/* Sprite mode alpha
+ *
+ * Mode is: 32bpp 8:8:8:8 AABBGGRR mode (a RISC OS 5 type)
+ */
+#define alpha_SPRITE_MODE (os_mode)0x78608051
#endif
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=287e5e89b56c688bfc6...
commit 287e5e89b56c688bfc67bd742b386c68506c6e40
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
RISC OS: GUI: Add check for sprite alpha channel OS support.
diff --git a/frontends/riscos/gui.c b/frontends/riscos/gui.c
index cc12eac..3f2a212 100644
--- a/frontends/riscos/gui.c
+++ b/frontends/riscos/gui.c
@@ -94,6 +94,7 @@ bool riscos_done = false;
extern bool ro_plot_patterned_lines;
int os_version = 0;
+bool os_alpha_sprite_supported = false;
const char * const __dynamic_da_name = "NetSurf"; /**< For UnixLib. */
int __dynamic_da_max_size = 128 * 1024 * 1024; /**< For UnixLib. */
@@ -1110,6 +1111,33 @@ static void ro_gui_check_resolvers(void)
}
}
+/**
+ * Set global variable for whether the OS version supports alpha channels.
+ */
+static void ro_gui__check_os_alpha_sprites(void)
+{
+ os_error *error;
+ int var_val;
+ bits psr;
+
+ psr = 0;
+ error = xos_read_mode_variable(alpha_SPRITE_MODE,
+ os_MODEVAR_MODE_FLAGS, &var_val, &psr);
+ if (error) {
+ NSLOG(netsurf, ERROR, "xos_read_mode_variable: 0x%x: %s",
+ error->errnum, error->errmess);
+ return;
+ }
+
+ if (var_val == (1 << 15)) {
+ os_alpha_sprite_supported = true;
+ } else {
+ os_alpha_sprite_supported = false;
+ }
+
+ NSLOG(netsurf, INFO, "OS supports alpha sprites: %s (%i)",
+ os_alpha_sprite_supported ? "yes" : "no", var_val);
+}
/**
* Initialise the RISC OS specific GUI.
@@ -1151,6 +1179,7 @@ static nserror gui_init(int argc, char** argv)
* (remember that it's preferable to check for specific features
* being present) */
xos_byte(osbyte_IN_KEY, 0, 0xff, &os_version, NULL);
+ ro_gui__check_os_alpha_sprites();
/* the first release version of the A9home OS is incapable of
plotting patterned lines (presumably a fault in the hw acceleration) */
diff --git a/frontends/riscos/gui.h b/frontends/riscos/gui.h
index 5ff17e9..03989ae 100644
--- a/frontends/riscos/gui.h
+++ b/frontends/riscos/gui.h
@@ -34,6 +34,8 @@
extern int os_version;
+extern bool os_alpha_sprite_supported;
+
extern const char * NETSURF_DIR;
struct toolbar;
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=d58f893c57711fd353f...
commit d58f893c57711fd353f33404418f54a824b1c304
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
RISC OS: Image: Add support for tiled plots with OS renderer.
diff --git a/frontends/riscos/image.c b/frontends/riscos/image.c
index 885364e..83653ba 100644
--- a/frontends/riscos/image.c
+++ b/frontends/riscos/image.c
@@ -92,10 +92,11 @@ static bool image_redraw_tinct(osspriteop_id header, int x, int y,
* \param req_height The requested height of the sprite
* \param width The actual width of the sprite
* \param height The actual height of the sprite
+ * \param tile Whether to tile the sprite
* \return true on success, false otherwise
*/
static bool image_redraw_os(osspriteop_id header, int x, int y, int req_width,
- int req_height, int width, int height)
+ int req_height, int width, int height, bool tile)
{
int size;
os_factors f;
@@ -141,10 +142,17 @@ static bool image_redraw_os(osspriteop_id header, int x, int y, int req_width,
f.xdiv = width;
f.ydiv = height;
- error = xosspriteop_put_sprite_scaled(osspriteop_PTR,
- osspriteop_UNSPECIFIED, header,
- x, (int)(y - req_height),
- osspriteop_USE_MASK, &f, table);
+ if (tile) {
+ error = xosspriteop_plot_tiled_sprite(osspriteop_PTR,
+ osspriteop_UNSPECIFIED, header,
+ x, (int)(y - req_height),
+ osspriteop_USE_MASK, &f, table);
+ } else {
+ error = xosspriteop_put_sprite_scaled(osspriteop_PTR,
+ osspriteop_UNSPECIFIED, header,
+ x, (int)(y - req_height),
+ osspriteop_USE_MASK, &f, table);
+ }
if (error) {
NSLOG(netsurf, INFO,
"xosspriteop_put_sprite_scaled: 0x%x: %s",
@@ -212,7 +220,8 @@ bool image_redraw(osspriteop_area *area, int x, int y, int req_width,
tinct_options);
case IMAGE_PLOT_OS:
return image_redraw_os(header, x, y, req_width,
- req_height, width, height);
+ req_height, width, height,
+ repeatx | repeaty);
default:
break;
}
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=e177254db4628912364...
commit e177254db462891236454a262afc8f1f7a31eaf8
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
RISC OS: Image: Remove forward declaration.
diff --git a/frontends/riscos/image.c b/frontends/riscos/image.c
index 4cf2869..885364e 100644
--- a/frontends/riscos/image.c
+++ b/frontends/riscos/image.c
@@ -29,74 +29,6 @@
#include "riscos/gui.h"
#include "riscos/tinct.h"
-static bool image_redraw_tinct(osspriteop_id header, int x, int y,
- int req_width, int req_height, int width, int height,
- colour background_colour, bool repeatx, bool repeaty,
- bool alpha, unsigned int tinct_options);
-static bool image_redraw_os(osspriteop_id header, int x, int y,
- int req_width, int req_height, int width, int height);
-
-/**
- * Plot an image at the given coordinates using the method specified
- *
- * \param area The sprite area containing the sprite
- * \param x Left edge of sprite
- * \param y Top edge of sprite
- * \param req_width The requested width of the sprite
- * \param req_height The requested height of the sprite
- * \param width The actual width of the sprite
- * \param height The actual height of the sprite
- * \param background_colour The background colour to blend to
- * \param repeatx Repeat the image in the x direction
- * \param repeaty Repeat the image in the y direction
- * \param background Use background image settings (otherwise foreground)
- * \param type The plot method to use
- * \return true on success, false otherwise
- */
-bool image_redraw(osspriteop_area *area, int x, int y, int req_width,
- int req_height, int width, int height,
- colour background_colour,
- bool repeatx, bool repeaty, bool background, image_type type)
-{
- unsigned int tinct_options;
-
- /* failed decompression/loading can result in no image being present */
- if (!area)
- return false;
-
- osspriteop_id header = (osspriteop_id)
- ((char*) area + area->first);
- req_width *= 2;
- req_height *= 2;
- width *= 2;
- height *= 2;
- tinct_options = background ? nsoption_int(plot_bg_quality) :
- nsoption_int(plot_fg_quality);
- switch (type) {
- case IMAGE_PLOT_TINCT_ALPHA:
- return image_redraw_tinct(header, x, y,
- req_width, req_height,
- width, height,
- background_colour,
- repeatx, repeaty, true,
- tinct_options);
- case IMAGE_PLOT_TINCT_OPAQUE:
- return image_redraw_tinct(header, x, y,
- req_width, req_height,
- width, height,
- background_colour,
- repeatx, repeaty, false,
- tinct_options);
- case IMAGE_PLOT_OS:
- return image_redraw_os(header, x, y, req_width,
- req_height, width, height);
- default:
- break;
- }
-
- return false;
-}
-
/**
* Plot an image at the given coordinates using tinct
*
@@ -114,7 +46,7 @@ bool image_redraw(osspriteop_area *area, int x, int y, int req_width,
* \param tinct_options The base option set to use
* \return true on success, false otherwise
*/
-bool image_redraw_tinct(osspriteop_id header, int x, int y,
+static bool image_redraw_tinct(osspriteop_id header, int x, int y,
int req_width, int req_height, int width, int height,
colour background_colour, bool repeatx, bool repeaty,
bool alpha, unsigned int tinct_options)
@@ -150,7 +82,6 @@ bool image_redraw_tinct(osspriteop_id header, int x, int y,
return true;
}
-
/**
* Plot an image at the given coordinates using os_spriteop
*
@@ -163,7 +94,7 @@ bool image_redraw_tinct(osspriteop_id header, int x, int y,
* \param height The actual height of the sprite
* \return true on success, false otherwise
*/
-bool image_redraw_os(osspriteop_id header, int x, int y, int req_width,
+static bool image_redraw_os(osspriteop_id header, int x, int y, int req_width,
int req_height, int width, int height)
{
int size;
@@ -227,3 +158,64 @@ bool image_redraw_os(osspriteop_id header, int x, int y, int req_width,
return true;
}
+
+/**
+ * Plot an image at the given coordinates using the method specified
+ *
+ * \param area The sprite area containing the sprite
+ * \param x Left edge of sprite
+ * \param y Top edge of sprite
+ * \param req_width The requested width of the sprite
+ * \param req_height The requested height of the sprite
+ * \param width The actual width of the sprite
+ * \param height The actual height of the sprite
+ * \param background_colour The background colour to blend to
+ * \param repeatx Repeat the image in the x direction
+ * \param repeaty Repeat the image in the y direction
+ * \param background Use background image settings (otherwise foreground)
+ * \param type The plot method to use
+ * \return true on success, false otherwise
+ */
+bool image_redraw(osspriteop_area *area, int x, int y, int req_width,
+ int req_height, int width, int height,
+ colour background_colour,
+ bool repeatx, bool repeaty, bool background, image_type type)
+{
+ unsigned int tinct_options;
+
+ /* failed decompression/loading can result in no image being present */
+ if (!area)
+ return false;
+
+ osspriteop_id header = (osspriteop_id)
+ ((char*) area + area->first);
+ req_width *= 2;
+ req_height *= 2;
+ width *= 2;
+ height *= 2;
+ tinct_options = background ? nsoption_int(plot_bg_quality) :
+ nsoption_int(plot_fg_quality);
+ switch (type) {
+ case IMAGE_PLOT_TINCT_ALPHA:
+ return image_redraw_tinct(header, x, y,
+ req_width, req_height,
+ width, height,
+ background_colour,
+ repeatx, repeaty, true,
+ tinct_options);
+ case IMAGE_PLOT_TINCT_OPAQUE:
+ return image_redraw_tinct(header, x, y,
+ req_width, req_height,
+ width, height,
+ background_colour,
+ repeatx, repeaty, false,
+ tinct_options);
+ case IMAGE_PLOT_OS:
+ return image_redraw_os(header, x, y, req_width,
+ req_height, width, height);
+ default:
+ break;
+ }
+
+ return false;
+}
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=4b15a49bde7343c7072...
commit 4b15a49bde7343c707263c7ee1d73be07a0bf060
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
RISC OS: Image: Use #define to enable use of mask.
diff --git a/frontends/riscos/image.c b/frontends/riscos/image.c
index e6e0f7f..4cf2869 100644
--- a/frontends/riscos/image.c
+++ b/frontends/riscos/image.c
@@ -213,7 +213,7 @@ bool image_redraw_os(osspriteop_id header, int x, int y, int req_width,
error = xosspriteop_put_sprite_scaled(osspriteop_PTR,
osspriteop_UNSPECIFIED, header,
x, (int)(y - req_height),
- 8, &f, table);
+ osspriteop_USE_MASK, &f, table);
if (error) {
NSLOG(netsurf, INFO,
"xosspriteop_put_sprite_scaled: 0x%x: %s",
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=b65abe987c4611bbd51...
commit b65abe987c4611bbd514c921a90f1800abb1c4b0
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
RISC OS: Image: Use #define for unspecified sprite area.
diff --git a/frontends/riscos/image.c b/frontends/riscos/image.c
index 30cb300..e6e0f7f 100644
--- a/frontends/riscos/image.c
+++ b/frontends/riscos/image.c
@@ -172,7 +172,7 @@ bool image_redraw_os(osspriteop_id header, int x, int y, int req_width,
os_error *error;
error = xcolourtrans_generate_table_for_sprite(
- (osspriteop_area *)0x100, header,
+ osspriteop_UNSPECIFIED, header,
os_CURRENT_MODE,
colourtrans_CURRENT_PALETTE,
0, colourtrans_GIVEN_SPRITE, 0, 0, &size);
@@ -192,7 +192,7 @@ bool image_redraw_os(osspriteop_id header, int x, int y, int req_width,
}
error = xcolourtrans_generate_table_for_sprite(
- (osspriteop_area *)0x100, header,
+ osspriteop_UNSPECIFIED, header,
os_CURRENT_MODE,
colourtrans_CURRENT_PALETTE,
table, colourtrans_GIVEN_SPRITE, 0, 0, 0);
@@ -211,7 +211,7 @@ bool image_redraw_os(osspriteop_id header, int x, int y, int req_width,
f.ydiv = height;
error = xosspriteop_put_sprite_scaled(osspriteop_PTR,
- (osspriteop_area *)0x100, header,
+ osspriteop_UNSPECIFIED, header,
x, (int)(y - req_height),
8, &f, table);
if (error) {
-----------------------------------------------------------------------
Summary of changes:
frontends/riscos/gui.c | 29 +++++++
frontends/riscos/gui.h | 2 +
frontends/riscos/image.c | 209 +++++++++++++++++++++++++++++-----------------
frontends/riscos/tinct.h | 13 ++-
4 files changed, 173 insertions(+), 80 deletions(-)
diff --git a/frontends/riscos/gui.c b/frontends/riscos/gui.c
index cc12eac..3f2a212 100644
--- a/frontends/riscos/gui.c
+++ b/frontends/riscos/gui.c
@@ -94,6 +94,7 @@ bool riscos_done = false;
extern bool ro_plot_patterned_lines;
int os_version = 0;
+bool os_alpha_sprite_supported = false;
const char * const __dynamic_da_name = "NetSurf"; /**< For UnixLib. */
int __dynamic_da_max_size = 128 * 1024 * 1024; /**< For UnixLib. */
@@ -1110,6 +1111,33 @@ static void ro_gui_check_resolvers(void)
}
}
+/**
+ * Set global variable for whether the OS version supports alpha channels.
+ */
+static void ro_gui__check_os_alpha_sprites(void)
+{
+ os_error *error;
+ int var_val;
+ bits psr;
+
+ psr = 0;
+ error = xos_read_mode_variable(alpha_SPRITE_MODE,
+ os_MODEVAR_MODE_FLAGS, &var_val, &psr);
+ if (error) {
+ NSLOG(netsurf, ERROR, "xos_read_mode_variable: 0x%x: %s",
+ error->errnum, error->errmess);
+ return;
+ }
+
+ if (var_val == (1 << 15)) {
+ os_alpha_sprite_supported = true;
+ } else {
+ os_alpha_sprite_supported = false;
+ }
+
+ NSLOG(netsurf, INFO, "OS supports alpha sprites: %s (%i)",
+ os_alpha_sprite_supported ? "yes" : "no", var_val);
+}
/**
* Initialise the RISC OS specific GUI.
@@ -1151,6 +1179,7 @@ static nserror gui_init(int argc, char** argv)
* (remember that it's preferable to check for specific features
* being present) */
xos_byte(osbyte_IN_KEY, 0, 0xff, &os_version, NULL);
+ ro_gui__check_os_alpha_sprites();
/* the first release version of the A9home OS is incapable of
plotting patterned lines (presumably a fault in the hw acceleration) */
diff --git a/frontends/riscos/gui.h b/frontends/riscos/gui.h
index 5ff17e9..03989ae 100644
--- a/frontends/riscos/gui.h
+++ b/frontends/riscos/gui.h
@@ -34,6 +34,8 @@
extern int os_version;
+extern bool os_alpha_sprite_supported;
+
extern const char * NETSURF_DIR;
struct toolbar;
diff --git a/frontends/riscos/image.c b/frontends/riscos/image.c
index 30cb300..0bad948 100644
--- a/frontends/riscos/image.c
+++ b/frontends/riscos/image.c
@@ -29,74 +29,6 @@
#include "riscos/gui.h"
#include "riscos/tinct.h"
-static bool image_redraw_tinct(osspriteop_id header, int x, int y,
- int req_width, int req_height, int width, int height,
- colour background_colour, bool repeatx, bool repeaty,
- bool alpha, unsigned int tinct_options);
-static bool image_redraw_os(osspriteop_id header, int x, int y,
- int req_width, int req_height, int width, int height);
-
-/**
- * Plot an image at the given coordinates using the method specified
- *
- * \param area The sprite area containing the sprite
- * \param x Left edge of sprite
- * \param y Top edge of sprite
- * \param req_width The requested width of the sprite
- * \param req_height The requested height of the sprite
- * \param width The actual width of the sprite
- * \param height The actual height of the sprite
- * \param background_colour The background colour to blend to
- * \param repeatx Repeat the image in the x direction
- * \param repeaty Repeat the image in the y direction
- * \param background Use background image settings (otherwise foreground)
- * \param type The plot method to use
- * \return true on success, false otherwise
- */
-bool image_redraw(osspriteop_area *area, int x, int y, int req_width,
- int req_height, int width, int height,
- colour background_colour,
- bool repeatx, bool repeaty, bool background, image_type type)
-{
- unsigned int tinct_options;
-
- /* failed decompression/loading can result in no image being present */
- if (!area)
- return false;
-
- osspriteop_id header = (osspriteop_id)
- ((char*) area + area->first);
- req_width *= 2;
- req_height *= 2;
- width *= 2;
- height *= 2;
- tinct_options = background ? nsoption_int(plot_bg_quality) :
- nsoption_int(plot_fg_quality);
- switch (type) {
- case IMAGE_PLOT_TINCT_ALPHA:
- return image_redraw_tinct(header, x, y,
- req_width, req_height,
- width, height,
- background_colour,
- repeatx, repeaty, true,
- tinct_options);
- case IMAGE_PLOT_TINCT_OPAQUE:
- return image_redraw_tinct(header, x, y,
- req_width, req_height,
- width, height,
- background_colour,
- repeatx, repeaty, false,
- tinct_options);
- case IMAGE_PLOT_OS:
- return image_redraw_os(header, x, y, req_width,
- req_height, width, height);
- default:
- break;
- }
-
- return false;
-}
-
/**
* Plot an image at the given coordinates using tinct
*
@@ -114,7 +46,7 @@ bool image_redraw(osspriteop_area *area, int x, int y, int req_width,
* \param tinct_options The base option set to use
* \return true on success, false otherwise
*/
-bool image_redraw_tinct(osspriteop_id header, int x, int y,
+static bool image_redraw_tinct(osspriteop_id header, int x, int y,
int req_width, int req_height, int width, int height,
colour background_colour, bool repeatx, bool repeaty,
bool alpha, unsigned int tinct_options)
@@ -150,7 +82,6 @@ bool image_redraw_tinct(osspriteop_id header, int x, int y,
return true;
}
-
/**
* Plot an image at the given coordinates using os_spriteop
*
@@ -161,10 +92,11 @@ bool image_redraw_tinct(osspriteop_id header, int x, int y,
* \param req_height The requested height of the sprite
* \param width The actual width of the sprite
* \param height The actual height of the sprite
+ * \param tile Whether to tile the sprite
* \return true on success, false otherwise
*/
-bool image_redraw_os(osspriteop_id header, int x, int y, int req_width,
- int req_height, int width, int height)
+static bool image_redraw_os(osspriteop_id header, int x, int y, int req_width,
+ int req_height, int width, int height, bool tile)
{
int size;
os_factors f;
@@ -172,7 +104,7 @@ bool image_redraw_os(osspriteop_id header, int x, int y, int req_width,
os_error *error;
error = xcolourtrans_generate_table_for_sprite(
- (osspriteop_area *)0x100, header,
+ osspriteop_UNSPECIFIED, header,
os_CURRENT_MODE,
colourtrans_CURRENT_PALETTE,
0, colourtrans_GIVEN_SPRITE, 0, 0, &size);
@@ -192,7 +124,7 @@ bool image_redraw_os(osspriteop_id header, int x, int y, int req_width,
}
error = xcolourtrans_generate_table_for_sprite(
- (osspriteop_area *)0x100, header,
+ osspriteop_UNSPECIFIED, header,
os_CURRENT_MODE,
colourtrans_CURRENT_PALETTE,
table, colourtrans_GIVEN_SPRITE, 0, 0, 0);
@@ -210,10 +142,17 @@ bool image_redraw_os(osspriteop_id header, int x, int y, int req_width,
f.xdiv = width;
f.ydiv = height;
- error = xosspriteop_put_sprite_scaled(osspriteop_PTR,
- (osspriteop_area *)0x100, header,
- x, (int)(y - req_height),
- 8, &f, table);
+ if (tile) {
+ error = xosspriteop_plot_tiled_sprite(osspriteop_PTR,
+ osspriteop_UNSPECIFIED, header,
+ x, (int)(y - req_height),
+ osspriteop_USE_MASK, &f, table);
+ } else {
+ error = xosspriteop_put_sprite_scaled(osspriteop_PTR,
+ osspriteop_UNSPECIFIED, header,
+ x, (int)(y - req_height),
+ osspriteop_USE_MASK, &f, table);
+ }
if (error) {
NSLOG(netsurf, INFO,
"xosspriteop_put_sprite_scaled: 0x%x: %s",
@@ -227,3 +166,117 @@ bool image_redraw_os(osspriteop_id header, int x, int y, int req_width,
return true;
}
+
+/**
+ * Override a sprite's mode.
+ *
+ * Only replaces mode if existing mode matches \ref old.
+ *
+ * \param[in] area The sprite area containing the sprite.
+ * \param[in] old Existing sprite mode to check for.
+ * \param[in] new Sprite mode to set if existing mode is expected.
+ */
+static inline void image__override_sprite_mode(
+ osspriteop_area *area,
+ os_mode old,
+ os_mode new)
+{
+ osspriteop_header *sprite = (osspriteop_header *)(area + 1);
+
+ if (sprite->mode == old) {
+ sprite->mode = new;
+ }
+}
+
+/**
+ * Plot an image at the given coordinates using the method specified
+ *
+ * \param area The sprite area containing the sprite
+ * \param x Left edge of sprite
+ * \param y Top edge of sprite
+ * \param req_width The requested width of the sprite
+ * \param req_height The requested height of the sprite
+ * \param width The actual width of the sprite
+ * \param height The actual height of the sprite
+ * \param background_colour The background colour to blend to
+ * \param repeatx Repeat the image in the x direction
+ * \param repeaty Repeat the image in the y direction
+ * \param background Use background image settings (otherwise foreground)
+ * \param type The plot method to use
+ * \return true on success, false otherwise
+ */
+bool image_redraw(osspriteop_area *area, int x, int y, int req_width,
+ int req_height, int width, int height,
+ colour background_colour,
+ bool repeatx, bool repeaty, bool background, image_type type)
+{
+ unsigned int tinct_options;
+ bool tinct_avoid = false;
+ bool res = false;
+
+ /* failed decompression/loading can result in no image being present */
+ if (!area)
+ return false;
+
+ osspriteop_id header = (osspriteop_id)
+ ((char*) area + area->first);
+ req_width *= 2;
+ req_height *= 2;
+ width *= 2;
+ height *= 2;
+ tinct_options = background ? nsoption_int(plot_bg_quality) :
+ nsoption_int(plot_fg_quality);
+
+ if (os_alpha_sprite_supported) {
+ /* Ideally Tinct would be updated to understand that modern OS
+ * versions can cope with alpha channels, and we could continue
+ * to pass to Tinct. The main drawback of fully avoiding Tinct
+ * is that we lose the optimisation for tiling tiny bitmaps.
+ */
+ if (tinct_options & tinct_USE_OS_SPRITE_OP) {
+ type = IMAGE_PLOT_OS;
+ tinct_avoid = true;
+ }
+ }
+
+ switch (type) {
+ case IMAGE_PLOT_TINCT_ALPHA:
+ res = image_redraw_tinct(header, x, y,
+ req_width, req_height,
+ width, height,
+ background_colour,
+ repeatx, repeaty, true,
+ tinct_options);
+ break;
+
+ case IMAGE_PLOT_TINCT_OPAQUE:
+ res = image_redraw_tinct(header, x, y,
+ req_width, req_height,
+ width, height,
+ background_colour,
+ repeatx, repeaty, false,
+ tinct_options);
+ break;
+
+ case IMAGE_PLOT_OS:
+ if (tinct_avoid) {
+ image__override_sprite_mode(area,
+ tinct_SPRITE_MODE,
+ alpha_SPRITE_MODE);
+ }
+ res = image_redraw_os(header, x, y, req_width,
+ req_height, width, height,
+ repeatx | repeaty);
+ if (tinct_avoid) {
+ image__override_sprite_mode(area,
+ alpha_SPRITE_MODE,
+ tinct_SPRITE_MODE);
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ return res;
+}
diff --git a/frontends/riscos/tinct.h b/frontends/riscos/tinct.h
index e02dcde..2931372 100644
--- a/frontends/riscos/tinct.h
+++ b/frontends/riscos/tinct.h
@@ -148,7 +148,16 @@
*/
#define tinct_BACKGROUND_SHIFT 0x08
-/* Sprite mode
-*/
+/* Sprite mode tinct
+ *
+ * Mode is: 32bpp 8:8:8:8 XXBBGGRR mode (a RISC OS 3.5+ type)
+ * We put alpha in the unused XX channel and Tinct treats it as alpha.
+ */
#define tinct_SPRITE_MODE (os_mode)0x301680b5
+
+/* Sprite mode alpha
+ *
+ * Mode is: 32bpp 8:8:8:8 AABBGGRR mode (a RISC OS 5 type)
+ */
+#define alpha_SPRITE_MODE (os_mode)0x78608051
#endif
--
NetSurf Browser
2 years, 3 months
libdom: branch master updated. release/0.4.1-10-g77c2920
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/libdom.git/shortlog/77c29208368a77524e24a4...
...commit http://git.netsurf-browser.org/libdom.git/commit/77c29208368a77524e24a419...
...tree http://git.netsurf-browser.org/libdom.git/tree/77c29208368a77524e24a41923...
The branch, master has been updated
via 77c29208368a77524e24a419238529edeec82c4d (commit)
from ac5f4ce817d1421798aa4b94daee8deb84e40f76 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/libdom.git/commit/?id=77c29208368a77524e24...
commit 77c29208368a77524e24a419238529edeec82c4d
Author: Michael Drake <michael.drake(a)codethink.co.uk>
Commit: Michael Drake <michael.drake(a)codethink.co.uk>
Buildsystem: LibDOM depends on LibWapcaplet.
This fixes the installed pkgconfig file to express the dependency
on libwapcaplet.
diff --git a/Makefile b/Makefile
index 5690403..4b82106 100644
--- a/Makefile
+++ b/Makefile
@@ -149,6 +149,8 @@ INSTALL_ITEMS := $(INSTALL_ITEMS) $(I):$(Is)/html_isindex_element.h
INSTALL_ITEMS := $(INSTALL_ITEMS) /$(LIBDIR)/pkgconfig:lib$(COMPONENT).pc.in
INSTALL_ITEMS := $(INSTALL_ITEMS) /$(LIBDIR):$(OUTPUT)
+REQUIRED_PKGS := $(REQUIRED_PKGS) libwapcaplet
+
ifeq ($(WITH_LIBXML_BINDING),yes)
REQUIRED_PKGS := $(REQUIRED_PKGS) libxml-2.0
endif
-----------------------------------------------------------------------
Summary of changes:
Makefile | 2 ++
1 file changed, 2 insertions(+)
diff --git a/Makefile b/Makefile
index 5690403..4b82106 100644
--- a/Makefile
+++ b/Makefile
@@ -149,6 +149,8 @@ INSTALL_ITEMS := $(INSTALL_ITEMS) $(I):$(Is)/html_isindex_element.h
INSTALL_ITEMS := $(INSTALL_ITEMS) /$(LIBDIR)/pkgconfig:lib$(COMPONENT).pc.in
INSTALL_ITEMS := $(INSTALL_ITEMS) /$(LIBDIR):$(OUTPUT)
+REQUIRED_PKGS := $(REQUIRED_PKGS) libwapcaplet
+
ifeq ($(WITH_LIBXML_BINDING),yes)
REQUIRED_PKGS := $(REQUIRED_PKGS) libxml-2.0
endif
--
Document Object Model library
2 years, 3 months
netsurf-website: branch master updated. 0877e3a1bb6d08abc5bdd0a9f51f570e1ed139e5
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf-website.git/shortlog/0877e3a1bb6d0...
...commit http://git.netsurf-browser.org/netsurf-website.git/commit/0877e3a1bb6d08a...
...tree http://git.netsurf-browser.org/netsurf-website.git/tree/0877e3a1bb6d08abc...
The branch, master has been updated
via 0877e3a1bb6d08abc5bdd0a9f51f570e1ed139e5 (commit)
from 3f189f1d8a5107d5d5e4f8ff8b461f7c1ec33a30 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf-website.git/commit/?id=0877e3a1bb6...
commit 0877e3a1bb6d08abc5bdd0a9f51f570e1ed139e5
Author: Michael Drake <michael.drake(a)codethink.co.uk>
Commit: Michael Drake <michael.drake(a)codethink.co.uk>
Tinct: Fix download link.
diff --git a/projects/tinct/index.html b/projects/tinct/index.html
index 635cddc..f2b22e3 100644
--- a/projects/tinct/index.html
+++ b/projects/tinct/index.html
@@ -3,7 +3,7 @@
<html>
<head>
<title>Tinct for RISC OS</title>
-<link rel="stylesheet" type="text/css" href="../../projects/projects.css">
+<link rel="stylesheet" type="text/css" href="/projects/projects.css">
<link rel="icon" type="image/png" href="/webimages/favicon.png">
</head>
<body>
@@ -52,7 +52,7 @@ in touch.</p>
<h2>Download</h2>
-<p>Please visit the <a href="http://www.tinct.net/tinct.asp">Tinct web site</a> to download Tinct.</p>
+<p>Please visit the <a href="http://www.tinct.net/Downloads/Tinct.aspx">Tinct web site</a> to download Tinct.</p>
<h2>Contact</h2>
-----------------------------------------------------------------------
Summary of changes:
projects/tinct/index.html | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/projects/tinct/index.html b/projects/tinct/index.html
index 635cddc..f2b22e3 100644
--- a/projects/tinct/index.html
+++ b/projects/tinct/index.html
@@ -3,7 +3,7 @@
<html>
<head>
<title>Tinct for RISC OS</title>
-<link rel="stylesheet" type="text/css" href="../../projects/projects.css">
+<link rel="stylesheet" type="text/css" href="/projects/projects.css">
<link rel="icon" type="image/png" href="/webimages/favicon.png">
</head>
<body>
@@ -52,7 +52,7 @@ in touch.</p>
<h2>Download</h2>
-<p>Please visit the <a href="http://www.tinct.net/tinct.asp">Tinct web site</a> to download Tinct.</p>
+<p>Please visit the <a href="http://www.tinct.net/Downloads/Tinct.aspx">Tinct web site</a> to download Tinct.</p>
<h2>Contact</h2>
--
NetSurf website source for *.netsurf-browser.org
2 years, 3 months