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

Side by Side Diff: ui/compositor/layer_unittest.cc

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
« no previous file with comments | « ui/base/x/x11_util.cc ('k') | ui/gfx/android/java_bitmap.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/compositor/layer.h" 5 #include "ui/compositor/layer.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
(...skipping 1165 matching lines...) Expand 10 before | Expand all | Expand 10 after
1176 SK_ColorBLUE, gfx::Rect(0, 0, viewport_size.width(), blue_height))); 1176 SK_ColorBLUE, gfx::Rect(0, 0, viewport_size.width(), blue_height)));
1177 1177
1178 layer->Add(layer2.get()); 1178 layer->Add(layer2.get());
1179 1179
1180 DrawTree(layer.get()); 1180 DrawTree(layer.get());
1181 1181
1182 SkBitmap bitmap; 1182 SkBitmap bitmap;
1183 ReadPixels(&bitmap, gfx::Rect(viewport_size)); 1183 ReadPixels(&bitmap, gfx::Rect(viewport_size));
1184 ASSERT_FALSE(bitmap.empty()); 1184 ASSERT_FALSE(bitmap.empty());
1185 1185
1186 SkAutoLockPixels lock(bitmap);
1187 for (int x = 0; x < viewport_size.width(); x++) { 1186 for (int x = 0; x < viewport_size.width(); x++) {
1188 for (int y = 0; y < viewport_size.height(); y++) { 1187 for (int y = 0; y < viewport_size.height(); y++) {
1189 SkColor actual_color = bitmap.getColor(x, y); 1188 SkColor actual_color = bitmap.getColor(x, y);
1190 SkColor expected_color = y < blue_height ? SK_ColorBLUE : SK_ColorRED; 1189 SkColor expected_color = y < blue_height ? SK_ColorBLUE : SK_ColorRED;
1191 ExpectRgba(x, y, expected_color, actual_color); 1190 ExpectRgba(x, y, expected_color, actual_color);
1192 } 1191 }
1193 } 1192 }
1194 } 1193 }
1195 1194
1196 // Checks that drawing a layer with transparent pixels is blended correctly 1195 // Checks that drawing a layer with transparent pixels is blended correctly
(...skipping 17 matching lines...) Expand all
1214 // This must be set to false for layers with alpha to be blended correctly. 1213 // This must be set to false for layers with alpha to be blended correctly.
1215 foreground_layer->SetFillsBoundsOpaquely(false); 1214 foreground_layer->SetFillsBoundsOpaquely(false);
1216 1215
1217 background_layer->Add(foreground_layer.get()); 1216 background_layer->Add(foreground_layer.get());
1218 DrawTree(background_layer.get()); 1217 DrawTree(background_layer.get());
1219 1218
1220 SkBitmap bitmap; 1219 SkBitmap bitmap;
1221 ReadPixels(&bitmap, gfx::Rect(viewport_size)); 1220 ReadPixels(&bitmap, gfx::Rect(viewport_size));
1222 ASSERT_FALSE(bitmap.empty()); 1221 ASSERT_FALSE(bitmap.empty());
1223 1222
1224 SkAutoLockPixels lock(bitmap);
1225 for (int x = 0; x < test_size; x++) { 1223 for (int x = 0; x < test_size; x++) {
1226 for (int y = 0; y < test_size; y++) { 1224 for (int y = 0; y < test_size; y++) {
1227 SkColor actual_color = bitmap.getColor(x, y); 1225 SkColor actual_color = bitmap.getColor(x, y);
1228 ExpectRgba(x, y, blend_color, actual_color); 1226 ExpectRgba(x, y, blend_color, actual_color);
1229 } 1227 }
1230 } 1228 }
1231 } 1229 }
1232 1230
1233 // Checks that using the AlphaShape filter applied to a layer with 1231 // Checks that using the AlphaShape filter applied to a layer with
1234 // transparency, alpha-blends properly with the layer below. 1232 // transparency, alpha-blends properly with the layer below.
(...skipping 20 matching lines...) Expand all
1255 1253
1256 foreground_layer->SetFillsBoundsOpaquely(false); 1254 foreground_layer->SetFillsBoundsOpaquely(false);
1257 1255
1258 background_layer->Add(foreground_layer.get()); 1256 background_layer->Add(foreground_layer.get());
1259 DrawTree(background_layer.get()); 1257 DrawTree(background_layer.get());
1260 1258
1261 SkBitmap bitmap; 1259 SkBitmap bitmap;
1262 ReadPixels(&bitmap, gfx::Rect(viewport_size)); 1260 ReadPixels(&bitmap, gfx::Rect(viewport_size));
1263 ASSERT_FALSE(bitmap.empty()); 1261 ASSERT_FALSE(bitmap.empty());
1264 1262
1265 SkAutoLockPixels lock(bitmap);
1266 for (int x = 0; x < test_size; x++) { 1263 for (int x = 0; x < test_size; x++) {
1267 for (int y = 0; y < test_size; y++) { 1264 for (int y = 0; y < test_size; y++) {
1268 SkColor actual_color = bitmap.getColor(x, y); 1265 SkColor actual_color = bitmap.getColor(x, y);
1269 ExpectRgba(x, y, actual_color, 1266 ExpectRgba(x, y, actual_color,
1270 y < blue_height ? blend_color : SK_ColorRED); 1267 y < blue_height ? blend_color : SK_ColorRED);
1271 } 1268 }
1272 } 1269 }
1273 } 1270 }
1274 1271
1275 // Checks the logic around Compositor::SetRootLayer and Layer::SetCompositor. 1272 // Checks the logic around Compositor::SetRootLayer and Layer::SetCompositor.
(...skipping 962 matching lines...) Expand 10 before | Expand all | Expand 10 after
2238 layer.set_name("foo"); 2235 layer.set_name("foo");
2239 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> debug_info = 2236 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> debug_info =
2240 layer.TakeDebugInfo(nullptr); 2237 layer.TakeDebugInfo(nullptr);
2241 std::string trace_format("bar,"); 2238 std::string trace_format("bar,");
2242 debug_info->AppendAsTraceFormat(&trace_format); 2239 debug_info->AppendAsTraceFormat(&trace_format);
2243 std::string expected("bar,{\"layer_name\":\"foo\"}"); 2240 std::string expected("bar,{\"layer_name\":\"foo\"}");
2244 EXPECT_EQ(expected, trace_format); 2241 EXPECT_EQ(expected, trace_format);
2245 } 2242 }
2246 2243
2247 } // namespace ui 2244 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/x/x11_util.cc ('k') | ui/gfx/android/java_bitmap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698