gfx/skia/trunk/include/core/SkAnnotation.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/skia/trunk/include/core/SkAnnotation.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,123 @@
     1.4 +/*
     1.5 + * Copyright 2012 Google Inc.
     1.6 + *
     1.7 + * Use of this source code is governed by a BSD-style license that can be
     1.8 + * found in the LICENSE file.
     1.9 + */
    1.10 +
    1.11 +#ifndef SkAnnotation_DEFINED
    1.12 +#define SkAnnotation_DEFINED
    1.13 +
    1.14 +#include "SkRefCnt.h"
    1.15 +#include "SkString.h"
    1.16 +
    1.17 +class SkData;
    1.18 +class SkReadBuffer;
    1.19 +class SkWriteBuffer;
    1.20 +class SkStream;
    1.21 +class SkWStream;
    1.22 +struct SkPoint;
    1.23 +
    1.24 +/**
    1.25 + *  Experimental class for annotating draws. Do not use directly yet.
    1.26 + *  Use helper functions at the bottom of this file for now.
    1.27 + */
    1.28 +class SkAnnotation : public SkRefCnt {
    1.29 +public:
    1.30 +    virtual ~SkAnnotation();
    1.31 +
    1.32 +    static SkAnnotation* Create(const char key[], SkData* value) {
    1.33 +        return SkNEW_ARGS(SkAnnotation, (key, value));
    1.34 +    }
    1.35 +
    1.36 +    static SkAnnotation* Create(SkReadBuffer& buffer) {
    1.37 +        return SkNEW_ARGS(SkAnnotation, (buffer));
    1.38 +    }
    1.39 +
    1.40 +    /**
    1.41 +     *  Return the data for the specified key, or NULL.
    1.42 +     */
    1.43 +    SkData* find(const char key[]) const;
    1.44 +
    1.45 +    void writeToBuffer(SkWriteBuffer&) const;
    1.46 +
    1.47 +private:
    1.48 +    SkAnnotation(const char key[], SkData* value);
    1.49 +    SkAnnotation(SkReadBuffer&);
    1.50 +
    1.51 +    SkString    fKey;
    1.52 +    SkData*     fData;
    1.53 +
    1.54 +    typedef SkRefCnt INHERITED;
    1.55 +};
    1.56 +
    1.57 +/**
    1.58 + *  Experimental collection of predefined Keys into the Annotation dictionary
    1.59 + */
    1.60 +class SkAnnotationKeys {
    1.61 +public:
    1.62 +    /**
    1.63 +     *  Returns the canonical key whose payload is a URL
    1.64 +     */
    1.65 +    static const char* URL_Key();
    1.66 +
    1.67 +    /**
    1.68 +     *  Returns the canonical key whose payload is the name of a destination to
    1.69 +     *  be defined.
    1.70 +     */
    1.71 +    static const char* Define_Named_Dest_Key();
    1.72 +
    1.73 +    /**
    1.74 +     *  Returns the canonical key whose payload is the name of a destination to
    1.75 +     *  be linked to.
    1.76 +     */
    1.77 +    static const char* Link_Named_Dest_Key();
    1.78 +};
    1.79 +
    1.80 +///////////////////////////////////////////////////////////////////////////////
    1.81 +//
    1.82 +// Experimental helper functions to use Annotations
    1.83 +//
    1.84 +
    1.85 +struct SkRect;
    1.86 +class SkCanvas;
    1.87 +
    1.88 +/**
    1.89 + *  Experimental!
    1.90 + *
    1.91 + *  Annotate the canvas by associating the specified URL with the
    1.92 + *  specified rectangle (in local coordinates, just like drawRect). If the
    1.93 + *  backend of this canvas does not support annotations, this call is
    1.94 + *  safely ignored.
    1.95 + *
    1.96 + *  The caller is responsible for managing its ownership of the SkData.
    1.97 + */
    1.98 +SK_API void SkAnnotateRectWithURL(SkCanvas*, const SkRect&, SkData*);
    1.99 +
   1.100 +/**
   1.101 + *  Experimental!
   1.102 + *
   1.103 + *  Annotate the canvas by associating a name with the specified point.
   1.104 + *
   1.105 + *  If the backend of this canvas does not support annotations, this call is
   1.106 + *  safely ignored.
   1.107 + *
   1.108 + *  The caller is responsible for managing its ownership of the SkData.
   1.109 + */
   1.110 +SK_API void SkAnnotateNamedDestination(SkCanvas*, const SkPoint&, SkData*);
   1.111 +
   1.112 +/**
   1.113 + *  Experimental!
   1.114 + *
   1.115 + *  Annotate the canvas by making the specified rectangle link to a named
   1.116 + *  destination.
   1.117 + *
   1.118 + *  If the backend of this canvas does not support annotations, this call is
   1.119 + *  safely ignored.
   1.120 + *
   1.121 + *  The caller is responsible for managing its ownership of the SkData.
   1.122 + */
   1.123 +SK_API void SkAnnotateLinkToDestination(SkCanvas*, const SkRect&, SkData*);
   1.124 +
   1.125 +
   1.126 +#endif

mercurial