other-licenses/skia-npapi/ANPPath.cpp

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/other-licenses/skia-npapi/ANPPath.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,109 @@
     1.4 +/*
     1.5 + * Copyright 2009, The Android Open Source Project
     1.6 + *
     1.7 + * Redistribution and use in source and binary forms, with or without
     1.8 + * modification, are permitted provided that the following conditions
     1.9 + * are met:
    1.10 + *  * Redistributions of source code must retain the above copyright
    1.11 + *    notice, this list of conditions and the following disclaimer.
    1.12 + *  * Redistributions in binary form must reproduce the above copyright
    1.13 + *    notice, this list of conditions and the following disclaimer in the
    1.14 + *    documentation and/or other materials provided with the distribution.
    1.15 + *
    1.16 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
    1.17 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    1.18 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
    1.19 + * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
    1.20 + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
    1.21 + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
    1.22 + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
    1.23 + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
    1.24 + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    1.25 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    1.26 + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    1.27 + */
    1.28 +
    1.29 +// must include config.h first for webkit to fiddle with new/delete
    1.30 +#include "SkANP.h"
    1.31 +
    1.32 +static ANPPath* anp_newPath() {
    1.33 +    return new ANPPath;
    1.34 +}
    1.35 +
    1.36 +static void anp_deletePath(ANPPath* path) {
    1.37 +    delete path;
    1.38 +}
    1.39 +
    1.40 +static void anp_copy(ANPPath* dst, const ANPPath* src) {
    1.41 +    *dst = *src;
    1.42 +}
    1.43 +
    1.44 +static bool anp_equal(const ANPPath* p0, const ANPPath* p1) {
    1.45 +    return *p0 == *p1;
    1.46 +}
    1.47 +
    1.48 +static void anp_reset(ANPPath* path) {
    1.49 +    path->reset();
    1.50 +}
    1.51 +
    1.52 +static bool anp_isEmpty(const ANPPath* path) {
    1.53 +    return path->isEmpty();
    1.54 +}
    1.55 +
    1.56 +static void anp_getBounds(const ANPPath* path, ANPRectF* bounds) {
    1.57 +    SkANP::SetRect(bounds, path->getBounds());
    1.58 +}
    1.59 +
    1.60 +static void anp_moveTo(ANPPath* path, float x, float y) {
    1.61 +    path->moveTo(SkFloatToScalar(x), SkFloatToScalar(y));
    1.62 +}
    1.63 +
    1.64 +static void anp_lineTo(ANPPath* path, float x, float y) {
    1.65 +    path->lineTo(SkFloatToScalar(x), SkFloatToScalar(y));
    1.66 +}
    1.67 +
    1.68 +static void anp_quadTo(ANPPath* path, float x0, float y0, float x1, float y1) {
    1.69 +    path->quadTo(SkFloatToScalar(x0), SkFloatToScalar(y0),
    1.70 +                 SkFloatToScalar(x1), SkFloatToScalar(y1));
    1.71 +}
    1.72 +
    1.73 +static void anp_cubicTo(ANPPath* path, float x0, float y0,
    1.74 +                        float x1, float y1, float x2, float y2) {
    1.75 +    path->cubicTo(SkFloatToScalar(x0), SkFloatToScalar(y0),
    1.76 +                  SkFloatToScalar(x1), SkFloatToScalar(y1),
    1.77 +                  SkFloatToScalar(x2), SkFloatToScalar(y2));
    1.78 +}
    1.79 +
    1.80 +static void anp_close(ANPPath* path) {
    1.81 +    path->close();
    1.82 +}
    1.83 +
    1.84 +static void anp_offset(ANPPath* path, float dx, float dy, ANPPath* dst) {
    1.85 +    path->offset(SkFloatToScalar(dx), SkFloatToScalar(dy), dst);
    1.86 +}
    1.87 +
    1.88 +static void anp_transform(ANPPath* src, const ANPMatrix* matrix,
    1.89 +                          ANPPath* dst) {
    1.90 +    src->transform(*matrix, dst);
    1.91 +}
    1.92 +
    1.93 +///////////////////////////////////////////////////////////////////////////////
    1.94 +
    1.95 +#define ASSIGN(obj, name)   (obj)->name = anp_##name
    1.96 +
    1.97 +void InitPathInterface(ANPPathInterfaceV0* i) {
    1.98 +    ASSIGN(i, newPath);
    1.99 +    ASSIGN(i, deletePath);
   1.100 +    ASSIGN(i, copy);
   1.101 +    ASSIGN(i, equal);
   1.102 +    ASSIGN(i, reset);
   1.103 +    ASSIGN(i, isEmpty);
   1.104 +    ASSIGN(i, getBounds);
   1.105 +    ASSIGN(i, moveTo);
   1.106 +    ASSIGN(i, lineTo);
   1.107 +    ASSIGN(i, quadTo);
   1.108 +    ASSIGN(i, cubicTo);
   1.109 +    ASSIGN(i, close);
   1.110 +    ASSIGN(i, offset);
   1.111 +    ASSIGN(i, transform);
   1.112 +}

mercurial