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