SkAnnotation.cpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. #include "include/core/SkAnnotation.h"
  8. #include "include/core/SkCanvas.h"
  9. #include "include/core/SkPoint.h"
  10. #include "include/core/SkRect.h"
  11. #include "src/core/SkAnnotationKeys.h"
  12. const char* SkAnnotationKeys::URL_Key() {
  13. return "SkAnnotationKey_URL";
  14. };
  15. const char* SkAnnotationKeys::Define_Named_Dest_Key() {
  16. return "SkAnnotationKey_Define_Named_Dest";
  17. };
  18. const char* SkAnnotationKeys::Link_Named_Dest_Key() {
  19. return "SkAnnotationKey_Link_Named_Dest";
  20. };
  21. //////////////////////////////////////////////////////////////////////////////////////////////////
  22. void SkAnnotateRectWithURL(SkCanvas* canvas, const SkRect& rect, SkData* value) {
  23. if (nullptr == value) {
  24. return;
  25. }
  26. canvas->drawAnnotation(rect, SkAnnotationKeys::URL_Key(), value);
  27. }
  28. void SkAnnotateNamedDestination(SkCanvas* canvas, const SkPoint& point, SkData* name) {
  29. if (nullptr == name) {
  30. return;
  31. }
  32. const SkRect rect = SkRect::MakeXYWH(point.x(), point.y(), 0, 0);
  33. canvas->drawAnnotation(rect, SkAnnotationKeys::Define_Named_Dest_Key(), name);
  34. }
  35. void SkAnnotateLinkToDestination(SkCanvas* canvas, const SkRect& rect, SkData* name) {
  36. if (nullptr == name) {
  37. return;
  38. }
  39. canvas->drawAnnotation(rect, SkAnnotationKeys::Link_Named_Dest_Key(), name);
  40. }