| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 | 9 |
| 10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 fCommandVector[i]->execute(&canvas); | 85 fCommandVector[i]->execute(&canvas); |
| 86 } | 86 } |
| 87 if (prev != bitmap.getColor(0,0)) { | 87 if (prev != bitmap.getColor(0,0)) { |
| 88 layer = i; | 88 layer = i; |
| 89 } | 89 } |
| 90 prev = bitmap.getColor(0,0); | 90 prev = bitmap.getColor(0,0); |
| 91 } | 91 } |
| 92 return layer; | 92 return layer; |
| 93 } | 93 } |
| 94 | 94 |
| 95 static SkPMColor OverdrawXferModeProc(SkPMColor src, SkPMColor dst) { | 95 class OverdrawXfermode : public SkXfermode { |
| 96 // This table encodes the color progression of the overdraw visualization | 96 public: |
| 97 static const SkPMColor gTable[] = { | 97 virtual SkPMColor xferColor(SkPMColor src, SkPMColor dst) const SK_OVERRIDE
{ |
| 98 SkPackARGB32(0x00, 0x00, 0x00, 0x00), | 98 // This table encodes the color progression of the overdraw visualizatio
n |
| 99 SkPackARGB32(0xFF, 128, 158, 255), | 99 static const SkPMColor gTable[] = { |
| 100 SkPackARGB32(0xFF, 170, 185, 212), | 100 SkPackARGB32(0x00, 0x00, 0x00, 0x00), |
| 101 SkPackARGB32(0xFF, 213, 195, 170), | 101 SkPackARGB32(0xFF, 128, 158, 255), |
| 102 SkPackARGB32(0xFF, 255, 192, 127), | 102 SkPackARGB32(0xFF, 170, 185, 212), |
| 103 SkPackARGB32(0xFF, 255, 185, 85), | 103 SkPackARGB32(0xFF, 213, 195, 170), |
| 104 SkPackARGB32(0xFF, 255, 165, 42), | 104 SkPackARGB32(0xFF, 255, 192, 127), |
| 105 SkPackARGB32(0xFF, 255, 135, 0), | 105 SkPackARGB32(0xFF, 255, 185, 85), |
| 106 SkPackARGB32(0xFF, 255, 95, 0), | 106 SkPackARGB32(0xFF, 255, 165, 42), |
| 107 SkPackARGB32(0xFF, 255, 50, 0), | 107 SkPackARGB32(0xFF, 255, 135, 0), |
| 108 SkPackARGB32(0xFF, 255, 0, 0) | 108 SkPackARGB32(0xFF, 255, 95, 0), |
| 109 }; | 109 SkPackARGB32(0xFF, 255, 50, 0), |
| 110 | 110 SkPackARGB32(0xFF, 255, 0, 0) |
| 111 for (size_t i = 0; i < SK_ARRAY_COUNT(gTable)-1; ++i) { | 111 }; |
| 112 if (gTable[i] == dst) { | 112 |
| 113 return gTable[i+1]; | 113 for (size_t i = 0; i < SK_ARRAY_COUNT(gTable)-1; ++i) { |
| 114 if (gTable[i] == dst) { |
| 115 return gTable[i+1]; |
| 116 } |
| 114 } | 117 } |
| 118 |
| 119 return gTable[SK_ARRAY_COUNT(gTable)-1]; |
| 115 } | 120 } |
| 116 | 121 |
| 117 return gTable[SK_ARRAY_COUNT(gTable)-1]; | 122 virtual Factory getFactory() const SK_OVERRIDE { return NULL; } |
| 118 } | 123 #ifndef SK_IGNORE_TO_STRING |
| 124 virtual void toString(SkString* str) const { str->set("OverdrawXfermode"); } |
| 125 #endif |
| 126 }; |
| 119 | 127 |
| 120 // The OverdrawFilter modifies every paint to use an SkProcXfermode which | 128 // The OverdrawFilter modifies every paint to use an SkProcXfermode which |
| 121 // in turn invokes OverdrawXferModeProc | 129 // in turn invokes OverdrawXferModeProc |
| 122 class SkOverdrawFilter : public SkDrawFilter { | 130 class SkOverdrawFilter : public SkDrawFilter { |
| 123 public: | 131 public: |
| 124 SkOverdrawFilter() { | 132 SkOverdrawFilter() { |
| 125 fXferMode = SkProcXfermode::Create(OverdrawXferModeProc); | 133 fXferMode = SkNEW(OverdrawXfermode); |
| 126 } | 134 } |
| 127 | 135 |
| 128 virtual ~SkOverdrawFilter() { | 136 virtual ~SkOverdrawFilter() { |
| 129 delete fXferMode; | 137 delete fXferMode; |
| 130 } | 138 } |
| 131 | 139 |
| 132 virtual bool filter(SkPaint* p, Type) SK_OVERRIDE { | 140 virtual bool filter(SkPaint* p, Type) SK_OVERRIDE { |
| 133 p->setXfermode(fXferMode); | 141 p->setXfermode(fXferMode); |
| 134 return true; | 142 return true; |
| 135 } | 143 } |
| (...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 575 | 583 |
| 576 void SkDebugCanvas::didSetMatrix(const SkMatrix& matrix) { | 584 void SkDebugCanvas::didSetMatrix(const SkMatrix& matrix) { |
| 577 this->addDrawCommand(new SkSetMatrixCommand(matrix)); | 585 this->addDrawCommand(new SkSetMatrixCommand(matrix)); |
| 578 this->INHERITED::didSetMatrix(matrix); | 586 this->INHERITED::didSetMatrix(matrix); |
| 579 } | 587 } |
| 580 | 588 |
| 581 void SkDebugCanvas::toggleCommand(int index, bool toggle) { | 589 void SkDebugCanvas::toggleCommand(int index, bool toggle) { |
| 582 SkASSERT(index < fCommandVector.count()); | 590 SkASSERT(index < fCommandVector.count()); |
| 583 fCommandVector[index]->setVisible(toggle); | 591 fCommandVector[index]->setVisible(toggle); |
| 584 } | 592 } |
| OLD | NEW |