All Downloads are FREE. Search and download functionalities are using the official Maven repository.

native-prism.Dasher.h Maven / Gradle / Ivy

/*
 * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This code is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 only, as
 * published by the Free Software Foundation.  Oracle designates this
 * particular file as subject to the "Classpath" exception as provided
 * by Oracle in the LICENSE file that accompanied this code.
 *
 * This code is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * version 2 for more details (a copy is included in the LICENSE file that
 * accompanied this code).
 *
 * You should have received a copy of the GNU General Public License version
 * 2 along with this work; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 * or visit www.oracle.com if you need additional information or have any
 * questions.
 */

#ifndef DASHER_H
#define DASHER_H

#ifdef __cplusplus
extern "C" {
#endif

enum Side {LEFT, RIGHT};

typedef struct {
    // Objects of this class are used to iterate through curves. They return
    // t values where the left side of the curve has a specified length.
    // It does this by subdividing the input curve until a certain error
    // condition has been met. A recursive subdivision procedure would
    // return as many as 1<= 0.
    jfloat flatLeafCoefCache[4];
} LengthIterator;

typedef struct {
    PathConsumer consumer;
    PathConsumer *out;

    jfloat *dash;
    jint numdashes;
    jfloat startPhase;
    jboolean startDashOn;
    jint startIdx;

    jboolean starting;
    jboolean needsMoveTo;

    jint idx;
    jboolean dashOn;
    jfloat phase;

    jfloat sx, sy;
    jfloat x0, y0;

    // temporary storage for the current curve
    jfloat curCurvepts[8 * 2];

    // We don't emit the first dash right away. If we did, caps would be
    // drawn on it, but we need joins to be drawn if there's a closePath()
    // So, we store the path elements that make up the first dash in the
    // buffer below.
    jint firstSegmentsBufferSIZE /* = 7*/;
    jfloat *firstSegmentsBuffer /* = malloc(firstSegmentsBufferSIZE * sizeof(jfloat))*/;
    jint firstSegidx /* = 0*/;

    LengthIterator li;
} Dasher;

void Dasher_init(Dasher *pDasher,
                 PathConsumer *out,
                 jfloat dash[], jint numdashes,
                 jfloat phase);

void Dasher_reset(Dasher *pDasher, jfloat dash[], jint ndashes, jfloat phase);

void Dasher_destroy(Dasher *pDasher);

#ifdef __cplusplus
}
#endif

#endif /* DASHER_H */





© 2015 - 2024 Weber Informatics LLC | Privacy Policy