• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2012 Google Inc.
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7 
8 #include "SkAnnotation.h"
9 #include "SkAnnotationKeys.h"
10 #include "SkCanvas.h"
11 #include "SkPoint.h"
12 #include "SkRect.h"
13 
URL_Key()14 const char* SkAnnotationKeys::URL_Key() {
15     return "SkAnnotationKey_URL";
16 };
17 
Define_Named_Dest_Key()18 const char* SkAnnotationKeys::Define_Named_Dest_Key() {
19     return "SkAnnotationKey_Define_Named_Dest";
20 };
21 
Link_Named_Dest_Key()22 const char* SkAnnotationKeys::Link_Named_Dest_Key() {
23     return "SkAnnotationKey_Link_Named_Dest";
24 };
25 
26 //////////////////////////////////////////////////////////////////////////////////////////////////
27 
SkAnnotateRectWithURL(SkCanvas * canvas,const SkRect & rect,SkData * value)28 void SkAnnotateRectWithURL(SkCanvas* canvas, const SkRect& rect, SkData* value) {
29     if (nullptr == value) {
30         return;
31     }
32     canvas->drawAnnotation(rect, SkAnnotationKeys::URL_Key(), value);
33 }
34 
SkAnnotateNamedDestination(SkCanvas * canvas,const SkPoint & point,SkData * name)35 void SkAnnotateNamedDestination(SkCanvas* canvas, const SkPoint& point, SkData* name) {
36     if (nullptr == name) {
37         return;
38     }
39     const SkRect rect = SkRect::MakeXYWH(point.x(), point.y(), 0, 0);
40     canvas->drawAnnotation(rect, SkAnnotationKeys::Define_Named_Dest_Key(), name);
41 }
42 
SkAnnotateLinkToDestination(SkCanvas * canvas,const SkRect & rect,SkData * name)43 void SkAnnotateLinkToDestination(SkCanvas* canvas, const SkRect& rect, SkData* name) {
44     if (nullptr == name) {
45         return;
46     }
47     canvas->drawAnnotation(rect, SkAnnotationKeys::Link_Named_Dest_Key(), name);
48 }
49