Re-enable overdraw mode in debugger.
Debugger is the last user of the deprecated SkPaintFilterCanvas
constructor. Stop using it and remove the constructor.
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=3268
Change-Id: I3e9180d48abdf86cb2c05bd8d95acabcdaa70427
Reviewed-on: https://skia-review.googlesource.com/3268
Commit-Queue: Ben Wagner <bungeman@google.com>
Reviewed-by: Mike Reed <reed@google.com>
diff --git a/BUILD.gn b/BUILD.gn
index 95e7259..7308fa1 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -792,7 +792,6 @@
"tools/debugger/SkDrawCommand.cpp",
"tools/debugger/SkJsonWriteBuffer.cpp",
"tools/debugger/SkObjectParser.cpp",
- "tools/debugger/SkOverdrawMode.cpp",
"tools/picture_utils.cpp",
"tools/random_parse_path.cpp",
"tools/sk_tool_utils.cpp",
@@ -1027,6 +1026,7 @@
"tools/skiaserve/urlhandlers/EnableGPUHandler.cpp",
"tools/skiaserve/urlhandlers/ImgHandler.cpp",
"tools/skiaserve/urlhandlers/InfoHandler.cpp",
+ "tools/skiaserve/urlhandlers/OverdrawHandler.cpp",
"tools/skiaserve/urlhandlers/PostHandler.cpp",
"tools/skiaserve/urlhandlers/QuitHandler.cpp",
"tools/skiaserve/urlhandlers/RootHandler.cpp",
diff --git a/gyp/debugger.gyp b/gyp/debugger.gyp
index dcc6f44..9cce342 100644
--- a/gyp/debugger.gyp
+++ b/gyp/debugger.gyp
@@ -103,8 +103,6 @@
'../tools/debugger/SkJsonWriteBuffer.cpp',
'../tools/debugger/SkObjectParser.h',
'../tools/debugger/SkObjectParser.cpp',
- '../tools/debugger/SkOverdrawMode.h',
- '../tools/debugger/SkOverdrawMode.cpp',
'../debugger/debuggermain.cpp',
'../debugger/QT/SkDebuggerGUI.cpp',
'../debugger/QT/SkDebuggerGUI.h',
diff --git a/gyp/dm.gypi b/gyp/dm.gypi
index bc19ee4..8a02f66 100644
--- a/gyp/dm.gypi
+++ b/gyp/dm.gypi
@@ -51,8 +51,6 @@
'../tools/debugger/SkDrawCommand.cpp',
'../tools/debugger/SkJsonWriteBuffer.cpp',
'../tools/debugger/SkObjectParser.cpp',
- '../tools/debugger/SkOverdrawMode.cpp',
- '../tools/debugger/SkOverdrawMode.h',
],
'conditions': [
[ 'skia_gpu == 1', {
diff --git a/gyp/gmslides.gypi b/gyp/gmslides.gypi
index 0dfc0bd..d318a53 100644
--- a/gyp/gmslides.gypi
+++ b/gyp/gmslides.gypi
@@ -31,8 +31,6 @@
'../tools/debugger/SkJsonWriteBuffer.cpp',
'../tools/debugger/SkObjectParser.h',
'../tools/debugger/SkObjectParser.cpp',
- '../tools/debugger/SkOverdrawMode.h',
- '../tools/debugger/SkOverdrawMode.cpp',
],
'dependencies': [
'libpng.gyp:libpng',
diff --git a/gyp/skiaserve.gyp b/gyp/skiaserve.gyp
index 21712fc..7fdf1b4 100644
--- a/gyp/skiaserve.gyp
+++ b/gyp/skiaserve.gyp
@@ -29,8 +29,6 @@
'../tools/debugger/SkJsonWriteBuffer.cpp',
'../tools/debugger/SkObjectParser.h',
'../tools/debugger/SkObjectParser.cpp',
- '../tools/debugger/SkOverdrawMode.h',
- '../tools/debugger/SkOverdrawMode.cpp',
'<!@(python find.py "*.cpp" ../tools/skiaserve ../tools/skiaserve/urlhandlers)',
],
'dependencies': [
diff --git a/gyp/tests.gypi b/gyp/tests.gypi
index eb2b9c8..517e256 100644
--- a/gyp/tests.gypi
+++ b/gyp/tests.gypi
@@ -54,8 +54,6 @@
'../tools/debugger/SkJsonWriteBuffer.cpp',
'../tools/debugger/SkObjectParser.h',
'../tools/debugger/SkObjectParser.cpp',
- '../tools/debugger/SkOverdrawMode.h',
- '../tools/debugger/SkOverdrawMode.cpp',
],
'sources!': [
'../tests/SkpSkGrTest.cpp',
diff --git a/include/utils/SkPaintFilterCanvas.h b/include/utils/SkPaintFilterCanvas.h
index 63eaaa2..d0a79fd 100644
--- a/include/utils/SkPaintFilterCanvas.h
+++ b/include/utils/SkPaintFilterCanvas.h
@@ -18,11 +18,6 @@
class SK_API SkPaintFilterCanvas : public SkNWayCanvas {
public:
/**
- * DEPRECATED: use the variant below.
- */
- SkPaintFilterCanvas(int width, int height);
-
- /**
* The new SkPaintFilterCanvas is configured for forwarding to the
* specified canvas. Also copies the target canvas matrix and clip bounds.
*/
diff --git a/src/gpu/GrProcessor.cpp b/src/gpu/GrProcessor.cpp
index 5ca9935..7d7ce9b 100644
--- a/src/gpu/GrProcessor.cpp
+++ b/src/gpu/GrProcessor.cpp
@@ -48,13 +48,15 @@
* we verify the count is as expected. If a new factory is added, then these numbers must be
* manually adjusted.
*/
-static const int kFPFactoryCount = 41;
+static const int kFPFactoryCount = 40;
static const int kGPFactoryCount = 14;
-static const int kXPFactoryCount = 6;
+static const int kXPFactoryCount = 5;
template<>
void GrProcessorTestFactory<GrFragmentProcessor>::VerifyFactoryCount() {
if (kFPFactoryCount != GetFactories()->count()) {
+ SkDebugf("\nExpected %d fragment processor factories, found %d.\n",
+ kFPFactoryCount, GetFactories()->count());
SkFAIL("Wrong number of fragment processor factories!");
}
}
@@ -62,6 +64,8 @@
template<>
void GrProcessorTestFactory<GrGeometryProcessor>::VerifyFactoryCount() {
if (kGPFactoryCount != GetFactories()->count()) {
+ SkDebugf("\nExpected %d geometry processor factories, found %d.\n",
+ kGPFactoryCount, GetFactories()->count());
SkFAIL("Wrong number of geometry processor factories!");
}
}
@@ -69,6 +73,8 @@
template<>
void GrProcessorTestFactory<GrXPFactory>::VerifyFactoryCount() {
if (kXPFactoryCount != GetFactories()->count()) {
+ SkDebugf("\nExpected %d xp factory factories, found %d.\n",
+ kXPFactoryCount, GetFactories()->count());
SkFAIL("Wrong number of xp factory factories!");
}
}
diff --git a/src/utils/SkPaintFilterCanvas.cpp b/src/utils/SkPaintFilterCanvas.cpp
index 15d76d6..910647d 100644
--- a/src/utils/SkPaintFilterCanvas.cpp
+++ b/src/utils/SkPaintFilterCanvas.cpp
@@ -29,8 +29,6 @@
bool fShouldDraw;
};
-SkPaintFilterCanvas::SkPaintFilterCanvas(int width, int height) : INHERITED(width, height) { }
-
SkPaintFilterCanvas::SkPaintFilterCanvas(SkCanvas *canvas)
: INHERITED(canvas->imageInfo().width(), canvas->imageInfo().height()) {
diff --git a/tools/debugger/SkDebugCanvas.cpp b/tools/debugger/SkDebugCanvas.cpp
index 1da995b..74e65da 100644
--- a/tools/debugger/SkDebugCanvas.cpp
+++ b/tools/debugger/SkDebugCanvas.cpp
@@ -9,7 +9,6 @@
#include "SkClipStack.h"
#include "SkDebugCanvas.h"
#include "SkDrawCommand.h"
-#include "SkOverdrawMode.h"
#include "SkPaintFilterCanvas.h"
#include "SkTextBlob.h"
@@ -27,23 +26,22 @@
class DebugPaintFilterCanvas : public SkPaintFilterCanvas {
public:
- DebugPaintFilterCanvas(int width,
- int height,
+ DebugPaintFilterCanvas(SkCanvas* canvas,
bool overdrawViz,
bool overrideFilterQuality,
SkFilterQuality quality)
- : INHERITED(width, height)
- , fOverdrawXfermode(overdrawViz ? SkOverdrawMode::Make() : nullptr)
+ : INHERITED(canvas)
+ , fOverdrawViz(overdrawViz)
, fOverrideFilterQuality(overrideFilterQuality)
, fFilterQuality(quality) {}
protected:
bool onFilter(SkTCopyOnFirstWrite<SkPaint>* paint, Type) const override {
if (*paint) {
- if (nullptr != fOverdrawXfermode.get()) {
- paint->writable()->setAntiAlias(false);
- // TODO: replace overdraw mode with something else
-// paint->writable()->setXfermode(fOverdrawXfermode);
+ if (fOverdrawViz) {
+ paint->writable()->setColor(SK_ColorRED);
+ paint->writable()->setAlpha(0x08);
+ paint->writable()->setBlendMode(SkBlendMode::kSrcOver);
}
if (fOverrideFilterQuality) {
@@ -72,8 +70,7 @@
}
private:
- sk_sp<SkXfermode> fOverdrawXfermode;
-
+ bool fOverdrawViz;
bool fOverrideFilterQuality;
SkFilterQuality fFilterQuality;
@@ -227,11 +224,9 @@
}
this->applyUserTransform(canvas);
- if (fPaintFilterCanvas) {
- fPaintFilterCanvas->addCanvas(canvas);
- canvas = fPaintFilterCanvas.get();
-
- }
+ DebugPaintFilterCanvas fPaintFilterCanvas(canvas, fOverdrawViz,
+ fOverrideFilterQuality, fFilterQuality);
+ canvas = &fPaintFilterCanvas;
if (fMegaVizMode) {
this->markActiveCommands(index);
@@ -338,10 +333,6 @@
canvas->restoreToCount(saveCount);
- if (fPaintFilterCanvas) {
- fPaintFilterCanvas->removeAll();
- }
-
#if SK_SUPPORT_GPU
// draw any batches if required and issue a full reset onto GrAuditTrail
if (at) {
@@ -514,34 +505,13 @@
return parsedFromString;
}
-void SkDebugCanvas::updatePaintFilterCanvas() {
- if (!fOverdrawViz && !fOverrideFilterQuality) {
- fPaintFilterCanvas.reset(nullptr);
- return;
- }
-
- const SkImageInfo info = this->imageInfo();
- fPaintFilterCanvas.reset(new DebugPaintFilterCanvas(info.width(), info.height(), fOverdrawViz,
- fOverrideFilterQuality, fFilterQuality));
-}
-
void SkDebugCanvas::setOverdrawViz(bool overdrawViz) {
- if (fOverdrawViz == overdrawViz) {
- return;
- }
-
fOverdrawViz = overdrawViz;
- this->updatePaintFilterCanvas();
}
void SkDebugCanvas::overrideTexFiltering(bool overrideTexFiltering, SkFilterQuality quality) {
- if (fOverrideFilterQuality == overrideTexFiltering && fFilterQuality == quality) {
- return;
- }
-
fOverrideFilterQuality = overrideTexFiltering;
fFilterQuality = quality;
- this->updatePaintFilterCanvas();
}
void SkDebugCanvas::onClipPath(const SkPath& path, ClipOp op, ClipEdgeStyle edgeStyle) {
diff --git a/tools/debugger/SkDebugCanvas.h b/tools/debugger/SkDebugCanvas.h
index dc44207..42b6a09 100644
--- a/tools/debugger/SkDebugCanvas.h
+++ b/tools/debugger/SkDebugCanvas.h
@@ -288,8 +288,6 @@
SkColor fClipVizColor;
bool fDrawGpuBatchBounds;
- SkAutoTUnref<SkNWayCanvas> fPaintFilterCanvas;
-
/**
The active saveLayer commands at a given point in the renderering.
Only used when "mega" visualization is enabled.
@@ -320,7 +318,6 @@
GrAuditTrail* getAuditTrail(SkCanvas*);
- void updatePaintFilterCanvas();
void drawAndCollectBatches(int n, SkCanvas*);
void cleanupAuditTrail(SkCanvas*);
diff --git a/tools/debugger/SkOverdrawMode.cpp b/tools/debugger/SkOverdrawMode.cpp
deleted file mode 100644
index b17354e..0000000
--- a/tools/debugger/SkOverdrawMode.cpp
+++ /dev/null
@@ -1,321 +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 "SkColorPriv.h"
-#include "SkOverdrawMode.h"
-#include "SkString.h"
-#include "SkXfermode.h"
-
-#if SK_SUPPORT_GPU
-#include "GrFragmentProcessor.h"
-#include "GrInvariantOutput.h"
-#include "GrXferProcessor.h"
-#include "glsl/GrGLSLFragmentProcessor.h"
-#include "glsl/GrGLSLFragmentShaderBuilder.h"
-#include "glsl/GrGLSLXferProcessor.h"
-
- ///////////////////////////////////////////////////////////////////////////////
- // Fragment Processor
- ///////////////////////////////////////////////////////////////////////////////
-
-class GLOverdrawFP;
-
-class GrOverdrawFP : public GrFragmentProcessor {
-public:
- static sk_sp<GrFragmentProcessor> Make(sk_sp<GrFragmentProcessor> dst) {
- return sk_sp<GrFragmentProcessor>(new GrOverdrawFP(std::move(dst)));
- }
-
- ~GrOverdrawFP() override { }
-
- const char* name() const override { return "Overdraw"; }
-
- SkString dumpInfo() const override {
- SkString str;
- return str;
- }
-
-private:
- GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
-
- void onGetGLSLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder* b) const override;
-
- bool onIsEqual(const GrFragmentProcessor&) const override { return true; }
-
- void onComputeInvariantOutput(GrInvariantOutput* inout) const override {
- inout->setToUnknown(GrInvariantOutput::kWill_ReadInput);
- }
-
- GrOverdrawFP(sk_sp<GrFragmentProcessor> dst) {
- this->initClassID<GrOverdrawFP>();
-
- SkASSERT(dst);
- SkDEBUGCODE(int dstIndex = )this->registerChildProcessor(std::move(dst));
- SkASSERT(0 == dstIndex);
- }
-
- GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
- typedef GrFragmentProcessor INHERITED;
-};
-
-///////////////////////////////////////////////////////////////////////////////
-
-static void add_overdraw_code(GrGLSLFragmentBuilder* fragBuilder,
- const char* dstColor,
- const char* outputColor) {
-
- static const GrGLSLShaderVar gColorTableArgs[] = {
- // TODO: once kInt_GrSLType lands - switch this over
- GrGLSLShaderVar("index", kFloat_GrSLType),
- };
- SkString colorTableFuncName;
-
- // The 'colorTable' function exists to work around older GLSL's prohibition
- // of initialized arrays. It takes an integer index and just returns the
- // corresponding color.
- fragBuilder->emitFunction(kVec4f_GrSLType,
- "colorTable",
- SK_ARRAY_COUNT(gColorTableArgs),
- gColorTableArgs,
- "if (index < 1.5) { return vec4(0.5, 0.617, 1.0, 1.0); }"
- "if (index < 2.5) { return vec4(0.664, 0.723, 0.83, 1.0); }"
- "if (index < 3.5) { return vec4(0.832, 0.762, 0.664, 1.0); }"
- "if (index < 4.5) { return vec4(1, 0.75, 0.496, 1.0); }"
- "if (index < 5.5) { return vec4(1, 0.723, 0.332, 1.0); }"
- "if (index < 6.5) { return vec4(1, 0.645, 0.164, 1.0); }"
- "if (index < 7.5) { return vec4(1, 0.527, 0, 1.0); }"
- "if (index < 8.5) { return vec4(1, 0.371, 0, 1.0); }"
- "if (index < 9.5) { return vec4(1, 0.195, 0, 1.0); }"
- "return vec4(1, 0, 0, 1.0);",
- &colorTableFuncName);
-
- fragBuilder->codeAppend("int nextIdx;");
- fragBuilder->codeAppendf("vec4 dst = %s;", dstColor);
- fragBuilder->codeAppend("if (dst.r < 0.25) { nextIdx = 1; }");
- // cap 'idx' at 10
- fragBuilder->codeAppend("else if (dst.g < 0.0977) { nextIdx = 10; }");
- fragBuilder->codeAppend("else if (dst.b > 0.08) { nextIdx = 8 - int(6.0 * dst.b + 0.5); }");
- fragBuilder->codeAppend("else { nextIdx = 11 - int(5.7 * dst.g + 0.5); }");
- fragBuilder->codeAppendf("%s = %s(float(nextIdx));", outputColor, colorTableFuncName.c_str());
-}
-
-class GLOverdrawFP : public GrGLSLFragmentProcessor {
-public:
- void emitCode(EmitArgs& args) override {
- GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
- SkString dstColor("dstColor");
- this->emitChild(0, nullptr, &dstColor, args);
-
- add_overdraw_code(fragBuilder, dstColor.c_str(), args.fOutputColor);
- }
-
- static void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuilder*) { }
-
-private:
- typedef GrGLSLFragmentProcessor INHERITED;
-};
-
-///////////////////////////////////////////////////////////////////////////////
-
-GrGLSLFragmentProcessor* GrOverdrawFP::onCreateGLSLInstance() const {
- return new GLOverdrawFP;
-}
-
-void GrOverdrawFP::onGetGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const {
- GLOverdrawFP::GenKey(*this, caps, b);
-}
-
-sk_sp<GrFragmentProcessor> GrOverdrawFP::TestCreate(GrProcessorTestData* d) {
- return GrOverdrawFP::Make(GrProcessorUnitTest::MakeChildFP(d));
-}
-
-GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrOverdrawFP);
-
-///////////////////////////////////////////////////////////////////////////////
-// Xfer Processor
-///////////////////////////////////////////////////////////////////////////////
-
-class OverdrawXP : public GrXferProcessor {
-public:
- OverdrawXP(const DstTexture* dstTexture, bool hasMixedSamples)
- : INHERITED(dstTexture, true, hasMixedSamples) {
- this->initClassID<OverdrawXP>();
- }
-
- const char* name() const override { return "Overdraw"; }
-
- GrGLSLXferProcessor* createGLSLInstance() const override;
-
-private:
- GrXferProcessor::OptFlags onGetOptimizations(const GrPipelineOptimizations& optimizations,
- bool doesStencilWrite,
- GrColor* overrideColor,
- const GrCaps& caps) const override {
- // We never look at the color input
- return GrXferProcessor::kIgnoreColor_OptFlag;
- }
-
- void onGetGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const override;
-
- bool onIsEqual(const GrXferProcessor&) const override { return true; }
-
- typedef GrXferProcessor INHERITED;
-};
-
-///////////////////////////////////////////////////////////////////////////////
-
-class GLOverdrawXP : public GrGLSLXferProcessor {
-public:
- GLOverdrawXP(const OverdrawXP&) { }
-
- ~GLOverdrawXP() override {}
-
- static void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuilder*) { }
-
-private:
- void emitBlendCodeForDstRead(GrGLSLXPFragmentBuilder* fragBuilder,
- GrGLSLUniformHandler* uniformHandler,
- const char* srcColor,
- const char* srcCoverage,
- const char* dstColor,
- const char* outColor,
- const char* outColorSecondary,
- const GrXferProcessor& proc) override {
- add_overdraw_code(fragBuilder, dstColor, outColor);
-
- // Apply coverage.
- INHERITED::DefaultCoverageModulation(fragBuilder, srcCoverage, dstColor, outColor,
- outColorSecondary, proc);
- }
-
- void onSetData(const GrGLSLProgramDataManager&, const GrXferProcessor&) override { }
-
- typedef GrGLSLXferProcessor INHERITED;
-};
-
-///////////////////////////////////////////////////////////////////////////////
-
-void OverdrawXP::onGetGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const {
- GLOverdrawXP::GenKey(*this, caps, b);
-}
-
-GrGLSLXferProcessor* OverdrawXP::createGLSLInstance() const { return new GLOverdrawXP(*this); }
-
-///////////////////////////////////////////////////////////////////////////////
-class GrOverdrawXPFactory : public GrXPFactory {
-public:
- static sk_sp<GrXPFactory> Make() { return sk_sp<GrXPFactory>(new GrOverdrawXPFactory()); }
-
- void getInvariantBlendedColor(const GrProcOptInfo& colorPOI,
- GrXPFactory::InvariantBlendedColor* blendedColor) const override {
- blendedColor->fWillBlendWithDst = true;
- blendedColor->fKnownColorFlags = kNone_GrColorComponentFlags;
- }
-
-private:
- GrOverdrawXPFactory() {
- this->initClassID<GrOverdrawXPFactory>();
- }
-
- GrXferProcessor* onCreateXferProcessor(const GrCaps& caps,
- const GrPipelineOptimizations& optimizations,
- bool hasMixedSamples,
- const DstTexture* dstTexture) const override {
- return new OverdrawXP(dstTexture, hasMixedSamples);
- }
-
- bool onWillReadDstColor(const GrCaps&, const GrPipelineOptimizations&) const override {
- return true;
- }
-
- bool onIsEqual(const GrXPFactory& xpfBase) const override { return true; }
-
- GR_DECLARE_XP_FACTORY_TEST;
-
- typedef GrXPFactory INHERITED;
-};
-
-GR_DEFINE_XP_FACTORY_TEST(GrOverdrawXPFactory);
-
-sk_sp<GrXPFactory> GrOverdrawXPFactory::TestCreate(GrProcessorTestData* d) {
- return GrOverdrawXPFactory::Make();
-}
-#endif
-
-///////////////////////////////////////////////////////////////////////////////
-class SkOverdrawXfermode : public SkXfermode {
-public:
- static SkXfermode* Create() {
- return new SkOverdrawXfermode;
- }
-
- SkPMColor xferColor(SkPMColor src, SkPMColor dst) const override {
- // This table encodes the color progression of the overdraw visualization
- static const SkPMColor gTable[] = {
- SkPackARGB32(0x00, 0x00, 0x00, 0x00),
- SkPackARGB32(0xFF, 128, 158, 255),
- SkPackARGB32(0xFF, 170, 185, 212),
- SkPackARGB32(0xFF, 213, 195, 170),
- SkPackARGB32(0xFF, 255, 192, 127),
- SkPackARGB32(0xFF, 255, 185, 85),
- SkPackARGB32(0xFF, 255, 165, 42),
- SkPackARGB32(0xFF, 255, 135, 0),
- SkPackARGB32(0xFF, 255, 95, 0),
- SkPackARGB32(0xFF, 255, 50, 0),
- SkPackARGB32(0xFF, 255, 0, 0)
- };
-
-
- int nextIdx;
- if (SkColorGetR(dst) < 64) { // dst color is the 0th color so the next color is 1
- nextIdx = 1;
- } else if (SkColorGetG(dst) < 25) { // dst color is the 10th color so cap there
- nextIdx = 10;
- } else if ((SkColorGetB(dst)+21)/42 > 0) { // dst color is one of 1-6
- nextIdx = 8 - (SkColorGetB(dst)+21)/42;
- } else { // dst color is between 7 and 9
- nextIdx = 11 - (SkColorGetG(dst)+22)/45;
- }
- SkASSERT(nextIdx < (int)SK_ARRAY_COUNT(gTable));
-
- return gTable[nextIdx];
- }
-
- SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkOverdrawXfermode)
-
-#if SK_SUPPORT_GPU
- sk_sp<GrFragmentProcessor> makeFragmentProcessorForImageFilter(
- sk_sp<GrFragmentProcessor> dst) const override {
- return GrOverdrawFP::Make(dst);
- }
-
- sk_sp<GrXPFactory> asXPFactory() const override {
- return GrOverdrawXPFactory::Make();
- }
-#endif
-
-#ifndef SK_IGNORE_TO_STRING
- void toString(SkString* str) const override { str->set("SkOverdrawXfermode"); }
-#endif
-
-private:
- friend class SkOverdrawMode;
-
- void flatten(SkWriteBuffer& buffer) const override { }
-
- typedef SkXfermode INHERITED;
-};
-
-sk_sp<SkFlattenable> SkOverdrawXfermode::CreateProc(SkReadBuffer& buffer) {
- return sk_sp<SkFlattenable>(Create());
-}
-
-sk_sp<SkXfermode> SkOverdrawMode::Make() { return sk_make_sp<SkOverdrawXfermode>(); }
-
-SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkOverdrawMode)
- SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkOverdrawXfermode)
-SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
diff --git a/tools/debugger/SkOverdrawMode.h b/tools/debugger/SkOverdrawMode.h
deleted file mode 100644
index 9e69293..0000000
--- a/tools/debugger/SkOverdrawMode.h
+++ /dev/null
@@ -1,25 +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.
- */
-
-#ifndef SkOverdrawMode_DEFINED
-#define SkOverdrawMode_DEFINED
-
-#include "SkFlattenable.h"
-
-class SkXfermode;
-
-class SkOverdrawMode {
-public:
- static sk_sp<SkXfermode> Make();
-
- SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP();
-
-private:
- SkOverdrawMode(); // can't be instantiated
-};
-
-#endif
diff --git a/tools/skiaserve/Request.cpp b/tools/skiaserve/Request.cpp
index eb1ccce..487da35 100644
--- a/tools/skiaserve/Request.cpp
+++ b/tools/skiaserve/Request.cpp
@@ -24,6 +24,7 @@
: fUploadContext(nullptr)
, fUrlDataManager(rootUrl)
, fGPUEnabled(false)
+ , fOverdraw(false)
, fColorMode(0) {
// create surface
#if SK_SUPPORT_GPU
@@ -97,7 +98,9 @@
}
sk_sp<SkData> Request::drawToPng(int n, int m) {
+ //fDebugCanvas->setOverdrawViz(true);
this->drawToCanvas(n, m);
+ //fDebugCanvas->setOverdrawViz(false);
return writeCanvasToPng(this->getCanvas());
}
@@ -195,6 +198,11 @@
return surface;
}
+bool Request::setOverdraw(bool enable) {
+ fOverdraw = enable;
+ return true;
+}
+
bool Request::setColorMode(int mode) {
fColorMode = mode;
return enableGPU(fGPUEnabled);
diff --git a/tools/skiaserve/Request.h b/tools/skiaserve/Request.h
index 0b6ed3b..cadf15c 100644
--- a/tools/skiaserve/Request.h
+++ b/tools/skiaserve/Request.h
@@ -43,6 +43,7 @@
SkCanvas* getCanvas();
SkBitmap* getBitmapFromCanvas(SkCanvas* canvas);
bool enableGPU(bool enable);
+ bool setOverdraw(bool enable);
bool setColorMode(int mode);
bool hasPicture() const { return SkToBool(fPicture.get()); }
int getLastOp() const { return fDebugCanvas->getSize() - 1; }
@@ -77,6 +78,7 @@
sk_gpu_test::GrContextFactory* fContextFactory;
SkAutoTUnref<SkSurface> fSurface;
bool fGPUEnabled;
+ bool fOverdraw;
int fColorMode;
};
diff --git a/tools/skiaserve/urlhandlers/OverdrawHandler.cpp b/tools/skiaserve/urlhandlers/OverdrawHandler.cpp
new file mode 100644
index 0000000..7f8c404
--- /dev/null
+++ b/tools/skiaserve/urlhandlers/OverdrawHandler.cpp
@@ -0,0 +1,40 @@
+/*
+ * 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 "UrlHandler.h"
+
+#include "microhttpd.h"
+#include "../Request.h"
+#include "../Response.h"
+
+using namespace Response;
+
+bool OverdrawHandler::canHandle(const char* method, const char* url) {
+ static const char* kBasePath = "/overdraw/";
+ return 0 == strcmp(method, MHD_HTTP_METHOD_POST) &&
+ 0 == strncmp(url, kBasePath, strlen(kBasePath));
+}
+
+int OverdrawHandler::handle(Request* request, MHD_Connection* connection,
+ const char* url, const char* method,
+ const char* upload_data, size_t* upload_data_size) {
+ SkTArray<SkString> commands;
+ SkStrSplit(url, "/", &commands);
+
+ if (commands.count() != 2) {
+ return MHD_NO;
+ }
+
+ int enable;
+ sscanf(commands[1].c_str(), "%d", &enable);
+
+ bool success = request->setOverdraw(SkToBool(enable));
+ if (!success) {
+ return SendError(connection, "Unable to set overdraw");
+ }
+ return SendOK(connection);
+}
diff --git a/tools/skiaserve/urlhandlers/UrlHandler.h b/tools/skiaserve/urlhandlers/UrlHandler.h
index 2702f48..1536ef3 100644
--- a/tools/skiaserve/urlhandlers/UrlHandler.h
+++ b/tools/skiaserve/urlhandlers/UrlHandler.h
@@ -67,6 +67,18 @@
const char* upload_data, size_t* upload_data_size) override;
};
+/**
+ Controls whether overdraw rendering is enabled. Posting to /overdraw/1 turns overdraw on,
+ /overdraw/0 disables it.
+ */
+class OverdrawHandler : public UrlHandler {
+public:
+ bool canHandle(const char* method, const char* url) override;
+ int handle(Request* request, MHD_Connection* connection,
+ const char* url, const char* method,
+ const char* upload_data, size_t* upload_data_size) override;
+};
+
class PostHandler : public UrlHandler {
public:
bool canHandle(const char* method, const char* url) override;