michael@0: /* michael@0: * Copyright 2012 Google Inc. michael@0: * michael@0: * Use of this source code is governed by a BSD-style license that can be michael@0: * found in the LICENSE file. michael@0: */ michael@0: michael@0: #ifndef SkAnnotation_DEFINED michael@0: #define SkAnnotation_DEFINED michael@0: michael@0: #include "SkRefCnt.h" michael@0: #include "SkString.h" michael@0: michael@0: class SkData; michael@0: class SkReadBuffer; michael@0: class SkWriteBuffer; michael@0: class SkStream; michael@0: class SkWStream; michael@0: struct SkPoint; michael@0: michael@0: /** michael@0: * Experimental class for annotating draws. Do not use directly yet. michael@0: * Use helper functions at the bottom of this file for now. michael@0: */ michael@0: class SkAnnotation : public SkRefCnt { michael@0: public: michael@0: virtual ~SkAnnotation(); michael@0: michael@0: static SkAnnotation* Create(const char key[], SkData* value) { michael@0: return SkNEW_ARGS(SkAnnotation, (key, value)); michael@0: } michael@0: michael@0: static SkAnnotation* Create(SkReadBuffer& buffer) { michael@0: return SkNEW_ARGS(SkAnnotation, (buffer)); michael@0: } michael@0: michael@0: /** michael@0: * Return the data for the specified key, or NULL. michael@0: */ michael@0: SkData* find(const char key[]) const; michael@0: michael@0: void writeToBuffer(SkWriteBuffer&) const; michael@0: michael@0: private: michael@0: SkAnnotation(const char key[], SkData* value); michael@0: SkAnnotation(SkReadBuffer&); michael@0: michael@0: SkString fKey; michael@0: SkData* fData; michael@0: michael@0: typedef SkRefCnt INHERITED; michael@0: }; michael@0: michael@0: /** michael@0: * Experimental collection of predefined Keys into the Annotation dictionary michael@0: */ michael@0: class SkAnnotationKeys { michael@0: public: michael@0: /** michael@0: * Returns the canonical key whose payload is a URL michael@0: */ michael@0: static const char* URL_Key(); michael@0: michael@0: /** michael@0: * Returns the canonical key whose payload is the name of a destination to michael@0: * be defined. michael@0: */ michael@0: static const char* Define_Named_Dest_Key(); michael@0: michael@0: /** michael@0: * Returns the canonical key whose payload is the name of a destination to michael@0: * be linked to. michael@0: */ michael@0: static const char* Link_Named_Dest_Key(); michael@0: }; michael@0: michael@0: /////////////////////////////////////////////////////////////////////////////// michael@0: // michael@0: // Experimental helper functions to use Annotations michael@0: // michael@0: michael@0: struct SkRect; michael@0: class SkCanvas; michael@0: michael@0: /** michael@0: * Experimental! michael@0: * michael@0: * Annotate the canvas by associating the specified URL with the michael@0: * specified rectangle (in local coordinates, just like drawRect). If the michael@0: * backend of this canvas does not support annotations, this call is michael@0: * safely ignored. michael@0: * michael@0: * The caller is responsible for managing its ownership of the SkData. michael@0: */ michael@0: SK_API void SkAnnotateRectWithURL(SkCanvas*, const SkRect&, SkData*); michael@0: michael@0: /** michael@0: * Experimental! michael@0: * michael@0: * Annotate the canvas by associating a name with the specified point. michael@0: * michael@0: * If the backend of this canvas does not support annotations, this call is michael@0: * safely ignored. michael@0: * michael@0: * The caller is responsible for managing its ownership of the SkData. michael@0: */ michael@0: SK_API void SkAnnotateNamedDestination(SkCanvas*, const SkPoint&, SkData*); michael@0: michael@0: /** michael@0: * Experimental! michael@0: * michael@0: * Annotate the canvas by making the specified rectangle link to a named michael@0: * destination. michael@0: * michael@0: * If the backend of this canvas does not support annotations, this call is michael@0: * safely ignored. michael@0: * michael@0: * The caller is responsible for managing its ownership of the SkData. michael@0: */ michael@0: SK_API void SkAnnotateLinkToDestination(SkCanvas*, const SkRect&, SkData*); michael@0: michael@0: michael@0: #endif