Move Views into Sample and Viewer.
What is left of the SkView system is used only by samples or viewer. As a result, move it out of the Skia source tree and re-organize so it is a bit easier to understand and use more shared code. Move samplecode/ClockFaceView.cpp to samplecode/SampleTextEffects.cpp, sice that's what's actually in it. Move SkAnimTimer.h to tools/timer, since it's actually shared between gm and samples. Change-Id: I55dafd94c64e4f930ddbd19168e0f812af86c455 Reviewed-on: https://skia-review.googlesource.com/146161 Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: Ben Wagner <bungeman@google.com>
This commit is contained in:
parent
d1910d5664
commit
b2c4ea6219
26
BUILD.gn
26
BUILD.gn
@ -1359,6 +1359,7 @@ if (skia_enable_tools) {
|
||||
"tools/fonts/sk_tool_utils_font.cpp",
|
||||
"tools/random_parse_path.cpp",
|
||||
"tools/sk_tool_utils.cpp",
|
||||
"tools/timer/SkAnimTimer.h",
|
||||
"tools/timer/Timer.cpp",
|
||||
"tools/trace/SkChromeTracingTracer.cpp",
|
||||
"tools/trace/SkChromeTracingTracer.h",
|
||||
@ -1477,18 +1478,6 @@ if (skia_enable_tools) {
|
||||
}
|
||||
}
|
||||
|
||||
if (target_cpu != "wasm") {
|
||||
test_lib("views") {
|
||||
public_include_dirs = [ "include/views" ]
|
||||
sources = [
|
||||
"src/views/SkEvent.cpp",
|
||||
"src/views/SkEventSink.cpp",
|
||||
"src/views/SkTouchGesture.cpp",
|
||||
"src/views/SkView.cpp",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
if (skia_use_lua) {
|
||||
test_lib("lua") {
|
||||
public_include_dirs = []
|
||||
@ -1562,14 +1551,13 @@ if (skia_enable_tools) {
|
||||
public_include_dirs = [ "samplecode" ]
|
||||
include_dirs = [ "experimental" ]
|
||||
sources = samples_sources
|
||||
public_deps = [
|
||||
":tool_utils",
|
||||
]
|
||||
deps = [
|
||||
":experimental_svg_model",
|
||||
":flags",
|
||||
":gm",
|
||||
":tool_utils",
|
||||
":views",
|
||||
":xml",
|
||||
"modules/sksg:samples",
|
||||
"modules/skshaper",
|
||||
]
|
||||
|
||||
@ -2006,7 +1994,6 @@ if (skia_enable_tools) {
|
||||
":gpu_tool_utils",
|
||||
":skia",
|
||||
":tool_utils",
|
||||
":views",
|
||||
]
|
||||
if (is_android) {
|
||||
deps += [ "//third_party/native_app_glue" ]
|
||||
@ -2034,6 +2021,8 @@ if (skia_enable_tools) {
|
||||
"tools/viewer/SlideDir.cpp",
|
||||
"tools/viewer/StatsLayer.cpp",
|
||||
"tools/viewer/SvgSlide.cpp",
|
||||
"tools/viewer/TouchGesture.h",
|
||||
"tools/viewer/TouchGesture.cpp",
|
||||
"tools/viewer/Viewer.cpp",
|
||||
]
|
||||
libs = []
|
||||
@ -2048,9 +2037,9 @@ if (skia_enable_tools) {
|
||||
":sk_app",
|
||||
":skia",
|
||||
":tool_utils",
|
||||
":views",
|
||||
"modules/skottie",
|
||||
"modules/sksg",
|
||||
"modules/sksg:samples",
|
||||
"//third_party/imgui",
|
||||
]
|
||||
|
||||
@ -2129,7 +2118,6 @@ if (skia_enable_tools) {
|
||||
":sk_app",
|
||||
":skia",
|
||||
":tool_utils",
|
||||
":views",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,6 @@ public:
|
||||
ExtractBitmapGM() {}
|
||||
|
||||
protected:
|
||||
// overrides from SkEventSink
|
||||
SkString onShortName() override {
|
||||
return SkString("extractbitmap");
|
||||
}
|
||||
|
@ -7,8 +7,9 @@
|
||||
_samplecode = get_path_info("../samplecode", "abspath")
|
||||
|
||||
samples_sources = [
|
||||
"$_samplecode/ClockFaceView.cpp",
|
||||
"$_samplecode/PerlinPatch.cpp",
|
||||
"$_samplecode/Sample.cpp",
|
||||
"$_samplecode/Sample.h",
|
||||
"$_samplecode/Sample2PtRadial.cpp",
|
||||
"$_samplecode/SampleAAClip.cpp",
|
||||
"$_samplecode/SampleAAGeometry.cpp",
|
||||
@ -33,7 +34,6 @@ samples_sources = [
|
||||
"$_samplecode/SampleClip.cpp",
|
||||
"$_samplecode/SampleClipDrawMatch.cpp",
|
||||
"$_samplecode/SampleClock.cpp",
|
||||
"$_samplecode/SampleCode.cpp",
|
||||
"$_samplecode/SampleColorFilter.cpp",
|
||||
"$_samplecode/SampleComplexClip.cpp",
|
||||
"$_samplecode/SampleConcavePaths.cpp",
|
||||
@ -98,6 +98,7 @@ samples_sources = [
|
||||
"$_samplecode/SampleText.cpp",
|
||||
"$_samplecode/SampleTextAlpha.cpp",
|
||||
"$_samplecode/SampleTextBox.cpp",
|
||||
"$_samplecode/SampleTextEffects.cpp",
|
||||
"$_samplecode/SampleTextOnPath.cpp",
|
||||
"$_samplecode/SampleTextureDomain.cpp",
|
||||
"$_samplecode/SampleTiling.cpp",
|
||||
|
@ -1,131 +0,0 @@
|
||||
/*
|
||||
* Copyright 2006 The Android Open Source Project
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SkEvent_DEFINED
|
||||
#define SkEvent_DEFINED
|
||||
|
||||
#include "SkMetaData.h"
|
||||
|
||||
/** Unique 32bit id used to identify an instance of SkEventSink. When events are
|
||||
posted, they are posted to a specific sinkID. When it is time to dispatch the
|
||||
event, the sinkID is used to find the specific SkEventSink object. If it is found,
|
||||
its doEvent() method is called with the event.
|
||||
*/
|
||||
typedef uint32_t SkEventSinkID;
|
||||
|
||||
/**
|
||||
* \class SkEvent
|
||||
*
|
||||
* When an event is dispatched from the event queue, it is either sent to
|
||||
* the eventsink matching the target ID (if not 0), or the target proc is
|
||||
* called (if not NULL).
|
||||
*/
|
||||
class SkEvent {
|
||||
public:
|
||||
SkEvent();
|
||||
explicit SkEvent(const char type[]);
|
||||
SkEvent(const SkEvent& src);
|
||||
~SkEvent();
|
||||
|
||||
/** Returns true if the event's type matches exactly the specified type (case sensitive) */
|
||||
bool isType(const char type[]) const;
|
||||
|
||||
/**
|
||||
* Set the event's type to the specified string.
|
||||
*/
|
||||
void setType(const char type[]);
|
||||
|
||||
/**
|
||||
* Return the event's unnamed 32bit field. Default value is 0
|
||||
*/
|
||||
uint32_t getFast32() const { return f32; }
|
||||
|
||||
/**
|
||||
* Set the event's unnamed 32bit field.
|
||||
*/
|
||||
void setFast32(uint32_t x) { f32 = x; }
|
||||
|
||||
/** Return true if the event contains the named 32bit field, and return the field
|
||||
in value (if value is non-null). If there is no matching named field, return false
|
||||
and ignore the value parameter.
|
||||
*/
|
||||
bool findS32(const char name[], int32_t* value = nullptr) const {
|
||||
return fMeta.findS32(name, value);
|
||||
}
|
||||
/** Return true if the event contains the named SkScalar field, and return the field
|
||||
in value (if value is non-null). If there is no matching named field, return false
|
||||
and ignore the value parameter.
|
||||
*/
|
||||
bool findScalar(const char name[], SkScalar* value = nullptr) const {
|
||||
return fMeta.findScalar(name, value);
|
||||
}
|
||||
/** Return true if the event contains the named SkScalar field, and return the fields
|
||||
in value[] (if value is non-null), and return the number of SkScalars in count (if count is non-null).
|
||||
If there is no matching named field, return false and ignore the value and count parameters.
|
||||
*/
|
||||
const SkScalar* findScalars(const char name[], int* count, SkScalar values[] = nullptr) const {
|
||||
return fMeta.findScalars(name, count, values);
|
||||
}
|
||||
/** Return the value of the named string field, or if no matching named field exists, return null.
|
||||
*/
|
||||
const char* findString(const char name[]) const { return fMeta.findString(name); }
|
||||
/** Return true if the event contains the named pointer field, and return the field
|
||||
in value (if value is non-null). If there is no matching named field, return false
|
||||
and ignore the value parameter.
|
||||
*/
|
||||
bool findPtr(const char name[], void** value) const { return fMeta.findPtr(name, value); }
|
||||
bool findBool(const char name[], bool* value) const { return fMeta.findBool(name, value); }
|
||||
const void* findData(const char name[], size_t* byteCount = nullptr) const {
|
||||
return fMeta.findData(name, byteCount);
|
||||
}
|
||||
|
||||
/** Returns true if ethe event contains the named 32bit field, and if it equals the specified value */
|
||||
bool hasS32(const char name[], int32_t value) const { return fMeta.hasS32(name, value); }
|
||||
/** Returns true if ethe event contains the named SkScalar field, and if it equals the specified value */
|
||||
bool hasScalar(const char name[], SkScalar value) const { return fMeta.hasScalar(name, value); }
|
||||
/** Returns true if ethe event contains the named string field, and if it equals (using strcmp) the specified value */
|
||||
bool hasString(const char name[], const char value[]) const { return fMeta.hasString(name, value); }
|
||||
/** Returns true if ethe event contains the named pointer field, and if it equals the specified value */
|
||||
bool hasPtr(const char name[], void* value) const { return fMeta.hasPtr(name, value); }
|
||||
bool hasBool(const char name[], bool value) const { return fMeta.hasBool(name, value); }
|
||||
bool hasData(const char name[], const void* data, size_t byteCount) const {
|
||||
return fMeta.hasData(name, data, byteCount);
|
||||
}
|
||||
|
||||
/** Add/replace the named 32bit field to the event. In XML use the subelement <data name=... s32=... /> */
|
||||
void setS32(const char name[], int32_t value) { fMeta.setS32(name, value); }
|
||||
/** Add/replace the named SkScalar field to the event. In XML use the subelement <data name=... scalar=... /> */
|
||||
void setScalar(const char name[], SkScalar value) { fMeta.setScalar(name, value); }
|
||||
/** Add/replace the named SkScalar[] field to the event. */
|
||||
SkScalar* setScalars(const char name[], int count, const SkScalar values[] = nullptr) {
|
||||
return fMeta.setScalars(name, count, values);
|
||||
}
|
||||
/** Add/replace the named string field to the event. In XML use the subelement <data name=... string=... */
|
||||
void setString(const char name[], const char value[]) { fMeta.setString(name, value); }
|
||||
/** Add/replace the named pointer field to the event. There is no XML equivalent for this call */
|
||||
void setPtr(const char name[], void* value) { fMeta.setPtr(name, value); }
|
||||
void setBool(const char name[], bool value) { fMeta.setBool(name, value); }
|
||||
void setData(const char name[], const void* data, size_t byteCount) {
|
||||
fMeta.setData(name, data, byteCount);
|
||||
}
|
||||
|
||||
/** Return the underlying metadata object */
|
||||
SkMetaData& getMetaData() { return fMeta; }
|
||||
/** Return the underlying metadata object */
|
||||
const SkMetaData& getMetaData() const { return fMeta; }
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private:
|
||||
SkMetaData fMeta;
|
||||
char* fType;
|
||||
uint32_t f32;
|
||||
|
||||
void initialize(const char* type);
|
||||
};
|
||||
|
||||
#endif
|
@ -1,65 +0,0 @@
|
||||
|
||||
/*
|
||||
* Copyright 2006 The Android Open Source Project
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef SkEventSink_DEFINED
|
||||
#define SkEventSink_DEFINED
|
||||
|
||||
#include "SkRefCnt.h"
|
||||
#include "SkEvent.h"
|
||||
|
||||
/** \class SkEventSink
|
||||
|
||||
SkEventSink is the base class for all objects that receive SkEvents.
|
||||
*/
|
||||
class SkEventSink : public SkRefCnt {
|
||||
public:
|
||||
|
||||
|
||||
SkEventSink();
|
||||
virtual ~SkEventSink();
|
||||
|
||||
/**
|
||||
* Returns this eventsink's unique ID. Use this to post SkEvents to
|
||||
* this eventsink.
|
||||
*/
|
||||
SkEventSinkID getSinkID() const { return fID; }
|
||||
|
||||
/**
|
||||
* Call this to pass an event to this object for processing. Returns true if the
|
||||
* event was handled.
|
||||
*/
|
||||
bool doEvent(const SkEvent&);
|
||||
|
||||
/** Returns true if the sink (or one of its subclasses) understands the event as a query.
|
||||
If so, the sink may modify the event to communicate its "answer".
|
||||
*/
|
||||
bool doQuery(SkEvent* query);
|
||||
|
||||
/**
|
||||
* Returns the matching eventsink, or null if not found
|
||||
*/
|
||||
static SkEventSink* FindSink(SkEventSinkID);
|
||||
|
||||
protected:
|
||||
/** Override this to handle events in your subclass. Be sure to call the inherited version
|
||||
for events that you don't handle.
|
||||
*/
|
||||
virtual bool onEvent(const SkEvent&);
|
||||
virtual bool onQuery(SkEvent*);
|
||||
|
||||
private:
|
||||
SkEventSinkID fID;
|
||||
|
||||
// for our private link-list
|
||||
SkEventSink* fNextSink;
|
||||
|
||||
typedef SkRefCnt INHERITED;
|
||||
};
|
||||
|
||||
#endif
|
@ -1,22 +0,0 @@
|
||||
|
||||
/*
|
||||
* Copyright 2006 The Android Open Source Project
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef SkKey_DEFINED
|
||||
#define SkKey_DEFINED
|
||||
|
||||
#include "SkTypes.h"
|
||||
|
||||
enum SkModifierKeys {
|
||||
kShift_SkModifierKey = 1 << 0,
|
||||
kControl_SkModifierKey = 1 << 1,
|
||||
kOption_SkModifierKey = 1 << 2, // same as ALT
|
||||
kCommand_SkModifierKey = 1 << 3,
|
||||
};
|
||||
|
||||
#endif
|
@ -1,119 +0,0 @@
|
||||
|
||||
/*
|
||||
* Copyright 2006 The Android Open Source Project
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef SkView_DEFINED
|
||||
#define SkView_DEFINED
|
||||
|
||||
#include "SkEventSink.h"
|
||||
#include "SkRect.h"
|
||||
#include "SkMatrix.h"
|
||||
#include "SkMetaData.h"
|
||||
|
||||
class SkCanvas;
|
||||
|
||||
/** \class SkView
|
||||
|
||||
SkView is the base class for screen management. All widgets and controls inherit
|
||||
from SkView.
|
||||
*/
|
||||
class SkView : public SkEventSink {
|
||||
public:
|
||||
enum Flag_Shift {
|
||||
kVisible_Shift,
|
||||
kNoClip_Shift,
|
||||
|
||||
kFlagShiftCount
|
||||
};
|
||||
enum Flag_Mask {
|
||||
kVisible_Mask = 1 << kVisible_Shift, //!< set if the view is visible
|
||||
kNoClip_Mask = 1 << kNoClip_Shift, //!< set if the view is not clipped to its bounds
|
||||
|
||||
kAllFlagMasks = (uint32_t)(0 - 1) >> (32 - kFlagShiftCount)
|
||||
};
|
||||
|
||||
SkView(uint32_t flags = 0);
|
||||
virtual ~SkView();
|
||||
|
||||
/** Return the flags associated with the view
|
||||
*/
|
||||
uint32_t getFlags() const { return fFlags; }
|
||||
/** Set the flags associated with the view
|
||||
*/
|
||||
void setFlags(uint32_t flags);
|
||||
|
||||
/** Helper that returns non-zero if the kVisible_Mask bit is set in the view's flags
|
||||
*/
|
||||
int isVisible() const { return fFlags & kVisible_Mask; }
|
||||
int isClipToBounds() const { return !(fFlags & kNoClip_Mask); }
|
||||
/** Helper to set/clear the view's kVisible_Mask flag */
|
||||
void setVisibleP(bool);
|
||||
void setClipToBounds(bool);
|
||||
|
||||
/** Return the view's width */
|
||||
SkScalar width() const { return fWidth; }
|
||||
/** Return the view's height */
|
||||
SkScalar height() const { return fHeight; }
|
||||
/** Set the view's width and height. These must both be >= 0. This does not affect the view's loc */
|
||||
void setSize(SkScalar width, SkScalar height);
|
||||
void setSize(const SkPoint& size) { this->setSize(size.fX, size.fY); }
|
||||
void setWidth(SkScalar width) { this->setSize(width, fHeight); }
|
||||
void setHeight(SkScalar height) { this->setSize(fWidth, height); }
|
||||
|
||||
/** Call this to have the view draw into the specified canvas. */
|
||||
virtual void draw(SkCanvas* canvas);
|
||||
|
||||
// Click handling
|
||||
|
||||
class Click {
|
||||
public:
|
||||
Click(SkView* target);
|
||||
virtual ~Click();
|
||||
|
||||
enum State {
|
||||
kDown_State,
|
||||
kMoved_State,
|
||||
kUp_State
|
||||
};
|
||||
SkPoint fOrig, fPrev, fCurr;
|
||||
SkIPoint fIOrig, fIPrev, fICurr;
|
||||
State fState;
|
||||
unsigned fModifierKeys;
|
||||
|
||||
SkMetaData fMeta;
|
||||
private:
|
||||
SkEventSinkID fTargetID;
|
||||
|
||||
friend class SkView;
|
||||
};
|
||||
Click* findClickHandler(SkScalar x, SkScalar y, unsigned modifierKeys);
|
||||
|
||||
static void DoClickDown(Click*, int x, int y, unsigned modi);
|
||||
static void DoClickMoved(Click*, int x, int y, unsigned modi);
|
||||
static void DoClickUp(Click*, int x, int y, unsigned modi);
|
||||
|
||||
protected:
|
||||
/** Override this to draw inside the view. Be sure to call the inherited version too */
|
||||
virtual void onDraw(SkCanvas*);
|
||||
/** Override this to be notified when the view's size changes. Be sure to call the inherited version too */
|
||||
virtual void onSizeChange();
|
||||
|
||||
/** Override this if you might handle the click
|
||||
*/
|
||||
virtual Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned modi);
|
||||
/** Override this to track clicks, returning true as long as you want to track
|
||||
the pen/mouse.
|
||||
*/
|
||||
virtual bool onClick(Click*);
|
||||
|
||||
private:
|
||||
SkScalar fWidth, fHeight;
|
||||
uint8_t fFlags;
|
||||
};
|
||||
|
||||
#endif
|
@ -47,9 +47,8 @@ source_set("samples") {
|
||||
]
|
||||
deps = [
|
||||
":sksg",
|
||||
"../..:gm", # TODO: refactor to make this nicer
|
||||
"../..:skia",
|
||||
"../..:views", # TODO: refactor to make this nicer
|
||||
"../..:samples",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "SampleCode.h"
|
||||
#include "Sample.h"
|
||||
#include "SkAnimTimer.h"
|
||||
#include "SkColor.h"
|
||||
#include "SkRandom.h"
|
||||
@ -75,7 +75,7 @@ void update_pos(const sk_sp<sksg::RRect>& rr, const SkPoint& pos) {
|
||||
|
||||
} // anonymous ns
|
||||
|
||||
class PongView final : public SampleView {
|
||||
class PongView final : public Sample {
|
||||
public:
|
||||
PongView() = default;
|
||||
|
||||
@ -151,14 +151,14 @@ protected:
|
||||
this->updatePaddleStrategy();
|
||||
}
|
||||
|
||||
bool onQuery(SkEvent* evt) override {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "SGPong");
|
||||
bool onQuery(Event* evt) override {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "SGPong");
|
||||
return true;
|
||||
}
|
||||
|
||||
SkUnichar uni;
|
||||
if (SampleCode::CharQ(*evt, &uni)) {
|
||||
if (Sample::CharQ(*evt, &uni)) {
|
||||
switch (uni) {
|
||||
case '[':
|
||||
fTimeScale = SkTPin(fTimeScale - 0.1f, kTimeScaleMin, kTimeScaleMax);
|
||||
@ -292,8 +292,7 @@ private:
|
||||
SkScalar fTimeScale = 1.0f;
|
||||
bool fShowInval = false;
|
||||
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
static SkView* PongFactory() { return new PongView; }
|
||||
static SkViewRegister reg(PongFactory);
|
||||
DEF_SAMPLE( return new PongView(); )
|
||||
|
@ -66,7 +66,6 @@ def skia_public_hdrs():
|
||||
["include/**/*.h"],
|
||||
exclude = [
|
||||
"include/private/**/*",
|
||||
"include/views/**/*", # Not used.
|
||||
],
|
||||
)
|
||||
|
||||
@ -239,9 +238,6 @@ BASE_SRCS_ALL = struct(
|
||||
"src/utils/android/**/*",
|
||||
"src/utils/mac/**/*",
|
||||
"src/utils/win/**/*",
|
||||
"src/views/sdl/*",
|
||||
"src/views/win/*",
|
||||
"src/views/unix/*",
|
||||
|
||||
# Exclude multiple definitions.
|
||||
# TODO(mtklein): Move to opts?
|
||||
@ -255,9 +251,6 @@ BASE_SRCS_ALL = struct(
|
||||
# Conflicting dependencies among Lua versions. See cl/107087297.
|
||||
"src/utils/SkLua*",
|
||||
|
||||
# Not used.
|
||||
"src/views/**/*",
|
||||
|
||||
# Currently exclude all vulkan specific files
|
||||
"src/gpu/vk/*",
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "SampleCode.h"
|
||||
#include "Sample.h"
|
||||
#include "SkAnimTimer.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkGradientShader.h"
|
||||
@ -59,7 +59,7 @@ static void draw_control_points(SkCanvas* canvas, const SkPoint cubics[12]) {
|
||||
const SkScalar TexWidth = 100.0f;
|
||||
const SkScalar TexHeight = 100.0f;
|
||||
|
||||
class PerlinPatchView : public SampleView {
|
||||
class PerlinPatchView : public Sample {
|
||||
sk_sp<SkShader> fShader0;
|
||||
sk_sp<SkShader> fShader1;
|
||||
sk_sp<SkShader> fShaderCompose;
|
||||
@ -110,14 +110,13 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
// overrides from SkEventSink
|
||||
bool onQuery(SkEvent* evt) override {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "PerlinPatch");
|
||||
bool onQuery(Sample::Event* evt) override {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "PerlinPatch");
|
||||
return true;
|
||||
}
|
||||
SkUnichar uni;
|
||||
if (SampleCode::CharQ(*evt, &uni)) {
|
||||
if (Sample::CharQ(*evt, &uni)) {
|
||||
switch (uni) {
|
||||
case 'g': fShowGrid = !fShowGrid; return true;
|
||||
default: break;
|
||||
@ -167,14 +166,14 @@ protected:
|
||||
class PtClick : public Click {
|
||||
public:
|
||||
int fIndex;
|
||||
PtClick(SkView* view, int index) : Click(view), fIndex(index) {}
|
||||
PtClick(Sample* view, int index) : Click(view), fIndex(index) {}
|
||||
};
|
||||
|
||||
static bool hittest(const SkPoint& pt, SkScalar x, SkScalar y) {
|
||||
return SkPoint::Length(pt.fX - x, pt.fY - y) < SkIntToScalar(5);
|
||||
}
|
||||
|
||||
SkView::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned modi) override {
|
||||
Sample::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned modi) override {
|
||||
// holding down shift
|
||||
if (1 == modi) {
|
||||
return new PtClick(this, -1);
|
||||
@ -211,7 +210,7 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
DEF_SAMPLE( return new PerlinPatchView(); )
|
||||
|
222
samplecode/Sample.cpp
Normal file
222
samplecode/Sample.cpp
Normal file
@ -0,0 +1,222 @@
|
||||
/*
|
||||
* Copyright 2016 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "Sample.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkString.h"
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
# include "GrContext.h"
|
||||
#else
|
||||
class GrContext;
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Sample::Event::Event() : Event("") {}
|
||||
|
||||
Sample::Event::Event(const Event& that) {
|
||||
*this = that;
|
||||
}
|
||||
|
||||
Sample::Event::Event(const char type[]) : fType(type), f32(0) {
|
||||
SkASSERT(type);
|
||||
}
|
||||
|
||||
Sample::Event::~Event() {}
|
||||
|
||||
bool Sample::Event::isType(const char type[]) const {
|
||||
return fType.equals(type);
|
||||
}
|
||||
|
||||
const char* Sample::kCharEvtName = "SampleCode_Char_Event";
|
||||
const char* Sample::kTitleEvtName = "SampleCode_Title_Event";
|
||||
|
||||
bool Sample::CharQ(const Event& evt, SkUnichar* outUni) {
|
||||
if (evt.isType(kCharEvtName)) {
|
||||
if (outUni) {
|
||||
*outUni = evt.getFast32();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Sample::TitleQ(const Event& evt) {
|
||||
return evt.isType(kTitleEvtName);
|
||||
}
|
||||
|
||||
void Sample::TitleR(Event* evt, const char title[]) {
|
||||
SkASSERT(evt && TitleQ(*evt));
|
||||
evt->setString(kTitleEvtName, title);
|
||||
}
|
||||
|
||||
bool Sample::RequestTitle(Sample* view, SkString* title) {
|
||||
Event evt(kTitleEvtName);
|
||||
if (view->doQuery(&evt)) {
|
||||
title->set(evt.findString(kTitleEvtName));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool Sample::doEvent(const Event& evt) {
|
||||
return this->onEvent(evt);
|
||||
}
|
||||
|
||||
bool Sample::onEvent(const Event&) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Sample::doQuery(Event* evt) {
|
||||
SkASSERT(evt);
|
||||
return this->onQuery(evt);
|
||||
}
|
||||
|
||||
bool Sample::onQuery(Sample::Event* evt) {
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
void Sample::setSize(SkScalar width, SkScalar height) {
|
||||
width = SkMaxScalar(0, width);
|
||||
height = SkMaxScalar(0, height);
|
||||
|
||||
if (fWidth != width || fHeight != height)
|
||||
{
|
||||
fWidth = width;
|
||||
fHeight = height;
|
||||
this->onSizeChange();
|
||||
}
|
||||
}
|
||||
|
||||
void Sample::draw(SkCanvas* canvas) {
|
||||
if (fWidth && fHeight) {
|
||||
SkRect r;
|
||||
r.set(0, 0, fWidth, fHeight);
|
||||
if (canvas->quickReject(r)) {
|
||||
return;
|
||||
}
|
||||
|
||||
SkAutoCanvasRestore as(canvas, true);
|
||||
int sc = canvas->save();
|
||||
|
||||
if (!fHaveCalledOnceBeforeDraw) {
|
||||
fHaveCalledOnceBeforeDraw = true;
|
||||
this->onOnceBeforeDraw();
|
||||
}
|
||||
this->onDrawBackground(canvas);
|
||||
|
||||
SkAutoCanvasRestore acr(canvas, true);
|
||||
this->onDrawContent(canvas);
|
||||
#if SK_SUPPORT_GPU
|
||||
// Ensure the GrContext doesn't combine GrDrawOps across draw loops.
|
||||
if (GrContext* context = canvas->getGrContext()) {
|
||||
context->flush();
|
||||
}
|
||||
#endif
|
||||
|
||||
canvas->restoreToCount(sc);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Sample::Click::Click(Sample* target) {
|
||||
SkASSERT(target);
|
||||
fTarget = sk_ref_sp(target);
|
||||
}
|
||||
|
||||
Sample::Click::~Click() {}
|
||||
|
||||
Sample::Click* Sample::findClickHandler(SkScalar x, SkScalar y, unsigned modi) {
|
||||
if (x < 0 || y < 0 || x >= fWidth || y >= fHeight) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return this->onFindClickHandler(x, y, modi);
|
||||
}
|
||||
|
||||
void Sample::DoClickDown(Click* click, int x, int y, unsigned modi) {
|
||||
SkASSERT(click);
|
||||
|
||||
Sample* target = click->fTarget.get();
|
||||
if (nullptr == target) {
|
||||
return;
|
||||
}
|
||||
|
||||
click->fIOrig.set(x, y);
|
||||
click->fICurr = click->fIPrev = click->fIOrig;
|
||||
|
||||
click->fOrig.iset(x, y);
|
||||
click->fPrev = click->fCurr = click->fOrig;
|
||||
|
||||
click->fState = Click::kDown_State;
|
||||
click->fModifierKeys = modi;
|
||||
target->onClick(click);
|
||||
}
|
||||
|
||||
void Sample::DoClickMoved(Click* click, int x, int y, unsigned modi) {
|
||||
SkASSERT(click);
|
||||
|
||||
Sample* target = click->fTarget.get();
|
||||
if (nullptr == target) {
|
||||
return;
|
||||
}
|
||||
|
||||
click->fIPrev = click->fICurr;
|
||||
click->fICurr.set(x, y);
|
||||
|
||||
click->fPrev = click->fCurr;
|
||||
click->fCurr.iset(x, y);
|
||||
|
||||
click->fState = Click::kMoved_State;
|
||||
click->fModifierKeys = modi;
|
||||
target->onClick(click);
|
||||
}
|
||||
|
||||
void Sample::DoClickUp(Click* click, int x, int y, unsigned modi) {
|
||||
SkASSERT(click);
|
||||
|
||||
Sample* target = click->fTarget.get();
|
||||
if (nullptr == target) {
|
||||
return;
|
||||
}
|
||||
|
||||
click->fIPrev = click->fICurr;
|
||||
click->fICurr.set(x, y);
|
||||
|
||||
click->fPrev = click->fCurr;
|
||||
click->fCurr.iset(x, y);
|
||||
|
||||
click->fState = Click::kUp_State;
|
||||
click->fModifierKeys = modi;
|
||||
target->onClick(click);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
void Sample::onSizeChange() {}
|
||||
|
||||
Sample::Click* Sample::onFindClickHandler(SkScalar x, SkScalar y, unsigned modi) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool Sample::onClick(Click*) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void Sample::onDrawBackground(SkCanvas* canvas) {
|
||||
canvas->drawColor(fBGColor);
|
||||
}
|
||||
|
||||
// need to explicitly declare this, or we get some weird infinite loop llist
|
||||
template SampleRegistry* SampleRegistry::gHead;
|
221
samplecode/Sample.h
Normal file
221
samplecode/Sample.h
Normal file
@ -0,0 +1,221 @@
|
||||
/*
|
||||
* Copyright 2011 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SampleCode_DEFINED
|
||||
#define SampleCode_DEFINED
|
||||
|
||||
#include "Registry.h"
|
||||
#include "SkColor.h"
|
||||
#include "SkMacros.h"
|
||||
#include "SkMetaData.h"
|
||||
#include "SkPoint.h"
|
||||
#include "SkRefCnt.h"
|
||||
#include "SkString.h"
|
||||
|
||||
class SkAnimTimer;
|
||||
class SkCanvas;
|
||||
class Sample;
|
||||
|
||||
using SampleFactory = Sample* (*)();
|
||||
using SampleRegistry = sk_tools::Registry<SampleFactory>;
|
||||
|
||||
#define DEF_SAMPLE(code) \
|
||||
static Sample* SK_MACRO_APPEND_LINE(F_)() { code } \
|
||||
static SampleRegistry SK_MACRO_APPEND_LINE(R_)(SK_MACRO_APPEND_LINE(F_));
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class Sample : public SkRefCnt {
|
||||
public:
|
||||
Sample()
|
||||
: fBGColor(SK_ColorWHITE)
|
||||
, fWidth(0), fHeight(0)
|
||||
, fHaveCalledOnceBeforeDraw(false)
|
||||
{}
|
||||
|
||||
SkScalar width() const { return fWidth; }
|
||||
SkScalar height() const { return fHeight; }
|
||||
void setSize(SkScalar width, SkScalar height);
|
||||
void setSize(const SkPoint& size) { this->setSize(size.fX, size.fY); }
|
||||
void setWidth(SkScalar width) { this->setSize(width, fHeight); }
|
||||
void setHeight(SkScalar height) { this->setSize(fWidth, height); }
|
||||
|
||||
/** Call this to have the view draw into the specified canvas. */
|
||||
virtual void draw(SkCanvas* canvas);
|
||||
|
||||
// Click handling
|
||||
class Click {
|
||||
public:
|
||||
Click(Sample* target);
|
||||
virtual ~Click();
|
||||
|
||||
enum State {
|
||||
kDown_State,
|
||||
kMoved_State,
|
||||
kUp_State
|
||||
};
|
||||
enum ModifierKeys {
|
||||
kShift_ModifierKey = 1 << 0,
|
||||
kControl_ModifierKey = 1 << 1,
|
||||
kOption_ModifierKey = 1 << 2, // same as ALT
|
||||
kCommand_ModifierKey = 1 << 3,
|
||||
};
|
||||
SkPoint fOrig, fPrev, fCurr;
|
||||
SkIPoint fIOrig, fIPrev, fICurr;
|
||||
State fState;
|
||||
unsigned fModifierKeys;
|
||||
|
||||
SkMetaData fMeta;
|
||||
private:
|
||||
sk_sp<Sample> fTarget;
|
||||
|
||||
friend class Sample;
|
||||
};
|
||||
Click* findClickHandler(SkScalar x, SkScalar y, unsigned modifierKeys);
|
||||
static void DoClickDown(Click*, int x, int y, unsigned modi);
|
||||
static void DoClickMoved(Click*, int x, int y, unsigned modi);
|
||||
static void DoClickUp(Click*, int x, int y, unsigned modi);
|
||||
|
||||
void setBGColor(SkColor color) { fBGColor = color; }
|
||||
bool animate(const SkAnimTimer& timer) { return this->onAnimate(timer); }
|
||||
|
||||
class Event {
|
||||
public:
|
||||
Event();
|
||||
explicit Event(const char type[]);
|
||||
Event(const Event& src);
|
||||
~Event();
|
||||
|
||||
/** Returns true if the event's type matches exactly the specified type (case sensitive) */
|
||||
bool isType(const char type[]) const;
|
||||
|
||||
/** Return the event's unnamed 32bit field. Default value is 0 */
|
||||
uint32_t getFast32() const { return f32; }
|
||||
|
||||
/** Set the event's unnamed 32bit field. */
|
||||
void setFast32(uint32_t x) { f32 = x; }
|
||||
|
||||
/** Return true if the event contains the named 32bit field, and return the field
|
||||
in value (if value is non-null). If there is no matching named field, return false
|
||||
and ignore the value parameter.
|
||||
*/
|
||||
bool findS32(const char name[], int32_t* value = nullptr) const {
|
||||
return fMeta.findS32(name, value);
|
||||
}
|
||||
/** Return true if the event contains the named SkScalar field, and return the field
|
||||
in value (if value is non-null). If there is no matching named field, return false
|
||||
and ignore the value parameter.
|
||||
*/
|
||||
bool findScalar(const char name[], SkScalar* value = nullptr) const {
|
||||
return fMeta.findScalar(name, value);
|
||||
}
|
||||
/** Return true if the event contains the named SkScalar field, and return the fields
|
||||
in value[] (if value is non-null), and return the number of SkScalars in count
|
||||
(if count is non-null). If there is no matching named field, return false
|
||||
and ignore the value and count parameters.
|
||||
*/
|
||||
const SkScalar* findScalars(const char name[], int* count, SkScalar values[]=nullptr) const{
|
||||
return fMeta.findScalars(name, count, values);
|
||||
}
|
||||
/** Return the value of the named string field, or nullptr. */
|
||||
const char* findString(const char name[]) const { return fMeta.findString(name); }
|
||||
/** Return true if the event contains the named pointer field, and return the field
|
||||
in value (if value is non-null). If there is no matching named field, return false
|
||||
and ignore the value parameter.
|
||||
*/
|
||||
bool findPtr(const char name[], void** value) const { return fMeta.findPtr(name, value); }
|
||||
bool findBool(const char name[], bool* value) const { return fMeta.findBool(name, value); }
|
||||
const void* findData(const char name[], size_t* byteCount = nullptr) const {
|
||||
return fMeta.findData(name, byteCount);
|
||||
}
|
||||
|
||||
/** Returns true if ethe event contains the named 32bit field, and if it equals the specified value */
|
||||
bool hasS32(const char name[], int32_t value) const { return fMeta.hasS32(name, value); }
|
||||
/** Returns true if ethe event contains the named SkScalar field, and if it equals the specified value */
|
||||
bool hasScalar(const char name[], SkScalar value) const { return fMeta.hasScalar(name, value); }
|
||||
/** Returns true if ethe event contains the named string field, and if it equals (using strcmp) the specified value */
|
||||
bool hasString(const char name[], const char value[]) const { return fMeta.hasString(name, value); }
|
||||
/** Returns true if ethe event contains the named pointer field, and if it equals the specified value */
|
||||
bool hasPtr(const char name[], void* value) const { return fMeta.hasPtr(name, value); }
|
||||
bool hasBool(const char name[], bool value) const { return fMeta.hasBool(name, value); }
|
||||
bool hasData(const char name[], const void* data, size_t byteCount) const {
|
||||
return fMeta.hasData(name, data, byteCount);
|
||||
}
|
||||
|
||||
/** Add/replace the named 32bit field to the event. */
|
||||
void setS32(const char name[], int32_t value) { fMeta.setS32(name, value); }
|
||||
/** Add/replace the named SkScalar field to the event. */
|
||||
void setScalar(const char name[], SkScalar value) { fMeta.setScalar(name, value); }
|
||||
/** Add/replace the named SkScalar[] field to the event. */
|
||||
SkScalar* setScalars(const char name[], int count, const SkScalar values[] = nullptr) {
|
||||
return fMeta.setScalars(name, count, values);
|
||||
}
|
||||
/** Add/replace the named string field to the event. */
|
||||
void setString(const char name[], const char value[]) { fMeta.setString(name, value); }
|
||||
/** Add/replace the named pointer field to the event. */
|
||||
void setPtr(const char name[], void* value) { fMeta.setPtr(name, value); }
|
||||
void setBool(const char name[], bool value) { fMeta.setBool(name, value); }
|
||||
void setData(const char name[], const void* data, size_t byteCount) {
|
||||
fMeta.setData(name, data, byteCount);
|
||||
}
|
||||
|
||||
/** Return the underlying metadata object */
|
||||
SkMetaData& getMetaData() { return fMeta; }
|
||||
/** Return the underlying metadata object */
|
||||
const SkMetaData& getMetaData() const { return fMeta; }
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private:
|
||||
SkMetaData fMeta;
|
||||
SkString fType;
|
||||
uint32_t f32;
|
||||
};
|
||||
|
||||
/** Pass an event to this object for processing. Returns true if the event was handled. */
|
||||
bool doEvent(const Event&);
|
||||
|
||||
/** Returns true if the sink (or one of its subclasses) understands the event as a query.
|
||||
If so, the sink may modify the event to communicate its "answer".
|
||||
*/
|
||||
bool doQuery(Event* query);
|
||||
|
||||
static const char* kCharEvtName;
|
||||
static const char* kTitleEvtName;
|
||||
static bool CharQ(const Event&, SkUnichar* outUni);
|
||||
static bool TitleQ(const Event&);
|
||||
static void TitleR(Event*, const char title[]);
|
||||
static bool RequestTitle(Sample* view, SkString* title);
|
||||
|
||||
protected:
|
||||
/** Override to handle events in your subclass.
|
||||
* Overriders must call the super class for unhandled events.
|
||||
*/
|
||||
virtual bool onEvent(const Event&);
|
||||
virtual bool onQuery(Event*);
|
||||
|
||||
/** Override to be notified of size changes. Overriders must call the super class. */
|
||||
virtual void onSizeChange();
|
||||
|
||||
/** Override this if you might handle the click */
|
||||
virtual Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned modi);
|
||||
|
||||
/** Override to track clicks. Return true as long as you want to track the pen/mouse. */
|
||||
virtual bool onClick(Click*);
|
||||
|
||||
virtual void onDrawBackground(SkCanvas*);
|
||||
virtual void onDrawContent(SkCanvas*) = 0;
|
||||
virtual bool onAnimate(const SkAnimTimer&) { return false; }
|
||||
virtual void onOnceBeforeDraw() {}
|
||||
|
||||
private:
|
||||
SkColor fBGColor;
|
||||
SkScalar fWidth, fHeight;
|
||||
bool fHaveCalledOnceBeforeDraw;
|
||||
};
|
||||
|
||||
#endif
|
@ -4,21 +4,19 @@
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
#include "SampleCode.h"
|
||||
#include "SkView.h"
|
||||
#include "Sample.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkGradientShader.h"
|
||||
|
||||
|
||||
class TwoPtConicalView : public SampleView {
|
||||
class TwoPtConicalView : public Sample {
|
||||
public:
|
||||
TwoPtConicalView() {}
|
||||
|
||||
protected:
|
||||
// overrides from SkEventSink
|
||||
virtual bool onQuery(SkEvent* evt) {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "2PtConical");
|
||||
virtual bool onQuery(Sample::Event* evt) {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "2PtConical");
|
||||
return true;
|
||||
}
|
||||
return this->INHERITED::onQuery(evt);
|
||||
@ -40,10 +38,9 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static SkView* MyFactory() { return new TwoPtConicalView; }
|
||||
static SkViewRegister reg(MyFactory);
|
||||
DEF_SAMPLE( return new TwoPtConicalView(); )
|
||||
|
@ -5,11 +5,10 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "SampleCode.h"
|
||||
#include "Sample.h"
|
||||
#include "SkAAClip.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkPath.h"
|
||||
#include "SkView.h"
|
||||
|
||||
static void testop(const SkIRect& r0, const SkIRect& r1, SkRegion::Op op,
|
||||
const SkIRect& expectedR) {
|
||||
@ -55,17 +54,16 @@ static void drawClip(SkCanvas* canvas, const SkAAClip& clip) {
|
||||
&paint);
|
||||
}
|
||||
|
||||
class AAClipView : public SampleView {
|
||||
class AAClipView : public Sample {
|
||||
public:
|
||||
AAClipView() {
|
||||
testop();
|
||||
}
|
||||
|
||||
protected:
|
||||
// overrides from SkEventSink
|
||||
virtual bool onQuery(SkEvent* evt) {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "AAClip");
|
||||
virtual bool onQuery(Sample::Event* evt) {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "AAClip");
|
||||
return true;
|
||||
}
|
||||
return this->INHERITED::onQuery(evt);
|
||||
@ -116,10 +114,9 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
typedef SkView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static SkView* MyFactory() { return new AAClipView; }
|
||||
static SkViewRegister reg(MyFactory);
|
||||
DEF_SAMPLE( return new AAClipView(); )
|
||||
|
@ -5,7 +5,7 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "SampleCode.h"
|
||||
#include "Sample.h"
|
||||
#include "SkBitmap.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkGeometry.h"
|
||||
@ -16,7 +16,6 @@
|
||||
// #include "SkPathStroker.h"
|
||||
#include "SkPointPriv.h"
|
||||
#include "SkString.h"
|
||||
#include "SkView.h"
|
||||
|
||||
#if 0
|
||||
void SkStrokeSegment::dump() const {
|
||||
@ -645,7 +644,7 @@ struct BiControl : public UniControl {
|
||||
};
|
||||
|
||||
|
||||
class MyClick : public SampleView::Click {
|
||||
class MyClick : public Sample::Click {
|
||||
public:
|
||||
enum ClickType {
|
||||
kInvalidType = -1,
|
||||
@ -684,7 +683,7 @@ public:
|
||||
SkPath::Verb fVerb;
|
||||
SkScalar fWeight;
|
||||
|
||||
MyClick(SkView* target, ClickType type, ControlType control)
|
||||
MyClick(Sample* target, ClickType type, ControlType control)
|
||||
: Click(target)
|
||||
, fType(type)
|
||||
, fControl(control)
|
||||
@ -692,7 +691,7 @@ public:
|
||||
, fWeight(1) {
|
||||
}
|
||||
|
||||
MyClick(SkView* target, ClickType type, int index)
|
||||
MyClick(Sample* target, ClickType type, int index)
|
||||
: Click(target)
|
||||
, fType(type)
|
||||
, fControl((ControlType) index)
|
||||
@ -700,7 +699,7 @@ public:
|
||||
, fWeight(1) {
|
||||
}
|
||||
|
||||
MyClick(SkView* target, ClickType type, int index, SkPath::Verb verb, SkScalar weight)
|
||||
MyClick(Sample* target, ClickType type, int index, SkPath::Verb verb, SkScalar weight)
|
||||
: Click(target)
|
||||
, fType(type)
|
||||
, fControl((ControlType) index)
|
||||
@ -783,7 +782,7 @@ struct PathUndo {
|
||||
PathUndo* fNext;
|
||||
};
|
||||
|
||||
class AAGeometryView : public SampleView {
|
||||
class AAGeometryView : public Sample {
|
||||
SkPaint fActivePaint;
|
||||
SkPaint fComplexPaint;
|
||||
SkPaint fCoveragePaint;
|
||||
@ -971,8 +970,7 @@ public:
|
||||
|
||||
#undef SET_BUTTON
|
||||
|
||||
// overrides from SkEventSink
|
||||
bool onQuery(SkEvent* evt) override;
|
||||
bool onQuery(Sample::Event* evt) override;
|
||||
|
||||
void onSizeChange() override {
|
||||
setControlButtonsPos();
|
||||
@ -1611,7 +1609,7 @@ public:
|
||||
return -1;
|
||||
}
|
||||
|
||||
virtual SkView::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned modi) override {
|
||||
virtual Sample::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned modi) override {
|
||||
SkPoint pt = {x, y};
|
||||
int ptHit = hittest_pt(pt);
|
||||
if (ptHit >= 0) {
|
||||
@ -1787,7 +1785,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
static struct KeyCommand {
|
||||
@ -1822,17 +1820,16 @@ void AAGeometryView::draw_legend(SkCanvas* canvas) {
|
||||
}
|
||||
}
|
||||
|
||||
// overrides from SkEventSink
|
||||
bool AAGeometryView::onQuery(SkEvent* evt) {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "AAGeometry");
|
||||
bool AAGeometryView::onQuery(Sample::Event* evt) {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "AAGeometry");
|
||||
return true;
|
||||
}
|
||||
SkUnichar uni;
|
||||
if (false) {
|
||||
return this->INHERITED::onQuery(evt);
|
||||
}
|
||||
if (SampleCode::CharQ(*evt, &uni)) {
|
||||
if (Sample::CharQ(*evt, &uni)) {
|
||||
for (int index = 0; index < kButtonCount; ++index) {
|
||||
Button* button = kButtonList[index].fButton;
|
||||
if (button->fVisible && uni == button->fLabel) {
|
||||
|
@ -5,8 +5,7 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "SampleCode.h"
|
||||
#include "SkView.h"
|
||||
#include "Sample.h"
|
||||
#include "SkBitmap.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkColorPriv.h"
|
||||
@ -72,7 +71,7 @@ static sk_sp<SkShader> make_bg_shader() {
|
||||
&m);
|
||||
}
|
||||
|
||||
class AARectsModesView : public SampleView {
|
||||
class AARectsModesView : public Sample {
|
||||
SkPaint fBGPaint;
|
||||
public:
|
||||
AARectsModesView () {
|
||||
@ -80,10 +79,9 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
// overrides from SkEventSink
|
||||
virtual bool onQuery(SkEvent* evt) {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "AARectsModes");
|
||||
virtual bool onQuery(Sample::Event* evt) {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "AARectsModes");
|
||||
return true;
|
||||
}
|
||||
return this->INHERITED::onQuery(evt);
|
||||
@ -120,10 +118,9 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static SkView* MyFactory() { return new AARectsModesView; }
|
||||
static SkViewRegister reg(MyFactory);
|
||||
DEF_SAMPLE( return new AARectsModesView(); )
|
||||
|
@ -4,8 +4,7 @@
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
#include "SampleCode.h"
|
||||
#include "SkView.h"
|
||||
#include "Sample.h"
|
||||
#include "SkBitmap.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkPaint.h"
|
||||
@ -33,7 +32,7 @@ static SkBitmap createBitmap(int n) {
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
class AARectView : public SampleView {
|
||||
class AARectView : public Sample {
|
||||
SkBitmap fBitmap;
|
||||
enum {
|
||||
N = 64
|
||||
@ -46,10 +45,9 @@ protected:
|
||||
fWidth = N;
|
||||
}
|
||||
|
||||
// overrides from SkEventSink
|
||||
bool onQuery(SkEvent* evt) override {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "AA Rects");
|
||||
bool onQuery(Sample::Event* evt) override {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "AA Rects");
|
||||
return true;
|
||||
}
|
||||
return this->INHERITED::onQuery(evt);
|
||||
@ -184,10 +182,9 @@ protected:
|
||||
private:
|
||||
int fWidth;
|
||||
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static SkView* MyFactory() { return new AARectView; }
|
||||
static SkViewRegister reg(MyFactory);
|
||||
DEF_SAMPLE( return new AARectView(); )
|
||||
|
@ -4,10 +4,9 @@
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
#include "SampleCode.h"
|
||||
#include "Sample.h"
|
||||
#include "SkBlurMask.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkView.h"
|
||||
#include "Sk1DPathEffect.h"
|
||||
#include "Sk2DPathEffect.h"
|
||||
#include "SkBlurMaskFilter.h"
|
||||
@ -58,15 +57,14 @@ private:
|
||||
typedef Sk2DPathEffect INHERITED;
|
||||
};
|
||||
|
||||
class DemoView : public SampleView {
|
||||
class DemoView : public Sample {
|
||||
public:
|
||||
DemoView() {}
|
||||
|
||||
protected:
|
||||
// overrides from SkEventSink
|
||||
virtual bool onQuery(SkEvent* evt) {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "Demo");
|
||||
virtual bool onQuery(Sample::Event* evt) {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "Demo");
|
||||
return true;
|
||||
}
|
||||
return this->INHERITED::onQuery(evt);
|
||||
@ -273,7 +271,7 @@ protected:
|
||||
canvas->restore();
|
||||
}
|
||||
|
||||
virtual SkView::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned modi) {
|
||||
virtual Sample::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned modi) {
|
||||
fClickPt.set(x, y);
|
||||
return this->INHERITED::onFindClickHandler(x, y, modi);
|
||||
}
|
||||
@ -316,10 +314,9 @@ protected:
|
||||
private:
|
||||
SkPoint fClickPt;
|
||||
SkBitmap fBug, fTb, fTx;
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static SkView* MyFactory() { return new DemoView; }
|
||||
static SkViewRegister reg(MyFactory);
|
||||
DEF_SAMPLE( return new DemoView(); )
|
||||
|
@ -5,7 +5,7 @@
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
#include "SampleCode.h"
|
||||
#include "Sample.h"
|
||||
#include "SkAnimTimer.h"
|
||||
#include "SkBlurMask.h"
|
||||
#include "SkBlurMaskFilter.h"
|
||||
@ -17,12 +17,11 @@
|
||||
#include "SkPoint3.h"
|
||||
#include "SkShadowUtils.h"
|
||||
#include "SkUtils.h"
|
||||
#include "SkView.h"
|
||||
#include "sk_tool_utils.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class ShadowsView : public SampleView {
|
||||
class ShadowsView : public Sample {
|
||||
SkPath fRectPath;
|
||||
SkPath fRRPath;
|
||||
SkPath fCirclePath;
|
||||
@ -107,15 +106,14 @@ protected:
|
||||
fLightPos = SkPoint3::Make(350, 0, 600);
|
||||
}
|
||||
|
||||
// overrides from SkEventSink
|
||||
bool onQuery(SkEvent* evt) override {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "AndroidShadows");
|
||||
bool onQuery(Sample::Event* evt) override {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "AndroidShadows");
|
||||
return true;
|
||||
}
|
||||
|
||||
SkUnichar uni;
|
||||
if (SampleCode::CharQ(*evt, &uni)) {
|
||||
if (Sample::CharQ(*evt, &uni)) {
|
||||
bool handled = false;
|
||||
switch (uni) {
|
||||
case 'W':
|
||||
@ -353,10 +351,9 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static SkView* MyFactory() { return new ShadowsView; }
|
||||
static SkViewRegister reg(MyFactory);
|
||||
DEF_SAMPLE( return new ShadowsView(); )
|
||||
|
@ -5,7 +5,7 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "SampleCode.h"
|
||||
#include "Sample.h"
|
||||
#include "SkAnimTimer.h"
|
||||
#include "SkColorPriv.h"
|
||||
#include "SkCanvas.h"
|
||||
@ -22,15 +22,14 @@ SkScalar get_anim_sin(double secs, SkScalar amplitude, SkScalar periodInSec, SkS
|
||||
return amplitude * SkDoubleToScalar(sin(t)) + amplitude;
|
||||
}
|
||||
|
||||
class AnimBlurView : public SampleView {
|
||||
class AnimBlurView : public Sample {
|
||||
public:
|
||||
AnimBlurView() : fBlurSigma(0), fCircleRadius(100) {}
|
||||
|
||||
protected:
|
||||
// overrides from SkEventSink
|
||||
bool onQuery(SkEvent* evt) override {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "AnimBlur");
|
||||
bool onQuery(Sample::Event* evt) override {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "AnimBlur");
|
||||
return true;
|
||||
}
|
||||
return this->INHERITED::onQuery(evt);
|
||||
@ -65,10 +64,9 @@ protected:
|
||||
private:
|
||||
SkScalar fBlurSigma, fCircleRadius;
|
||||
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static SkView* MyFactory() { return new AnimBlurView; }
|
||||
static SkViewRegister reg(MyFactory);
|
||||
DEF_SAMPLE( return new AnimBlurView(); )
|
||||
|
@ -15,13 +15,13 @@
|
||||
#include "SkScalar.h"
|
||||
#include "SkString.h"
|
||||
|
||||
#include "SampleCode.h"
|
||||
#include "Sample.h"
|
||||
#include "Resources.h"
|
||||
|
||||
static constexpr char kPauseKey = 'p';
|
||||
static constexpr char kResetKey = 'r';
|
||||
|
||||
class SampleAnimatedImage : public SampleView {
|
||||
class SampleAnimatedImage : public Sample {
|
||||
public:
|
||||
SampleAnimatedImage()
|
||||
: INHERITED()
|
||||
@ -97,14 +97,14 @@ protected:
|
||||
fDrawable = recorder.finishRecordingAsDrawable();
|
||||
}
|
||||
|
||||
bool onQuery(SkEvent* evt) override {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "AnimatedImage");
|
||||
bool onQuery(Sample::Event* evt) override {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "AnimatedImage");
|
||||
return true;
|
||||
}
|
||||
|
||||
SkUnichar uni;
|
||||
if (fImage && SampleCode::CharQ(*evt, &uni)) {
|
||||
if (fImage && Sample::CharQ(*evt, &uni)) {
|
||||
switch (uni) {
|
||||
case kPauseKey:
|
||||
fRunning = !fRunning;
|
||||
@ -133,13 +133,9 @@ private:
|
||||
double fCurrentTime = 0.0;
|
||||
double fLastWallTime = 0.0;
|
||||
double fTimeToShowNextFrame = 0.0;
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static SkView* MyFactory() {
|
||||
return new SampleAnimatedImage;
|
||||
}
|
||||
|
||||
static SkViewRegister reg(MyFactory);
|
||||
DEF_SAMPLE( return new SampleAnimatedImage(); )
|
||||
|
@ -5,8 +5,7 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "SampleCode.h"
|
||||
#include "SkView.h"
|
||||
#include "Sample.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkUtils.h"
|
||||
#include "SkColorPriv.h"
|
||||
@ -40,7 +39,7 @@ static void DrawTheText(SkCanvas* canvas, const char text[], size_t length, SkSc
|
||||
// -- this feature boosts the rendering out of the small point-size
|
||||
// SDF-text special case (which falls back to bitmap fonts for small points)
|
||||
|
||||
class AnimatedTextView : public SampleView {
|
||||
class AnimatedTextView : public Sample {
|
||||
public:
|
||||
AnimatedTextView() : fScale(1.0f), fScaleInc(0.1f), fRotation(0.0f), fSizeScale(1) {
|
||||
fCurrentTime = 0;
|
||||
@ -49,15 +48,14 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
// overrides from SkEventSink
|
||||
bool onQuery(SkEvent* evt) override {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "AnimatedText");
|
||||
bool onQuery(Sample::Event* evt) override {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "AnimatedText");
|
||||
return true;
|
||||
}
|
||||
|
||||
SkUnichar uni;
|
||||
if (SampleCode::CharQ(*evt, &uni)) {
|
||||
if (Sample::CharQ(*evt, &uni)) {
|
||||
if ('2' == uni) {
|
||||
if (fSizeScale == 2) {
|
||||
fSizeScale = 1;
|
||||
@ -155,10 +153,9 @@ private:
|
||||
int fCurrentTime;
|
||||
|
||||
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static SkView* MyFactory() { return new AnimatedTextView; }
|
||||
static SkViewRegister reg(MyFactory);
|
||||
DEF_SAMPLE( return new AnimatedTextView(); )
|
||||
|
@ -1,173 +0,0 @@
|
||||
/*
|
||||
* Copyright 2011 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
#include "SampleCode.h"
|
||||
#include "SkView.h"
|
||||
#include "SkCanvas.h"
|
||||
|
||||
#include "SkAnimator.h"
|
||||
#include "SkStream.h"
|
||||
#include "SkDOM.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class SkAnimatorView : public SkView {
|
||||
public:
|
||||
SkAnimatorView();
|
||||
virtual ~SkAnimatorView();
|
||||
|
||||
void setURIBase(const char dir[]);
|
||||
|
||||
SkAnimator* getAnimator() const { return fAnimator; }
|
||||
|
||||
bool decodeFile(const char path[]);
|
||||
bool decodeMemory(const void* buffer, size_t size);
|
||||
bool decodeStream(SkStream* stream);
|
||||
|
||||
protected:
|
||||
// overrides
|
||||
virtual void onDraw(SkCanvas*);
|
||||
virtual bool onQuery(SkEvent* evt);
|
||||
|
||||
private:
|
||||
SkString fBaseURI;
|
||||
SkAnimator* fAnimator;
|
||||
|
||||
typedef SkView INHERITED;
|
||||
};
|
||||
|
||||
SkAnimatorView::SkAnimatorView() : fAnimator(nullptr) {}
|
||||
|
||||
SkAnimatorView::~SkAnimatorView() {
|
||||
delete fAnimator;
|
||||
}
|
||||
|
||||
void SkAnimatorView::setURIBase(const char dir[]) {
|
||||
fBaseURI.set(dir);
|
||||
}
|
||||
|
||||
bool SkAnimatorView::decodeFile(const char path[]) {
|
||||
std::unique_ptr<SkStream> is = SkStream::MakeFromFile(path);
|
||||
return is && this->decodeStream(is.get());
|
||||
}
|
||||
|
||||
bool SkAnimatorView::decodeMemory(const void* buffer, size_t size) {
|
||||
SkMemoryStream is(buffer, size);
|
||||
return this->decodeStream(&is);
|
||||
}
|
||||
|
||||
static const SkDOMNode* find_nodeID(const SkDOM& dom,
|
||||
const SkDOMNode* node, const char name[]) {
|
||||
if (nullptr == node) {
|
||||
node = dom.getRootNode();
|
||||
}
|
||||
do {
|
||||
const char* idval = dom.findAttr(node, "id");
|
||||
if (idval && !strcmp(idval, name)) {
|
||||
return node;
|
||||
}
|
||||
const SkDOMNode* child = dom.getFirstChild(node);
|
||||
if (child) {
|
||||
const SkDOMNode* found = find_nodeID(dom, child, name);
|
||||
if (found) {
|
||||
return found;
|
||||
}
|
||||
}
|
||||
} while ((node = dom.getNextSibling(node)) != nullptr);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool SkAnimatorView::decodeStream(SkStream* stream) {
|
||||
delete fAnimator;
|
||||
fAnimator = new SkAnimator;
|
||||
fAnimator->setURIBase(fBaseURI.c_str());
|
||||
#if 0
|
||||
if (!fAnimator->decodeStream(stream)) {
|
||||
delete fAnimator;
|
||||
fAnimator = nullptr;
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
size_t len = stream->getLength();
|
||||
char* text = (char*)sk_malloc_throw(len);
|
||||
stream->read(text, len);
|
||||
SkDOM dom;
|
||||
const SkDOM::Node* root = dom.build(text, len);
|
||||
if (nullptr == root) {
|
||||
return false;
|
||||
}
|
||||
if (!fAnimator->decodeDOM(dom, root)) {
|
||||
delete fAnimator;
|
||||
fAnimator = nullptr;
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i <= 10; i++) {
|
||||
SkString name("glyph");
|
||||
name.appendS32(i);
|
||||
const SkDOM::Node* node = find_nodeID(dom, nullptr, name.c_str());
|
||||
SkASSERT(node);
|
||||
SkRect r;
|
||||
dom.findScalar(node, "left", &r.fLeft);
|
||||
dom.findScalar(node, "top", &r.fTop);
|
||||
dom.findScalar(node, "width", &r.fRight); r.fRight += r.fLeft;
|
||||
dom.findScalar(node, "height", &r.fBottom); r.fBottom += r.fTop;
|
||||
SkDebugf("--- %s [%g %g %g %g]\n", name.c_str(),
|
||||
r.fLeft, r.fTop, r.fRight, r.fBottom);
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
#include "SkTime.h"
|
||||
|
||||
void SkAnimatorView::onDraw(SkCanvas* canvas) {
|
||||
canvas->drawColor(SK_ColorWHITE);
|
||||
if (fAnimator) {
|
||||
fAnimator->draw(canvas, 0);
|
||||
#if 0
|
||||
canvas->save();
|
||||
canvas->translate(120, 30);
|
||||
canvas->scale(0.5, 0.5);
|
||||
fAnimator->draw(canvas, 0);
|
||||
canvas->restore();
|
||||
|
||||
canvas->save();
|
||||
canvas->translate(190, 40);
|
||||
canvas->scale(0.25, 0.25);
|
||||
fAnimator->draw(canvas, 0);
|
||||
canvas->restore();
|
||||
|
||||
this->inval(nullptr);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
bool SkAnimatorView::onQuery(SkEvent* evt) {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "Animator");
|
||||
return true;
|
||||
}
|
||||
return this->INHERITED::onQuery(evt);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static SkView* MyFactory() {
|
||||
SkAnimatorView* av = new SkAnimatorView;
|
||||
// av->decodeFile("/skimages/test.xml");
|
||||
#if 0
|
||||
av->setURIBase("/skia/trunk/animations/");
|
||||
av->decodeFile("/skia/trunk/animations/checkbox.xml");
|
||||
#else
|
||||
av->setURIBase("/");
|
||||
av->decodeFile("/testanim.txt");
|
||||
#endif
|
||||
return av;
|
||||
}
|
||||
|
||||
static SkViewRegister reg(MyFactory);
|
@ -5,7 +5,7 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "SampleCode.h"
|
||||
#include "Sample.h"
|
||||
#include "SkAnimTimer.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkColorFilter.h"
|
||||
@ -21,7 +21,6 @@
|
||||
#include "SkShader.h"
|
||||
#include "SkString.h"
|
||||
#include "SkUtils.h"
|
||||
#include "SkView.h"
|
||||
#include "Sk1DPathEffect.h"
|
||||
|
||||
#include "SkParsePath.h"
|
||||
@ -37,7 +36,7 @@ static void testparse() {
|
||||
SkParsePath::ToSVGString(p2, &str2);
|
||||
}
|
||||
|
||||
class ArcsView : public SampleView {
|
||||
class ArcsView : public Sample {
|
||||
class MyDrawable : public SkDrawable {
|
||||
SkRect fR;
|
||||
SkScalar fSweep;
|
||||
@ -99,10 +98,9 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
// overrides from SkEventSink
|
||||
bool onQuery(SkEvent* evt) override {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "Arcs");
|
||||
bool onQuery(Sample::Event* evt) override {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "Arcs");
|
||||
return true;
|
||||
}
|
||||
return this->INHERITED::onQuery(evt);
|
||||
@ -199,10 +197,9 @@ protected:
|
||||
private:
|
||||
SkScalar fSweep;
|
||||
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static SkView* MyFactory() { return new ArcsView; }
|
||||
static SkViewRegister reg(MyFactory);
|
||||
DEF_SAMPLE( return new ArcsView(); )
|
||||
|
@ -5,9 +5,8 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "SampleCode.h"
|
||||
#include "Sample.h"
|
||||
#include "SkAnimTimer.h"
|
||||
#include "SkView.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkDrawable.h"
|
||||
#include "SkPath.h"
|
||||
@ -201,7 +200,7 @@ private:
|
||||
typedef SkDrawable INHERITED;
|
||||
};
|
||||
|
||||
class DrawAtlasView : public SampleView {
|
||||
class DrawAtlasView : public Sample {
|
||||
const char* fName;
|
||||
DrawAtlasProc fProc;
|
||||
sk_sp<DrawAtlasDrawable> fDrawable;
|
||||
@ -210,13 +209,13 @@ public:
|
||||
DrawAtlasView(const char name[], DrawAtlasProc proc) : fName(name), fProc(proc) { }
|
||||
|
||||
protected:
|
||||
bool onQuery(SkEvent* evt) override {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, fName);
|
||||
bool onQuery(Sample::Event* evt) override {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, fName);
|
||||
return true;
|
||||
}
|
||||
SkUnichar uni;
|
||||
if (SampleCode::CharQ(*evt, &uni)) {
|
||||
if (Sample::CharQ(*evt, &uni)) {
|
||||
switch (uni) {
|
||||
case 'C': fDrawable->toggleUseColors(); return true;
|
||||
default: break;
|
||||
@ -246,7 +245,7 @@ protected:
|
||||
#endif
|
||||
|
||||
private:
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -4,22 +4,20 @@
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
#include "SampleCode.h"
|
||||
#include "Sample.h"
|
||||
#include "SkBlurMask.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkMaskFilter.h"
|
||||
#include "SkView.h"
|
||||
|
||||
class BigBlurView : public SampleView {
|
||||
class BigBlurView : public Sample {
|
||||
public:
|
||||
BigBlurView() {
|
||||
}
|
||||
|
||||
protected:
|
||||
// overrides from SkEventSink
|
||||
virtual bool onQuery(SkEvent* evt) {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "BigBlur");
|
||||
virtual bool onQuery(Sample::Event* evt) {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "BigBlur");
|
||||
return true;
|
||||
}
|
||||
return this->INHERITED::onQuery(evt);
|
||||
@ -38,10 +36,9 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
typedef SkView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static SkView* MyFactory() { return new BigBlurView; }
|
||||
static SkViewRegister reg(MyFactory);
|
||||
DEF_SAMPLE( return new BigBlurView(); )
|
||||
|
@ -5,8 +5,7 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "SampleCode.h"
|
||||
#include "SkView.h"
|
||||
#include "Sample.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkGradientShader.h"
|
||||
#include "SkMakeUnique.h"
|
||||
@ -17,14 +16,14 @@ static sk_sp<SkShader> make_grad(SkScalar w, SkScalar h) {
|
||||
return SkGradientShader::MakeLinear(pts, colors, nullptr, 2, SkShader::kClamp_TileMode);
|
||||
}
|
||||
|
||||
class BigGradientView : public SampleView {
|
||||
class BigGradientView : public Sample {
|
||||
public:
|
||||
BigGradientView() {}
|
||||
|
||||
protected:
|
||||
bool onQuery(SkEvent* evt) override {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "BigGradient");
|
||||
bool onQuery(Sample::Event* evt) override {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "BigGradient");
|
||||
return true;
|
||||
}
|
||||
return this->INHERITED::onQuery(evt);
|
||||
@ -39,13 +38,12 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static SkView* MyFactory() { return new BigGradientView; }
|
||||
static SkViewRegister reg(MyFactory);
|
||||
DEF_SAMPLE( return new BigGradientView(); )
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ -261,14 +259,14 @@ public:
|
||||
#endif
|
||||
|
||||
#ifdef MyAllocator
|
||||
class RasterAllocatorSample : public SampleView {
|
||||
class RasterAllocatorSample : public Sample {
|
||||
public:
|
||||
RasterAllocatorSample() {}
|
||||
|
||||
protected:
|
||||
bool onQuery(SkEvent* evt) override {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "raster-allocator");
|
||||
bool onQuery(Sample::Event* evt) override {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "raster-allocator");
|
||||
return true;
|
||||
}
|
||||
return this->INHERITED::onQuery(evt);
|
||||
@ -310,7 +308,7 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
DEF_SAMPLE( return new RasterAllocatorSample; )
|
||||
#endif
|
||||
|
@ -5,9 +5,8 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "SampleCode.h"
|
||||
#include "Sample.h"
|
||||
#include "SkAnimTimer.h"
|
||||
#include "SkView.h"
|
||||
#include "SkBitmap.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkGradientShader.h"
|
||||
@ -64,7 +63,7 @@ static void bounce_pt(SkPoint* pt, SkVector* vec, const SkRect& limit) {
|
||||
bounce(&pt->fY, &vec->fY, limit.fTop, limit.fBottom);
|
||||
}
|
||||
|
||||
class BitmapRectView : public SampleView {
|
||||
class BitmapRectView : public Sample {
|
||||
SkPoint fSrcPts[2];
|
||||
SkPoint fSrcVec[2];
|
||||
SkRect fSrcLimit;
|
||||
@ -102,9 +101,9 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
bool onQuery(SkEvent* evt) override {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "BitmapRect");
|
||||
bool onQuery(Sample::Event* evt) override {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "BitmapRect");
|
||||
return true;
|
||||
}
|
||||
return this->INHERITED::onQuery(evt);
|
||||
@ -146,7 +145,7 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
@ -175,7 +174,7 @@ static void make_big_bitmap(SkBitmap* bm) {
|
||||
canvas.drawString(gText, 0, paint.getTextSize()*4/5, paint);
|
||||
}
|
||||
|
||||
class BitmapRectView2 : public SampleView {
|
||||
class BitmapRectView2 : public Sample {
|
||||
SkBitmap fBitmap;
|
||||
|
||||
SkRect fSrcR;
|
||||
@ -198,9 +197,9 @@ public:
|
||||
BitmapRectView2() { }
|
||||
|
||||
protected:
|
||||
bool onQuery(SkEvent* evt) override {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "BigBitmapRect");
|
||||
bool onQuery(Sample::Event* evt) override {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "BigBitmapRect");
|
||||
return true;
|
||||
}
|
||||
return this->INHERITED::onQuery(evt);
|
||||
@ -243,12 +242,10 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static SkView* F0() { return new BitmapRectView; }
|
||||
static SkView* F1() { return new BitmapRectView2; }
|
||||
static SkViewRegister gR0(F0);
|
||||
static SkViewRegister gR1(F1);
|
||||
DEF_SAMPLE( return new BitmapRectView(); )
|
||||
DEF_SAMPLE( return new BitmapRectView2(); )
|
||||
|
@ -5,7 +5,7 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "SampleCode.h"
|
||||
#include "Sample.h"
|
||||
#include "SkBitmap.h"
|
||||
#include "SkBlurMask.h"
|
||||
#include "SkCanvas.h"
|
||||
@ -13,18 +13,16 @@
|
||||
#include "SkGradientShader.h"
|
||||
#include "SkMaskFilter.h"
|
||||
#include "SkUtils.h"
|
||||
#include "SkView.h"
|
||||
|
||||
class BlurView : public SampleView {
|
||||
class BlurView : public Sample {
|
||||
SkBitmap fBM;
|
||||
public:
|
||||
BlurView() {}
|
||||
|
||||
protected:
|
||||
// overrides from SkEventSink
|
||||
virtual bool onQuery(SkEvent* evt) {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "Blur");
|
||||
virtual bool onQuery(Sample::Event* evt) {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "Blur");
|
||||
return true;
|
||||
}
|
||||
return this->INHERITED::onQuery(evt);
|
||||
@ -83,10 +81,9 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
typedef SkView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static SkView* MyFactory() { return new BlurView; }
|
||||
static SkViewRegister reg(MyFactory);
|
||||
DEF_SAMPLE( return new BlurView(); )
|
||||
|
@ -14,13 +14,12 @@
|
||||
#include "GrRenderTargetContext.h"
|
||||
#include "GrRenderTargetContextPriv.h"
|
||||
#include "GrResourceProvider.h"
|
||||
#include "SampleCode.h"
|
||||
#include "Sample.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkMakeUnique.h"
|
||||
#include "SkPaint.h"
|
||||
#include "SkPath.h"
|
||||
#include "SkRectPriv.h"
|
||||
#include "SkView.h"
|
||||
#include "ccpr/GrCCCoverageProcessor.h"
|
||||
#include "ccpr/GrCCGeometry.h"
|
||||
#include "gl/GrGLGpu.cpp"
|
||||
@ -39,14 +38,14 @@ static constexpr float kDebugBloat = 40;
|
||||
* coverage=0 -> black, coverage=-1 -> red). Use the keys 1-7 to cycle through the different
|
||||
* geometry processors.
|
||||
*/
|
||||
class CCPRGeometryView : public SampleView {
|
||||
class CCPRGeometryView : public Sample {
|
||||
public:
|
||||
CCPRGeometryView() { this->updateGpuData(); }
|
||||
void onDrawContent(SkCanvas*) override;
|
||||
|
||||
SkView::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned) override;
|
||||
bool onClick(SampleView::Click*) override;
|
||||
bool onQuery(SkEvent* evt) override;
|
||||
Sample::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned) override;
|
||||
bool onClick(Sample::Click*) override;
|
||||
bool onQuery(Sample::Event* evt) override;
|
||||
|
||||
private:
|
||||
class Click;
|
||||
@ -69,7 +68,7 @@ private:
|
||||
SkTArray<TriPointInstance> fTriPointInstances;
|
||||
SkTArray<QuadPointInstance> fQuadPointInstances;
|
||||
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
class CCPRGeometryView::DrawCoverageCountOp : public GrDrawOp {
|
||||
@ -365,9 +364,9 @@ void CCPRGeometryView::DrawCoverageCountOp::onExecute(GrOpFlushState* state) {
|
||||
}
|
||||
}
|
||||
|
||||
class CCPRGeometryView::Click : public SampleView::Click {
|
||||
class CCPRGeometryView::Click : public Sample::Click {
|
||||
public:
|
||||
Click(SkView* target, int ptIdx) : SampleView::Click(target), fPtIdx(ptIdx) {}
|
||||
Click(Sample* target, int ptIdx) : Sample::Click(target), fPtIdx(ptIdx) {}
|
||||
|
||||
void doClick(SkPoint points[]) {
|
||||
if (fPtIdx >= 0) {
|
||||
@ -388,7 +387,7 @@ private:
|
||||
int fPtIdx;
|
||||
};
|
||||
|
||||
SkView::Click* CCPRGeometryView::onFindClickHandler(SkScalar x, SkScalar y, unsigned) {
|
||||
Sample::Click* CCPRGeometryView::onFindClickHandler(SkScalar x, SkScalar y, unsigned) {
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
if (PrimitiveType::kCubics != fPrimitiveType && 2 == i) {
|
||||
continue;
|
||||
@ -400,20 +399,20 @@ SkView::Click* CCPRGeometryView::onFindClickHandler(SkScalar x, SkScalar y, unsi
|
||||
return new Click(this, -1);
|
||||
}
|
||||
|
||||
bool CCPRGeometryView::onClick(SampleView::Click* click) {
|
||||
bool CCPRGeometryView::onClick(Sample::Click* click) {
|
||||
Click* myClick = (Click*)click;
|
||||
myClick->doClick(fPoints);
|
||||
this->updateAndInval();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CCPRGeometryView::onQuery(SkEvent* evt) {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "CCPRGeometry");
|
||||
bool CCPRGeometryView::onQuery(Sample::Event* evt) {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "CCPRGeometry");
|
||||
return true;
|
||||
}
|
||||
SkUnichar unichar;
|
||||
if (SampleCode::CharQ(*evt, &unichar)) {
|
||||
if (Sample::CharQ(*evt, &unichar)) {
|
||||
if (unichar >= '1' && unichar <= '4') {
|
||||
fPrimitiveType = PrimitiveType(unichar - '1');
|
||||
if (fPrimitiveType >= PrimitiveType::kWeightedTriangles) {
|
||||
|
@ -6,9 +6,8 @@
|
||||
*/
|
||||
|
||||
#include "DecodeFile.h"
|
||||
#include "SampleCode.h"
|
||||
#include "Sample.h"
|
||||
#include "SkAnimTimer.h"
|
||||
#include "SkView.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkCamera.h"
|
||||
#include "SkEmbossMaskFilter.h"
|
||||
@ -20,7 +19,7 @@
|
||||
#include "SkString.h"
|
||||
#include "SkUtils.h"
|
||||
|
||||
class CameraView : public SampleView {
|
||||
class CameraView : public Sample {
|
||||
SkTArray<sk_sp<SkShader>> fShaders;
|
||||
int fShaderIndex;
|
||||
bool fFrontFace;
|
||||
@ -52,10 +51,9 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
// overrides from SkEventSink
|
||||
bool onQuery(SkEvent* evt) override {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "Camera");
|
||||
bool onQuery(Sample::Event* evt) override {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "Camera");
|
||||
return true;
|
||||
}
|
||||
return this->INHERITED::onQuery(evt);
|
||||
@ -96,10 +94,9 @@ protected:
|
||||
|
||||
private:
|
||||
SkScalar fRX, fRY, fRZ;
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static SkView* MyFactory() { return new CameraView; }
|
||||
static SkViewRegister reg(MyFactory);
|
||||
DEF_SAMPLE( return new CameraView(); )
|
||||
|
@ -5,12 +5,11 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "SampleCode.h"
|
||||
#include "Sample.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkPaint.h"
|
||||
#include "SkPath.h"
|
||||
#include "SkRandom.h"
|
||||
#include "SkView.h"
|
||||
|
||||
// Generates y values for the chart plots.
|
||||
static void gen_data(SkScalar yAvg, SkScalar ySpread, int count, SkTDArray<SkScalar>* dataPts) {
|
||||
@ -81,7 +80,7 @@ static void gen_paths(const SkTDArray<SkScalar>& topData,
|
||||
|
||||
// A set of scrolling line plots with the area between each plot filled. Stresses out GPU path
|
||||
// filling
|
||||
class ChartView : public SampleView {
|
||||
class ChartView : public Sample {
|
||||
public:
|
||||
ChartView() {
|
||||
fShift = 0;
|
||||
@ -89,9 +88,9 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
bool onQuery(SkEvent* evt) override {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "Chart");
|
||||
bool onQuery(Sample::Event* evt) override {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "Chart");
|
||||
return true;
|
||||
}
|
||||
return this->INHERITED::onQuery(evt);
|
||||
@ -175,10 +174,9 @@ private:
|
||||
int fShift;
|
||||
SkISize fSize;
|
||||
SkTDArray<SkScalar> fData[kNumGraphs];
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static SkView* MyFactory() { return new ChartView; }
|
||||
static SkViewRegister reg(MyFactory);
|
||||
DEF_SAMPLE( return new ChartView(); )
|
||||
|
@ -6,7 +6,7 @@
|
||||
*/
|
||||
|
||||
#include "Resources.h"
|
||||
#include "SampleCode.h"
|
||||
#include "Sample.h"
|
||||
#include "sk_tool_utils.h"
|
||||
|
||||
#include "SkCanvas.h"
|
||||
@ -46,14 +46,14 @@ static sk_sp<SkTypeface> chinese_typeface() {
|
||||
#endif
|
||||
}
|
||||
|
||||
class ChineseFlingView : public SampleView {
|
||||
class ChineseFlingView : public Sample {
|
||||
public:
|
||||
ChineseFlingView() : fBlobs(kNumBlobs) {}
|
||||
|
||||
protected:
|
||||
bool onQuery(SkEvent* evt) override {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "chinese-fling");
|
||||
bool onQuery(Sample::Event* evt) override {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "chinese-fling");
|
||||
return true;
|
||||
}
|
||||
return this->INHERITED::onQuery(evt);
|
||||
@ -126,21 +126,21 @@ private:
|
||||
SkRandom fRand;
|
||||
int fIndex;
|
||||
|
||||
typedef SkView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
class ChineseZoomView : public SampleView {
|
||||
class ChineseZoomView : public Sample {
|
||||
public:
|
||||
ChineseZoomView() : fBlobs(kNumBlobs), fScale(15.0f), fTranslate(0.0f) {}
|
||||
|
||||
protected:
|
||||
bool onQuery(SkEvent* evt) override {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "chinese-zoom");
|
||||
bool onQuery(Sample::Event* evt) override {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "chinese-zoom");
|
||||
return true;
|
||||
}
|
||||
SkUnichar uni;
|
||||
if (SampleCode::CharQ(*evt, &uni)) {
|
||||
if (Sample::CharQ(*evt, &uni)) {
|
||||
if ('>' == uni) {
|
||||
fScale += 0.125f;
|
||||
return true;
|
||||
@ -260,13 +260,10 @@ private:
|
||||
SkScalar fTranslate;
|
||||
int fIndex;
|
||||
|
||||
typedef SkView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static SkView* FlingFactory() { return new ChineseFlingView; }
|
||||
static SkViewRegister regFling(FlingFactory);
|
||||
|
||||
static SkView* ZoomFactory() { return new ChineseZoomView; }
|
||||
static SkViewRegister regZoom(ZoomFactory);
|
||||
DEF_SAMPLE( return new ChineseFlingView(); )
|
||||
DEF_SAMPLE( return new ChineseZoomView(); )
|
||||
|
@ -5,11 +5,10 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "SampleCode.h"
|
||||
#include "Sample.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkPaint.h"
|
||||
#include "SkPath.h"
|
||||
#include "SkView.h"
|
||||
|
||||
// ensure that we don't accidentally screw up the bounds when the oval is
|
||||
// fractional, and the impl computes the center and radii, and uses them to
|
||||
@ -22,7 +21,7 @@ static void test_circlebounds(SkCanvas*) {
|
||||
SkASSERT(r == p.getBounds());
|
||||
}
|
||||
|
||||
class CircleView : public SampleView {
|
||||
class CircleView : public Sample {
|
||||
public:
|
||||
static const SkScalar ANIM_DX;
|
||||
static const SkScalar ANIM_DY;
|
||||
@ -35,10 +34,9 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
// overrides from SkEventSink
|
||||
virtual bool onQuery(SkEvent* evt) {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "Circles");
|
||||
virtual bool onQuery(Sample::Event* evt) {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "Circles");
|
||||
return true;
|
||||
}
|
||||
return this->INHERITED::onQuery(evt);
|
||||
@ -107,7 +105,7 @@ protected:
|
||||
|
||||
private:
|
||||
int fN;
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
const SkScalar CircleView::ANIM_DX(SK_Scalar1 / 67);
|
||||
@ -116,5 +114,4 @@ const SkScalar CircleView::ANIM_RAD(SK_Scalar1 / 19);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static SkView* MyFactory() { return new CircleView; }
|
||||
static SkViewRegister reg(MyFactory);
|
||||
DEF_SAMPLE( return new CircleView(); )
|
||||
|
@ -4,8 +4,7 @@
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
#include "SampleCode.h"
|
||||
#include "SkView.h"
|
||||
#include "Sample.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkGraphics.h"
|
||||
#include "SkRandom.h"
|
||||
@ -18,7 +17,7 @@ static sk_sp<SkShader> make_linear() {
|
||||
return SkGradientShader::MakeLinear(pts, colors, nullptr, 2, SkShader::kClamp_TileMode);
|
||||
}
|
||||
|
||||
class ClampView : public SampleView {
|
||||
class ClampView : public Sample {
|
||||
sk_sp<SkShader> fGrad;
|
||||
|
||||
public:
|
||||
@ -27,10 +26,9 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
// overrides from SkEventSink
|
||||
virtual bool onQuery(SkEvent* evt) {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "Clamp");
|
||||
virtual bool onQuery(Sample::Event* evt) {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "Clamp");
|
||||
return true;
|
||||
}
|
||||
return this->INHERITED::onQuery(evt);
|
||||
@ -52,10 +50,10 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static SkView* MyFactory() { return new ClampView; }
|
||||
static SkViewRegister reg(MyFactory);
|
||||
static Sample* MyFactory() { return new ClampView; }
|
||||
static SampleRegister reg(MyFactory);
|
||||
|
@ -5,9 +5,8 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "SampleCode.h"
|
||||
#include "Sample.h"
|
||||
#include "SkAAClip.h"
|
||||
#include "SkView.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkColorPriv.h"
|
||||
#include "SkPaint.h"
|
||||
@ -103,7 +102,7 @@ static void show_thick(SkCanvas* canvas, bool doAA) {
|
||||
|
||||
typedef void (*CanvasProc)(SkCanvas*, bool);
|
||||
|
||||
class ClipView : public SampleView {
|
||||
class ClipView : public Sample {
|
||||
public:
|
||||
ClipView() {
|
||||
SkAAClip clip;
|
||||
@ -115,10 +114,9 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
// overrides from SkEventSink
|
||||
virtual bool onQuery(SkEvent* evt) {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "Clip");
|
||||
virtual bool onQuery(Sample::Event* evt) {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "Clip");
|
||||
return true;
|
||||
}
|
||||
return this->INHERITED::onQuery(evt);
|
||||
@ -155,10 +153,9 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static SkView* MyFactory() { return new ClipView; }
|
||||
static SkViewRegister reg(MyFactory);
|
||||
DEF_SAMPLE( return new ClipView(); )
|
||||
|
@ -5,7 +5,7 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "SampleCode.h"
|
||||
#include "Sample.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkInterpolator.h"
|
||||
#include "SkPath.h"
|
||||
@ -114,7 +114,7 @@ static void draw_normal_geom(SkCanvas* canvas, const SkPoint& offset, int geom,
|
||||
}
|
||||
}
|
||||
|
||||
class ClipDrawMatchView : public SampleView {
|
||||
class ClipDrawMatchView : public Sample {
|
||||
public:
|
||||
ClipDrawMatchView() : fTrans(2, 5), fGeom(kRect_Geometry), fClipFirst(true), fSign(1) {
|
||||
SkScalar values[2];
|
||||
@ -133,13 +133,13 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
bool onQuery(SkEvent* evt) override {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "ClipDrawMatch");
|
||||
bool onQuery(Sample::Event* evt) override {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "ClipDrawMatch");
|
||||
return true;
|
||||
}
|
||||
SkUnichar uni;
|
||||
if (SampleCode::CharQ(*evt, &uni)) {
|
||||
if (Sample::CharQ(*evt, &uni)) {
|
||||
switch (uni) {
|
||||
case '1': fGeom = kRect_Geometry; return true;
|
||||
case '2': fGeom = kRRect_Geometry; return true;
|
||||
@ -252,10 +252,9 @@ private:
|
||||
int fSign;
|
||||
const double fStart = SkTime::GetMSecs();
|
||||
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static SkView* MyFactory() { return new ClipDrawMatchView; }
|
||||
static SkViewRegister reg(MyFactory);
|
||||
DEF_SAMPLE( return new ClipDrawMatchView(); )
|
||||
|
@ -4,7 +4,7 @@
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
#include "SampleCode.h"
|
||||
#include "Sample.h"
|
||||
|
||||
#include "SkCanvas.h"
|
||||
#include "SkPath.h"
|
||||
@ -17,15 +17,14 @@
|
||||
|
||||
#define USE_PATH 1
|
||||
|
||||
class ClockView : public SampleView {
|
||||
class ClockView : public Sample {
|
||||
public:
|
||||
ClockView() {}
|
||||
|
||||
protected:
|
||||
// overrides from SkEventSink
|
||||
bool onQuery(SkEvent* evt) override {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "Clock");
|
||||
bool onQuery(Sample::Event* evt) override {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "Clock");
|
||||
return true;
|
||||
}
|
||||
return this->INHERITED::onQuery(evt);
|
||||
@ -223,10 +222,9 @@ protected:
|
||||
|
||||
private:
|
||||
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static SkView* MyFactory() { return new ClockView; }
|
||||
static SkViewRegister reg(MyFactory);
|
||||
DEF_SAMPLE( return new ClockView(); )
|
||||
|
@ -1,107 +0,0 @@
|
||||
/*
|
||||
* Copyright 2016 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "SampleCode.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkString.h"
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
# include "GrContext.h"
|
||||
#else
|
||||
class GrContext;
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool SampleCode::CharQ(const SkEvent& evt, SkUnichar* outUni) {
|
||||
if (evt.isType(gCharEvtName)) {
|
||||
if (outUni) {
|
||||
*outUni = evt.getFast32();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SampleCode::TitleQ(const SkEvent& evt) {
|
||||
return evt.isType(gTitleEvtName);
|
||||
}
|
||||
|
||||
void SampleCode::TitleR(SkEvent* evt, const char title[]) {
|
||||
SkASSERT(evt && TitleQ(*evt));
|
||||
evt->setString(gTitleEvtName, title);
|
||||
}
|
||||
|
||||
bool SampleCode::RequestTitle(SkView* view, SkString* title) {
|
||||
SkEvent evt(gTitleEvtName);
|
||||
if (view->doQuery(&evt)) {
|
||||
title->set(evt.findString(gTitleEvtName));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
SkViewRegister* SkViewRegister::gHead;
|
||||
SkViewRegister::SkViewRegister(SkViewFactory* fact) : fFact(fact) {
|
||||
fFact->ref();
|
||||
fChain = gHead;
|
||||
gHead = this;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
SkFuncViewFactory::SkFuncViewFactory(SkViewCreateFunc func)
|
||||
: fCreateFunc(func) {
|
||||
}
|
||||
|
||||
SkView* SkFuncViewFactory::operator() () const {
|
||||
return (*fCreateFunc)();
|
||||
}
|
||||
|
||||
SkViewRegister::SkViewRegister(SkViewCreateFunc func) {
|
||||
fFact = new SkFuncViewFactory(func);
|
||||
fChain = gHead;
|
||||
gHead = this;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static const char is_sample_view_tag[] = "sample-is-sample-view";
|
||||
|
||||
bool SampleView::IsSampleView(SkView* view) {
|
||||
SkEvent evt(is_sample_view_tag);
|
||||
return view->doQuery(&evt);
|
||||
}
|
||||
|
||||
bool SampleView::onQuery(SkEvent* evt) {
|
||||
if (evt->isType(is_sample_view_tag)) {
|
||||
return true;
|
||||
}
|
||||
return this->INHERITED::onQuery(evt);
|
||||
}
|
||||
|
||||
void SampleView::onDraw(SkCanvas* canvas) {
|
||||
if (!fHaveCalledOnceBeforeDraw) {
|
||||
fHaveCalledOnceBeforeDraw = true;
|
||||
this->onOnceBeforeDraw();
|
||||
}
|
||||
this->onDrawBackground(canvas);
|
||||
|
||||
SkAutoCanvasRestore acr(canvas, true);
|
||||
this->onDrawContent(canvas);
|
||||
#if SK_SUPPORT_GPU
|
||||
// Ensure the GrContext doesn't combine GrDrawOps across draw loops.
|
||||
if (GrContext* context = canvas->getGrContext()) {
|
||||
context->flush();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void SampleView::onDrawBackground(SkCanvas* canvas) {
|
||||
canvas->drawColor(fBGColor);
|
||||
}
|
||||
|
@ -1,108 +0,0 @@
|
||||
/*
|
||||
* Copyright 2011 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SampleCode_DEFINED
|
||||
#define SampleCode_DEFINED
|
||||
|
||||
#include "SkColor.h"
|
||||
#include "SkEvent.h"
|
||||
#include "SkMacros.h"
|
||||
#include "SkView.h"
|
||||
|
||||
class SkAnimTimer;
|
||||
|
||||
#define DEF_SAMPLE(code) \
|
||||
static SkView* SK_MACRO_APPEND_LINE(F_)() { code } \
|
||||
static SkViewRegister SK_MACRO_APPEND_LINE(R_)(SK_MACRO_APPEND_LINE(F_));
|
||||
|
||||
static const char gCharEvtName[] = "SampleCode_Char_Event";
|
||||
static const char gTitleEvtName[] = "SampleCode_Title_Event";
|
||||
|
||||
class SampleCode {
|
||||
public:
|
||||
static bool CharQ(const SkEvent&, SkUnichar* outUni);
|
||||
|
||||
static bool TitleQ(const SkEvent&);
|
||||
static void TitleR(SkEvent*, const char title[]);
|
||||
static bool RequestTitle(SkView* view, SkString* title);
|
||||
|
||||
friend class SampleWindow;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// interface that constructs SkViews
|
||||
class SkViewFactory : public SkRefCnt {
|
||||
public:
|
||||
virtual SkView* operator() () const = 0;
|
||||
};
|
||||
|
||||
typedef SkView* (*SkViewCreateFunc)();
|
||||
|
||||
// wraps SkViewCreateFunc in SkViewFactory interface
|
||||
class SkFuncViewFactory : public SkViewFactory {
|
||||
public:
|
||||
SkFuncViewFactory(SkViewCreateFunc func);
|
||||
SkView* operator() () const override;
|
||||
|
||||
private:
|
||||
SkViewCreateFunc fCreateFunc;
|
||||
};
|
||||
|
||||
class SkViewRegister : public SkRefCnt {
|
||||
public:
|
||||
explicit SkViewRegister(SkViewFactory*);
|
||||
explicit SkViewRegister(SkViewCreateFunc);
|
||||
|
||||
~SkViewRegister() {
|
||||
fFact->unref();
|
||||
}
|
||||
|
||||
static const SkViewRegister* Head() { return gHead; }
|
||||
|
||||
SkViewRegister* next() const { return fChain; }
|
||||
const SkViewFactory* factory() const { return fFact; }
|
||||
|
||||
private:
|
||||
SkViewFactory* fFact;
|
||||
SkViewRegister* fChain;
|
||||
|
||||
static SkViewRegister* gHead;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class SampleView : public SkView {
|
||||
public:
|
||||
SampleView()
|
||||
: fBGColor(SK_ColorWHITE)
|
||||
, fHaveCalledOnceBeforeDraw(false)
|
||||
{}
|
||||
|
||||
void setBGColor(SkColor color) { fBGColor = color; }
|
||||
bool animate(const SkAnimTimer& timer) { return this->onAnimate(timer); }
|
||||
|
||||
static bool IsSampleView(SkView*);
|
||||
|
||||
protected:
|
||||
virtual void onDrawBackground(SkCanvas*);
|
||||
virtual void onDrawContent(SkCanvas*) = 0;
|
||||
virtual bool onAnimate(const SkAnimTimer&) { return false; }
|
||||
virtual void onOnceBeforeDraw() {}
|
||||
|
||||
// overrides
|
||||
virtual bool onQuery(SkEvent* evt);
|
||||
virtual void onDraw(SkCanvas*);
|
||||
|
||||
SkColor fBGColor;
|
||||
|
||||
private:
|
||||
bool fHaveCalledOnceBeforeDraw;
|
||||
typedef SkView INHERITED;
|
||||
};
|
||||
|
||||
#endif
|
@ -5,8 +5,7 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
#include "sk_tool_utils.h"
|
||||
#include "SampleCode.h"
|
||||
#include "SkView.h"
|
||||
#include "Sample.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkColorFilter.h"
|
||||
#include "SkPaint.h"
|
||||
@ -107,7 +106,7 @@ static SkBitmap createBitmap(int n) {
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
class ColorFilterView : public SampleView {
|
||||
class ColorFilterView : public Sample {
|
||||
SkBitmap fBitmap;
|
||||
sk_sp<SkShader> fShader;
|
||||
enum {
|
||||
@ -125,10 +124,9 @@ protected:
|
||||
}
|
||||
}
|
||||
|
||||
// overrides from SkEventSink
|
||||
bool onQuery(SkEvent* evt) override {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "ColorFilter");
|
||||
bool onQuery(Sample::Event* evt) override {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "ColorFilter");
|
||||
return true;
|
||||
}
|
||||
return this->INHERITED::onQuery(evt);
|
||||
@ -190,10 +188,9 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static SkView* MyFactory() { return new ColorFilterView; }
|
||||
static SkViewRegister reg(MyFactory);
|
||||
DEF_SAMPLE( return new ColorFilterView(); )
|
||||
|
@ -5,23 +5,21 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "SampleCode.h"
|
||||
#include "Sample.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkPath.h"
|
||||
#include "SkView.h"
|
||||
#include "SkClipOpPriv.h"
|
||||
|
||||
class ComplexClipView : public SampleView {
|
||||
class ComplexClipView : public Sample {
|
||||
public:
|
||||
ComplexClipView() {
|
||||
this->setBGColor(0xFFA0DDA0);
|
||||
}
|
||||
|
||||
protected:
|
||||
// overrides from SkEventSink
|
||||
virtual bool onQuery(SkEvent* evt) {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "ComplexClip");
|
||||
virtual bool onQuery(Sample::Event* evt) {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "ComplexClip");
|
||||
return true;
|
||||
}
|
||||
return this->INHERITED::onQuery(evt);
|
||||
@ -145,10 +143,9 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static SkView* MyFactory() { return new ComplexClipView; }
|
||||
static SkViewRegister reg(MyFactory);
|
||||
DEF_SAMPLE( return new ComplexClipView(); )
|
||||
|
@ -5,8 +5,7 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "SampleCode.h"
|
||||
#include "SkView.h"
|
||||
#include "Sample.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkGradientShader.h"
|
||||
#include "SkGraphics.h"
|
||||
@ -22,15 +21,14 @@
|
||||
|
||||
#include "SkGeometry.h"
|
||||
|
||||
class ConcavePathView : public SampleView {
|
||||
class ConcavePathView : public Sample {
|
||||
public:
|
||||
ConcavePathView() {}
|
||||
|
||||
protected:
|
||||
// overrides from SkEventSink
|
||||
virtual bool onQuery(SkEvent* evt) {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "ConcavePaths");
|
||||
virtual bool onQuery(Sample::Event* evt) {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "ConcavePaths");
|
||||
return true;
|
||||
}
|
||||
return this->INHERITED::onQuery(evt);
|
||||
@ -135,10 +133,9 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static SkView* MyFactory() { return new ConcavePathView; }
|
||||
static SkViewRegister reg(MyFactory);
|
||||
DEF_SAMPLE( return new ConcavePathView(); )
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
#ifdef SK_XML
|
||||
|
||||
#include "SampleCode.h"
|
||||
#include "Sample.h"
|
||||
#include "Resources.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkDOM.h"
|
||||
@ -18,11 +18,10 @@
|
||||
#include "SkRect.h"
|
||||
#include "SkStream.h"
|
||||
#include "SkSVGDOM.h"
|
||||
#include "SkView.h"
|
||||
|
||||
namespace {
|
||||
|
||||
class CowboyView : public SampleView {
|
||||
class CowboyView : public Sample {
|
||||
public:
|
||||
CowboyView()
|
||||
: fLabel("SampleCowboy")
|
||||
@ -97,9 +96,9 @@ protected:
|
||||
this->INHERITED::onSizeChange();
|
||||
}
|
||||
|
||||
bool onQuery(SkEvent* evt) override {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, fLabel.c_str());
|
||||
bool onQuery(Sample::Event* evt) override {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, fLabel.c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -140,7 +139,7 @@ private:
|
||||
int fAnimationLoop;
|
||||
SkScalar fDelta;
|
||||
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
} // anonymous namespace
|
||||
|
@ -4,8 +4,7 @@
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
#include "SampleCode.h"
|
||||
#include "SkView.h"
|
||||
#include "Sample.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkGraphics.h"
|
||||
#include "SkRandom.h"
|
||||
@ -32,17 +31,16 @@ static void setBitmapDash(SkPaint* paint, int width) {
|
||||
paint->setShader(s)->unref();
|
||||
}
|
||||
|
||||
class DashView : public SampleView {
|
||||
class DashView : public Sample {
|
||||
public:
|
||||
DashView() {
|
||||
this->setBGColor(0xFFDDDDDD);
|
||||
}
|
||||
|
||||
protected:
|
||||
// overrides from SkEventSink
|
||||
virtual bool onQuery(SkEvent* evt) {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "Dash");
|
||||
virtual bool onQuery(Sample::Event* evt) {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "Dash");
|
||||
return true;
|
||||
}
|
||||
return this->INHERITED::onQuery(evt);
|
||||
@ -82,10 +80,10 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static SkView* MyFactory() { return new DashView; }
|
||||
static SkViewRegister reg(MyFactory);
|
||||
static Sample* MyFactory() { return new DashView; }
|
||||
static SampleRegister reg(MyFactory);
|
||||
|
@ -5,9 +5,8 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "SampleCode.h"
|
||||
#include "Sample.h"
|
||||
#include "SkAnimTimer.h"
|
||||
#include "SkView.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkGradientShader.h"
|
||||
#include "SkString.h"
|
||||
@ -35,7 +34,7 @@ static void draw_gradient2(SkCanvas* canvas, const SkRect& rect, SkScalar delta)
|
||||
}
|
||||
|
||||
|
||||
class DegenerateTwoPtRadialsView : public SampleView {
|
||||
class DegenerateTwoPtRadialsView : public Sample {
|
||||
public:
|
||||
DegenerateTwoPtRadialsView() {
|
||||
fTime = 0;
|
||||
@ -43,9 +42,9 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
bool onQuery(SkEvent* evt) override {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "DegenerateTwoPtRadials");
|
||||
bool onQuery(Sample::Event* evt) override {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "DegenerateTwoPtRadials");
|
||||
return true;
|
||||
}
|
||||
return this->INHERITED::onQuery(evt);
|
||||
@ -82,10 +81,9 @@ protected:
|
||||
|
||||
private:
|
||||
SkScalar fTime;
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static SkView* MyFactory() { return new DegenerateTwoPtRadialsView; }
|
||||
static SkViewRegister reg(MyFactory);
|
||||
DEF_SAMPLE( return new DegenerateTwoPtRadialsView(); )
|
||||
|
@ -4,8 +4,7 @@
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
#include "SampleCode.h"
|
||||
#include "SkView.h"
|
||||
#include "Sample.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkGradientShader.h"
|
||||
#include "SkPath.h"
|
||||
@ -103,7 +102,7 @@ static void pre_dither(const SkBitmap& bm) {
|
||||
}
|
||||
}
|
||||
|
||||
class DitherView : public SampleView {
|
||||
class DitherView : public Sample {
|
||||
public:
|
||||
SkBitmap fBM, fBMPreDither, fBM16;
|
||||
SkScalar fAngle;
|
||||
@ -120,10 +119,9 @@ protected:
|
||||
this->setBGColor(0xFF181818);
|
||||
}
|
||||
|
||||
// overrides from SkEventSink
|
||||
bool onQuery(SkEvent* evt) override {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "Dither");
|
||||
bool onQuery(Sample::Event* evt) override {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "Dither");
|
||||
return true;
|
||||
}
|
||||
return this->INHERITED::onQuery(evt);
|
||||
@ -162,10 +160,9 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static SkView* MyFactory() { return new DitherView; }
|
||||
static SkViewRegister reg(MyFactory);
|
||||
DEF_SAMPLE( return new DitherView(); )
|
||||
|
@ -4,7 +4,7 @@
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
#include "SampleCode.h"
|
||||
#include "Sample.h"
|
||||
#include "SkBlurMask.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkColorMatrixFilter.h"
|
||||
@ -12,7 +12,6 @@
|
||||
#include "SkEmbossMaskFilter.h"
|
||||
#include "SkGradientShader.h"
|
||||
#include "SkPaint.h"
|
||||
#include "SkView.h"
|
||||
|
||||
|
||||
//#define COLOR 0xFFFF8844
|
||||
@ -56,7 +55,7 @@ const PaintProc gPaintProcs[] = {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class EffectsView : public SampleView {
|
||||
class EffectsView : public Sample {
|
||||
public:
|
||||
SkPath fPath;
|
||||
SkPaint fPaint[SK_ARRAY_COUNT(gPaintProcs)];
|
||||
@ -91,10 +90,9 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
// overrides from SkEventSink
|
||||
virtual bool onQuery(SkEvent* evt) {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "Effects");
|
||||
virtual bool onQuery(Sample::Event* evt) {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "Effects");
|
||||
return true;
|
||||
}
|
||||
return this->INHERITED::onQuery(evt);
|
||||
@ -110,10 +108,9 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static SkView* MyFactory() { return new EffectsView; }
|
||||
static SkViewRegister reg(MyFactory);
|
||||
DEF_SAMPLE( return new EffectsView(); )
|
||||
|
@ -5,9 +5,8 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "SampleCode.h"
|
||||
#include "Sample.h"
|
||||
#include "SkBlurMask.h"
|
||||
#include "SkView.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkEmbossMaskFilter.h"
|
||||
#include "SkGradientShader.h"
|
||||
@ -22,7 +21,7 @@
|
||||
#include "SkTime.h"
|
||||
#include "SkTypeface.h"
|
||||
|
||||
class EmbossView : public SampleView {
|
||||
class EmbossView : public Sample {
|
||||
SkEmbossMaskFilter::Light fLight;
|
||||
public:
|
||||
EmbossView() {
|
||||
@ -34,10 +33,9 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
// overrides from SkEventSink
|
||||
virtual bool onQuery(SkEvent* evt) {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "Emboss");
|
||||
virtual bool onQuery(Sample::Event* evt) {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "Emboss");
|
||||
return true;
|
||||
}
|
||||
return this->INHERITED::onQuery(evt);
|
||||
@ -59,10 +57,9 @@ protected:
|
||||
|
||||
private:
|
||||
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static SkView* MyFactory() { return new EmbossView; }
|
||||
static SkViewRegister reg(MyFactory);
|
||||
DEF_SAMPLE( return new EmbossView(); )
|
||||
|
@ -5,7 +5,7 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "SampleCode.h"
|
||||
#include "Sample.h"
|
||||
#include "SkBlendMode.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkClipOpPriv.h"
|
||||
@ -23,7 +23,6 @@
|
||||
#include "SkString.h"
|
||||
#include "SkSurface.h"
|
||||
#include "SkTypes.h"
|
||||
#include "SkView.h"
|
||||
#include "sk_tool_utils.h"
|
||||
|
||||
class SkEvent;
|
||||
@ -362,17 +361,17 @@ void FatBits::drawTriangle(SkCanvas* canvas, SkPoint pts[3]) {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class IndexClick : public SkView::Click {
|
||||
class IndexClick : public Sample::Click {
|
||||
int fIndex;
|
||||
public:
|
||||
IndexClick(SkView* v, int index) : SkView::Click(v), fIndex(index) {}
|
||||
IndexClick(Sample* v, int index) : Sample::Click(v), fIndex(index) {}
|
||||
|
||||
static int GetIndex(SkView::Click* click) {
|
||||
static int GetIndex(Sample::Click* click) {
|
||||
return ((IndexClick*)click)->fIndex;
|
||||
}
|
||||
};
|
||||
|
||||
class DrawLineView : public SampleView {
|
||||
class DrawLineView : public Sample {
|
||||
FatBits fFB;
|
||||
SkPoint fPts[3];
|
||||
bool fIsRect;
|
||||
@ -392,13 +391,13 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
bool onQuery(SkEvent* evt) override {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "FatBits");
|
||||
bool onQuery(Sample::Event* evt) override {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "FatBits");
|
||||
return true;
|
||||
}
|
||||
SkUnichar uni;
|
||||
if (SampleCode::CharQ(*evt, &uni)) {
|
||||
if (Sample::CharQ(*evt, &uni)) {
|
||||
switch (uni) {
|
||||
case 'c':
|
||||
fFB.setUseClip(!fFB.getUseClip());
|
||||
@ -475,7 +474,7 @@ protected:
|
||||
}
|
||||
}
|
||||
|
||||
SkView::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned modi) override {
|
||||
Sample::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned modi) override {
|
||||
SkPoint pt = { x, y };
|
||||
int index = -1;
|
||||
int count = fFB.getTriangle() ? 3 : 2;
|
||||
@ -506,10 +505,9 @@ protected:
|
||||
|
||||
private:
|
||||
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static SkView* MyFactory() { return new DrawLineView; }
|
||||
static SkViewRegister reg(MyFactory);
|
||||
DEF_SAMPLE( return new DrawLineView(); )
|
||||
|
@ -4,8 +4,7 @@
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
#include "SampleCode.h"
|
||||
#include "SkView.h"
|
||||
#include "Sample.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkCornerPathEffect.h"
|
||||
#include "SkGradientShader.h"
|
||||
@ -14,7 +13,7 @@
|
||||
#include "SkShader.h"
|
||||
#include "SkUtils.h"
|
||||
|
||||
class FillTypeView : public SampleView {
|
||||
class FillTypeView : public Sample {
|
||||
SkPath fPath;
|
||||
public:
|
||||
FillTypeView() {
|
||||
@ -26,10 +25,9 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
// overrides from SkEventSink
|
||||
virtual bool onQuery(SkEvent* evt) {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "FillType");
|
||||
virtual bool onQuery(Sample::Event* evt) {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "FillType");
|
||||
return true;
|
||||
}
|
||||
return this->INHERITED::onQuery(evt);
|
||||
@ -85,10 +83,9 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static SkView* MyFactory() { return new FillTypeView; }
|
||||
static SkViewRegister reg(MyFactory);
|
||||
DEF_SAMPLE( return new FillTypeView(); )
|
||||
|
@ -6,8 +6,7 @@
|
||||
*/
|
||||
|
||||
#include "DecodeFile.h"
|
||||
#include "SampleCode.h"
|
||||
#include "SkView.h"
|
||||
#include "Sample.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkColorFilter.h"
|
||||
#include "SkColorPriv.h"
|
||||
@ -24,7 +23,7 @@ static const char* gNames[] = {
|
||||
"/skimages/background_01.png"
|
||||
};
|
||||
|
||||
class Filter2View : public SampleView {
|
||||
class Filter2View : public Sample {
|
||||
public:
|
||||
SkBitmap* fBitmaps;
|
||||
int fBitmapCount;
|
||||
@ -50,12 +49,11 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
// overrides from SkEventSink
|
||||
virtual bool onQuery(SkEvent* evt) {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
virtual bool onQuery(Sample::Event* evt) {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
SkString str("Filter/Dither ");
|
||||
str.append(gNames[fCurrIndex]);
|
||||
SampleCode::TitleR(evt, str.c_str());
|
||||
Sample::TitleR(evt, str.c_str());
|
||||
return true;
|
||||
}
|
||||
return this->INHERITED::onQuery(evt);
|
||||
@ -109,10 +107,9 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static SkView* MyFactory() { return new Filter2View; }
|
||||
static SkViewRegister reg(MyFactory);
|
||||
DEF_SAMPLE( return new Filter2View(); )
|
||||
|
@ -4,7 +4,7 @@
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
#include "SampleCode.h"
|
||||
#include "Sample.h"
|
||||
#include "Sk1DPathEffect.h"
|
||||
#include "Sk2DPathEffect.h"
|
||||
#include "SkAlphaThresholdFilter.h"
|
||||
@ -39,7 +39,6 @@
|
||||
#include "SkTableColorFilter.h"
|
||||
#include "SkTileImageFilter.h"
|
||||
#include "SkTypeface.h"
|
||||
#include "SkView.h"
|
||||
#include "SkXfermodeImageFilter.h"
|
||||
#if SK_SUPPORT_GPU
|
||||
#include "text/GrSDFMaskFilter.h"
|
||||
@ -786,17 +785,16 @@ static void do_fuzz(SkCanvas* canvas) {
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class ImageFilterFuzzView : public SampleView {
|
||||
class ImageFilterFuzzView : public Sample {
|
||||
public:
|
||||
ImageFilterFuzzView() {
|
||||
this->setBGColor(0xFFDDDDDD);
|
||||
}
|
||||
|
||||
protected:
|
||||
// overrides from SkEventSink
|
||||
virtual bool onQuery(SkEvent* evt) {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "ImageFilterFuzzer");
|
||||
virtual bool onQuery(Sample::Event* evt) {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "ImageFilterFuzzer");
|
||||
return true;
|
||||
}
|
||||
return this->INHERITED::onQuery(evt);
|
||||
@ -811,10 +809,9 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
typedef SkView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static SkView* MyFactory() { return new ImageFilterFuzzView; }
|
||||
static SkViewRegister reg(MyFactory);
|
||||
DEF_SAMPLE( return new ImageFilterFuzzView(); )
|
||||
|
@ -5,10 +5,8 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "gm.h"
|
||||
|
||||
#include "Resources.h"
|
||||
#include "SampleCode.h"
|
||||
#include "Sample.h"
|
||||
#include "SkAnimTimer.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkInterpolator.h"
|
||||
@ -138,7 +136,7 @@ static void draw_box_frame(SkCanvas* canvas, int width, int height) {
|
||||
canvas->drawLine(r.left(), r.bottom(), r.right(), r.top(), p);
|
||||
}
|
||||
|
||||
class FilterQualityView : public SampleView {
|
||||
class FilterQualityView : public Sample {
|
||||
sk_sp<SkImage> fImage;
|
||||
AnimValue fScale, fAngle;
|
||||
SkSize fCell;
|
||||
@ -167,13 +165,13 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
bool onQuery(SkEvent* evt) override {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "FilterQuality");
|
||||
bool onQuery(Sample::Event* evt) override {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "FilterQuality");
|
||||
return true;
|
||||
}
|
||||
SkUnichar uni;
|
||||
if (SampleCode::CharQ(*evt, &uni)) {
|
||||
if (Sample::CharQ(*evt, &uni)) {
|
||||
switch (uni) {
|
||||
case '1': fAngle.inc(-ANGLE_DELTA); return true;
|
||||
case '2': fAngle.inc( ANGLE_DELTA); return true;
|
||||
@ -297,10 +295,9 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static SkView* MyFactory() { return new FilterQualityView; }
|
||||
static SkViewRegister reg(MyFactory);
|
||||
DEF_SAMPLE( return new FilterQualityView(); )
|
||||
|
@ -5,9 +5,8 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "SampleCode.h"
|
||||
#include "Sample.h"
|
||||
#include "SkAnimTimer.h"
|
||||
#include "SkView.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkUtils.h"
|
||||
#include "SkColorPriv.h"
|
||||
@ -24,7 +23,7 @@
|
||||
|
||||
// Create an animation of a bunch of letters that rotate in place. This is intended to stress
|
||||
// the glyph atlas and test that we don't see corruption or bad slowdowns.
|
||||
class FlutterAnimateView : public SampleView {
|
||||
class FlutterAnimateView : public Sample {
|
||||
public:
|
||||
FlutterAnimateView() : fCurrTime(0), fResetTime(0) {}
|
||||
|
||||
@ -34,10 +33,9 @@ protected:
|
||||
initChars();
|
||||
}
|
||||
|
||||
// overrides from SkEventSink
|
||||
bool onQuery(SkEvent* evt) override {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "FlutterAnimate");
|
||||
bool onQuery(Sample::Event* evt) override {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "FlutterAnimate");
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -106,10 +104,9 @@ private:
|
||||
static constexpr int kNumChars = 40;
|
||||
AnimatedChar fChars[kNumChars];
|
||||
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static SkView* MyFactory() { return new FlutterAnimateView; }
|
||||
static SkViewRegister reg(MyFactory);
|
||||
DEF_SAMPLE( return new FlutterAnimateView(); )
|
||||
|
@ -4,8 +4,7 @@
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
#include "SampleCode.h"
|
||||
#include "SkView.h"
|
||||
#include "Sample.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkGraphics.h"
|
||||
#include "SkRandom.h"
|
||||
@ -75,7 +74,7 @@ static void* draw_proc(void* context) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
class FontCacheView : public SampleView {
|
||||
class FontCacheView : public Sample {
|
||||
public:
|
||||
enum { N = 4 };
|
||||
|
||||
@ -112,10 +111,9 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
// overrides from SkEventSink
|
||||
virtual bool onQuery(SkEvent* evt) {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "FontCache");
|
||||
virtual bool onQuery(Sample::Event* evt) {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "FontCache");
|
||||
return true;
|
||||
}
|
||||
return this->INHERITED::onQuery(evt);
|
||||
@ -132,10 +130,10 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static SkView* MyFactory() { return new FontCacheView; }
|
||||
static SkViewRegister reg(MyFactory);
|
||||
static Sample* MyFactory() { return new FontCacheView; }
|
||||
static SampleRegister reg(MyFactory);
|
||||
|
@ -4,7 +4,7 @@
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
#include "SampleCode.h"
|
||||
#include "Sample.h"
|
||||
#include "Sk1DPathEffect.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkColorFilter.h"
|
||||
@ -19,7 +19,6 @@
|
||||
#include "SkShader.h"
|
||||
#include "SkTypeface.h"
|
||||
#include "SkUtils.h"
|
||||
#include "SkView.h"
|
||||
|
||||
static constexpr struct {
|
||||
const char* fName;
|
||||
@ -36,7 +35,7 @@ static constexpr struct {
|
||||
|
||||
static const int gFaceCount = SK_ARRAY_COUNT(gFaces);
|
||||
|
||||
class FontScalerTestView : public SampleView {
|
||||
class FontScalerTestView : public Sample {
|
||||
sk_sp<SkTypeface> fFaces[gFaceCount];
|
||||
|
||||
public:
|
||||
@ -47,10 +46,9 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
// overrides from SkEventSink
|
||||
virtual bool onQuery(SkEvent* evt) {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "FontScaler Test");
|
||||
virtual bool onQuery(Sample::Event* evt) {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "FontScaler Test");
|
||||
return true;
|
||||
}
|
||||
return this->INHERITED::onQuery(evt);
|
||||
@ -117,10 +115,9 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
typedef SkView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static SkView* MyFactory() { return new FontScalerTestView; }
|
||||
static SkViewRegister reg(MyFactory);
|
||||
DEF_SAMPLE( return new FontScalerTestView(); )
|
||||
|
@ -5,8 +5,7 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "SampleCode.h"
|
||||
#include "SkView.h"
|
||||
#include "Sample.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkMaskFilter.h"
|
||||
#include "SkPaint.h"
|
||||
@ -359,17 +358,16 @@ static void do_fuzz(SkCanvas* canvas) {
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class FuzzView : public SampleView {
|
||||
class FuzzView : public Sample {
|
||||
public:
|
||||
FuzzView() {
|
||||
this->setBGColor(0xFFDDDDDD);
|
||||
}
|
||||
|
||||
protected:
|
||||
// overrides from SkEventSink
|
||||
virtual bool onQuery(SkEvent* evt) {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "Fuzzer");
|
||||
virtual bool onQuery(Sample::Event* evt) {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "Fuzzer");
|
||||
return true;
|
||||
}
|
||||
return this->INHERITED::onQuery(evt);
|
||||
@ -384,10 +382,9 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
typedef SkView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static SkView* MyFactory() { return new FuzzView; }
|
||||
static SkViewRegister reg(MyFactory);
|
||||
DEF_SAMPLE( return new FuzzView(); )
|
||||
|
@ -4,7 +4,7 @@
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
#include "SampleCode.h"
|
||||
#include "Sample.h"
|
||||
#include "sk_tool_utils.h"
|
||||
|
||||
#include "SkAnimTimer.h"
|
||||
@ -17,7 +17,7 @@
|
||||
// Implementation in C++ of Animated Emoji
|
||||
// See https://t.d3fc.io/status/705212795936247808
|
||||
|
||||
class GlyphTransformView : public SampleView {
|
||||
class GlyphTransformView : public Sample {
|
||||
public:
|
||||
GlyphTransformView() {}
|
||||
|
||||
@ -27,10 +27,9 @@ protected:
|
||||
fEmojiFont.fText = sk_tool_utils::emoji_sample_text();
|
||||
}
|
||||
|
||||
// overrides from SkEventSink
|
||||
bool onQuery(SkEvent* evt) override {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "Glyph Transform");
|
||||
bool onQuery(Sample::Event* evt) override {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "Glyph Transform");
|
||||
return true;
|
||||
}
|
||||
return this->INHERITED::onQuery(evt);
|
||||
@ -72,10 +71,9 @@ private:
|
||||
SkScalar fScale;
|
||||
SkScalar fRotate;
|
||||
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static SkView* MyFactory() { return new GlyphTransformView; }
|
||||
static SkViewRegister reg(MyFactory);
|
||||
DEF_SAMPLE( return new GlyphTransformView(); )
|
||||
|
@ -4,8 +4,7 @@
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
#include "SampleCode.h"
|
||||
#include "SkView.h"
|
||||
#include "Sample.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkGradientShader.h"
|
||||
|
||||
@ -112,16 +111,16 @@ static const GradMaker gGradMakers[] = {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class GradientsView : public SampleView {
|
||||
class GradientsView : public Sample {
|
||||
public:
|
||||
GradientsView() {
|
||||
this->setBGColor(0xFFDDDDDD);
|
||||
}
|
||||
|
||||
protected:
|
||||
bool onQuery(SkEvent* evt) override {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "Gradients");
|
||||
bool onQuery(Sample::Event* evt) override {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "Gradients");
|
||||
return true;
|
||||
}
|
||||
return this->INHERITED::onQuery(evt);
|
||||
@ -163,10 +162,9 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static SkView* MyFactory() { return new GradientsView; }
|
||||
static SkViewRegister reg(MyFactory);
|
||||
DEF_SAMPLE( return new GradientsView(); )
|
||||
|
@ -5,9 +5,8 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "SampleCode.h"
|
||||
#include "Sample.h"
|
||||
#include "SkAnimTimer.h"
|
||||
#include "SkView.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkDrawable.h"
|
||||
#include "SkInterpolator.h"
|
||||
@ -114,7 +113,7 @@ public:
|
||||
SkRect onGetBounds() override { return fR; }
|
||||
};
|
||||
|
||||
class HTView : public SampleView {
|
||||
class HTView : public Sample {
|
||||
public:
|
||||
enum {
|
||||
N = 50,
|
||||
@ -143,9 +142,9 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
bool onQuery(SkEvent* evt) override {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "HT");
|
||||
bool onQuery(Sample::Event* evt) override {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "HT");
|
||||
return true;
|
||||
}
|
||||
return this->INHERITED::onQuery(evt);
|
||||
@ -163,7 +162,7 @@ protected:
|
||||
return true;
|
||||
}
|
||||
|
||||
SkView::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned modi) override {
|
||||
Sample::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned modi) override {
|
||||
// search backwards to find the top-most
|
||||
for (int i = N - 1; i >= 0; --i) {
|
||||
if (fArray[i].fDrawable->hitTest(x, y)) {
|
||||
@ -175,10 +174,9 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static SkView* MyFactory() { return new HTView; }
|
||||
static SkViewRegister reg(MyFactory);
|
||||
DEF_SAMPLE( return new HTView(); )
|
||||
|
@ -4,22 +4,20 @@
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
#include "SampleCode.h"
|
||||
#include "SkView.h"
|
||||
#include "Sample.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkPath.h"
|
||||
#include "SkRandom.h"
|
||||
|
||||
class HairCurvesView : public SampleView {
|
||||
class HairCurvesView : public Sample {
|
||||
public:
|
||||
HairCurvesView() {
|
||||
}
|
||||
|
||||
protected:
|
||||
// overrides from SkEventSink
|
||||
virtual bool onQuery(SkEvent* evt) {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "HairCurves");
|
||||
virtual bool onQuery(Sample::Event* evt) {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "HairCurves");
|
||||
return true;
|
||||
}
|
||||
return this->INHERITED::onQuery(evt);
|
||||
@ -123,10 +121,9 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static SkView* MyFactory() { return new HairCurvesView; }
|
||||
static SkViewRegister reg(MyFactory);
|
||||
DEF_SAMPLE( return new HairCurvesView(); )
|
||||
|
@ -5,8 +5,7 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "SampleCode.h"
|
||||
#include "SkView.h"
|
||||
#include "Sample.h"
|
||||
#include "SkBitmap.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkColorPriv.h"
|
||||
@ -69,7 +68,7 @@ static sk_sp<SkShader> make_bg_shader() {
|
||||
SkShader::kRepeat_TileMode, &m);
|
||||
}
|
||||
|
||||
class HairModesView : public SampleView {
|
||||
class HairModesView : public Sample {
|
||||
SkPaint fBGPaint;
|
||||
public:
|
||||
HairModesView() {
|
||||
@ -77,10 +76,9 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
// overrides from SkEventSink
|
||||
virtual bool onQuery(SkEvent* evt) {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "HairlineModes");
|
||||
virtual bool onQuery(Sample::Event* evt) {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "HairlineModes");
|
||||
return true;
|
||||
}
|
||||
return this->INHERITED::onQuery(evt);
|
||||
@ -117,10 +115,9 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static SkView* MyFactory() { return new HairModesView; }
|
||||
static SkViewRegister reg(MyFactory);
|
||||
DEF_SAMPLE( return new HairModesView(); )
|
||||
|
@ -5,7 +5,7 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "SampleCode.h"
|
||||
#include "Sample.h"
|
||||
#include "SkAnimTimer.h"
|
||||
#include "SkBitmap.h"
|
||||
#include "SkCanvas.h"
|
||||
@ -23,7 +23,6 @@
|
||||
#include "SkTo.h"
|
||||
#include "SkTypeface.h"
|
||||
#include "SkUtils.h"
|
||||
#include "SkView.h"
|
||||
|
||||
static SkRandom gRand;
|
||||
|
||||
@ -168,7 +167,7 @@ static int cycle_hairproc_index(int index) {
|
||||
return (index + 1) % SK_ARRAY_COUNT(gProcs);
|
||||
}
|
||||
|
||||
class HairlineView : public SampleView {
|
||||
class HairlineView : public Sample {
|
||||
SkMSec fNow;
|
||||
int fProcIndex;
|
||||
bool fDoAA;
|
||||
@ -180,12 +179,11 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
// overrides from SkEventSink
|
||||
bool onQuery(SkEvent* evt) override {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
bool onQuery(Sample::Event* evt) override {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
SkString str;
|
||||
str.printf("Hair-%s", gProcs[fProcIndex].fName);
|
||||
SampleCode::TitleR(evt, str.c_str());
|
||||
Sample::TitleR(evt, str.c_str());
|
||||
return true;
|
||||
}
|
||||
return this->INHERITED::onQuery(evt);
|
||||
@ -227,17 +225,16 @@ protected:
|
||||
return true;
|
||||
}
|
||||
|
||||
SkView::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned modi) override {
|
||||
Sample::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned modi) override {
|
||||
fDoAA = !fDoAA;
|
||||
return this->INHERITED::onFindClickHandler(x, y, modi);
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static SkView* MyFactory() { return new HairlineView; }
|
||||
static SkViewRegister reg(MyFactory);
|
||||
DEF_SAMPLE( return new HairlineView(); )
|
||||
|
@ -6,10 +6,8 @@
|
||||
*/
|
||||
|
||||
#include "DecodeFile.h"
|
||||
#include "gm.h"
|
||||
|
||||
#include "Resources.h"
|
||||
#include "SampleCode.h"
|
||||
#include "Sample.h"
|
||||
#include "SkBlurMaskFilter.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkColorPriv.h"
|
||||
@ -22,7 +20,7 @@
|
||||
// Intended to exercise pixel snapping observed with scaled images (and
|
||||
// with non-scaled images, but for a different reason): Bug 1145
|
||||
|
||||
class IdentityScaleView : public SampleView {
|
||||
class IdentityScaleView : public Sample {
|
||||
public:
|
||||
IdentityScaleView(const char imageFilename[]) {
|
||||
if (!DecodeDataToBitmap(GetResourceAsData(imageFilename), &fBM)) {
|
||||
@ -34,10 +32,9 @@ public:
|
||||
protected:
|
||||
SkBitmap fBM;
|
||||
|
||||
// overrides from SkEventSink
|
||||
bool onQuery(SkEvent* evt) override {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "IdentityScale");
|
||||
bool onQuery(Sample::Event* evt) override {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "IdentityScale");
|
||||
return true;
|
||||
}
|
||||
return this->INHERITED::onQuery(evt);
|
||||
@ -74,10 +71,9 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static SkView* MyFactory() { return new IdentityScaleView("images/mandrill_256.png"); }
|
||||
static SkViewRegister reg(MyFactory);
|
||||
DEF_SAMPLE( return new IdentityScaleView("images/mandrill_256.png"); )
|
||||
|
@ -4,21 +4,19 @@
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
#include "SampleCode.h"
|
||||
#include "SkView.h"
|
||||
#include "Sample.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkPaint.h"
|
||||
#include "SkShader.h"
|
||||
|
||||
class LCDView : public SkView {
|
||||
class LCDView : public Sample {
|
||||
public:
|
||||
LCDView() {}
|
||||
|
||||
protected:
|
||||
// overrides from SkEventSink
|
||||
virtual bool onQuery(SkEvent* evt) {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "LCD Text");
|
||||
bool onQuery(Sample::Event* evt) override {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "LCD Text");
|
||||
return true;
|
||||
}
|
||||
return this->INHERITED::onQuery(evt);
|
||||
@ -28,7 +26,7 @@ protected:
|
||||
canvas->drawColor(SK_ColorWHITE);
|
||||
}
|
||||
|
||||
virtual void onDraw(SkCanvas* canvas) {
|
||||
void onDrawContent(SkCanvas* canvas) override {
|
||||
this->drawBG(canvas);
|
||||
|
||||
SkPaint paint;
|
||||
@ -56,10 +54,9 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
typedef SkView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static SkView* MyFactory() { return new LCDView; }
|
||||
static SkViewRegister reg(MyFactory);
|
||||
DEF_SAMPLE( return new LCDView(); )
|
||||
|
@ -5,26 +5,24 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "SampleCode.h"
|
||||
#include "Sample.h"
|
||||
#include "SkBitmap.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkPaint.h"
|
||||
#include "SkPath.h"
|
||||
#include "SkView.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class LayerMaskView : public SampleView {
|
||||
class LayerMaskView : public Sample {
|
||||
public:
|
||||
LayerMaskView() {
|
||||
this->setBGColor(0xFFDDDDDD);
|
||||
}
|
||||
|
||||
protected:
|
||||
// overrides from SkEventSink
|
||||
virtual bool onQuery(SkEvent* evt) {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "LayerMask");
|
||||
virtual bool onQuery(Sample::Event* evt) {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "LayerMask");
|
||||
return true;
|
||||
}
|
||||
return this->INHERITED::onQuery(evt);
|
||||
@ -66,10 +64,9 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static SkView* MyFactory() { return new LayerMaskView; }
|
||||
static SkViewRegister reg(MyFactory);
|
||||
DEF_SAMPLE( return new LayerMaskView(); )
|
||||
|
@ -5,8 +5,7 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "SampleCode.h"
|
||||
#include "SkView.h"
|
||||
#include "Sample.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkBlurMaskFilter.h"
|
||||
#include "SkCamera.h"
|
||||
@ -96,15 +95,14 @@ static void test_fade(SkCanvas* canvas) {
|
||||
canvas->drawRect(r, paint);
|
||||
}
|
||||
|
||||
class LayersView : public SkView {
|
||||
class LayersView : public Sample {
|
||||
public:
|
||||
LayersView() {}
|
||||
|
||||
protected:
|
||||
// overrides from SkEventSink
|
||||
bool onQuery(SkEvent* evt) override {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "Layers");
|
||||
bool onQuery(Sample::Event* evt) override {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "Layers");
|
||||
return true;
|
||||
}
|
||||
return this->INHERITED::onQuery(evt);
|
||||
@ -114,7 +112,7 @@ protected:
|
||||
canvas->drawColor(SK_ColorGRAY);
|
||||
}
|
||||
|
||||
void onDraw(SkCanvas* canvas) override {
|
||||
void onDrawContent(SkCanvas* canvas) override {
|
||||
this->drawBG(canvas);
|
||||
|
||||
if (true) {
|
||||
@ -176,7 +174,7 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
typedef SkView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
DEF_SAMPLE( return new LayersView; )
|
||||
|
||||
@ -189,7 +187,7 @@ DEF_SAMPLE( return new LayersView; )
|
||||
#include "Resources.h"
|
||||
#include "SkAnimTimer.h"
|
||||
|
||||
class BackdropView : public SampleView {
|
||||
class BackdropView : public Sample {
|
||||
SkPoint fCenter;
|
||||
SkScalar fAngle;
|
||||
sk_sp<SkImage> fImage;
|
||||
@ -203,10 +201,9 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
// overrides from SkEventSink
|
||||
bool onQuery(SkEvent* evt) override {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "Backdrop");
|
||||
bool onQuery(Sample::Event* evt) override {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "Backdrop");
|
||||
return true;
|
||||
}
|
||||
return this->INHERITED::onQuery(evt);
|
||||
@ -239,7 +236,7 @@ protected:
|
||||
return true;
|
||||
}
|
||||
|
||||
SkView::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned modi) override {
|
||||
Sample::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned modi) override {
|
||||
return new Click(this);
|
||||
}
|
||||
|
||||
@ -249,6 +246,6 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
DEF_SAMPLE( return new BackdropView; )
|
||||
|
@ -6,7 +6,7 @@
|
||||
*/
|
||||
|
||||
#include "DecodeFile.h"
|
||||
#include "SampleCode.h"
|
||||
#include "Sample.h"
|
||||
#include "Resources.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkLightingShader.h"
|
||||
@ -29,7 +29,7 @@ static sk_sp<SkLights> create_lights(SkScalar angle, SkScalar blue) {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class LightingView : public SampleView {
|
||||
class LightingView : public Sample {
|
||||
public:
|
||||
LightingView() : fLightAngle(0.0f) , fColorFactor(0.0f) {
|
||||
{
|
||||
@ -57,10 +57,9 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
// overrides from SkEventSink
|
||||
bool onQuery(SkEvent* evt) override {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "Lighting");
|
||||
bool onQuery(Sample::Event* evt) override {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "Lighting");
|
||||
return true;
|
||||
}
|
||||
return this->INHERITED::onQuery(evt);
|
||||
@ -78,7 +77,7 @@ protected:
|
||||
canvas->drawRect(fRect, paint);
|
||||
}
|
||||
|
||||
SkView::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned modi) override {
|
||||
Sample::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned modi) override {
|
||||
return this->INHERITED::onFindClickHandler(x, y, modi);
|
||||
}
|
||||
|
||||
@ -100,10 +99,9 @@ private:
|
||||
SkScalar fLightAngle;
|
||||
SkScalar fColorFactor;
|
||||
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static SkView* MyFactory() { return new LightingView; }
|
||||
static SkViewRegister reg(MyFactory);
|
||||
DEF_SAMPLE( return new LightingView(); )
|
||||
|
@ -6,8 +6,7 @@
|
||||
*/
|
||||
|
||||
#include "DecodeFile.h"
|
||||
#include "SampleCode.h"
|
||||
#include "SkView.h"
|
||||
#include "Sample.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkCornerPathEffect.h"
|
||||
#include "SkGradientShader.h"
|
||||
@ -24,15 +23,14 @@
|
||||
#include "SkStream.h"
|
||||
#include "SkColorPriv.h"
|
||||
|
||||
class LinesView : public SampleView {
|
||||
class LinesView : public Sample {
|
||||
public:
|
||||
LinesView() {}
|
||||
|
||||
protected:
|
||||
// overrides from SkEventSink
|
||||
bool onQuery(SkEvent* evt) override {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "Lines");
|
||||
bool onQuery(Sample::Event* evt) override {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "Lines");
|
||||
return true;
|
||||
}
|
||||
return this->INHERITED::onQuery(evt);
|
||||
@ -92,17 +90,16 @@ protected:
|
||||
canvas->drawLine(x, y, x + SkIntToScalar(90), y + SkIntToScalar(90), paint);
|
||||
}
|
||||
|
||||
SkView::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned) override {
|
||||
Sample::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned) override {
|
||||
fAlpha = SkScalarRoundToInt(y);
|
||||
return nullptr;
|
||||
}
|
||||
private:
|
||||
|
||||
int fAlpha;
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static SkView* MyFactory() { return new LinesView; }
|
||||
static SkViewRegister reg(MyFactory);
|
||||
DEF_SAMPLE( return new LinesView(); )
|
||||
|
@ -5,7 +5,7 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "SampleCode.h"
|
||||
#include "Sample.h"
|
||||
#include "SkAnimTimer.h"
|
||||
#include "SkBitmapProcShader.h"
|
||||
#include "SkCanvas.h"
|
||||
@ -15,7 +15,6 @@
|
||||
#include "SkNormalSource.h"
|
||||
#include "SkRandom.h"
|
||||
#include "SkRSXform.h"
|
||||
#include "SkView.h"
|
||||
|
||||
#include "sk_tool_utils.h"
|
||||
|
||||
@ -448,18 +447,18 @@ private:
|
||||
typedef SkDrawable INHERITED;
|
||||
};
|
||||
|
||||
class DrawLitAtlasView : public SampleView {
|
||||
class DrawLitAtlasView : public Sample {
|
||||
public:
|
||||
DrawLitAtlasView() : fDrawable(new DrawLitAtlasDrawable(SkRect::MakeWH(640, 480))) {}
|
||||
|
||||
protected:
|
||||
bool onQuery(SkEvent* evt) override {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "DrawLitAtlas");
|
||||
bool onQuery(Sample::Event* evt) override {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "DrawLitAtlas");
|
||||
return true;
|
||||
}
|
||||
SkUnichar uni;
|
||||
if (SampleCode::CharQ(*evt, &uni)) {
|
||||
if (Sample::CharQ(*evt, &uni)) {
|
||||
switch (uni) {
|
||||
case 'C':
|
||||
fDrawable->toggleUseColors();
|
||||
@ -494,10 +493,9 @@ protected:
|
||||
private:
|
||||
sk_sp<DrawLitAtlasDrawable> fDrawable;
|
||||
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static SkView* MyFactory() { return new DrawLitAtlasView; }
|
||||
static SkViewRegister reg(MyFactory);
|
||||
DEF_SAMPLE( return new DrawLitAtlasView(); )
|
||||
|
@ -5,8 +5,7 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "SampleCode.h"
|
||||
#include "SkView.h"
|
||||
#include "Sample.h"
|
||||
#include "SkLua.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "Resources.h"
|
||||
@ -35,7 +34,7 @@ static const char gMissingCode[] = ""
|
||||
"end"
|
||||
;
|
||||
|
||||
class LuaView : public SampleView {
|
||||
class LuaView : public Sample {
|
||||
public:
|
||||
LuaView() : fLua(nullptr) {}
|
||||
|
||||
@ -69,13 +68,13 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
bool onQuery(SkEvent* evt) override {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "Lua");
|
||||
bool onQuery(Sample::Event* evt) override {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "Lua");
|
||||
return true;
|
||||
}
|
||||
SkUnichar uni;
|
||||
if (SampleCode::CharQ(*evt, &uni)) {
|
||||
if (Sample::CharQ(*evt, &uni)) {
|
||||
lua_State* L = this->ensureLua();
|
||||
lua_getglobal(L, gUnicharName);
|
||||
if (lua_isfunction(L, -1)) {
|
||||
@ -114,7 +113,7 @@ protected:
|
||||
}
|
||||
}
|
||||
|
||||
virtual SkView::Click* onFindClickHandler(SkScalar x, SkScalar y,
|
||||
virtual Sample::Click* onFindClickHandler(SkScalar x, SkScalar y,
|
||||
unsigned modi) override {
|
||||
lua_State* L = this->ensureLua();
|
||||
lua_getglobal(L, gClickName);
|
||||
@ -160,10 +159,9 @@ protected:
|
||||
private:
|
||||
SkLua* fLua;
|
||||
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static SkView* MyFactory() { return new LuaView; }
|
||||
static SkViewRegister reg(MyFactory);
|
||||
DEF_SAMPLE( return new LuaView(); )
|
||||
|
@ -4,17 +4,16 @@
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
#include "SampleCode.h"
|
||||
#include "Sample.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkPaint.h"
|
||||
#include "SkRandom.h"
|
||||
#include "SkShader.h"
|
||||
#include "SkView.h"
|
||||
|
||||
/**
|
||||
* Animated sample used to develop a predecessor of GrDrawOp combining.
|
||||
*/
|
||||
class ManyRectsView : public SampleView {
|
||||
class ManyRectsView : public Sample {
|
||||
private:
|
||||
enum {
|
||||
N = 1000,
|
||||
@ -24,9 +23,9 @@ public:
|
||||
ManyRectsView() {}
|
||||
|
||||
protected:
|
||||
bool onQuery(SkEvent* evt) override {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "ManyRects");
|
||||
bool onQuery(Sample::Event* evt) override {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "ManyRects");
|
||||
return true;
|
||||
}
|
||||
return this->INHERITED::onQuery(evt);
|
||||
@ -66,10 +65,9 @@ protected:
|
||||
|
||||
private:
|
||||
SkRandom fRandom;
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static SkView* MyFactory() { return new ManyRectsView; }
|
||||
static SkViewRegister reg(MyFactory);
|
||||
DEF_SAMPLE( return new ManyRectsView(); )
|
||||
|
@ -4,8 +4,7 @@
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
#include "SampleCode.h"
|
||||
#include "SkView.h"
|
||||
#include "Sample.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkGradientShader.h"
|
||||
#include "SkPath.h"
|
||||
@ -77,7 +76,7 @@ static void doMeasure(SkCanvas* canvas, const SkPaint& paint, const char text[])
|
||||
}
|
||||
}
|
||||
|
||||
class MeasureView : public SampleView {
|
||||
class MeasureView : public Sample {
|
||||
public:
|
||||
SkPaint fPaint;
|
||||
|
||||
@ -88,10 +87,9 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
// overrides from SkEventSink
|
||||
virtual bool onQuery(SkEvent* evt) {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "Measure");
|
||||
virtual bool onQuery(Sample::Event* evt) {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "Measure");
|
||||
return true;
|
||||
}
|
||||
return this->INHERITED::onQuery(evt);
|
||||
@ -103,10 +101,9 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static SkView* MyFactory() { return new MeasureView; }
|
||||
static SkViewRegister reg(MyFactory);
|
||||
DEF_SAMPLE( return new MeasureView(); )
|
||||
|
@ -5,12 +5,12 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "SampleCode.h"
|
||||
#include "Sample.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkPath.h"
|
||||
#include "SkRandom.h"
|
||||
|
||||
class MegaStrokeView : public SampleView {
|
||||
class MegaStrokeView : public Sample {
|
||||
public:
|
||||
MegaStrokeView() {
|
||||
fClip.set(0, 0, 950, 600);
|
||||
@ -26,15 +26,14 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
// overrides from SkEventSink
|
||||
bool onQuery(SkEvent* evt) override {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "MegaStroke");
|
||||
bool onQuery(Sample::Event* evt) override {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "MegaStroke");
|
||||
return true;
|
||||
}
|
||||
|
||||
SkUnichar uni;
|
||||
if (SampleCode::CharQ(*evt, &uni)) {
|
||||
if (Sample::CharQ(*evt, &uni)) {
|
||||
fClip.set(0, 0, 950, 600);
|
||||
}
|
||||
if (evt->isType("SampleCode_Key_Event")) {
|
||||
@ -88,10 +87,9 @@ private:
|
||||
SkRect fClip;
|
||||
int fAngle;
|
||||
int fPlusMinus;
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static SkView* MyFactory() { return new MegaStrokeView; }
|
||||
static SkViewRegister reg(MyFactory);
|
||||
DEF_SAMPLE( return new MegaStrokeView(); )
|
||||
|
@ -5,16 +5,15 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "SampleCode.h"
|
||||
#include "Sample.h"
|
||||
#include "SampleNimaActor.h"
|
||||
#include "SkAnimTimer.h"
|
||||
#include "SkView.h"
|
||||
#include <nima/Animation/ActorAnimationInstance.hpp>
|
||||
#include <cmath>
|
||||
|
||||
using namespace nima;
|
||||
|
||||
class NimaView : public SampleView {
|
||||
class NimaView : public Sample {
|
||||
public:
|
||||
NimaView()
|
||||
: fActor(nullptr)
|
||||
@ -22,10 +21,9 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
// overrides from SkEventSink
|
||||
virtual bool onQuery(SkEvent* evt) override {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "Nima");
|
||||
virtual bool onQuery(Sample::Event* evt) override {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "Nima");
|
||||
return true;
|
||||
}
|
||||
return this->INHERITED::onQuery(evt);
|
||||
@ -65,10 +63,9 @@ private:
|
||||
std::unique_ptr<SampleActor> fActor;
|
||||
ActorAnimationInstance* fAnimation;
|
||||
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static SkView* MyFactory() { return new NimaView; }
|
||||
static SkViewRegister reg(MyFactory);
|
||||
DEF_SAMPLE( return new NimaView(); )
|
||||
|
@ -6,9 +6,8 @@
|
||||
*/
|
||||
|
||||
#include "DecodeFile.h"
|
||||
#include "SampleCode.h"
|
||||
#include "Sample.h"
|
||||
#include "SkAnimTimer.h"
|
||||
#include "SkView.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkGradientShader.h"
|
||||
#include "SkGraphics.h"
|
||||
@ -203,7 +202,7 @@ static void drawpatches(SkCanvas* canvas, const SkPaint& paint, int nu, int nv,
|
||||
const SkScalar DX = 20;
|
||||
const SkScalar DY = 0;
|
||||
|
||||
class PatchView : public SampleView {
|
||||
class PatchView : public Sample {
|
||||
SkScalar fAngle;
|
||||
sk_sp<SkShader> fShader0;
|
||||
sk_sp<SkShader> fShader1;
|
||||
@ -238,10 +237,9 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
// overrides from SkEventSink
|
||||
bool onQuery(SkEvent* evt) override {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "Patch");
|
||||
bool onQuery(Sample::Event* evt) override {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "Patch");
|
||||
return true;
|
||||
}
|
||||
return this->INHERITED::onQuery(evt);
|
||||
@ -302,14 +300,14 @@ protected:
|
||||
class PtClick : public Click {
|
||||
public:
|
||||
int fIndex;
|
||||
PtClick(SkView* view, int index) : Click(view), fIndex(index) {}
|
||||
PtClick(Sample* view, int index) : Click(view), fIndex(index) {}
|
||||
};
|
||||
|
||||
static bool hittest(const SkPoint& pt, SkScalar x, SkScalar y) {
|
||||
return SkPoint::Length(pt.fX - x, pt.fY - y) < SkIntToScalar(5);
|
||||
}
|
||||
|
||||
SkView::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned modi) override {
|
||||
Sample::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned modi) override {
|
||||
x -= DX;
|
||||
y -= DY;
|
||||
for (size_t i = 0; i < SK_ARRAY_COUNT(fPts); i++) {
|
||||
@ -326,10 +324,9 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static SkView* MyFactory() { return new PatchView; }
|
||||
static SkViewRegister reg(MyFactory);
|
||||
DEF_SAMPLE( return new PatchView(); )
|
||||
|
@ -5,9 +5,8 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "SampleCode.h"
|
||||
#include "Sample.h"
|
||||
#include "SkAnimTimer.h"
|
||||
#include "SkView.h"
|
||||
#include "SkBitmap.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkGradientShader.h"
|
||||
@ -71,7 +70,7 @@ static void test_cubic2() {
|
||||
canvas.drawPath(path, paint);
|
||||
}
|
||||
|
||||
class PathView : public SampleView {
|
||||
class PathView : public Sample {
|
||||
SkScalar fPrevSecs;
|
||||
public:
|
||||
SkScalar fDStroke, fStroke, fMinStroke, fMaxStroke;
|
||||
@ -130,10 +129,9 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
// overrides from SkEventSink
|
||||
bool onQuery(SkEvent* evt) override {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "Paths");
|
||||
bool onQuery(Sample::Event* evt) override {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "Paths");
|
||||
return true;
|
||||
}
|
||||
return this->INHERITED::onQuery(evt);
|
||||
@ -196,13 +194,13 @@ protected:
|
||||
return true;
|
||||
}
|
||||
|
||||
SkView::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned modi) override {
|
||||
Sample::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned modi) override {
|
||||
fShowHairline = !fShowHairline;
|
||||
return this->INHERITED::onFindClickHandler(x, y, modi);
|
||||
}
|
||||
|
||||
private:
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
DEF_SAMPLE( return new PathView; )
|
||||
|
||||
@ -211,7 +209,7 @@ DEF_SAMPLE( return new PathView; )
|
||||
#include "SkCornerPathEffect.h"
|
||||
#include "SkRandom.h"
|
||||
|
||||
class ArcToView : public SampleView {
|
||||
class ArcToView : public Sample {
|
||||
bool fDoFrame, fDoCorner, fDoConic;
|
||||
SkPaint fPtsPaint, fSkeletonPaint, fCornerPaint;
|
||||
public:
|
||||
@ -251,14 +249,13 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
// overrides from SkEventSink
|
||||
bool onQuery(SkEvent* evt) override {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "ArcTo");
|
||||
bool onQuery(Sample::Event* evt) override {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "ArcTo");
|
||||
return true;
|
||||
}
|
||||
SkUnichar uni;
|
||||
if (SampleCode::CharQ(*evt, &uni)) {
|
||||
if (Sample::CharQ(*evt, &uni)) {
|
||||
switch (uni) {
|
||||
case '1': this->toggle(fDoFrame); return true;
|
||||
case '2': this->toggle(fDoCorner); return true;
|
||||
@ -302,7 +299,7 @@ protected:
|
||||
return false;
|
||||
}
|
||||
|
||||
SkView::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned modi) override {
|
||||
Sample::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned modi) override {
|
||||
const SkScalar tol = 4;
|
||||
const SkRect r = SkRect::MakeXYWH(x - tol, y - tol, tol * 2, tol * 2);
|
||||
for (int i = 0; i < N; ++i) {
|
||||
@ -316,13 +313,13 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
DEF_SAMPLE( return new ArcToView; )
|
||||
|
||||
/////////////
|
||||
|
||||
class FatStroke : public SampleView {
|
||||
class FatStroke : public Sample {
|
||||
bool fClosed, fShowStroke, fShowHidden, fShowSkeleton;
|
||||
int fJoinType, fCapType;
|
||||
float fWidth = 30;
|
||||
@ -369,14 +366,13 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
// overrides from SkEventSink
|
||||
bool onQuery(SkEvent* evt) override {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "FatStroke");
|
||||
bool onQuery(Sample::Event* evt) override {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "FatStroke");
|
||||
return true;
|
||||
}
|
||||
SkUnichar uni;
|
||||
if (SampleCode::CharQ(*evt, &uni)) {
|
||||
if (Sample::CharQ(*evt, &uni)) {
|
||||
switch (uni) {
|
||||
case '1': this->toggle(fShowSkeleton); return true;
|
||||
case '2': this->toggle(fShowStroke); return true;
|
||||
@ -436,7 +432,7 @@ protected:
|
||||
return false;
|
||||
}
|
||||
|
||||
SkView::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned modi) override {
|
||||
Sample::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned modi) override {
|
||||
const SkScalar tol = 4;
|
||||
const SkRect r = SkRect::MakeXYWH(x - tol, y - tol, tol * 2, tol * 2);
|
||||
for (int i = 0; i < N; ++i) {
|
||||
@ -450,7 +446,7 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
DEF_SAMPLE( return new FatStroke; )
|
||||
|
||||
@ -475,7 +471,7 @@ static int compute_parallel_to_base(const SkPoint pts[4], SkScalar t[2]) {
|
||||
return n;
|
||||
}
|
||||
|
||||
class CubicCurve : public SampleView {
|
||||
class CubicCurve : public Sample {
|
||||
public:
|
||||
enum {
|
||||
N = 4
|
||||
@ -491,9 +487,9 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
bool onQuery(SkEvent* evt) override {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "CubicCurve");
|
||||
bool onQuery(Sample::Event* evt) override {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "CubicCurve");
|
||||
return true;
|
||||
}
|
||||
return this->INHERITED::onQuery(evt);
|
||||
@ -559,7 +555,7 @@ protected:
|
||||
return false;
|
||||
}
|
||||
|
||||
SkView::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned modi) override {
|
||||
Sample::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned modi) override {
|
||||
const SkScalar tol = 8;
|
||||
const SkRect r = SkRect::MakeXYWH(x - tol, y - tol, tol * 2, tol * 2);
|
||||
for (int i = 0; i < N; ++i) {
|
||||
@ -573,7 +569,7 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
DEF_SAMPLE( return new CubicCurve; )
|
||||
|
||||
@ -596,7 +592,7 @@ static int find_max_deviation_cubic(const SkPoint src[4], SkScalar ts[2]) {
|
||||
return SkFindUnitQuadRoots(3 * A.cross(Z), 2 * B.cross(Z), C.cross(Z), ts);
|
||||
}
|
||||
|
||||
class CubicCurve2 : public SampleView {
|
||||
class CubicCurve2 : public Sample {
|
||||
public:
|
||||
enum {
|
||||
N = 7
|
||||
@ -620,13 +616,13 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
bool onQuery(SkEvent* evt) override {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "CubicCurve2");
|
||||
bool onQuery(Sample::Event* evt) override {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "CubicCurve2");
|
||||
return true;
|
||||
}
|
||||
SkUnichar uni;
|
||||
if (SampleCode::CharQ(*evt, &uni)) {
|
||||
if (Sample::CharQ(*evt, &uni)) {
|
||||
switch (uni) {
|
||||
case 's': fShowSub = !fShowSub; break;
|
||||
case 'f': fShowFlatness = !fShowFlatness; break;
|
||||
@ -753,7 +749,7 @@ protected:
|
||||
return false;
|
||||
}
|
||||
|
||||
SkView::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned modi) override {
|
||||
Sample::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned modi) override {
|
||||
const SkScalar tol = 8;
|
||||
const SkRect r = SkRect::MakeXYWH(x - tol, y - tol, tol * 2, tol * 2);
|
||||
for (int i = 0; i < N; ++i) {
|
||||
@ -767,7 +763,7 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
DEF_SAMPLE( return new CubicCurve2; )
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "SampleCode.h"
|
||||
#include "Sample.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkColorFilter.h"
|
||||
#include "SkColorPriv.h"
|
||||
@ -18,11 +18,10 @@
|
||||
#include "SkTo.h"
|
||||
#include "SkTypeface.h"
|
||||
#include "SkUtils.h"
|
||||
#include "SkView.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
class PathClipView : public SampleView {
|
||||
class PathClipView : public Sample {
|
||||
public:
|
||||
SkRect fOval;
|
||||
SkPoint fCenter;
|
||||
@ -30,9 +29,9 @@ public:
|
||||
PathClipView() : fOval(SkRect::MakeWH(200, 50)), fCenter(SkPoint::Make(250, 250)) {}
|
||||
|
||||
protected:
|
||||
bool onQuery(SkEvent* evt) override {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "PathClip");
|
||||
bool onQuery(Sample::Event* evt) override {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "PathClip");
|
||||
return true;
|
||||
}
|
||||
return this->INHERITED::onQuery(evt);
|
||||
@ -59,7 +58,7 @@ protected:
|
||||
canvas->drawOval(oval, p);
|
||||
}
|
||||
|
||||
SkView::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned) override {
|
||||
Sample::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned) override {
|
||||
return new Click(this);
|
||||
}
|
||||
|
||||
@ -69,7 +68,7 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
DEF_SAMPLE( return new PathClipView; )
|
||||
|
||||
@ -152,7 +151,7 @@ static void draw_clipped_line(SkCanvas* canvas, const SkRect& bounds,
|
||||
|
||||
// Demonstrate edge-clipping that is used in the scan converter
|
||||
//
|
||||
class EdgeClipView : public SampleView {
|
||||
class EdgeClipView : public Sample {
|
||||
enum {
|
||||
N = 3
|
||||
};
|
||||
@ -172,9 +171,9 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
bool onQuery(SkEvent* evt) override {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "EdgeClip");
|
||||
bool onQuery(Sample::Event* evt) override {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "EdgeClip");
|
||||
return true;
|
||||
}
|
||||
return this->INHERITED::onQuery(evt);
|
||||
@ -240,21 +239,21 @@ protected:
|
||||
|
||||
class MyClick : public Click {
|
||||
public:
|
||||
MyClick(SkView* view) : Click(view) {}
|
||||
MyClick(Sample* view) : Click(view) {}
|
||||
virtual void handleMove() = 0;
|
||||
};
|
||||
|
||||
class VertClick : public MyClick {
|
||||
SkPoint* fPt;
|
||||
public:
|
||||
VertClick(SkView* view, SkPoint* pt) : MyClick(view), fPt(pt) {}
|
||||
VertClick(Sample* view, SkPoint* pt) : MyClick(view), fPt(pt) {}
|
||||
void handleMove() override { *fPt = snap(fCurr); }
|
||||
};
|
||||
|
||||
class DragRectClick : public MyClick {
|
||||
SkRect* fRect;
|
||||
public:
|
||||
DragRectClick(SkView* view, SkRect* rect) : MyClick(view), fRect(rect) {}
|
||||
DragRectClick(Sample* view, SkRect* rect) : MyClick(view), fRect(rect) {}
|
||||
void handleMove() override { fRect->offset(fCurr.x() - fPrev.x(), fCurr.y() - fPrev.y()); }
|
||||
};
|
||||
|
||||
@ -263,7 +262,7 @@ protected:
|
||||
SkPoint* fPoly;
|
||||
int fCount;
|
||||
public:
|
||||
DragPolyClick(SkView* view, SkPoint poly[], int count)
|
||||
DragPolyClick(Sample* view, SkPoint poly[], int count)
|
||||
: MyClick(view), fPoly(poly), fCount(count)
|
||||
{
|
||||
SkASSERT((size_t)count <= SK_ARRAY_COUNT(fSrc));
|
||||
@ -280,7 +279,7 @@ protected:
|
||||
|
||||
class DoNothingClick : public MyClick {
|
||||
public:
|
||||
DoNothingClick(SkView* view) : MyClick(view) {}
|
||||
DoNothingClick(Sample* view) : MyClick(view) {}
|
||||
void handleMove() override {}
|
||||
};
|
||||
|
||||
@ -291,7 +290,7 @@ protected:
|
||||
return dx*dx + dy*dy <= rad*rad;
|
||||
}
|
||||
|
||||
SkView::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned) override {
|
||||
Sample::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned) override {
|
||||
for (int i = 0; i < N; ++i) {
|
||||
if (hit_test(fPoly[i], x, y)) {
|
||||
return new VertClick(this, &fPoly[i]);
|
||||
@ -316,6 +315,7 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
DEF_SAMPLE( return new EdgeClipView; )
|
||||
|
@ -5,9 +5,8 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "SampleCode.h"
|
||||
#include "Sample.h"
|
||||
#include "SkAnimTimer.h"
|
||||
#include "SkView.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkGradientShader.h"
|
||||
#include "SkPath.h"
|
||||
@ -68,7 +67,7 @@ static sk_sp<SkPathEffect> make_warp_pe(SkScalar phase) {
|
||||
|
||||
#include "SkColorFilter.h"
|
||||
|
||||
class PathEffectView : public SampleView {
|
||||
class PathEffectView : public Sample {
|
||||
SkPath fPath;
|
||||
SkPoint fClickPt;
|
||||
SkScalar fPhase;
|
||||
@ -109,9 +108,9 @@ protected:
|
||||
this->setBGColor(0xFFDDDDDD);
|
||||
}
|
||||
|
||||
bool onQuery(SkEvent* evt) override {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "PathEffects");
|
||||
bool onQuery(Sample::Event* evt) override {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "PathEffects");
|
||||
return true;
|
||||
}
|
||||
return this->INHERITED::onQuery(evt);
|
||||
@ -145,10 +144,9 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static SkView* MyFactory() { return new PathEffectView; }
|
||||
static SkViewRegister reg(MyFactory);
|
||||
DEF_SAMPLE( return new PathEffectView(); )
|
||||
|
@ -4,8 +4,7 @@
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
#include "SampleCode.h"
|
||||
#include "SkView.h"
|
||||
#include "Sample.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkGraphics.h"
|
||||
#include "SkRandom.h"
|
||||
@ -103,7 +102,7 @@ static const MakePathProc gProcs[] = {
|
||||
|
||||
#define N SK_ARRAY_COUNT(gProcs)
|
||||
|
||||
class PathFillView : public SampleView {
|
||||
class PathFillView : public Sample {
|
||||
SkPath fPath[N];
|
||||
SkScalar fDY[N];
|
||||
|
||||
@ -116,10 +115,9 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
// overrides from SkEventSink
|
||||
virtual bool onQuery(SkEvent* evt) {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "PathFill");
|
||||
virtual bool onQuery(Sample::Event* evt) {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "PathFill");
|
||||
return true;
|
||||
}
|
||||
return this->INHERITED::onQuery(evt);
|
||||
@ -136,10 +134,10 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static SkView* MyFactory() { return new PathFillView; }
|
||||
static SkViewRegister reg(MyFactory);
|
||||
static Sample* MyFactory() { return new PathFillView; }
|
||||
static SampleRegister reg(MyFactory);
|
||||
|
@ -5,8 +5,7 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "SampleCode.h"
|
||||
#include "SkView.h"
|
||||
#include "Sample.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkPaint.h"
|
||||
#include "SkPath.h"
|
||||
@ -646,17 +645,16 @@ static void path_fuzz_stroker(SkBitmap* bitmap, int seed) {
|
||||
});
|
||||
}
|
||||
|
||||
class PathFuzzView : public SampleView {
|
||||
class PathFuzzView : public Sample {
|
||||
public:
|
||||
PathFuzzView()
|
||||
: fOneDraw(false)
|
||||
{
|
||||
}
|
||||
protected:
|
||||
// overrides from SkEventSink
|
||||
bool onQuery(SkEvent* evt) override {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "PathFuzzer");
|
||||
bool onQuery(Sample::Event* evt) override {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "PathFuzzer");
|
||||
return true;
|
||||
}
|
||||
return this->INHERITED::onQuery(evt);
|
||||
@ -693,8 +691,7 @@ private:
|
||||
SkBitmap offscreen;
|
||||
FuzzPath fuzzPath;
|
||||
bool fOneDraw;
|
||||
typedef SkView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
static SkView* MyFactory() { return new PathFuzzView; }
|
||||
static SkViewRegister reg(MyFactory);
|
||||
DEF_SAMPLE( return new PathFuzzView(); )
|
||||
|
@ -4,8 +4,7 @@
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
#include "SampleCode.h"
|
||||
#include "SkView.h"
|
||||
#include "Sample.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkPath.h"
|
||||
|
||||
@ -16,7 +15,7 @@
|
||||
|
||||
#define LIN_SEGMENTS 10
|
||||
|
||||
class OverstrokeView : public SampleView {
|
||||
class OverstrokeView : public Sample {
|
||||
public:
|
||||
SkScalar fStroke;
|
||||
int fPathType; // super lazy enum
|
||||
@ -33,13 +32,13 @@ class OverstrokeView : public SampleView {
|
||||
}
|
||||
|
||||
protected:
|
||||
bool onQuery(SkEvent* evt) override {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "PathOverstroke");
|
||||
bool onQuery(Sample::Event* evt) override {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "PathOverstroke");
|
||||
return true;
|
||||
}
|
||||
SkUnichar uni;
|
||||
if (SampleCode::CharQ(*evt, &uni)) {
|
||||
if (Sample::CharQ(*evt, &uni)) {
|
||||
switch (uni) {
|
||||
case ',':
|
||||
fStroke += 1.0;
|
||||
@ -197,10 +196,9 @@ class OverstrokeView : public SampleView {
|
||||
}
|
||||
|
||||
private:
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static SkView* MyFactory() { return new OverstrokeView; }
|
||||
static SkViewRegister reg(MyFactory);
|
||||
DEF_SAMPLE( return new OverstrokeView(); )
|
||||
|
@ -5,7 +5,7 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "SampleCode.h"
|
||||
#include "Sample.h"
|
||||
#include "SkAnimTimer.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkGlyphCache.h"
|
||||
@ -18,7 +18,7 @@
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Static text from paths.
|
||||
class PathText : public SampleView {
|
||||
class PathText : public Sample {
|
||||
public:
|
||||
constexpr static int kNumPaths = 1500;
|
||||
virtual const char* getName() const { return "PathText"; }
|
||||
@ -49,13 +49,13 @@ public:
|
||||
void onOnceBeforeDraw() final { this->INHERITED::onOnceBeforeDraw(); this->reset(); }
|
||||
void onSizeChange() final { this->INHERITED::onSizeChange(); this->reset(); }
|
||||
|
||||
bool onQuery(SkEvent* evt) final {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, this->getName());
|
||||
bool onQuery(Sample::Event* evt) final {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, this->getName());
|
||||
return true;
|
||||
}
|
||||
SkUnichar unichar;
|
||||
if (SampleCode::CharQ(*evt, &unichar)) {
|
||||
if (Sample::CharQ(*evt, &unichar)) {
|
||||
if (unichar == 'X') {
|
||||
fDoClip = !fDoClip;
|
||||
return true;
|
||||
@ -106,7 +106,7 @@ protected:
|
||||
SkPath fClipPath = sk_tool_utils::make_star(SkRect{0,0,1,1}, 11, 3);
|
||||
bool fDoClip = false;
|
||||
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
void PathText::Glyph::init(SkRandom& rand, const SkPath& path) {
|
||||
|
@ -9,8 +9,7 @@
|
||||
|
||||
#ifdef SAMPLE_PDF_FILE_VIEWER
|
||||
|
||||
#include "SampleCode.h"
|
||||
#include "SkView.h"
|
||||
#include "Sample.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkGradientShader.h"
|
||||
#include "SkGraphics.h"
|
||||
@ -27,7 +26,7 @@
|
||||
#include "SkTypeface.h"
|
||||
#include "SkPdfRenderer.h"
|
||||
|
||||
class PdfFileViewer : public SampleView {
|
||||
class PdfFileViewer : public Sample {
|
||||
private:
|
||||
SkString fFilename;
|
||||
SkPicture* fPicture; // TODO(edisonn): multiple pages, one page / picture, make it an array
|
||||
@ -56,13 +55,12 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
// overrides from SkEventSink
|
||||
virtual bool onQuery(SkEvent* evt) {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
virtual bool onQuery(Sample::Event* evt) {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
SkString name("P:");
|
||||
const char* basename = strrchr(fFilename.c_str(), SkPATH_SEPARATOR);
|
||||
name.append(basename ? basename+1: fFilename.c_str());
|
||||
SampleCode::TitleR(evt, name.c_str());
|
||||
Sample::TitleR(evt, name.c_str());
|
||||
return true;
|
||||
}
|
||||
return this->INHERITED::onQuery(evt);
|
||||
@ -85,19 +83,19 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
SampleView* CreateSamplePdfFileViewer(const char filename[]);
|
||||
SampleView* CreateSamplePdfFileViewer(const char filename[]) {
|
||||
Sample* CreateSamplePdfFileViewer(const char filename[]);
|
||||
Sample* CreateSamplePdfFileViewer(const char filename[]) {
|
||||
return new PdfFileViewer(filename);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if 0
|
||||
static SkView* MyFactory() { return new PdfFileViewer; }
|
||||
static SkViewRegister reg(MyFactory);
|
||||
static Sample* MyFactory() { return new PdfFileViewer; }
|
||||
static SampleRegister reg(MyFactory);
|
||||
#endif
|
||||
|
||||
#endif // SAMPLE_PDF_FILE_VIEWER
|
||||
|
@ -5,8 +5,7 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "SampleCode.h"
|
||||
#include "SkView.h"
|
||||
#include "Sample.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkGradientShader.h"
|
||||
#include "SkGraphics.h"
|
||||
@ -21,15 +20,14 @@
|
||||
#include "SkTypeface.h"
|
||||
#include "SkStream.h"
|
||||
|
||||
class PointsView : public SampleView {
|
||||
class PointsView : public Sample {
|
||||
public:
|
||||
PointsView() {}
|
||||
|
||||
protected:
|
||||
// overrides from SkEventSink
|
||||
virtual bool onQuery(SkEvent* evt) {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "Points");
|
||||
virtual bool onQuery(Sample::Event* evt) {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "Points");
|
||||
return true;
|
||||
}
|
||||
return this->INHERITED::onQuery(evt);
|
||||
@ -69,10 +67,9 @@ protected:
|
||||
|
||||
private:
|
||||
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static SkView* MyFactory() { return new PointsView; }
|
||||
static SkViewRegister reg(MyFactory);
|
||||
DEF_SAMPLE( return new PointsView(); )
|
||||
|
@ -4,8 +4,7 @@
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
#include "SampleCode.h"
|
||||
#include "SkView.h"
|
||||
#include "Sample.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkGraphics.h"
|
||||
#include "SkPath.h"
|
||||
@ -13,7 +12,7 @@
|
||||
#include "SkString.h"
|
||||
#include "SkTime.h"
|
||||
|
||||
class PolyToPolyView : public SampleView {
|
||||
class PolyToPolyView : public Sample {
|
||||
public:
|
||||
PolyToPolyView() {
|
||||
// tests
|
||||
@ -67,10 +66,9 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
// overrides from SkEventSink
|
||||
virtual bool onQuery(SkEvent* evt) {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "PolyToPolyView");
|
||||
virtual bool onQuery(Sample::Event* evt) {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "PolyToPolyView");
|
||||
return true;
|
||||
}
|
||||
return this->INHERITED::onQuery(evt);
|
||||
@ -153,10 +151,9 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static SkView* MyFactory() { return new PolyToPolyView; }
|
||||
static SkViewRegister reg(MyFactory);
|
||||
DEF_SAMPLE( return new PolyToPolyView(); )
|
||||
|
@ -5,7 +5,7 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "SampleCode.h"
|
||||
#include "Sample.h"
|
||||
#include "SkBlendMode.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkColor.h"
|
||||
@ -28,7 +28,6 @@
|
||||
#include "SkTArray.h"
|
||||
#include "SkTemplates.h"
|
||||
#include "SkTypes.h"
|
||||
#include "SkView.h"
|
||||
#include "sk_tool_utils.h"
|
||||
|
||||
#include <cfloat>
|
||||
@ -111,7 +110,7 @@ struct CircleTypeButton : public StrokeTypeButton {
|
||||
bool fFill;
|
||||
};
|
||||
|
||||
class QuadStrokerView : public SampleView {
|
||||
class QuadStrokerView : public Sample {
|
||||
enum {
|
||||
SKELETON_COLOR = 0xFF0000FF,
|
||||
WIREFRAME_COLOR = 0x80FF0000
|
||||
@ -208,13 +207,13 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
bool onQuery(SkEvent* evt) override {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "QuadStroker");
|
||||
bool onQuery(Sample::Event* evt) override {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "QuadStroker");
|
||||
return true;
|
||||
}
|
||||
SkUnichar uni;
|
||||
if (fTextButton.fEnabled && SampleCode::CharQ(*evt, &uni)) {
|
||||
if (fTextButton.fEnabled && Sample::CharQ(*evt, &uni)) {
|
||||
switch (uni) {
|
||||
case ' ':
|
||||
fText = "";
|
||||
@ -718,10 +717,10 @@ protected:
|
||||
class MyClick : public Click {
|
||||
public:
|
||||
int fIndex;
|
||||
MyClick(SkView* target, int index) : Click(target), fIndex(index) {}
|
||||
MyClick(Sample* target, int index) : Click(target), fIndex(index) {}
|
||||
};
|
||||
|
||||
virtual SkView::Click* onFindClickHandler(SkScalar x, SkScalar y,
|
||||
virtual Sample::Click* onFindClickHandler(SkScalar x, SkScalar y,
|
||||
unsigned modi) override {
|
||||
for (size_t i = 0; i < SK_ARRAY_COUNT(fPts); ++i) {
|
||||
if (hittest(fPts[i], x, y)) {
|
||||
@ -807,10 +806,9 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
typedef SkView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static SkView* F2() { return new QuadStrokerView; }
|
||||
static SkViewRegister gR2(F2);
|
||||
DEF_SAMPLE( return new QuadStrokerView(); )
|
||||
|
@ -5,9 +5,10 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "gm.h"
|
||||
#include "SampleCode.h"
|
||||
#include "Sample.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkRandom.h"
|
||||
#include "SkPaint.h"
|
||||
#include "SkUtils.h"
|
||||
#if SK_SUPPORT_GPU
|
||||
#include "GrRectanizer_pow2.h"
|
||||
@ -22,7 +23,7 @@
|
||||
// Rand -> random rects from 2-256
|
||||
// Pow2Rand -> random power of 2 sized rects from 2-256
|
||||
// SmallPow2 -> 128x128 rects
|
||||
class RectanizerView : public SampleView {
|
||||
class RectanizerView : public Sample {
|
||||
public:
|
||||
RectanizerView()
|
||||
: fCurRandRect(0)
|
||||
@ -52,13 +53,13 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
bool onQuery(SkEvent* evt) override {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "Rectanizer");
|
||||
bool onQuery(Sample::Event* evt) override {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "Rectanizer");
|
||||
return true;
|
||||
}
|
||||
SkUnichar uni;
|
||||
if (SampleCode::CharQ(*evt, &uni)) {
|
||||
if (Sample::CharQ(*evt, &uni)) {
|
||||
char utf8[SkUTF::kMaxBytesInUTF8Sequence];
|
||||
size_t size = SkUTF::ToUTF8(uni, utf8);
|
||||
// Only consider events for single char keys
|
||||
@ -183,11 +184,11 @@ private:
|
||||
fCurRandRect = 0;
|
||||
}
|
||||
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
static SkView* MyFactory() { return new RectanizerView; }
|
||||
static SkViewRegister reg(MyFactory);
|
||||
|
||||
DEF_SAMPLE( return new RectanizerView(); )
|
||||
|
||||
#endif
|
||||
|
@ -5,8 +5,7 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "SampleCode.h"
|
||||
#include "SkView.h"
|
||||
#include "Sample.h"
|
||||
#include "SkBitmap.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkGradientShader.h"
|
||||
@ -148,7 +147,7 @@ static void paint_rgn(SkCanvas* canvas, const SkRegion& rgn,
|
||||
}
|
||||
}
|
||||
|
||||
class RegionView : public SampleView {
|
||||
class RegionView : public Sample {
|
||||
public:
|
||||
RegionView() {
|
||||
fBase.set(100, 100, 150, 150);
|
||||
@ -172,10 +171,9 @@ public:
|
||||
|
||||
|
||||
protected:
|
||||
// overrides from SkEventSink
|
||||
bool onQuery(SkEvent* evt) override {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "Regions");
|
||||
bool onQuery(Sample::Event* evt) override {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "Regions");
|
||||
return true;
|
||||
}
|
||||
return this->INHERITED::onQuery(evt);
|
||||
@ -328,7 +326,7 @@ protected:
|
||||
}
|
||||
}
|
||||
|
||||
virtual SkView::Click* onFindClickHandler(SkScalar x, SkScalar y,
|
||||
virtual Sample::Click* onFindClickHandler(SkScalar x, SkScalar y,
|
||||
unsigned modi) override {
|
||||
return fRect.contains(SkScalarRoundToInt(x),
|
||||
SkScalarRoundToInt(y)) ? new Click(this) : nullptr;
|
||||
@ -343,10 +341,9 @@ protected:
|
||||
private:
|
||||
SkIRect fBase, fRect;
|
||||
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static SkView* MyFactory() { return new RegionView; }
|
||||
static SkViewRegister reg(MyFactory);
|
||||
DEF_SAMPLE( return new RegionView(); )
|
||||
|
@ -4,8 +4,7 @@
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
#include "SampleCode.h"
|
||||
#include "SkView.h"
|
||||
#include "Sample.h"
|
||||
#include "SkBitmap.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkShader.h"
|
||||
@ -39,17 +38,16 @@ static void make_paint(SkPaint* paint, SkShader::TileMode tm) {
|
||||
paint->setShader(SkShader::MakeBitmapShader(bm, tm, tm));
|
||||
}
|
||||
|
||||
class RepeatTileView : public SampleView {
|
||||
class RepeatTileView : public Sample {
|
||||
public:
|
||||
RepeatTileView() {
|
||||
this->setBGColor(SK_ColorGRAY);
|
||||
}
|
||||
|
||||
protected:
|
||||
// overrides from SkEventSink
|
||||
bool onQuery(SkEvent* evt) override {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "RepeatTile");
|
||||
bool onQuery(Sample::Event* evt) override {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "RepeatTile");
|
||||
return true;
|
||||
}
|
||||
return this->INHERITED::onQuery(evt);
|
||||
@ -65,10 +63,9 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static SkView* MyFactory() { return new RepeatTileView; }
|
||||
static SkViewRegister reg(MyFactory);
|
||||
DEF_SAMPLE( return new RepeatTileView(); )
|
||||
|
@ -9,18 +9,17 @@
|
||||
|
||||
#ifdef SK_XML
|
||||
|
||||
#include "SampleCode.h"
|
||||
#include "Sample.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkDOM.h"
|
||||
#include "SkOSFile.h"
|
||||
#include "SkOSPath.h"
|
||||
#include "SkStream.h"
|
||||
#include "SkSVGDOM.h"
|
||||
#include "SkView.h"
|
||||
|
||||
namespace {
|
||||
|
||||
class SVGFileView : public SampleView {
|
||||
class SVGFileView : public Sample {
|
||||
public:
|
||||
SVGFileView(const SkString& path)
|
||||
: fPath(path), fLabel(SkStringPrintf("[%s]", SkOSPath::Basename(path.c_str()).c_str())) {}
|
||||
@ -60,9 +59,9 @@ protected:
|
||||
this->INHERITED::onSizeChange();
|
||||
}
|
||||
|
||||
bool onQuery(SkEvent* evt) override {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, fLabel.c_str());
|
||||
bool onQuery(Sample::Event* evt) override {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, fLabel.c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -73,13 +72,13 @@ private:
|
||||
SkString fPath;
|
||||
SkString fLabel;
|
||||
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
SampleView* CreateSampleSVGFileView(const SkString& filename);
|
||||
SampleView* CreateSampleSVGFileView(const SkString& filename) {
|
||||
Sample* CreateSampleSVGFileView(const SkString& filename);
|
||||
Sample* CreateSampleSVGFileView(const SkString& filename) {
|
||||
return new SVGFileView(filename);
|
||||
}
|
||||
#endif // SK_XML
|
||||
|
@ -5,12 +5,11 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "SampleCode.h"
|
||||
#include "Sample.h"
|
||||
#include "SkBitmap.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkGradientShader.h"
|
||||
#include "SkPath.h"
|
||||
#include "SkView.h"
|
||||
|
||||
static void makebm(SkBitmap* bm, int w, int h) {
|
||||
bm->allocN32Pixels(w, h);
|
||||
@ -94,17 +93,16 @@ static const GradMaker gGradMakers[] = {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class ShaderTextView : public SampleView {
|
||||
class ShaderTextView : public Sample {
|
||||
public:
|
||||
ShaderTextView() {
|
||||
this->setBGColor(0xFFDDDDDD);
|
||||
}
|
||||
|
||||
protected:
|
||||
// overrides from SkEventSink
|
||||
virtual bool onQuery(SkEvent* evt) {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "Shader Text");
|
||||
virtual bool onQuery(Sample::Event* evt) {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "Shader Text");
|
||||
return true;
|
||||
}
|
||||
return this->INHERITED::onQuery(evt);
|
||||
@ -190,10 +188,9 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static SkView* MyFactory() { return new ShaderTextView; }
|
||||
static SkViewRegister reg(MyFactory);
|
||||
DEF_SAMPLE( return new ShaderTextView(); )
|
||||
|
@ -6,8 +6,7 @@
|
||||
*/
|
||||
|
||||
#include "DecodeFile.h"
|
||||
#include "SampleCode.h"
|
||||
#include "SkView.h"
|
||||
#include "Sample.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkGradientShader.h"
|
||||
#include "SkGraphics.h"
|
||||
@ -36,7 +35,7 @@ static sk_sp<SkShader> make_bitmapfade(const SkBitmap& bm) {
|
||||
return SkShader::MakeComposeShader(std::move(shaderB), std::move(shaderA), SkBlendMode::kDstIn);
|
||||
}
|
||||
|
||||
class ShaderView : public SampleView {
|
||||
class ShaderView : public Sample {
|
||||
public:
|
||||
sk_sp<SkShader> fShader;
|
||||
SkBitmap fBitmap;
|
||||
@ -64,10 +63,9 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
// overrides from SkEventSink
|
||||
bool onQuery(SkEvent* evt) override {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "Shaders");
|
||||
bool onQuery(Sample::Event* evt) override {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "Shaders");
|
||||
return true;
|
||||
}
|
||||
return this->INHERITED::onQuery(evt);
|
||||
@ -101,10 +99,9 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static SkView* MyFactory() { return new ShaderView; }
|
||||
static SkViewRegister reg(MyFactory);
|
||||
DEF_SAMPLE( return new ShaderView(); )
|
||||
|
@ -5,7 +5,7 @@
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
#include "SampleCode.h"
|
||||
#include "Sample.h"
|
||||
#include "Resources.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkImage.h"
|
||||
@ -16,7 +16,7 @@
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// Sample to demonstrate tonal color shadows
|
||||
|
||||
class ShadowColorView : public SampleView {
|
||||
class ShadowColorView : public Sample {
|
||||
SkPath fRectPath;
|
||||
int fZIndex;
|
||||
|
||||
@ -42,15 +42,14 @@ protected:
|
||||
fRectPath.addRect(SkRect::MakeXYWH(-50, -50, 100, 100));
|
||||
}
|
||||
|
||||
// overrides from SkEventSink
|
||||
bool onQuery(SkEvent* evt) override {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "ShadowColor");
|
||||
bool onQuery(Sample::Event* evt) override {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "ShadowColor");
|
||||
return true;
|
||||
}
|
||||
|
||||
SkUnichar uni;
|
||||
if (SampleCode::CharQ(*evt, &uni)) {
|
||||
if (Sample::CharQ(*evt, &uni)) {
|
||||
bool handled = false;
|
||||
switch (uni) {
|
||||
case 'W':
|
||||
@ -225,10 +224,9 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static SkView* MyFactory() { return new ShadowColorView; }
|
||||
static SkViewRegister reg(MyFactory);
|
||||
DEF_SAMPLE( return new ShadowColorView(); )
|
||||
|
@ -5,7 +5,7 @@
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
#include "SampleCode.h"
|
||||
#include "Sample.h"
|
||||
#include "Resources.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkImage.h"
|
||||
@ -16,7 +16,7 @@
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// Sample to compare the Material Design shadow reference to our results
|
||||
|
||||
class ShadowRefView : public SampleView {
|
||||
class ShadowRefView : public Sample {
|
||||
SkPath fRRectPath;
|
||||
sk_sp<SkImage> fReferenceImage;
|
||||
|
||||
@ -38,15 +38,14 @@ protected:
|
||||
fReferenceImage = GetResourceAsImage("images/shadowreference.png");
|
||||
}
|
||||
|
||||
// overrides from SkEventSink
|
||||
bool onQuery(SkEvent* evt) override {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "ShadowReference");
|
||||
bool onQuery(Sample::Event* evt) override {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "ShadowReference");
|
||||
return true;
|
||||
}
|
||||
|
||||
SkUnichar uni;
|
||||
if (SampleCode::CharQ(*evt, &uni)) {
|
||||
if (Sample::CharQ(*evt, &uni)) {
|
||||
bool handled = false;
|
||||
switch (uni) {
|
||||
case 'W':
|
||||
@ -198,10 +197,9 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static SkView* MyFactory() { return new ShadowRefView; }
|
||||
static SkViewRegister reg(MyFactory);
|
||||
DEF_SAMPLE( return new ShadowRefView(); )
|
||||
|
@ -5,7 +5,7 @@
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
#include "SampleCode.h"
|
||||
#include "Sample.h"
|
||||
#include "SkAnimTimer.h"
|
||||
#include "SkBlurMask.h"
|
||||
#include "SkBlurMaskFilter.h"
|
||||
@ -17,12 +17,11 @@
|
||||
#include "SkPoint3.h"
|
||||
#include "SkShadowUtils.h"
|
||||
#include "SkUtils.h"
|
||||
#include "SkView.h"
|
||||
#include "sk_tool_utils.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class ShadowUtilsView : public SampleView {
|
||||
class ShadowUtilsView : public Sample {
|
||||
SkTArray<SkPath> fConvexPaths;
|
||||
SkTArray<SkPath> fConcavePaths;
|
||||
SkScalar fZDelta;
|
||||
@ -74,15 +73,14 @@ protected:
|
||||
fConcavePaths.back().cubicTo(0, -25, 40, -50, 50, 0);
|
||||
}
|
||||
|
||||
// overrides from SkEventSink
|
||||
bool onQuery(SkEvent* evt) override {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "ShadowUtils");
|
||||
bool onQuery(Sample::Event* evt) override {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "ShadowUtils");
|
||||
return true;
|
||||
}
|
||||
|
||||
SkUnichar uni;
|
||||
if (SampleCode::CharQ(*evt, &uni)) {
|
||||
if (Sample::CharQ(*evt, &uni)) {
|
||||
bool handled = false;
|
||||
switch (uni) {
|
||||
case 'W':
|
||||
@ -257,10 +255,9 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static SkView* MyFactory() { return new ShadowUtilsView; }
|
||||
static SkViewRegister reg(MyFactory);
|
||||
DEF_SAMPLE( return new ShadowUtilsView(); )
|
||||
|
@ -5,10 +5,9 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "SampleCode.h"
|
||||
#include "Sample.h"
|
||||
#include "Resources.h"
|
||||
#include "SkAnimTimer.h"
|
||||
#include "SkView.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkRSXform.h"
|
||||
#include "SkSurface.h"
|
||||
@ -45,7 +44,7 @@ static void draw_atlas_sim(SkCanvas* canvas, SkImage* atlas, const SkRSXform xfo
|
||||
}
|
||||
|
||||
|
||||
class DrawShipView : public SampleView {
|
||||
class DrawShipView : public Sample {
|
||||
public:
|
||||
DrawShipView(const char name[], DrawAtlasProc proc) : fName(name), fProc(proc) {
|
||||
fAtlas = GetResourceAsImage("images/ship.png");
|
||||
@ -88,10 +87,9 @@ public:
|
||||
~DrawShipView() override {}
|
||||
|
||||
protected:
|
||||
// overrides from SkEventSink
|
||||
bool onQuery(SkEvent* evt) override {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, fName);
|
||||
bool onQuery(Sample::Event* evt) override {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, fName);
|
||||
return true;
|
||||
}
|
||||
return this->INHERITED::onQuery(evt);
|
||||
@ -174,7 +172,7 @@ private:
|
||||
int fCurrentTime;
|
||||
|
||||
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -4,7 +4,7 @@
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
#include "SampleCode.h"
|
||||
#include "Sample.h"
|
||||
#include "SkBlurMask.h"
|
||||
#include "SkBlurMaskFilter.h"
|
||||
#include "SkCanvas.h"
|
||||
@ -13,7 +13,6 @@
|
||||
#include "SkGradientShader.h"
|
||||
#include "SkPaint.h"
|
||||
#include "SkVertices.h"
|
||||
#include "SkView.h"
|
||||
|
||||
#include "sk_tool_utils.h"
|
||||
|
||||
@ -470,7 +469,7 @@ static const SlideProc gProc[] = {
|
||||
mesh_slide,
|
||||
};
|
||||
|
||||
class SlideView : public SampleView {
|
||||
class SlideView : public Sample {
|
||||
int fIndex;
|
||||
bool fOnce;
|
||||
public:
|
||||
@ -504,10 +503,9 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
// overrides from SkEventSink
|
||||
bool onQuery(SkEvent* evt) override {
|
||||
if (SampleCode::TitleQ(*evt)) {
|
||||
SampleCode::TitleR(evt, "Slides");
|
||||
bool onQuery(Sample::Event* evt) override {
|
||||
if (Sample::TitleQ(*evt)) {
|
||||
Sample::TitleR(evt, "Slides");
|
||||
return true;
|
||||
}
|
||||
return this->INHERITED::onQuery(evt);
|
||||
@ -518,17 +516,16 @@ protected:
|
||||
gProc[fIndex](canvas);
|
||||
}
|
||||
|
||||
SkView::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned) override {
|
||||
Sample::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned) override {
|
||||
this->init();
|
||||
fIndex = (fIndex + 1) % SK_ARRAY_COUNT(gProc);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
private:
|
||||
typedef SampleView INHERITED;
|
||||
typedef Sample INHERITED;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static SkView* MyFactory() { return new SlideView; }
|
||||
static SkViewRegister reg(MyFactory);
|
||||
DEF_SAMPLE( return new SlideView(); )
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user