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

Side by Side Diff: components/display_compositor/gl_helper_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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 #include <stdio.h> 7 #include <stdio.h>
8 #include <string.h> 8 #include <string.h>
9 #include <cmath> 9 #include <cmath>
10 #include <string> 10 #include <string>
(...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 // Step 2: Encode to grayscale if needed. 729 // Step 2: Encode to grayscale if needed.
730 if (out_color_type == kAlpha_8_SkColorType) { 730 if (out_color_type == kAlpha_8_SkColorType) {
731 truth_pixels.allocPixels(SkImageInfo::Make( 731 truth_pixels.allocPixels(SkImageInfo::Make(
732 scaled_xsize, scaled_ysize, out_color_type, kPremul_SkAlphaType)); 732 scaled_xsize, scaled_ysize, out_color_type, kPremul_SkAlphaType));
733 EncodeToGrayscaleSlow(&scaled_pixels, &truth_pixels); 733 EncodeToGrayscaleSlow(&scaled_pixels, &truth_pixels);
734 } else { 734 } else {
735 truth_pixels = scaled_pixels; 735 truth_pixels = scaled_pixels;
736 } 736 }
737 737
738 // Now compare the results. 738 // Now compare the results.
739 SkAutoLockPixels lock_input(truth_pixels);
740 const std::vector<GLHelperScaling::ScalerStage> dummy_stages; 739 const std::vector<GLHelperScaling::ScalerStage> dummy_stages;
741 Compare(&truth_pixels, &output_pixels, 2, input_pixels.get(), dummy_stages, 740 Compare(&truth_pixels, &output_pixels, 2, input_pixels.get(), dummy_stages,
742 message + " comparing against transformed/scaled"); 741 message + " comparing against transformed/scaled");
743 742
744 gl_->DeleteTextures(1, &src_texture); 743 gl_->DeleteTextures(1, &src_texture);
745 gl_->DeleteFramebuffers(1, &framebuffer); 744 gl_->DeleteFramebuffers(1, &framebuffer);
746 } 745 }
747 746
748 // Scaling test: Create a test image, scale it using GLHelperScaling 747 // Scaling test: Create a test image, scale it using GLHelperScaling
749 // and a reference implementation and compare the results. 748 // and a reference implementation and compare the results.
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
954 bool IsEqual(const SkBitmap& bmp1, const SkBitmap& bmp2) { 953 bool IsEqual(const SkBitmap& bmp1, const SkBitmap& bmp2) {
955 if (bmp1.isNull() && bmp2.isNull()) 954 if (bmp1.isNull() && bmp2.isNull())
956 return true; 955 return true;
957 if (bmp1.width() != bmp2.width() || bmp1.height() != bmp2.height()) { 956 if (bmp1.width() != bmp2.width() || bmp1.height() != bmp2.height()) {
958 LOG(ERROR) << "Bitmap geometry check failure"; 957 LOG(ERROR) << "Bitmap geometry check failure";
959 return false; 958 return false;
960 } 959 }
961 if (bmp1.colorType() != bmp2.colorType()) 960 if (bmp1.colorType() != bmp2.colorType())
962 return false; 961 return false;
963 962
964 SkAutoLockPixels lock1(bmp1);
965 SkAutoLockPixels lock2(bmp2);
966 if (!bmp1.getPixels() || !bmp2.getPixels()) { 963 if (!bmp1.getPixels() || !bmp2.getPixels()) {
967 LOG(ERROR) << "Empty Bitmap!"; 964 LOG(ERROR) << "Empty Bitmap!";
968 return false; 965 return false;
969 } 966 }
970 for (int y = 0; y < bmp1.height(); ++y) { 967 for (int y = 0; y < bmp1.height(); ++y) {
971 for (int x = 0; x < bmp1.width(); ++x) { 968 for (int x = 0; x < bmp1.width(); ++x) {
972 if (!ColorsClose(bmp1.getColor(x, y), bmp2.getColor(x, y), 969 if (!ColorsClose(bmp1.getColor(x, y), bmp2.getColor(x, y),
973 bmp1.colorType())) { 970 bmp1.colorType())) {
974 LOG(ERROR) << "Bitmap color comparision failure"; 971 LOG(ERROR) << "Bitmap color comparision failure";
975 return false; 972 return false;
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
1428 } 1425 }
1429 } 1426 }
1430 } 1427 }
1431 1428
1432 TEST_F(GLHelperTest, CheckOptimizations) { 1429 TEST_F(GLHelperTest, CheckOptimizations) {
1433 // Test in baseclass since it is friends with GLHelperScaling 1430 // Test in baseclass since it is friends with GLHelperScaling
1434 CheckOptimizationsTest(); 1431 CheckOptimizationsTest();
1435 } 1432 }
1436 1433
1437 } // namespace display_compositor 1434 } // namespace display_compositor
OLDNEW
« no previous file with comments | « chrome/renderer/chrome_render_frame_observer.cc ('k') | components/favicon_base/select_favicon_frames_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698