65cdba6ba7
Reason for revert: underlying problem with portable refs deleted more than once fixed Original issue's description: > Revert of make gm background colors 565 compatible (patchset #2 id:20001 of https://codereview.chromium.org/1176243006/) > > Reason for revert: > breaks many bots with refcnt error > > Original issue's description: > > make gm background colors 565 compatible > > > > Change a batch of GM tests to convert their background color > > so that it is representable in 8888 and 565. > > > > Enable portable text in those same tests to minimize platform > > differences. > > > > In a couple of bitmap tests, use portable typefaces instead of > > choosing 'Times' which may or may not be available on the platform. > > > > R=borenet@google.com > > > > Committed: https://skia.googlesource.com/skia/+/be7f768a357aefb39c42d24b81b24d647bb6ab70 > > TBR=borenet@google.com > NOPRESUBMIT=true > NOTREECHECKS=true > NOTRY=true > > Committed: https://skia.googlesource.com/skia/+/0bdb08b1ba8fbd18c4838f86a23f1ef4b3a3bfdf TBR=borenet@google.com NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Review URL: https://codereview.chromium.org/1182403003
79 lines
2.4 KiB
C++
79 lines
2.4 KiB
C++
|
|
/*
|
|
* Copyright 2013 Google Inc.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
#include "gm.h"
|
|
|
|
#include "SkAnnotation.h"
|
|
#include "SkData.h"
|
|
|
|
namespace skiagm {
|
|
|
|
/** Draws two rectangles. In output formats that support internal links (PDF),
|
|
* clicking the one labeled "Link to A" should take you to the one labeled
|
|
* "Target A". Note that you'll need to zoom your PDF viewer in a fair bit in
|
|
* order for the scrolling to not be blocked by the edge of the document.
|
|
*/
|
|
class InternalLinksGM : public GM {
|
|
public:
|
|
InternalLinksGM() {
|
|
this->setBGColor(sk_tool_utils::color_to_565(0xFFDDDDDD));
|
|
}
|
|
|
|
protected:
|
|
virtual SkString onShortName() {
|
|
return SkString("internal_links");
|
|
}
|
|
|
|
virtual SkISize onISize() {
|
|
return SkISize::Make(700, 500);
|
|
}
|
|
|
|
virtual void onDraw(SkCanvas* canvas) {
|
|
SkAutoTUnref<SkData> name(SkData::NewWithCString("target-a"));
|
|
|
|
canvas->save();
|
|
canvas->translate(SkIntToScalar(100), SkIntToScalar(100));
|
|
drawLabeledRect(canvas, "Link to A", 0, 0);
|
|
SkRect rect = SkRect::MakeXYWH(0, 0, SkIntToScalar(50), SkIntToScalar(20));
|
|
SkAnnotateLinkToDestination(canvas, rect, name.get());
|
|
canvas->restore();
|
|
|
|
canvas->save();
|
|
canvas->translate(SkIntToScalar(200), SkIntToScalar(200));
|
|
SkPoint point = SkPoint::Make(SkIntToScalar(100), SkIntToScalar(50));
|
|
drawLabeledRect(canvas, "Target A", point.x(), point.y());
|
|
SkAnnotateNamedDestination(canvas, point, name.get());
|
|
canvas->restore();
|
|
}
|
|
|
|
private:
|
|
/** Draw an arbitrary rectangle at a given location and label it with some
|
|
* text. */
|
|
void drawLabeledRect(SkCanvas* canvas, const char* text, SkScalar x, SkScalar y) {
|
|
SkPaint paint;
|
|
paint.setColor(SK_ColorBLUE);
|
|
SkRect rect = SkRect::MakeXYWH(x, y,
|
|
SkIntToScalar(50), SkIntToScalar(20));
|
|
canvas->drawRect(rect, paint);
|
|
|
|
paint.setAntiAlias(true);
|
|
sk_tool_utils::set_portable_typeface_always(&paint);
|
|
paint.setTextSize(SkIntToScalar(25));
|
|
paint.setColor(SK_ColorBLACK);
|
|
canvas->drawText(text, strlen(text), x, y, paint);
|
|
}
|
|
|
|
typedef GM INHERITED;
|
|
};
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
static GM* MyFactory(void*) { return SkNEW(InternalLinksGM); }
|
|
static GMRegistry reg(MyFactory);
|
|
|
|
}
|