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

Unified Diff: ui/gfx/color_analysis_unittest.cc

Issue 361643002: setConfig is deprecated, use setInfo or allocPixels instead (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: don't call allocPixels+rowbytes yet (skia bug) 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/gfx/color_analysis.cc ('k') | ui/gfx/color_utils.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/color_analysis_unittest.cc
diff --git a/ui/gfx/color_analysis_unittest.cc b/ui/gfx/color_analysis_unittest.cc
index 8e6ec831c1ea2ad9a1e0c322efe87ff642a0c8d8..fe5b585d3f18c9056570437234201fb0fef01099 100644
--- a/ui/gfx/color_analysis_unittest.cc
+++ b/ui/gfx/color_analysis_unittest.cc
@@ -94,8 +94,7 @@ const HSL kDefaultUpperBound = {-1, -1, 0.85};
scoped_refptr<base::RefCountedMemory> CreateTestPNG(
const std::vector<SkColor>& colors) {
SkBitmap bitmap;
- bitmap.setConfig(SkBitmap::kARGB_8888_Config, colors.size(), 1);
- bitmap.allocPixels();
+ bitmap.allocN32Pixels(colors.size(), 1);
SkAutoLockPixels lock(bitmap);
for (size_t i = 0; i < colors.size(); ++i) {
@@ -279,8 +278,7 @@ TEST_F(ColorAnalysisTest, FindClosestColor) {
// Single color image returns that color.
SkBitmap bitmap;
- bitmap.setConfig(SkBitmap::kARGB_8888_Config, 16, 16);
- bitmap.allocPixels();
+ bitmap.allocN32Pixels(16, 16);
bitmap.eraseColor(SK_ColorWHITE);
color = FindClosestColor(static_cast<uint8_t*>(bitmap.getPixels()),
bitmap.width(),
@@ -302,8 +300,7 @@ TEST_F(ColorAnalysisTest, FindClosestColor) {
TEST_F(ColorAnalysisTest, CalculateKMeanColorOfBitmap) {
// Create a 16x16 bitmap to represent a favicon.
SkBitmap bitmap;
- bitmap.setConfig(SkBitmap::kARGB_8888_Config, 16, 16);
- bitmap.allocPixels();
+ bitmap.allocN32Pixels(16, 16);
bitmap.eraseARGB(255, 100, 150, 200);
SkColor color = CalculateKMeanColorOfBitmap(bitmap);
@@ -326,7 +323,7 @@ TEST_F(ColorAnalysisTest, CalculateKMeanColorOfBitmap) {
TEST_F(ColorAnalysisTest, ComputeColorCovarianceTrivial) {
SkBitmap bitmap;
- bitmap.setConfig(SkBitmap::kARGB_8888_Config, 100, 200);
+ bitmap.setInfo(SkImageInfo::MakeN32Premul(100, 200));
EXPECT_EQ(gfx::Matrix3F::Zeros(), ComputeColorCovariance(bitmap));
bitmap.allocPixels();
@@ -361,11 +358,9 @@ TEST_F(ColorAnalysisTest, ApplyColorReductionSingleColor) {
// The test runs color reduction on a single-colot image, where results are
// bound to be uninteresting. This is an important edge case, though.
SkBitmap source, result;
- source.setConfig(SkBitmap::kARGB_8888_Config, 300, 200);
- result.setConfig(SkBitmap::kA8_Config, 300, 200);
+ source.allocN32Pixels(300, 200);
+ result.allocPixels(SkImageInfo::MakeA8(300, 200));
- source.allocPixels();
- result.allocPixels();
source.eraseARGB(255, 50, 150, 200);
gfx::Vector3dF transform(1.0f, .5f, 0.1f);
@@ -410,8 +405,7 @@ TEST_F(ColorAnalysisTest, ApplyColorReductionBlackAndWhite) {
SkBitmap source =
skia::GetTopDevice(*canvas.sk_canvas())->accessBitmap(false);
SkBitmap result;
- result.setConfig(SkBitmap::kA8_Config, 300, 200);
- result.allocPixels();
+ result.allocPixels(SkImageInfo::MakeA8(300, 200));
gfx::Vector3dF transform(1.0f, 0.5f, 0.1f);
EXPECT_TRUE(ApplyColorReduction(source, transform, true, &result));
@@ -449,8 +443,7 @@ TEST_F(ColorAnalysisTest, ApplyColorReductionMultiColor) {
SkBitmap source =
skia::GetTopDevice(*canvas.sk_canvas())->accessBitmap(false);
SkBitmap result;
- result.setConfig(SkBitmap::kA8_Config, 300, 200);
- result.allocPixels();
+ result.allocPixels(SkImageInfo::MakeA8(300, 200));
gfx::Vector3dF transform(1.0f, 0.5f, 0.1f);
EXPECT_TRUE(ApplyColorReduction(source, transform, false, &result));
@@ -474,11 +467,9 @@ TEST_F(ColorAnalysisTest, ApplyColorReductionMultiColor) {
TEST_F(ColorAnalysisTest, ComputePrincipalComponentImageNotComputable) {
SkBitmap source, result;
- source.setConfig(SkBitmap::kARGB_8888_Config, 300, 200);
- result.setConfig(SkBitmap::kA8_Config, 300, 200);
+ source.allocN32Pixels(300, 200);
+ result.allocPixels(SkImageInfo::MakeA8(300, 200));
- source.allocPixels();
- result.allocPixels();
source.eraseARGB(255, 50, 150, 200);
// This computation should fail since all colors always vary together.
@@ -495,8 +486,7 @@ TEST_F(ColorAnalysisTest, ComputePrincipalComponentImage) {
SkBitmap source =
skia::GetTopDevice(*canvas.sk_canvas())->accessBitmap(false);
SkBitmap result;
- result.setConfig(SkBitmap::kA8_Config, 300, 200);
- result.allocPixels();
+ result.allocPixels(SkImageInfo::MakeA8(300, 200));
// This computation should fail since all colors always vary together.
EXPECT_TRUE(ComputePrincipalComponentImage(source, &result));
« no previous file with comments | « ui/gfx/color_analysis.cc ('k') | ui/gfx/color_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698