Commit ce1a41cd authored by Tavmjong Bah's avatar Tavmjong Bah Committed by Tavmjong Bah

Render mesh gradients that reference other mesh gradients.

(bzr r15163)
parent 09a4b15b
......@@ -1144,15 +1144,17 @@ sp_gradient_pattern_common_setup(cairo_pattern_t *cp,
}
// add stops
for (std::vector<SPGradientStop>::iterator i = gr->vector.stops.begin();
i != gr->vector.stops.end(); ++i)
{
// multiply stop opacity by paint opacity
cairo_pattern_add_color_stop_rgba(cp, i->offset,
i->color.v.c[0], i->color.v.c[1], i->color.v.c[2], i->opacity * opacity);
if (!SP_IS_MESHGRADIENT(gr)) {
for (std::vector<SPGradientStop>::iterator i = gr->vector.stops.begin();
i != gr->vector.stops.end(); ++i)
{
// multiply stop opacity by paint opacity
cairo_pattern_add_color_stop_rgba(cp, i->offset,
i->color.v.c[0], i->color.v.c[1], i->color.v.c[2], i->opacity * opacity);
}
}
// set pattern matrix
// set pattern transform matrix
Geom::Affine gs2user = gr->gradientTransform;
if (gr->getUnits() == SP_GRADIENT_UNITS_OBJECTBOUNDINGBOX && bbox) {
Geom::Affine bbox2user(bbox->width(), 0, 0, bbox->height(), bbox->left(), bbox->top());
......
......@@ -678,11 +678,17 @@ SPMeshNodeArray& SPMeshNodeArray::operator=( const SPMeshNodeArray& rhs ) {
bool SPMeshNodeArray::read( SPMeshGradient *mg_in ) {
mg = mg_in;
SPMeshGradient* mg_array = dynamic_cast<SPMeshGradient*>(mg->getArray());
if (!mg_array) {
std::cerr << "SPMeshNodeArray::read: No mesh array!" << std::endl;
return false;
}
// std::cout << "SPMeshNodeArray::read: " << mg_in << " array: " << mg_array << std::endl;
// Count rows and columns, if unchanged reuse array to keep draggers valid.
unsigned cols = 0;
unsigned rows = 0;
for (auto& ro: mg->children) {
for (auto& ro: mg_array->children) {
if (SP_IS_MESHROW(&ro)) {
++rows;
if (rows == 1 ) {
......@@ -707,7 +713,7 @@ bool SPMeshNodeArray::read( SPMeshGradient *mg_in ) {
guint max_column = 0;
guint irow = 0; // Corresponds to top of patch being read in.
for (auto& ro: mg->children) {
for (auto& ro: mg_array->children) {
if (SP_IS_MESHROW(&ro)) {
......@@ -921,10 +927,16 @@ void SPMeshNodeArray::write( SPMeshGradient *mg ) {
using Geom::X;
using Geom::Y;
SPMeshGradient* mg_array = dynamic_cast<SPMeshGradient*>(mg->getArray());
if (!mg_array) {
std::cerr << "SPMeshNodeArray::write: missing patches!" << std::endl;
mg_array = mg;
}
// First we must delete reprs for old mesh rows and patches.
GSList *descendant_reprs = NULL;
GSList *descendant_objects = NULL;
for (auto& row: mg->children) {
for (auto& row: mg_array->children) {
descendant_reprs = g_slist_prepend (descendant_reprs, row.getRepr());
descendant_objects = g_slist_prepend (descendant_objects, &row);
for (auto& patch: row.children) {
......@@ -950,8 +962,9 @@ void SPMeshNodeArray::write( SPMeshGradient *mg ) {
// Now we build new reprs
Inkscape::XML::Node *mesh = mg->getRepr();
Inkscape::XML::Node *mesh_array = mg_array->getRepr();
SPMeshNodeArray* array = &(mg->array);
SPMeshNodeArray* array = &(mg_array->array);
SPMeshPatchI patch0( &(array->nodes), 0, 0 );
Geom::Point current_p = patch0.getPoint( 0, 0 ); // Side 0, point 0
......@@ -966,7 +979,7 @@ void SPMeshNodeArray::write( SPMeshGradient *mg ) {
// Write row
Inkscape::XML::Node *row = xml_doc->createElement("svg:meshrow");
mesh->appendChild( row ); // No attributes
mesh_array->appendChild( row ); // No attributes
guint columns = array->patch_columns();
for( guint j = 0; j < columns; ++j ) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment