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

Side by Side Diff: tests/SurfaceTest.cpp

Issue 2066903003: Document SkSurface::MakeRaster's memory initialization (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: review Created 4 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
« no previous file with comments | « src/image/SkSurface_Raster.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include <functional> 8 #include <functional>
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkData.h" 10 #include "SkData.h"
(...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after
744 auto surf1(SkSurface::MakeRaster(info, 500, nullptr)); 744 auto surf1(SkSurface::MakeRaster(info, 500, nullptr));
745 check_rowbytes_remain_consistent(surf1.get(), reporter); 745 check_rowbytes_remain_consistent(surf1.get(), reporter);
746 746
747 // Try some illegal rowByte values 747 // Try some illegal rowByte values
748 auto s = SkSurface::MakeRaster(info, 396, nullptr); // needs to be at lea st 400 748 auto s = SkSurface::MakeRaster(info, 396, nullptr); // needs to be at lea st 400
749 REPORTER_ASSERT(reporter, nullptr == s); 749 REPORTER_ASSERT(reporter, nullptr == s);
750 s = SkSurface::MakeRaster(info, 1 << 30, nullptr); // allocation to large 750 s = SkSurface::MakeRaster(info, 1 << 30, nullptr); // allocation to large
751 REPORTER_ASSERT(reporter, nullptr == s); 751 REPORTER_ASSERT(reporter, nullptr == s);
752 } 752 }
753 753
754 DEF_TEST(surface_raster_zeroinitialized, reporter) {
755 sk_sp<SkSurface> s(SkSurface::MakeRasterN32Premul(100, 100));
756 SkPixmap pixmap;
757 REPORTER_ASSERT(reporter, s->peekPixels(&pixmap));
758
759 for (int i = 0; i < pixmap.info().width(); ++i) {
760 for (int j = 0; j < pixmap.info().height(); ++j) {
761 REPORTER_ASSERT(reporter, *pixmap.addr32(i, j) == 0);
762 }
763 }
764 }
765
754 #if SK_SUPPORT_GPU 766 #if SK_SUPPORT_GPU
755 static sk_sp<SkSurface> create_gpu_surface_backend_texture( 767 static sk_sp<SkSurface> create_gpu_surface_backend_texture(
756 GrContext* context, int sampleCnt, uint32_t color, GrBackendObject* outTextu re) { 768 GrContext* context, int sampleCnt, uint32_t color, GrBackendObject* outTextu re) {
757 const int kWidth = 10; 769 const int kWidth = 10;
758 const int kHeight = 10; 770 const int kHeight = 10;
759 SkAutoTDeleteArray<uint32_t> pixels(new uint32_t[kWidth * kHeight]); 771 SkAutoTDeleteArray<uint32_t> pixels(new uint32_t[kWidth * kHeight]);
760 sk_memset32(pixels.get(), color, kWidth * kHeight); 772 sk_memset32(pixels.get(), color, kWidth * kHeight);
761 GrBackendTextureDesc desc; 773 GrBackendTextureDesc desc;
762 desc.fConfig = kRGBA_8888_GrPixelConfig; 774 desc.fConfig = kRGBA_8888_GrPixelConfig;
763 desc.fWidth = kWidth; 775 desc.fWidth = kWidth;
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
958 // our surface functions. 970 // our surface functions.
959 GrRenderTarget* rt = surface->getCanvas()->internal_private_accessTo pLayerDrawContext() 971 GrRenderTarget* rt = surface->getCanvas()->internal_private_accessTo pLayerDrawContext()
960 ->accessRenderTarget(); 972 ->accessRenderTarget();
961 REPORTER_ASSERT(reporter, 973 REPORTER_ASSERT(reporter,
962 ctxInfo.grContext()->resourceProvider()->attachStenc ilAttachment(rt)); 974 ctxInfo.grContext()->resourceProvider()->attachStenc ilAttachment(rt));
963 gpu->deleteTestingOnlyBackendTexture(textureObject); 975 gpu->deleteTestingOnlyBackendTexture(textureObject);
964 } 976 }
965 } 977 }
966 } 978 }
967 #endif 979 #endif
OLDNEW
« no previous file with comments | « src/image/SkSurface_Raster.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698