OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // WARNING! This file is copied from third_party/skia/tools/skpdiff and slightly | 5 // WARNING! This file is copied from third_party/skia/tools/skpdiff and slightly |
6 // modified to be compilable outside Skia and suit chromium style. Some comments | 6 // modified to be compilable outside Skia and suit chromium style. Some comments |
7 // can make no sense. | 7 // can make no sense. |
8 // TODO(elizavetai): remove this file and reuse the original one in Skia | 8 // TODO(elizavetai): remove this file and reuse the original one in Skia |
9 | 9 |
| 10 #include <stdint.h> |
| 11 |
10 #include "chrome/browser/chromeos/login/screenshot_testing/SkDiffPixelsMetric.h" | 12 #include "chrome/browser/chromeos/login/screenshot_testing/SkDiffPixelsMetric.h" |
11 #include "third_party/skia/include/core/SkBitmap.h" | 13 #include "third_party/skia/include/core/SkBitmap.h" |
12 | 14 |
13 bool SkDifferentPixelsMetric::diff( | 15 bool SkDifferentPixelsMetric::diff( |
14 SkBitmap* baseline, | 16 SkBitmap* baseline, |
15 SkBitmap* test, | 17 SkBitmap* test, |
16 const SkImageDiffer::BitmapsToCreate& bitmapsToCreate, | 18 const SkImageDiffer::BitmapsToCreate& bitmapsToCreate, |
17 SkImageDiffer::Result* result) { | 19 SkImageDiffer::Result* result) { |
18 // Ensure the images are comparable | 20 // Ensure the images are comparable |
19 if (baseline->width() != test->width() || | 21 if (baseline->width() != test->width() || |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 } | 117 } |
116 if (bitmapsToCreate.whiteDiff) { | 118 if (bitmapsToCreate.whiteDiff) { |
117 result->whiteDiffBitmap.unlockPixels(); | 119 result->whiteDiffBitmap.unlockPixels(); |
118 } | 120 } |
119 | 121 |
120 // Calculates the percentage of identical pixels | 122 // Calculates the percentage of identical pixels |
121 result->result = 1.0 - ((double)result->poiCount / (width * height)); | 123 result->result = 1.0 - ((double)result->poiCount / (width * height)); |
122 | 124 |
123 return true; | 125 return true; |
124 } | 126 } |
OLD | NEW |