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

Unified Diff: src/core/SkAnnotation.cpp

Issue 1744103002: move annotations to canvas virtual (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « samplecode/SampleFilterFuzz.cpp ('k') | src/core/SkAnnotationKeys.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkAnnotation.cpp
diff --git a/src/core/SkAnnotation.cpp b/src/core/SkAnnotation.cpp
index 84d41fc66933625863597dc137ce039c3a8dd3d1..09a6296fbabf7f45b19300d24132f4a35fe21dea 100644
--- a/src/core/SkAnnotation.cpp
+++ b/src/core/SkAnnotation.cpp
@@ -6,38 +6,10 @@
*/
#include "SkAnnotation.h"
-#include "SkData.h"
-#include "SkPaint.h"
+#include "SkAnnotationKeys.h"
+#include "SkCanvas.h"
#include "SkPoint.h"
-#include "SkReadBuffer.h"
-#include "SkWriteBuffer.h"
-
-SkAnnotation::SkAnnotation(const char key[], SkData* value) : fKey(key) {
- if (nullptr == value) {
- value = SkData::NewEmpty();
- } else {
- value->ref();
- }
- fData = value;
-}
-
-SkAnnotation::~SkAnnotation() {
- fData->unref();
-}
-
-SkData* SkAnnotation::find(const char key[]) const {
- return fKey.equals(key) ? fData : nullptr;
-}
-
-SkAnnotation::SkAnnotation(SkReadBuffer& buffer) {
- buffer.readString(&fKey);
- fData = buffer.readByteArrayAsData();
-}
-
-void SkAnnotation::writeToBuffer(SkWriteBuffer& buffer) const {
- buffer.writeString(fKey.c_str());
- buffer.writeDataAsByteArray(fData);
-}
+#include "SkRect.h"
const char* SkAnnotationKeys::URL_Key() {
return "SkAnnotationKey_URL";
@@ -51,37 +23,26 @@ const char* SkAnnotationKeys::Link_Named_Dest_Key() {
return "SkAnnotationKey_Link_Named_Dest";
};
-///////////////////////////////////////////////////////////////////////////////
-
-#include "SkCanvas.h"
-
-static void annotate_paint(SkPaint& paint, const char* key, SkData* value) {
- paint.setAnnotation(SkAnnotation::Create(key, value))->unref();
-}
+//////////////////////////////////////////////////////////////////////////////////////////////////
void SkAnnotateRectWithURL(SkCanvas* canvas, const SkRect& rect, SkData* value) {
if (nullptr == value) {
return;
}
- SkPaint paint;
- annotate_paint(paint, SkAnnotationKeys::URL_Key(), value);
- canvas->drawRect(rect, paint);
+ canvas->drawAnnotation(rect, SkAnnotationKeys::URL_Key(), value);
}
void SkAnnotateNamedDestination(SkCanvas* canvas, const SkPoint& point, SkData* name) {
if (nullptr == name) {
return;
}
- SkPaint paint;
- annotate_paint(paint, SkAnnotationKeys::Define_Named_Dest_Key(), name);
- canvas->drawPoint(point.x(), point.y(), paint);
+ 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;
}
- SkPaint paint;
- annotate_paint(paint, SkAnnotationKeys::Link_Named_Dest_Key(), name);
- canvas->drawRect(rect, paint);
+ canvas->drawAnnotation(rect, SkAnnotationKeys::Link_Named_Dest_Key(), name);
}
« no previous file with comments | « samplecode/SampleFilterFuzz.cpp ('k') | src/core/SkAnnotationKeys.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698