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

Side by Side Diff: src/utils/debugger/SkDebugCanvas.cpp

Issue 1626443002: Revert of Add gpu implementation of OverdrawXfermode (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/glsl/GrGLSLXferProcessor.cpp ('k') | src/utils/debugger/SkOverdrawMode.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkClipStack.h" 8 #include "SkClipStack.h"
9 #include "SkColorPriv.h"
9 #include "SkDebugCanvas.h" 10 #include "SkDebugCanvas.h"
10 #include "SkDrawCommand.h" 11 #include "SkDrawCommand.h"
11 #include "SkDevice.h" 12 #include "SkDevice.h"
12 #include "SkPaintFilterCanvas.h" 13 #include "SkPaintFilterCanvas.h"
13 #include "SkOverdrawMode.h" 14 #include "SkXfermode.h"
15
16 namespace {
17
18 class OverdrawXfermode : public SkXfermode {
19 public:
20 SkPMColor xferColor(SkPMColor src, SkPMColor dst) const override {
21 // This table encodes the color progression of the overdraw visualizatio n
22 static const SkPMColor gTable[] = {
23 SkPackARGB32(0x00, 0x00, 0x00, 0x00),
24 SkPackARGB32(0xFF, 128, 158, 255),
25 SkPackARGB32(0xFF, 170, 185, 212),
26 SkPackARGB32(0xFF, 213, 195, 170),
27 SkPackARGB32(0xFF, 255, 192, 127),
28 SkPackARGB32(0xFF, 255, 185, 85),
29 SkPackARGB32(0xFF, 255, 165, 42),
30 SkPackARGB32(0xFF, 255, 135, 0),
31 SkPackARGB32(0xFF, 255, 95, 0),
32 SkPackARGB32(0xFF, 255, 50, 0),
33 SkPackARGB32(0xFF, 255, 0, 0)
34 };
35
36
37 int idx;
38 if (SkColorGetR(dst) < 64) { // 0
39 idx = 0;
40 } else if (SkColorGetG(dst) < 25) { // 10
41 idx = 9; // cap at 9 for upcoming increment
42 } else if ((SkColorGetB(dst)+21)/42 > 0) { // 1-6
43 idx = 7 - (SkColorGetB(dst)+21)/42;
44 } else { // 7-9
45 idx = 10 - (SkColorGetG(dst)+22)/45;
46 }
47 ++idx;
48 SkASSERT(idx < (int)SK_ARRAY_COUNT(gTable));
49
50 return gTable[idx];
51 }
52
53 Factory getFactory() const override { return nullptr; }
54 #ifndef SK_IGNORE_TO_STRING
55 void toString(SkString* str) const override { str->set("OverdrawXfermode"); }
56 #endif
57 };
14 58
15 class DebugPaintFilterCanvas : public SkPaintFilterCanvas { 59 class DebugPaintFilterCanvas : public SkPaintFilterCanvas {
16 public: 60 public:
17 DebugPaintFilterCanvas(int width, 61 DebugPaintFilterCanvas(int width,
18 int height, 62 int height,
19 bool overdrawViz, 63 bool overdrawViz,
20 bool overrideFilterQuality, 64 bool overrideFilterQuality,
21 SkFilterQuality quality) 65 SkFilterQuality quality)
22 : INHERITED(width, height) 66 : INHERITED(width, height)
23 , fOverdrawXfermode(overdrawViz ? SkOverdrawMode::Create() : nullptr) 67 , fOverdrawXfermode(overdrawViz ? new OverdrawXfermode : nullptr)
24 , fOverrideFilterQuality(overrideFilterQuality) 68 , fOverrideFilterQuality(overrideFilterQuality)
25 , fFilterQuality(quality) {} 69 , fFilterQuality(quality) {}
26 70
27 protected: 71 protected:
28 bool onFilter(SkTCopyOnFirstWrite<SkPaint>* paint, Type) const override { 72 bool onFilter(SkTCopyOnFirstWrite<SkPaint>* paint, Type) const override {
29 if (*paint) { 73 if (*paint) {
30 if (nullptr != fOverdrawXfermode.get()) { 74 if (nullptr != fOverdrawXfermode.get()) {
31 paint->writable()->setAntiAlias(false); 75 paint->writable()->setAntiAlias(false);
32 paint->writable()->setXfermode(fOverdrawXfermode.get()); 76 paint->writable()->setXfermode(fOverdrawXfermode.get());
33 } 77 }
(...skipping 14 matching lines...) Expand all
48 92
49 private: 93 private:
50 SkAutoTUnref<SkXfermode> fOverdrawXfermode; 94 SkAutoTUnref<SkXfermode> fOverdrawXfermode;
51 95
52 bool fOverrideFilterQuality; 96 bool fOverrideFilterQuality;
53 SkFilterQuality fFilterQuality; 97 SkFilterQuality fFilterQuality;
54 98
55 typedef SkPaintFilterCanvas INHERITED; 99 typedef SkPaintFilterCanvas INHERITED;
56 }; 100 };
57 101
102 }
103
58 SkDebugCanvas::SkDebugCanvas(int width, int height) 104 SkDebugCanvas::SkDebugCanvas(int width, int height)
59 : INHERITED(width, height) 105 : INHERITED(width, height)
60 , fPicture(nullptr) 106 , fPicture(nullptr)
61 , fFilter(false) 107 , fFilter(false)
62 , fMegaVizMode(false) 108 , fMegaVizMode(false)
63 , fOverdrawViz(false) 109 , fOverdrawViz(false)
64 , fOverrideFilterQuality(false) 110 , fOverrideFilterQuality(false)
65 , fFilterQuality(kNone_SkFilterQuality) { 111 , fFilterQuality(kNone_SkFilterQuality) {
66 fUserMatrix.reset(); 112 fUserMatrix.reset();
67 113
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 } 661 }
616 662
617 bool SkDebugCanvas::lastClipStackData(const SkPath& devPath) { 663 bool SkDebugCanvas::lastClipStackData(const SkPath& devPath) {
618 if (fCalledAddStackData) { 664 if (fCalledAddStackData) {
619 fClipStackData.appendf("<br>"); 665 fClipStackData.appendf("<br>");
620 addPathData(devPath, "pathOut"); 666 addPathData(devPath, "pathOut");
621 return true; 667 return true;
622 } 668 }
623 return false; 669 return false;
624 } 670 }
OLDNEW
« no previous file with comments | « src/gpu/glsl/GrGLSLXferProcessor.cpp ('k') | src/utils/debugger/SkOverdrawMode.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698