michael@0: /* michael@0: * Copyright 2009, The Android Open Source Project michael@0: * michael@0: * Redistribution and use in source and binary forms, with or without michael@0: * modification, are permitted provided that the following conditions michael@0: * are met: michael@0: * * Redistributions of source code must retain the above copyright michael@0: * notice, this list of conditions and the following disclaimer. michael@0: * * Redistributions in binary form must reproduce the above copyright michael@0: * notice, this list of conditions and the following disclaimer in the michael@0: * documentation and/or other materials provided with the distribution. michael@0: * michael@0: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY michael@0: * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE michael@0: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR michael@0: * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR michael@0: * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, michael@0: * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, michael@0: * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR michael@0: * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY michael@0: * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT michael@0: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE michael@0: * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. michael@0: */ michael@0: michael@0: // must include config.h first for webkit to fiddle with new/delete michael@0: #include "SkANP.h" michael@0: michael@0: static ANPPath* anp_newPath() { michael@0: return new ANPPath; michael@0: } michael@0: michael@0: static void anp_deletePath(ANPPath* path) { michael@0: delete path; michael@0: } michael@0: michael@0: static void anp_copy(ANPPath* dst, const ANPPath* src) { michael@0: *dst = *src; michael@0: } michael@0: michael@0: static bool anp_equal(const ANPPath* p0, const ANPPath* p1) { michael@0: return *p0 == *p1; michael@0: } michael@0: michael@0: static void anp_reset(ANPPath* path) { michael@0: path->reset(); michael@0: } michael@0: michael@0: static bool anp_isEmpty(const ANPPath* path) { michael@0: return path->isEmpty(); michael@0: } michael@0: michael@0: static void anp_getBounds(const ANPPath* path, ANPRectF* bounds) { michael@0: SkANP::SetRect(bounds, path->getBounds()); michael@0: } michael@0: michael@0: static void anp_moveTo(ANPPath* path, float x, float y) { michael@0: path->moveTo(SkFloatToScalar(x), SkFloatToScalar(y)); michael@0: } michael@0: michael@0: static void anp_lineTo(ANPPath* path, float x, float y) { michael@0: path->lineTo(SkFloatToScalar(x), SkFloatToScalar(y)); michael@0: } michael@0: michael@0: static void anp_quadTo(ANPPath* path, float x0, float y0, float x1, float y1) { michael@0: path->quadTo(SkFloatToScalar(x0), SkFloatToScalar(y0), michael@0: SkFloatToScalar(x1), SkFloatToScalar(y1)); michael@0: } michael@0: michael@0: static void anp_cubicTo(ANPPath* path, float x0, float y0, michael@0: float x1, float y1, float x2, float y2) { michael@0: path->cubicTo(SkFloatToScalar(x0), SkFloatToScalar(y0), michael@0: SkFloatToScalar(x1), SkFloatToScalar(y1), michael@0: SkFloatToScalar(x2), SkFloatToScalar(y2)); michael@0: } michael@0: michael@0: static void anp_close(ANPPath* path) { michael@0: path->close(); michael@0: } michael@0: michael@0: static void anp_offset(ANPPath* path, float dx, float dy, ANPPath* dst) { michael@0: path->offset(SkFloatToScalar(dx), SkFloatToScalar(dy), dst); michael@0: } michael@0: michael@0: static void anp_transform(ANPPath* src, const ANPMatrix* matrix, michael@0: ANPPath* dst) { michael@0: src->transform(*matrix, dst); michael@0: } michael@0: michael@0: /////////////////////////////////////////////////////////////////////////////// michael@0: michael@0: #define ASSIGN(obj, name) (obj)->name = anp_##name michael@0: michael@0: void InitPathInterface(ANPPathInterfaceV0* i) { michael@0: ASSIGN(i, newPath); michael@0: ASSIGN(i, deletePath); michael@0: ASSIGN(i, copy); michael@0: ASSIGN(i, equal); michael@0: ASSIGN(i, reset); michael@0: ASSIGN(i, isEmpty); michael@0: ASSIGN(i, getBounds); michael@0: ASSIGN(i, moveTo); michael@0: ASSIGN(i, lineTo); michael@0: ASSIGN(i, quadTo); michael@0: ASSIGN(i, cubicTo); michael@0: ASSIGN(i, close); michael@0: ASSIGN(i, offset); michael@0: ASSIGN(i, transform); michael@0: }