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

Side by Side Diff: chrome/browser/chromeos/login/screenshot_testing/SkPMetric.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 <cmath> 10 #include <cmath>
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 return false; 132 return false;
133 } 133 }
134 bitmap = &bm8888; 134 bitmap = &bm8888;
135 } 135 }
136 136
137 int width = bitmap->width(); 137 int width = bitmap->width();
138 int height = bitmap->height(); 138 int height = bitmap->height();
139 DCHECK(outImageLAB->width == width); 139 DCHECK(outImageLAB->width == width);
140 DCHECK(outImageLAB->height == height); 140 DCHECK(outImageLAB->height == height);
141 141
142 bitmap->lockPixels();
143 RGB rgb; 142 RGB rgb;
144 LAB lab; 143 LAB lab;
145 for (int y = 0; y < height; y++) { 144 for (int y = 0; y < height; y++) {
146 unsigned char* row = (unsigned char*)bitmap->getAddr(0, y); 145 unsigned char* row = (unsigned char*)bitmap->getAddr(0, y);
147 for (int x = 0; x < width; x++) { 146 for (int x = 0; x < width; x++) {
148 // Perform gamma correction which is assumed to be 2.2 147 // Perform gamma correction which is assumed to be 2.2
149 rgb.r = SkPMetricUtil::get_gamma(row[x * 4 + 2]); 148 rgb.r = SkPMetricUtil::get_gamma(row[x * 4 + 2]);
150 rgb.g = SkPMetricUtil::get_gamma(row[x * 4 + 1]); 149 rgb.g = SkPMetricUtil::get_gamma(row[x * 4 + 1]);
151 rgb.b = SkPMetricUtil::get_gamma(row[x * 4 + 0]); 150 rgb.b = SkPMetricUtil::get_gamma(row[x * 4 + 0]);
152 adobergb_to_cielab(rgb.r, rgb.g, rgb.b, &lab); 151 adobergb_to_cielab(rgb.r, rgb.g, rgb.b, &lab);
153 outImageLAB->writePixel(x, y, lab); 152 outImageLAB->writePixel(x, y, lab);
154 } 153 }
155 } 154 }
156 bitmap->unlockPixels();
157 return true; 155 return true;
158 } 156 }
159 157
160 // From Barten SPIE 1989 158 // From Barten SPIE 1989
161 static float contrast_sensitivity(float cyclesPerDegree, float luminance) { 159 static float contrast_sensitivity(float cyclesPerDegree, float luminance) {
162 float a = 440.0f * powf(1.0f + 0.7f / luminance, -0.2f); 160 float a = 440.0f * powf(1.0f + 0.7f / luminance, -0.2f);
163 float b = 0.3f * powf(1.0f + 100.0f / luminance, 0.15f); 161 float b = 0.3f * powf(1.0f + 100.0f / luminance, 0.15f);
164 float exp = expf(-b * cyclesPerDegree); 162 float exp = expf(-b * cyclesPerDegree);
165 float root = sqrtf(1.0f + 0.06f * expf(b * cyclesPerDegree)); 163 float root = sqrtf(1.0f + 0.06f * expf(b * cyclesPerDegree));
166 if (!SkScalarIsFinite(exp) || !SkScalarIsFinite(root)) { 164 if (!SkScalarIsFinite(exp) || !SkScalarIsFinite(root)) {
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 if (!bitmap_to_cielab(baseline, &baselineLAB) || 469 if (!bitmap_to_cielab(baseline, &baselineLAB) ||
472 !bitmap_to_cielab(test, &testLAB)) { 470 !bitmap_to_cielab(test, &testLAB)) {
473 return true; 471 return true;
474 } 472 }
475 473
476 result->poiCount = 0; 474 result->poiCount = 0;
477 result->result = pmetric(&baselineLAB, &testLAB, &result->poiCount); 475 result->result = pmetric(&baselineLAB, &testLAB, &result->poiCount);
478 476
479 return true; 477 return true;
480 } 478 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698