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

Side by Side Diff: tools/skpdiff/SkDifferentPixelsMetric_cpu.cpp

Issue 340533002: hide SkBitmap::Config entirely (behind a flag) (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 6 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 | « third_party/ktx/ktx.cpp ('k') | no next file » | 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 2013 Google Inc. 2 * Copyright 2013 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 "SkDifferentPixelsMetric.h" 8 #include "SkDifferentPixelsMetric.h"
9 9
10 #include "SkBitmap.h" 10 #include "SkBitmap.h"
11 #include "skpdiff_util.h" 11 #include "skpdiff_util.h"
12 12
13 const char* SkDifferentPixelsMetric::getName() const { 13 const char* SkDifferentPixelsMetric::getName() const {
14 return "different_pixels"; 14 return "different_pixels";
15 } 15 }
16 16
17 bool SkDifferentPixelsMetric::diff(SkBitmap* baseline, SkBitmap* test, bool comp uteMask, 17 bool SkDifferentPixelsMetric::diff(SkBitmap* baseline, SkBitmap* test, bool comp uteMask,
18 Result* result) const { 18 Result* result) const {
19 double startTime = get_seconds(); 19 double startTime = get_seconds();
20 20
21 // Ensure the images are comparable 21 // Ensure the images are comparable
22 if (baseline->width() != test->width() || baseline->height() != test->height () || 22 if (baseline->width() != test->width() || baseline->height() != test->height () ||
23 baseline->width() <= 0 || baseline->height() <= 0 || 23 baseline->width() <= 0 || baseline->height() <= 0 ||
24 baseline->config() != test->config()) { 24 baseline->colorType() != test->colorType()) {
25 return false; 25 return false;
26 } 26 }
27 27
28 int width = baseline->width(); 28 int width = baseline->width();
29 int height = baseline->height(); 29 int height = baseline->height();
30 30
31 // Prepare the POI alpha mask if needed 31 // Prepare the POI alpha mask if needed
32 if (computeMask) { 32 if (computeMask) {
33 result->poiAlphaMask.allocPixels(SkImageInfo::MakeA8(width, height)); 33 result->poiAlphaMask.allocPixels(SkImageInfo::MakeA8(width, height));
34 result->poiAlphaMask.eraseARGB(SK_AlphaOPAQUE, 0, 0, 0); 34 result->poiAlphaMask.eraseARGB(SK_AlphaOPAQUE, 0, 0, 0);
(...skipping 23 matching lines...) Expand all
58 if (computeMask) { 58 if (computeMask) {
59 result->poiAlphaMask.unlockPixels(); 59 result->poiAlphaMask.unlockPixels();
60 } 60 }
61 61
62 // Calculates the percentage of identical pixels 62 // Calculates the percentage of identical pixels
63 result->result = 1.0 - ((double)result->poiCount / (width * height)); 63 result->result = 1.0 - ((double)result->poiCount / (width * height));
64 result->timeElapsed = get_seconds() - startTime; 64 result->timeElapsed = get_seconds() - startTime;
65 65
66 return true; 66 return true;
67 } 67 }
OLDNEW
« no previous file with comments | « third_party/ktx/ktx.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698