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

Unified Diff: experimental/skpdiff/SkDifferentPixelsMetric_cpu.cpp

Issue 19608005: move skpdiff into tools (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: experimental/skpdiff/SkDifferentPixelsMetric_cpu.cpp
diff --git a/experimental/skpdiff/SkDifferentPixelsMetric_cpu.cpp b/experimental/skpdiff/SkDifferentPixelsMetric_cpu.cpp
deleted file mode 100644
index 4e5e93969c3f743ecc6024bbba9576a06a3791ef..0000000000000000000000000000000000000000
--- a/experimental/skpdiff/SkDifferentPixelsMetric_cpu.cpp
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright 2013 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <cstring>
-
-#include "SkBitmap.h"
-
-#include "SkDifferentPixelsMetric.h"
-#include "skpdiff_util.h"
-
-struct SkDifferentPixelsMetric::QueuedDiff {
- bool finished;
- double result;
- SkTDArray<SkIPoint>* poi;
-};
-
-const char* SkDifferentPixelsMetric::getName() {
- return "different_pixels";
-}
-
-int SkDifferentPixelsMetric::queueDiff(SkBitmap* baseline, SkBitmap* test) {
- double startTime = get_seconds();
- int diffID = fQueuedDiffs.count();
- QueuedDiff* diff = fQueuedDiffs.push();
- SkTDArray<SkIPoint>* poi = diff->poi = new SkTDArray<SkIPoint>();
-
- // If we never end up running the kernel, include some safe defaults in the result.
- diff->finished = false;
- diff->result = -1;
-
- // Ensure the images are comparable
- if (baseline->width() != test->width() || baseline->height() != test->height() ||
- baseline->width() <= 0 || baseline->height() <= 0 ||
- baseline->config() != test->config()) {
- diff->finished = true;
- return diffID;
- }
-
- int width = baseline->width();
- int height = baseline->height();
- int differentPixelsCount = 0;
-
- // Prepare the pixels for comparison
- baseline->lockPixels();
- test->lockPixels();
- for (int y = 0; y < height; y++) {
- // Grab a row from each image for easy comparison
- unsigned char* baselineRow = (unsigned char*)baseline->getAddr(0, y);
- unsigned char* testRow = (unsigned char*)test->getAddr(0, y);
- for (int x = 0; x < width; x++) {
- // Compare one pixel at a time so each differing pixel can be noted
- if (std::memcmp(&baselineRow[x * 4], &testRow[x * 4], 4) != 0) {
- poi->push()->set(x, y);
- differentPixelsCount++;
- }
- }
- }
- test->unlockPixels();
- baseline->unlockPixels();
-
- // Calculates the percentage of identical pixels
- diff->result = 1.0 - ((double)differentPixelsCount / (width * height));
-
- SkDebugf("Time: %f\n", (get_seconds() - startTime));
-
- return diffID;
-}
-
-void SkDifferentPixelsMetric::deleteDiff(int id) {
- if (NULL != fQueuedDiffs[id].poi)
- {
- delete fQueuedDiffs[id].poi;
- fQueuedDiffs[id].poi = NULL;
- }
-}
-
-bool SkDifferentPixelsMetric::isFinished(int id) {
- return fQueuedDiffs[id].finished;
-}
-
-double SkDifferentPixelsMetric::getResult(int id) {
- return fQueuedDiffs[id].result;
-}
-
-int SkDifferentPixelsMetric::getPointsOfInterestCount(int id) {
- return fQueuedDiffs[id].poi->count();
-}
-
-SkIPoint* SkDifferentPixelsMetric::getPointsOfInterest(int id) {
- return fQueuedDiffs[id].poi->begin();
-}
« no previous file with comments | « experimental/skpdiff/SkDifferentPixelsMetric.h ('k') | experimental/skpdiff/SkDifferentPixelsMetric_opencl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698