other-licenses/skia-npapi/SkANP.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 /*
michael@0 2 * Copyright 2008, 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 #ifndef SkANP_DEFINED
michael@0 27 #define SkANP_DEFINED
michael@0 28
michael@0 29 #include "android_npapi.h"
michael@0 30 #include "SkCanvas.h"
michael@0 31 #include "SkMatrix.h"
michael@0 32 #include "SkPaint.h"
michael@0 33 #include "SkPath.h"
michael@0 34 #include "SkTypeface.h"
michael@0 35
michael@0 36 struct ANPMatrix : SkMatrix {
michael@0 37 };
michael@0 38
michael@0 39 struct ANPPath : SkPath {
michael@0 40 };
michael@0 41
michael@0 42 struct ANPPaint : SkPaint {
michael@0 43 };
michael@0 44
michael@0 45 struct ANPTypeface : SkTypeface {
michael@0 46 };
michael@0 47
michael@0 48 struct ANPCanvas {
michael@0 49 SkCanvas* skcanvas;
michael@0 50
michael@0 51 // draw into the specified bitmap
michael@0 52 explicit ANPCanvas(const SkBitmap& bm) {
michael@0 53 skcanvas = new SkCanvas(bm);
michael@0 54 }
michael@0 55
michael@0 56 // redirect all drawing to the specific SkCanvas
michael@0 57 explicit ANPCanvas(SkCanvas* other) {
michael@0 58 skcanvas = other;
michael@0 59 skcanvas->ref();
michael@0 60 }
michael@0 61
michael@0 62 ~ANPCanvas() {
michael@0 63 skcanvas->unref();
michael@0 64 }
michael@0 65 };
michael@0 66
michael@0 67 class SkANP {
michael@0 68 public:
michael@0 69 static SkRect* SetRect(SkRect* dst, const ANPRectF& src);
michael@0 70 static SkIRect* SetRect(SkIRect* dst, const ANPRectI& src);
michael@0 71 static ANPRectI* SetRect(ANPRectI* dst, const SkIRect& src);
michael@0 72 static ANPRectF* SetRect(ANPRectF* dst, const SkRect& src);
michael@0 73 static SkBitmap* SetBitmap(SkBitmap* dst, const ANPBitmap& src);
michael@0 74 static bool SetBitmap(ANPBitmap* dst, const SkBitmap& src);
michael@0 75
michael@0 76 static void InitEvent(ANPEvent* event, ANPEventType et);
michael@0 77 };
michael@0 78
michael@0 79 #endif

mercurial