Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* |
michael@0 | 2 | * Copyright 2009, The Android Open Source Project |
michael@0 | 3 | * |
michael@0 | 4 | * Redistribution and use in source and binary forms, with or without |
michael@0 | 5 | * modification, are permitted provided that the following conditions |
michael@0 | 6 | * are met: |
michael@0 | 7 | * * Redistributions of source code must retain the above copyright |
michael@0 | 8 | * notice, this list of conditions and the following disclaimer. |
michael@0 | 9 | * * Redistributions in binary form must reproduce the above copyright |
michael@0 | 10 | * notice, this list of conditions and the following disclaimer in the |
michael@0 | 11 | * documentation and/or other materials provided with the distribution. |
michael@0 | 12 | * |
michael@0 | 13 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY |
michael@0 | 14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
michael@0 | 15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
michael@0 | 16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
michael@0 | 17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
michael@0 | 18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
michael@0 | 19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
michael@0 | 20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
michael@0 | 21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
michael@0 | 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
michael@0 | 23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
michael@0 | 24 | */ |
michael@0 | 25 | |
michael@0 | 26 | // must include config.h first for webkit to fiddle with new/delete |
michael@0 | 27 | #include "SkANP.h" |
michael@0 | 28 | |
michael@0 | 29 | static ANPPath* anp_newPath() { |
michael@0 | 30 | return new ANPPath; |
michael@0 | 31 | } |
michael@0 | 32 | |
michael@0 | 33 | static void anp_deletePath(ANPPath* path) { |
michael@0 | 34 | delete path; |
michael@0 | 35 | } |
michael@0 | 36 | |
michael@0 | 37 | static void anp_copy(ANPPath* dst, const ANPPath* src) { |
michael@0 | 38 | *dst = *src; |
michael@0 | 39 | } |
michael@0 | 40 | |
michael@0 | 41 | static bool anp_equal(const ANPPath* p0, const ANPPath* p1) { |
michael@0 | 42 | return *p0 == *p1; |
michael@0 | 43 | } |
michael@0 | 44 | |
michael@0 | 45 | static void anp_reset(ANPPath* path) { |
michael@0 | 46 | path->reset(); |
michael@0 | 47 | } |
michael@0 | 48 | |
michael@0 | 49 | static bool anp_isEmpty(const ANPPath* path) { |
michael@0 | 50 | return path->isEmpty(); |
michael@0 | 51 | } |
michael@0 | 52 | |
michael@0 | 53 | static void anp_getBounds(const ANPPath* path, ANPRectF* bounds) { |
michael@0 | 54 | SkANP::SetRect(bounds, path->getBounds()); |
michael@0 | 55 | } |
michael@0 | 56 | |
michael@0 | 57 | static void anp_moveTo(ANPPath* path, float x, float y) { |
michael@0 | 58 | path->moveTo(SkFloatToScalar(x), SkFloatToScalar(y)); |
michael@0 | 59 | } |
michael@0 | 60 | |
michael@0 | 61 | static void anp_lineTo(ANPPath* path, float x, float y) { |
michael@0 | 62 | path->lineTo(SkFloatToScalar(x), SkFloatToScalar(y)); |
michael@0 | 63 | } |
michael@0 | 64 | |
michael@0 | 65 | static void anp_quadTo(ANPPath* path, float x0, float y0, float x1, float y1) { |
michael@0 | 66 | path->quadTo(SkFloatToScalar(x0), SkFloatToScalar(y0), |
michael@0 | 67 | SkFloatToScalar(x1), SkFloatToScalar(y1)); |
michael@0 | 68 | } |
michael@0 | 69 | |
michael@0 | 70 | static void anp_cubicTo(ANPPath* path, float x0, float y0, |
michael@0 | 71 | float x1, float y1, float x2, float y2) { |
michael@0 | 72 | path->cubicTo(SkFloatToScalar(x0), SkFloatToScalar(y0), |
michael@0 | 73 | SkFloatToScalar(x1), SkFloatToScalar(y1), |
michael@0 | 74 | SkFloatToScalar(x2), SkFloatToScalar(y2)); |
michael@0 | 75 | } |
michael@0 | 76 | |
michael@0 | 77 | static void anp_close(ANPPath* path) { |
michael@0 | 78 | path->close(); |
michael@0 | 79 | } |
michael@0 | 80 | |
michael@0 | 81 | static void anp_offset(ANPPath* path, float dx, float dy, ANPPath* dst) { |
michael@0 | 82 | path->offset(SkFloatToScalar(dx), SkFloatToScalar(dy), dst); |
michael@0 | 83 | } |
michael@0 | 84 | |
michael@0 | 85 | static void anp_transform(ANPPath* src, const ANPMatrix* matrix, |
michael@0 | 86 | ANPPath* dst) { |
michael@0 | 87 | src->transform(*matrix, dst); |
michael@0 | 88 | } |
michael@0 | 89 | |
michael@0 | 90 | /////////////////////////////////////////////////////////////////////////////// |
michael@0 | 91 | |
michael@0 | 92 | #define ASSIGN(obj, name) (obj)->name = anp_##name |
michael@0 | 93 | |
michael@0 | 94 | void InitPathInterface(ANPPathInterfaceV0* i) { |
michael@0 | 95 | ASSIGN(i, newPath); |
michael@0 | 96 | ASSIGN(i, deletePath); |
michael@0 | 97 | ASSIGN(i, copy); |
michael@0 | 98 | ASSIGN(i, equal); |
michael@0 | 99 | ASSIGN(i, reset); |
michael@0 | 100 | ASSIGN(i, isEmpty); |
michael@0 | 101 | ASSIGN(i, getBounds); |
michael@0 | 102 | ASSIGN(i, moveTo); |
michael@0 | 103 | ASSIGN(i, lineTo); |
michael@0 | 104 | ASSIGN(i, quadTo); |
michael@0 | 105 | ASSIGN(i, cubicTo); |
michael@0 | 106 | ASSIGN(i, close); |
michael@0 | 107 | ASSIGN(i, offset); |
michael@0 | 108 | ASSIGN(i, transform); |
michael@0 | 109 | } |