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

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

Issue 2855503003: Replace uses of legacy SkBitmap::copyTo() API (Closed)
Patch Set: Fix paren errors Created 3 years, 7 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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 } 121 }
122 lab->l = 116.0f * f[1] - 16.0f; 122 lab->l = 116.0f * f[1] - 16.0f;
123 lab->a = 500.0f * (f[0] - f[1]); 123 lab->a = 500.0f * (f[0] - f[1]);
124 lab->b = 200.0f * (f[1] - f[2]); 124 lab->b = 200.0f * (f[1] - f[2]);
125 } 125 }
126 126
127 /// Converts a 8888 bitmap to LAB color space and puts it into the output 127 /// Converts a 8888 bitmap to LAB color space and puts it into the output
128 static bool bitmap_to_cielab(const SkBitmap* bitmap, ImageLAB* outImageLAB) { 128 static bool bitmap_to_cielab(const SkBitmap* bitmap, ImageLAB* outImageLAB) {
129 SkBitmap bm8888; 129 SkBitmap bm8888;
130 if (bitmap->colorType() != kN32_SkColorType) { 130 if (bitmap->colorType() != kN32_SkColorType) {
131 if (!bitmap->copyTo(&bm8888, kN32_SkColorType)) { 131 SkImageInfo info8888 = bitmap.info().makeColorType(kN32_SkColorType);
132 if (!bm8888.tryAllocPixels(info8888) ||
133 !bitmap->readPixels(info8888, bm8888.getPixels(), bm8888.rowBytes(), 0,
134 0)) {
132 return false; 135 return false;
133 } 136 }
134 bitmap = &bm8888; 137 bitmap = &bm8888;
135 } 138 }
136 139
137 int width = bitmap->width(); 140 int width = bitmap->width();
138 int height = bitmap->height(); 141 int height = bitmap->height();
139 DCHECK(outImageLAB->width == width); 142 DCHECK(outImageLAB->width == width);
140 DCHECK(outImageLAB->height == height); 143 DCHECK(outImageLAB->height == height);
141 144
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 if (!bitmap_to_cielab(baseline, &baselineLAB) || 472 if (!bitmap_to_cielab(baseline, &baselineLAB) ||
470 !bitmap_to_cielab(test, &testLAB)) { 473 !bitmap_to_cielab(test, &testLAB)) {
471 return true; 474 return true;
472 } 475 }
473 476
474 result->poiCount = 0; 477 result->poiCount = 0;
475 result->result = pmetric(&baselineLAB, &testLAB, &result->poiCount); 478 result->result = pmetric(&baselineLAB, &testLAB, &result->poiCount);
476 479
477 return true; 480 return true;
478 } 481 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698