2012-07-11 19:57:55 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2012 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SkAnnotation_DEFINED
|
|
|
|
#define SkAnnotation_DEFINED
|
|
|
|
|
2013-10-14 20:02:44 +00:00
|
|
|
#include "SkRefCnt.h"
|
2013-10-14 16:49:15 +00:00
|
|
|
#include "SkString.h"
|
2012-07-11 19:57:55 +00:00
|
|
|
|
|
|
|
class SkData;
|
2014-01-30 18:58:24 +00:00
|
|
|
class SkReadBuffer;
|
|
|
|
class SkWriteBuffer;
|
2012-08-07 15:54:32 +00:00
|
|
|
class SkStream;
|
|
|
|
class SkWStream;
|
2013-03-08 09:09:10 +00:00
|
|
|
struct SkPoint;
|
2012-07-11 19:57:55 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Experimental class for annotating draws. Do not use directly yet.
|
|
|
|
* Use helper functions at the bottom of this file for now.
|
|
|
|
*/
|
2013-10-14 20:02:44 +00:00
|
|
|
class SkAnnotation : public SkRefCnt {
|
2012-07-11 19:57:55 +00:00
|
|
|
public:
|
2013-10-29 20:44:39 +00:00
|
|
|
SkAnnotation(const char key[], SkData* value);
|
2012-07-11 19:57:55 +00:00
|
|
|
virtual ~SkAnnotation();
|
|
|
|
|
|
|
|
/**
|
2013-10-14 16:49:15 +00:00
|
|
|
* Return the data for the specified key, or NULL.
|
2012-07-11 19:57:55 +00:00
|
|
|
*/
|
2013-10-14 16:49:15 +00:00
|
|
|
SkData* find(const char key[]) const;
|
2012-07-11 19:57:55 +00:00
|
|
|
|
2014-01-30 18:58:24 +00:00
|
|
|
SkAnnotation(SkReadBuffer&);
|
|
|
|
void writeToBuffer(SkWriteBuffer&) const;
|
2012-07-11 19:57:55 +00:00
|
|
|
|
|
|
|
private:
|
2013-10-14 16:49:15 +00:00
|
|
|
SkString fKey;
|
|
|
|
SkData* fData;
|
2012-08-23 18:09:54 +00:00
|
|
|
|
2013-10-14 20:02:44 +00:00
|
|
|
typedef SkRefCnt INHERITED;
|
2012-07-11 19:57:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Experimental collection of predefined Keys into the Annotation dictionary
|
|
|
|
*/
|
|
|
|
class SkAnnotationKeys {
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Returns the canonical key whose payload is a URL
|
|
|
|
*/
|
|
|
|
static const char* URL_Key();
|
2013-03-08 09:09:10 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the canonical key whose payload is the name of a destination to
|
|
|
|
* be defined.
|
|
|
|
*/
|
|
|
|
static const char* Define_Named_Dest_Key();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the canonical key whose payload is the name of a destination to
|
|
|
|
* be linked to.
|
|
|
|
*/
|
|
|
|
static const char* Link_Named_Dest_Key();
|
2012-07-11 19:57:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Experimental helper functions to use Annotations
|
|
|
|
//
|
|
|
|
|
|
|
|
struct SkRect;
|
|
|
|
class SkCanvas;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Experimental!
|
|
|
|
*
|
|
|
|
* Annotate the canvas by associating the specified URL with the
|
|
|
|
* specified rectangle (in local coordinates, just like drawRect). If the
|
|
|
|
* backend of this canvas does not support annotations, this call is
|
|
|
|
* safely ignored.
|
|
|
|
*
|
|
|
|
* The caller is responsible for managing its ownership of the SkData.
|
|
|
|
*/
|
|
|
|
SK_API void SkAnnotateRectWithURL(SkCanvas*, const SkRect&, SkData*);
|
|
|
|
|
2013-03-08 09:09:10 +00:00
|
|
|
/**
|
|
|
|
* Experimental!
|
|
|
|
*
|
|
|
|
* Annotate the canvas by associating a name with the specified point.
|
|
|
|
*
|
|
|
|
* If the backend of this canvas does not support annotations, this call is
|
|
|
|
* safely ignored.
|
|
|
|
*
|
|
|
|
* The caller is responsible for managing its ownership of the SkData.
|
|
|
|
*/
|
|
|
|
SK_API void SkAnnotateNamedDestination(SkCanvas*, const SkPoint&, SkData*);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Experimental!
|
|
|
|
*
|
|
|
|
* Annotate the canvas by making the specified rectangle link to a named
|
|
|
|
* destination.
|
|
|
|
*
|
|
|
|
* If the backend of this canvas does not support annotations, this call is
|
|
|
|
* safely ignored.
|
|
|
|
*
|
|
|
|
* The caller is responsible for managing its ownership of the SkData.
|
|
|
|
*/
|
|
|
|
SK_API void SkAnnotateLinkToDestination(SkCanvas*, const SkRect&, SkData*);
|
|
|
|
|
|
|
|
|
2012-07-11 19:57:55 +00:00
|
|
|
#endif
|