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

Side by Side Diff: ui/base/resource/resource_bundle_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, 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/base/resource/resource_bundle.cc ('k') | ui/base/x/x11_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "ui/base/resource/resource_bundle.h" 5 #include "ui/base/resource/resource_bundle.h"
6 6
7 #include "base/base_paths.h" 7 #include "base/base_paths.h"
8 #include "base/big_endian.h" 8 #include "base/big_endian.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 } 120 }
121 121
122 // Creates datapack at |path| with a single bitmap at resource ID 3 122 // Creates datapack at |path| with a single bitmap at resource ID 3
123 // which is |edge_size|x|edge_size| pixels. 123 // which is |edge_size|x|edge_size| pixels.
124 // If |custom_chunk| is non empty, adds it after the IHDR chunk 124 // If |custom_chunk| is non empty, adds it after the IHDR chunk
125 // in the encoded bitmap data. 125 // in the encoded bitmap data.
126 void CreateDataPackWithSingleBitmap(const base::FilePath& path, 126 void CreateDataPackWithSingleBitmap(const base::FilePath& path,
127 int edge_size, 127 int edge_size,
128 const base::StringPiece& custom_chunk) { 128 const base::StringPiece& custom_chunk) {
129 SkBitmap bitmap; 129 SkBitmap bitmap;
130 bitmap.setConfig(SkBitmap::kARGB_8888_Config, edge_size, edge_size); 130 bitmap.allocN32Pixels(edge_size, edge_size);
131 bitmap.allocPixels();
132 bitmap.eraseColor(SK_ColorWHITE); 131 bitmap.eraseColor(SK_ColorWHITE);
133 std::vector<unsigned char> bitmap_data; 132 std::vector<unsigned char> bitmap_data;
134 EXPECT_TRUE(gfx::PNGCodec::EncodeBGRASkBitmap(bitmap, false, &bitmap_data)); 133 EXPECT_TRUE(gfx::PNGCodec::EncodeBGRASkBitmap(bitmap, false, &bitmap_data));
135 134
136 if (custom_chunk.size() > 0) 135 if (custom_chunk.size() > 0)
137 AddCustomChunk(custom_chunk, &bitmap_data); 136 AddCustomChunk(custom_chunk, &bitmap_data);
138 137
139 std::map<uint16, base::StringPiece> resources; 138 std::map<uint16, base::StringPiece> resources;
140 resources[3u] = base::StringPiece( 139 resources[3u] = base::StringPiece(
141 reinterpret_cast<const char*>(&bitmap_data[0]), bitmap_data.size()); 140 reinterpret_cast<const char*>(&bitmap_data[0]), bitmap_data.size());
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 resource_bundle->AddDataPackFromPath(data_default_path, SCALE_FACTOR_NONE); 590 resource_bundle->AddDataPackFromPath(data_default_path, SCALE_FACTOR_NONE);
592 591
593 gfx::ImageSkia* image_skia = resource_bundle->GetImageSkiaNamed(3); 592 gfx::ImageSkia* image_skia = resource_bundle->GetImageSkiaNamed(3);
594 EXPECT_EQ(1u, image_skia->image_reps().size()); 593 EXPECT_EQ(1u, image_skia->image_reps().size());
595 EXPECT_TRUE(image_skia->image_reps()[0].unscaled()); 594 EXPECT_TRUE(image_skia->image_reps()[0].unscaled());
596 EXPECT_EQ(ui::SCALE_FACTOR_100P, 595 EXPECT_EQ(ui::SCALE_FACTOR_100P,
597 GetSupportedScaleFactor(image_skia->image_reps()[0].scale())); 596 GetSupportedScaleFactor(image_skia->image_reps()[0].scale()));
598 } 597 }
599 598
600 } // namespace ui 599 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/resource/resource_bundle.cc ('k') | ui/base/x/x11_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698