aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkAnnotation.cpp
blob: 09a6296fbabf7f45b19300d24132f4a35fe21dea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*
 * Copyright 2012 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#include "SkAnnotation.h"
#include "SkAnnotationKeys.h"
#include "SkCanvas.h"
#include "SkPoint.h"
#include "SkRect.h"

const char* SkAnnotationKeys::URL_Key() {
    return "SkAnnotationKey_URL";
};

const char* SkAnnotationKeys::Define_Named_Dest_Key() {
    return "SkAnnotationKey_Define_Named_Dest";
};

const char* SkAnnotationKeys::Link_Named_Dest_Key() {
    return "SkAnnotationKey_Link_Named_Dest";
};

//////////////////////////////////////////////////////////////////////////////////////////////////

void SkAnnotateRectWithURL(SkCanvas* canvas, const SkRect& rect, SkData* value) {
    if (nullptr == value) {
        return;
    }
    canvas->drawAnnotation(rect, SkAnnotationKeys::URL_Key(), value);
}

void SkAnnotateNamedDestination(SkCanvas* canvas, const SkPoint& point, SkData* name) {
    if (nullptr == name) {
        return;
    }
    const SkRect rect = SkRect::MakeXYWH(point.x(), point.y(), 0, 0);
    canvas->drawAnnotation(rect, SkAnnotationKeys::Define_Named_Dest_Key(), name);
}

void SkAnnotateLinkToDestination(SkCanvas* canvas, const SkRect& rect, SkData* name) {
    if (nullptr == name) {
        return;
    }
    canvas->drawAnnotation(rect, SkAnnotationKeys::Link_Named_Dest_Key(), name);
}