| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "SkRecordOpts.h" | 8 #include "SkRecordOpts.h" |
| 9 | 9 |
| 10 #include "SkRecordPattern.h" | 10 #include "SkRecordPattern.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 // Run until they stop changing things. | 83 // Run until they stop changing things. |
| 84 while (apply(&onlyDraws, record) || apply(&noDraws, record)); | 84 while (apply(&onlyDraws, record) || apply(&noDraws, record)); |
| 85 } | 85 } |
| 86 | 86 |
| 87 // For some SaveLayer-[drawing command]-Restore patterns, merge the SaveLayer's
alpha into the | 87 // For some SaveLayer-[drawing command]-Restore patterns, merge the SaveLayer's
alpha into the |
| 88 // draw, and no-op the SaveLayer and Restore. | 88 // draw, and no-op the SaveLayer and Restore. |
| 89 struct SaveLayerDrawRestoreNooper { | 89 struct SaveLayerDrawRestoreNooper { |
| 90 typedef Pattern3<Is<SaveLayer>, IsDraw, Is<Restore> > Pattern; | 90 typedef Pattern3<Is<SaveLayer>, IsDraw, Is<Restore> > Pattern; |
| 91 | 91 |
| 92 bool onMatch(SkRecord* record, Pattern* pattern, unsigned begin, unsigned en
d) { | 92 bool onMatch(SkRecord* record, Pattern* pattern, unsigned begin, unsigned en
d) { |
| 93 SaveLayer* saveLayer = pattern->first<SaveLayer>(); | 93 // A SaveLayer's bounds field is just a hint, so we should be free to ig
nore it. |
| 94 if (saveLayer->bounds != NULL) { | 94 SkPaint* layerPaint = pattern->first<SaveLayer>()->paint; |
| 95 // SaveLayer with bounds is too tricky for us. | |
| 96 return false; | |
| 97 } | |
| 98 | |
| 99 SkPaint* layerPaint = saveLayer->paint; | |
| 100 if (NULL == layerPaint) { | 95 if (NULL == layerPaint) { |
| 101 // There wasn't really any point to this SaveLayer at all. | 96 // There wasn't really any point to this SaveLayer at all. |
| 102 return KillSaveLayerAndRestore(record, begin); | 97 return KillSaveLayerAndRestore(record, begin); |
| 103 } | 98 } |
| 104 | 99 |
| 105 SkPaint* drawPaint = pattern->second<SkPaint>(); | 100 SkPaint* drawPaint = pattern->second<SkPaint>(); |
| 106 if (drawPaint == NULL) { | 101 if (drawPaint == NULL) { |
| 107 // We can just give the draw the SaveLayer's paint. | 102 // We can just give the draw the SaveLayer's paint. |
| 108 // TODO(mtklein): figure out how to do this clearly | 103 // TODO(mtklein): figure out how to do this clearly |
| 109 return false; | 104 return false; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 } | 150 } |
| 156 static bool IsOnlyAlpha(SkColor color) { | 151 static bool IsOnlyAlpha(SkColor color) { |
| 157 return SK_ColorTRANSPARENT == SkColorSetA(color, SK_AlphaTRANSPARENT); | 152 return SK_ColorTRANSPARENT == SkColorSetA(color, SK_AlphaTRANSPARENT); |
| 158 } | 153 } |
| 159 }; | 154 }; |
| 160 void SkRecordNoopSaveLayerDrawRestores(SkRecord* record) { | 155 void SkRecordNoopSaveLayerDrawRestores(SkRecord* record) { |
| 161 SaveLayerDrawRestoreNooper pass; | 156 SaveLayerDrawRestoreNooper pass; |
| 162 apply(&pass, record); | 157 apply(&pass, record); |
| 163 } | 158 } |
| 164 | 159 |
| OLD | NEW |