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 "include/core/SkAnnotation.h"
9#include "include/core/SkCanvas.h"
10#include "include/core/SkPoint.h"
11#include "include/core/SkRect.h"
12#include "src/core/SkAnnotationKeys.h"
13
14const char* SkAnnotationKeys::URL_Key() {
15 return "SkAnnotationKey_URL";
16};
17
18const char* SkAnnotationKeys::Define_Named_Dest_Key() {
19 return "SkAnnotationKey_Define_Named_Dest";
20};
21
22const char* SkAnnotationKeys::Link_Named_Dest_Key() {
23 return "SkAnnotationKey_Link_Named_Dest";
24};
25
26//////////////////////////////////////////////////////////////////////////////////////////////////
27
28void 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
35void 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
43void 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