Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(334)

Side by Side Diff: src/core/SkAnnotation.cpp

Issue 181703003: Factory methods for heap-allocated SkAnnotation objects. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « include/core/SkAnnotation.h ('k') | src/core/SkPaint.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkAnnotation.h" 8 #include "SkAnnotation.h"
9 #include "SkData.h" 9 #include "SkData.h"
10 #include "SkReadBuffer.h" 10 #include "SkReadBuffer.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 49
50 const char* SkAnnotationKeys::Link_Named_Dest_Key() { 50 const char* SkAnnotationKeys::Link_Named_Dest_Key() {
51 return "SkAnnotationKey_Link_Named_Dest"; 51 return "SkAnnotationKey_Link_Named_Dest";
52 }; 52 };
53 53
54 /////////////////////////////////////////////////////////////////////////////// 54 ///////////////////////////////////////////////////////////////////////////////
55 55
56 #include "SkCanvas.h" 56 #include "SkCanvas.h"
57 57
58 static void annotate_paint(SkPaint& paint, const char* key, SkData* value) { 58 static void annotate_paint(SkPaint& paint, const char* key, SkData* value) {
59 paint.setAnnotation(SkNEW_ARGS(SkAnnotation, (key, value)))->unref(); 59 paint.setAnnotation(SkAnnotation::Create(key, value))->unref();
60 } 60 }
61 61
62 void SkAnnotateRectWithURL(SkCanvas* canvas, const SkRect& rect, SkData* value) { 62 void SkAnnotateRectWithURL(SkCanvas* canvas, const SkRect& rect, SkData* value) {
63 if (NULL == value) { 63 if (NULL == value) {
64 return; 64 return;
65 } 65 }
66 SkPaint paint; 66 SkPaint paint;
67 annotate_paint(paint, SkAnnotationKeys::URL_Key(), value); 67 annotate_paint(paint, SkAnnotationKeys::URL_Key(), value);
68 canvas->drawRect(rect, paint); 68 canvas->drawRect(rect, paint);
69 } 69 }
70 70
71 void SkAnnotateNamedDestination(SkCanvas* canvas, const SkPoint& point, SkData* name) { 71 void SkAnnotateNamedDestination(SkCanvas* canvas, const SkPoint& point, SkData* name) {
72 if (NULL == name) { 72 if (NULL == name) {
73 return; 73 return;
74 } 74 }
75 SkPaint paint; 75 SkPaint paint;
76 annotate_paint(paint, SkAnnotationKeys::Define_Named_Dest_Key(), name); 76 annotate_paint(paint, SkAnnotationKeys::Define_Named_Dest_Key(), name);
77 canvas->drawPoint(point.x(), point.y(), paint); 77 canvas->drawPoint(point.x(), point.y(), paint);
78 } 78 }
79 79
80 void SkAnnotateLinkToDestination(SkCanvas* canvas, const SkRect& rect, SkData* n ame) { 80 void SkAnnotateLinkToDestination(SkCanvas* canvas, const SkRect& rect, SkData* n ame) {
81 if (NULL == name) { 81 if (NULL == name) {
82 return; 82 return;
83 } 83 }
84 SkPaint paint; 84 SkPaint paint;
85 annotate_paint(paint, SkAnnotationKeys::Link_Named_Dest_Key(), name); 85 annotate_paint(paint, SkAnnotationKeys::Link_Named_Dest_Key(), name);
86 canvas->drawRect(rect, paint); 86 canvas->drawRect(rect, paint);
87 } 87 }
OLDNEW
« no previous file with comments | « include/core/SkAnnotation.h ('k') | src/core/SkPaint.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698