Revert of Add gpu implementation of OverdrawXfermode (patchset #6 id:100001 of https://codereview.chromium.org/1607253002/ )
Reason for revert:
Overdraw Xfer mode using new fangled glsl features
Original issue's description:
> Add gpu implementation of OverdrawXfermode
> GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1607253002
>
> Committed: https://skia.googlesource.com/skia/+/8bc3cf88bbf5e5d5724356f076931bb70a6117ba
TBR=egdaniel@google.com
# Not skipping CQ checks because original CL landed more than 1 days ago.
Review URL: https://codereview.chromium.org/1626443002
diff --git a/debugger/QT/SkDebuggerGUI.cpp b/debugger/QT/SkDebuggerGUI.cpp
index 0c369f6..0d009b3 100644
--- a/debugger/QT/SkDebuggerGUI.cpp
+++ b/debugger/QT/SkDebuggerGUI.cpp
@@ -202,6 +202,7 @@
void SkDebuggerGUI::actionRasterSettingsChanged() {
fCanvasWidget.setWidgetVisibility(SkCanvasWidget::kRaster_8888_WidgetType,
!fSettingsWidget.isRasterEnabled());
+ fDebugger.setOverdrawViz(fSettingsWidget.isOverdrawVizEnabled());
this->updateImage();
}
@@ -209,7 +210,6 @@
fDebugger.setMegaViz(fSettingsWidget.isMegaVizEnabled());
fDebugger.setPathOps(fSettingsWidget.isPathOpsEnabled());
fDebugger.highlightCurrentCommand(fSettingsWidget.isVisibilityFilterEnabled());
- fDebugger.setOverdrawViz(fSettingsWidget.isOverdrawVizEnabled());
this->updateImage();
}
diff --git a/debugger/QT/SkSettingsWidget.cpp b/debugger/QT/SkSettingsWidget.cpp
index 4665217..59b7920 100644
--- a/debugger/QT/SkSettingsWidget.cpp
+++ b/debugger/QT/SkSettingsWidget.cpp
@@ -21,36 +21,30 @@
// Visualizations toggles.
fVisualizationsGroup.setTitle("Visualizations");
-
fVisibilityFilterCheckBox.setText("Visibility Filter");
fVisualizationsLayout.addWidget(&fVisibilityFilterCheckBox);
-
fMegaVizCheckBox.setText("Mega Viz");
fVisualizationsLayout.addWidget(&fMegaVizCheckBox);
-
fPathOpsCheckBox.setText("PathOps ");
fVisualizationsLayout.addWidget(&fPathOpsCheckBox);
-
- fOverdrawVizCheckBox.setText("Overdraw Viz");
- fVisualizationsLayout.addWidget(&fOverdrawVizCheckBox);
-
fVisualizationsGroup.setLayout(&fVisualizationsLayout);
-
connect(&fVisibilityFilterCheckBox, SIGNAL(toggled(bool)), this,
SIGNAL(visualizationsChanged()));
connect(&fMegaVizCheckBox, SIGNAL(toggled(bool)), this, SIGNAL(visualizationsChanged()));
connect(&fPathOpsCheckBox, SIGNAL(toggled(bool)), this, SIGNAL(visualizationsChanged()));
- connect(&fOverdrawVizCheckBox, SIGNAL(toggled(bool)), this, SIGNAL(visualizationsChanged()));
fVerticalLayout.addRow(&fVisualizationsGroup);
// Raster toggles.
fRasterGroup.setTitle("Raster");
fRasterGroup.setCheckable(true);
+ fOverdrawVizCheckBox.setText("Overdraw Viz");
+ fRasterLayout.addWidget(&fOverdrawVizCheckBox);
fRasterGroup.setLayout(&fRasterLayout);
fVerticalLayout.addRow(&fRasterGroup);
connect(&fRasterGroup, SIGNAL(toggled(bool)), this, SIGNAL(rasterSettingsChanged()));
+ connect(&fOverdrawVizCheckBox, SIGNAL(toggled(bool)), this, SIGNAL(rasterSettingsChanged()));
#if SK_SUPPORT_GPU
fGLGroup.setTitle("OpenGL");
diff --git a/gyp/debugger.gyp b/gyp/debugger.gyp
index fb02696..6cc2a40 100644
--- a/gyp/debugger.gyp
+++ b/gyp/debugger.gyp
@@ -101,8 +101,6 @@
'../src/utils/debugger/SkDrawCommand.cpp',
'../src/utils/debugger/SkObjectParser.h',
'../src/utils/debugger/SkObjectParser.cpp',
- '../src/utils/debugger/SkOverdrawMode.h',
- '../src/utils/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 bb21923..8ad3e68 100644
--- a/gyp/dm.gypi
+++ b/gyp/dm.gypi
@@ -44,8 +44,6 @@
'../src/utils/debugger/SkDebugCanvas.cpp',
'../src/utils/debugger/SkDrawCommand.cpp',
'../src/utils/debugger/SkObjectParser.cpp',
- '../src/utils/debugger/SkOverdrawMode.h',
- '../src/utils/debugger/SkOverdrawMode.cpp',
],
'conditions': [
[ 'skia_gpu == 1', {
diff --git a/gyp/gmslides.gypi b/gyp/gmslides.gypi
index cf5d162..87910e5 100644
--- a/gyp/gmslides.gypi
+++ b/gyp/gmslides.gypi
@@ -27,8 +27,6 @@
'../src/utils/debugger/SkDebugCanvas.cpp',
'../src/utils/debugger/SkObjectParser.h',
'../src/utils/debugger/SkObjectParser.cpp',
- '../src/utils/debugger/SkOverdrawMode.h',
- '../src/utils/debugger/SkOverdrawMode.cpp',
],
}],
],
diff --git a/gyp/tests.gypi b/gyp/tests.gypi
index 5f3df96..10bfdb4 100644
--- a/gyp/tests.gypi
+++ b/gyp/tests.gypi
@@ -57,8 +57,6 @@
'../src/utils/debugger/SkDebugCanvas.cpp',
'../src/utils/debugger/SkObjectParser.h',
'../src/utils/debugger/SkObjectParser.cpp',
- '../src/utils/debugger/SkOverdrawMode.h',
- '../src/utils/debugger/SkOverdrawMode.cpp',
],
'sources!': [
'../tests/SkpSkGrTest.cpp',
diff --git a/src/effects/SkArithmeticMode.cpp b/src/effects/SkArithmeticMode.cpp
index 2e68cab..9eb7dd2 100644
--- a/src/effects/SkArithmeticMode.cpp
+++ b/src/effects/SkArithmeticMode.cpp
@@ -21,13 +21,13 @@
class SkArithmeticMode_scalar : public SkXfermode {
public:
- static SkXfermode* Create(SkScalar k1, SkScalar k2, SkScalar k3, SkScalar k4,
- bool enforcePMColor) {
+ static SkArithmeticMode_scalar* Create(SkScalar k1, SkScalar k2, SkScalar k3, SkScalar k4,
+ bool enforcePMColor) {
return new SkArithmeticMode_scalar(k1, k2, k3, k4, enforcePMColor);
}
- void xfer32(SkPMColor dst[], const SkPMColor src[], int count,
- const SkAlpha aa[]) const override;
+ virtual void xfer32(SkPMColor dst[], const SkPMColor src[], int count,
+ const SkAlpha aa[]) const override;
SK_TO_STRING_OVERRIDE()
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkArithmeticMode_scalar)
diff --git a/src/effects/SkArithmeticMode_gpu.cpp b/src/effects/SkArithmeticMode_gpu.cpp
index 29c6602..ce8e426 100644
--- a/src/effects/SkArithmeticMode_gpu.cpp
+++ b/src/effects/SkArithmeticMode_gpu.cpp
@@ -226,8 +226,17 @@
add_arithmetic_code(fragBuilder, srcColor, dstColor, outColor, kUni, fEnforcePMColor);
// Apply coverage.
- INHERITED::DefaultCoverageModulation(fragBuilder, srcCoverage, dstColor, outColor,
- outColorSecondary, proc);
+ if (proc.dstReadUsesMixedSamples()) {
+ if (srcCoverage) {
+ fragBuilder->codeAppendf("%s *= %s;", outColor, srcCoverage);
+ fragBuilder->codeAppendf("%s = %s;", outColorSecondary, srcCoverage);
+ } else {
+ fragBuilder->codeAppendf("%s = vec4(1.0);", outColorSecondary);
+ }
+ } else if (srcCoverage) {
+ fragBuilder->codeAppendf("%s = %s * %s + (vec4(1.0) - %s) * %s;",
+ outColor, srcCoverage, outColor, srcCoverage, dstColor);
+ }
}
void onSetData(const GrGLSLProgramDataManager& pdman,
diff --git a/src/gpu/GrProcessor.cpp b/src/gpu/GrProcessor.cpp
index 20f7d72..1db9d76 100644
--- a/src/gpu/GrProcessor.cpp
+++ b/src/gpu/GrProcessor.cpp
@@ -48,9 +48,9 @@
* we verify the count is as expected. If a new factory is added, then these numbers must be
* manually adjusted.
*/
-static const int kFPFactoryCount = 39;
+static const int kFPFactoryCount = 38;
static const int kGPFactoryCount = 14;
-static const int kXPFactoryCount = 6;
+static const int kXPFactoryCount = 5;
template<>
void GrProcessorTestFactory<GrFragmentProcessor>::VerifyFactoryCount() {
diff --git a/src/gpu/effects/GrCustomXfermode.cpp b/src/gpu/effects/GrCustomXfermode.cpp
index dccec0c..93f2073 100644
--- a/src/gpu/effects/GrCustomXfermode.cpp
+++ b/src/gpu/effects/GrCustomXfermode.cpp
@@ -175,8 +175,17 @@
GrGLSLBlend::AppendMode(fragBuilder, srcColor, dstColor, outColor, xp.mode());
// Apply coverage.
- INHERITED::DefaultCoverageModulation(fragBuilder, srcCoverage, dstColor, outColor,
- outColorSecondary, xp);
+ if (xp.dstReadUsesMixedSamples()) {
+ if (srcCoverage) {
+ fragBuilder->codeAppendf("%s *= %s;", outColor, srcCoverage);
+ fragBuilder->codeAppendf("%s = %s;", outColorSecondary, srcCoverage);
+ } else {
+ fragBuilder->codeAppendf("%s = vec4(1.0);", outColorSecondary);
+ }
+ } else if (srcCoverage) {
+ fragBuilder->codeAppendf("%s = %s * %s + (vec4(1.0) - %s) * %s;",
+ outColor, srcCoverage, outColor, srcCoverage, dstColor);
+ }
}
void onSetData(const GrGLSLProgramDataManager&, const GrXferProcessor&) override {}
diff --git a/src/gpu/effects/GrPorterDuffXferProcessor.cpp b/src/gpu/effects/GrPorterDuffXferProcessor.cpp
index d1059c7..2ea45a5 100644
--- a/src/gpu/effects/GrPorterDuffXferProcessor.cpp
+++ b/src/gpu/effects/GrPorterDuffXferProcessor.cpp
@@ -559,8 +559,17 @@
GrGLSLBlend::AppendMode(fragBuilder, srcColor, dstColor, outColor, xp.getXfermode());
// Apply coverage.
- INHERITED::DefaultCoverageModulation(fragBuilder, srcCoverage, dstColor, outColor,
- outColorSecondary, xp);
+ if (xp.dstReadUsesMixedSamples()) {
+ if (srcCoverage) {
+ fragBuilder->codeAppendf("%s *= %s;", outColor, srcCoverage);
+ fragBuilder->codeAppendf("%s = %s;", outColorSecondary, srcCoverage);
+ } else {
+ fragBuilder->codeAppendf("%s = vec4(1.0);", outColorSecondary);
+ }
+ } else if (srcCoverage) {
+ fragBuilder->codeAppendf("%s = %s * %s + (vec4(1.0) - %s) * %s;",
+ outColor, srcCoverage, outColor, srcCoverage, dstColor);
+ }
}
void onSetData(const GrGLSLProgramDataManager&, const GrXferProcessor&) override {}
diff --git a/src/gpu/glsl/GrGLSLXferProcessor.cpp b/src/gpu/glsl/GrGLSLXferProcessor.cpp
index 9d2538f..81bd015 100644
--- a/src/gpu/glsl/GrGLSLXferProcessor.cpp
+++ b/src/gpu/glsl/GrGLSLXferProcessor.cpp
@@ -88,21 +88,3 @@
this->onSetData(pdm, xp);
}
-void GrGLSLXferProcessor::DefaultCoverageModulation(GrGLSLXPFragmentBuilder* fragBuilder,
- const char* srcCoverage,
- const char* dstColor,
- const char* outColor,
- const char* outColorSecondary,
- const GrXferProcessor& proc) {
- if (proc.dstReadUsesMixedSamples()) {
- if (srcCoverage) {
- fragBuilder->codeAppendf("%s *= %s;", outColor, srcCoverage);
- fragBuilder->codeAppendf("%s = %s;", outColorSecondary, srcCoverage);
- } else {
- fragBuilder->codeAppendf("%s = vec4(1.0);", outColorSecondary);
- }
- } else if (srcCoverage) {
- fragBuilder->codeAppendf("%s = %s * %s + (vec4(1.0) - %s) * %s;",
- outColor, srcCoverage, outColor, srcCoverage, dstColor);
- }
-}
diff --git a/src/gpu/glsl/GrGLSLXferProcessor.h b/src/gpu/glsl/GrGLSLXferProcessor.h
index 478956d..1a997a5 100644
--- a/src/gpu/glsl/GrGLSLXferProcessor.h
+++ b/src/gpu/glsl/GrGLSLXferProcessor.h
@@ -71,14 +71,6 @@
*/
void setData(const GrGLSLProgramDataManager& pdm, const GrXferProcessor& xp);
-protected:
- static void DefaultCoverageModulation(GrGLSLXPFragmentBuilder* fragBuilder,
- const char* srcCoverage,
- const char* dstColor,
- const char* outColor,
- const char* outColorSecondary,
- const GrXferProcessor& proc);
-
private:
/**
* Called by emitCode() when the XP will not be performing a dst read. This method is
diff --git a/src/utils/debugger/SkDebugCanvas.cpp b/src/utils/debugger/SkDebugCanvas.cpp
index c2dd8f8..63739ae 100644
--- a/src/utils/debugger/SkDebugCanvas.cpp
+++ b/src/utils/debugger/SkDebugCanvas.cpp
@@ -6,11 +6,55 @@
*/
#include "SkClipStack.h"
+#include "SkColorPriv.h"
#include "SkDebugCanvas.h"
#include "SkDrawCommand.h"
#include "SkDevice.h"
#include "SkPaintFilterCanvas.h"
-#include "SkOverdrawMode.h"
+#include "SkXfermode.h"
+
+namespace {
+
+class OverdrawXfermode : public SkXfermode {
+public:
+ 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 idx;
+ if (SkColorGetR(dst) < 64) { // 0
+ idx = 0;
+ } else if (SkColorGetG(dst) < 25) { // 10
+ idx = 9; // cap at 9 for upcoming increment
+ } else if ((SkColorGetB(dst)+21)/42 > 0) { // 1-6
+ idx = 7 - (SkColorGetB(dst)+21)/42;
+ } else { // 7-9
+ idx = 10 - (SkColorGetG(dst)+22)/45;
+ }
+ ++idx;
+ SkASSERT(idx < (int)SK_ARRAY_COUNT(gTable));
+
+ return gTable[idx];
+ }
+
+ Factory getFactory() const override { return nullptr; }
+#ifndef SK_IGNORE_TO_STRING
+ void toString(SkString* str) const override { str->set("OverdrawXfermode"); }
+#endif
+};
class DebugPaintFilterCanvas : public SkPaintFilterCanvas {
public:
@@ -20,7 +64,7 @@
bool overrideFilterQuality,
SkFilterQuality quality)
: INHERITED(width, height)
- , fOverdrawXfermode(overdrawViz ? SkOverdrawMode::Create() : nullptr)
+ , fOverdrawXfermode(overdrawViz ? new OverdrawXfermode : nullptr)
, fOverrideFilterQuality(overrideFilterQuality)
, fFilterQuality(quality) {}
@@ -55,6 +99,8 @@
typedef SkPaintFilterCanvas INHERITED;
};
+}
+
SkDebugCanvas::SkDebugCanvas(int width, int height)
: INHERITED(width, height)
, fPicture(nullptr)
diff --git a/src/utils/debugger/SkOverdrawMode.cpp b/src/utils/debugger/SkOverdrawMode.cpp
deleted file mode 100644
index 72001ec..0000000
--- a/src/utils/debugger/SkOverdrawMode.cpp
+++ /dev/null
@@ -1,323 +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 const GrFragmentProcessor* Create(const GrFragmentProcessor* dst) {
- return new GrOverdrawFP(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(const GrFragmentProcessor* dst) {
- this->initClassID<GrOverdrawFP>();
-
- SkASSERT(dst);
- SkDEBUGCODE(int dstIndex = )this->registerChildProcessor(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) {
-
- fragBuilder->codeAppend("vec4 gTable[11] = vec4[11](");
- fragBuilder->codeAppend("vec4(0, 0, 0, 0.0),");
- fragBuilder->codeAppend("vec4(0.5, 0.617, 1.0, 1.0),");
- fragBuilder->codeAppend("vec4(0.664, 0.723, 0.83, 1.0),");
- fragBuilder->codeAppend("vec4(0.832, 0.762, 0.664, 1.0),");
- fragBuilder->codeAppend("vec4(1, 0.75, 0.496, 1.0),");
- fragBuilder->codeAppend("vec4(1, 0.723, 0.332, 1.0),");
- fragBuilder->codeAppend("vec4(1, 0.645, 0.164, 1.0),");
- fragBuilder->codeAppend("vec4(1, 0.527, 0, 1.0),");
- fragBuilder->codeAppend("vec4(1, 0.371, 0, 1.0),");
- fragBuilder->codeAppend("vec4(1, 0.195, 0, 1.0),");
- fragBuilder->codeAppend("vec4(1, 0, 0, 1.0)");
- fragBuilder->codeAppend(");");
-
- 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 * dst.b + 0.5); }");
- fragBuilder->codeAppend("else { nextIdx = 11 - int(5.7 * dst.g + 0.5); }");
- fragBuilder->codeAppendf("%s = gTable[nextIdx];", outputColor);
-}
-
-class GLOverdrawFP : public GrGLSLFragmentProcessor {
-public:
- GLOverdrawFP(const GrOverdrawFP&) {}
-
- ~GLOverdrawFP() override {}
-
- 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(*this);
-}
-
-void GrOverdrawFP::onGetGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) const {
- GLOverdrawFP::GenKey(*this, caps, b);
-}
-
-const GrFragmentProcessor* GrOverdrawFP::TestCreate(GrProcessorTestData* d) {
- SkAutoTUnref<const GrFragmentProcessor> dst(GrProcessorUnitTest::CreateChildFP(d));
- return new GrOverdrawFP(dst);
-}
-
-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 GrXPFactory* Create() { return 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& caps,
- const GrPipelineOptimizations& optimizations,
- bool hasMixedSamples) 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);
-
-const GrXPFactory* GrOverdrawXPFactory::TestCreate(GrProcessorTestData* d) {
- return GrOverdrawXPFactory::Create();
-}
-#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
- bool asFragmentProcessor(const GrFragmentProcessor** output,
- const GrFragmentProcessor* dst) const override {
- if (output) {
- *output = GrOverdrawFP::Create(dst);
- }
- return true;
- }
-
- bool asXPFactory(GrXPFactory** xpf) const override {
- if (xpf) {
- *xpf = GrOverdrawXPFactory::Create();
- }
- return true;
- }
-#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;
-};
-
-SkFlattenable* SkOverdrawXfermode::CreateProc(SkReadBuffer& buffer) {
- return Create();
-}
-
-SkXfermode* SkOverdrawMode::Create() { return new SkOverdrawXfermode; }
-
-SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkOverdrawMode)
- SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkOverdrawXfermode)
-SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
diff --git a/src/utils/debugger/SkOverdrawMode.h b/src/utils/debugger/SkOverdrawMode.h
deleted file mode 100644
index dba7635..0000000
--- a/src/utils/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 SkXfermode* Create();
-
- SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP();
-
-private:
- SkOverdrawMode(); // can't be instantiated
-};
-
-#endif