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

Side by Side Diff: chrome/browser/chromeos/login/screenshot_testing/SkDiffPixelsMetric_cpu.cpp

Issue 2823003002: SkBitmap and SkPixelRef no longer need lock/unlock (Closed)
Patch Set: win fix after rebase Created 3 years, 8 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
OLDNEW
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> 10 #include <stdint.h>
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 result->rgbDiffBitmap.eraseARGB(SK_AlphaTRANSPARENT, 0, 0, 0); 46 result->rgbDiffBitmap.eraseARGB(SK_AlphaTRANSPARENT, 0, 0, 0);
47 } 47 }
48 if (bitmapsToCreate.whiteDiff) { 48 if (bitmapsToCreate.whiteDiff) {
49 result->whiteDiffBitmap.allocPixels( 49 result->whiteDiffBitmap.allocPixels(
50 SkImageInfo::MakeN32Premul(width, height)); 50 SkImageInfo::MakeN32Premul(width, height));
51 result->whiteDiffBitmap.eraseARGB(SK_AlphaOPAQUE, 0, 0, 0); 51 result->whiteDiffBitmap.eraseARGB(SK_AlphaOPAQUE, 0, 0, 0);
52 } 52 }
53 53
54 // Prepare the pixels for comparison 54 // Prepare the pixels for comparison
55 result->poiCount = 0; 55 result->poiCount = 0;
56 baseline->lockPixels();
57 test->lockPixels();
58 for (int y = 0; y < height; y++) { 56 for (int y = 0; y < height; y++) {
59 // Grab a row from each image for easy comparison 57 // Grab a row from each image for easy comparison
60 // TODO(epoger): The code below already assumes 4 bytes per pixel, so I 58 // TODO(epoger): The code below already assumes 4 bytes per pixel, so I
61 // think 59 // think
62 // we could just call getAddr32() to save a little time. 60 // we could just call getAddr32() to save a little time.
63 // OR, if we want to play it safe, call ComputeBytesPerPixel instead 61 // OR, if we want to play it safe, call ComputeBytesPerPixel instead
64 // of assuming 4 bytes per pixel. 62 // of assuming 4 bytes per pixel.
65 uint32_t* baselineRow = static_cast<uint32_t*>(baseline->getAddr(0, y)); 63 uint32_t* baselineRow = static_cast<uint32_t*>(baseline->getAddr(0, y));
66 uint32_t* testRow = static_cast<uint32_t*>(test->getAddr(0, y)); 64 uint32_t* testRow = static_cast<uint32_t*>(test->getAddr(0, y));
67 for (int x = 0; x < width; x++) { 65 for (int x = 0; x < width; x++) {
(...skipping 27 matching lines...) Expand all
95 if (bitmapsToCreate.rgbDiff) { 93 if (bitmapsToCreate.rgbDiff) {
96 *result->rgbDiffBitmap.getAddr32(x, y) = 94 *result->rgbDiffBitmap.getAddr32(x, y) =
97 SkColorSetRGB(redDiff, greenDiff, blueDiff); 95 SkColorSetRGB(redDiff, greenDiff, blueDiff);
98 } 96 }
99 if (bitmapsToCreate.whiteDiff) { 97 if (bitmapsToCreate.whiteDiff) {
100 *result->whiteDiffBitmap.getAddr32(x, y) = SK_ColorWHITE; 98 *result->whiteDiffBitmap.getAddr32(x, y) = SK_ColorWHITE;
101 } 99 }
102 } 100 }
103 } 101 }
104 } 102 }
105 test->unlockPixels();
106 baseline->unlockPixels();
107 103
108 result->maxRedDiff = maxRedDiff; 104 result->maxRedDiff = maxRedDiff;
109 result->maxGreenDiff = maxGreenDiff; 105 result->maxGreenDiff = maxGreenDiff;
110 result->maxBlueDiff = maxBlueDiff; 106 result->maxBlueDiff = maxBlueDiff;
111 107
112 if (bitmapsToCreate.alphaMask) {
113 result->poiAlphaMask.unlockPixels();
114 }
115 if (bitmapsToCreate.rgbDiff) {
116 result->rgbDiffBitmap.unlockPixels();
117 }
118 if (bitmapsToCreate.whiteDiff) {
119 result->whiteDiffBitmap.unlockPixels();
120 }
121
122 // Calculates the percentage of identical pixels 108 // Calculates the percentage of identical pixels
123 result->result = 1.0 - ((double)result->poiCount / (width * height)); 109 result->result = 1.0 - ((double)result->poiCount / (width * height));
124 110
125 return true; 111 return true;
126 } 112 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698