Line data Source code
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 :
14 0 : const char* SkAnnotationKeys::URL_Key() {
15 0 : return "SkAnnotationKey_URL";
16 : };
17 :
18 0 : const char* SkAnnotationKeys::Define_Named_Dest_Key() {
19 0 : return "SkAnnotationKey_Define_Named_Dest";
20 : };
21 :
22 0 : const char* SkAnnotationKeys::Link_Named_Dest_Key() {
23 0 : return "SkAnnotationKey_Link_Named_Dest";
24 : };
25 :
26 : //////////////////////////////////////////////////////////////////////////////////////////////////
27 :
28 0 : void SkAnnotateRectWithURL(SkCanvas* canvas, const SkRect& rect, SkData* value) {
29 0 : if (nullptr == value) {
30 0 : return;
31 : }
32 0 : canvas->drawAnnotation(rect, SkAnnotationKeys::URL_Key(), value);
33 : }
34 :
35 0 : void SkAnnotateNamedDestination(SkCanvas* canvas, const SkPoint& point, SkData* name) {
36 0 : if (nullptr == name) {
37 0 : return;
38 : }
39 0 : const SkRect rect = SkRect::MakeXYWH(point.x(), point.y(), 0, 0);
40 0 : canvas->drawAnnotation(rect, SkAnnotationKeys::Define_Named_Dest_Key(), name);
41 : }
42 :
43 0 : void SkAnnotateLinkToDestination(SkCanvas* canvas, const SkRect& rect, SkData* name) {
44 0 : if (nullptr == name) {
45 0 : return;
46 : }
47 0 : canvas->drawAnnotation(rect, SkAnnotationKeys::Link_Named_Dest_Key(), name);
48 : }
|