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

Side by Side Diff: tests/SurfaceTest.cpp

Issue 536003002: Hide fields in SkImageInfo (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix qt Created 6 years, 3 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 | « tests/SerializationTest.cpp ('k') | tools/LazyDecodeBitmap.cpp » ('j') | 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 "SkCanvas.h" 8 #include "SkCanvas.h"
9 #include "SkData.h" 9 #include "SkData.h"
10 #include "SkImageEncoder.h" 10 #include "SkImageEncoder.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 image->unref(); 83 image->unref();
84 REPORTER_ASSERT(reporter, 1 == data->getRefCnt()); 84 REPORTER_ASSERT(reporter, 1 == data->getRefCnt());
85 data->unref(); 85 data->unref();
86 } 86 }
87 87
88 static SkImage* createImage(ImageType imageType, GrContext* context, 88 static SkImage* createImage(ImageType imageType, GrContext* context,
89 SkColor color) { 89 SkColor color) {
90 const SkPMColor pmcolor = SkPreMultiplyColor(color); 90 const SkPMColor pmcolor = SkPreMultiplyColor(color);
91 const SkImageInfo info = SkImageInfo::MakeN32Premul(10, 10); 91 const SkImageInfo info = SkImageInfo::MakeN32Premul(10, 10);
92 const size_t rowBytes = info.minRowBytes(); 92 const size_t rowBytes = info.minRowBytes();
93 const size_t size = rowBytes * info.fHeight; 93 const size_t size = rowBytes * info.height();
94 94
95 void* addr = sk_malloc_throw(size); 95 void* addr = sk_malloc_throw(size);
96 sk_memset32((SkPMColor*)addr, pmcolor, SkToInt(size >> 2)); 96 sk_memset32((SkPMColor*)addr, pmcolor, SkToInt(size >> 2));
97 SkAutoTUnref<SkData> data(SkData::NewFromMalloc(addr, size)); 97 SkAutoTUnref<SkData> data(SkData::NewFromMalloc(addr, size));
98 98
99 switch (imageType) { 99 switch (imageType) {
100 case kRasterCopy_ImageType: 100 case kRasterCopy_ImageType:
101 return SkImage::NewRasterCopy(info, addr, rowBytes); 101 return SkImage::NewRasterCopy(info, addr, rowBytes);
102 case kRasterData_ImageType: 102 case kRasterData_ImageType:
103 return SkImage::NewRasterData(info, data, rowBytes); 103 return SkImage::NewRasterData(info, data, rowBytes);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 size_t rowBytes; 135 size_t rowBytes;
136 136
137 SkAutoTUnref<SkImage> image(createImage(gRec[i].fType, NULL, color)); 137 SkAutoTUnref<SkImage> image(createImage(gRec[i].fType, NULL, color));
138 if (!image.get()) { 138 if (!image.get()) {
139 continue; // gpu may not be enabled 139 continue; // gpu may not be enabled
140 } 140 }
141 const void* addr = image->peekPixels(&info, &rowBytes); 141 const void* addr = image->peekPixels(&info, &rowBytes);
142 bool success = (NULL != addr); 142 bool success = (NULL != addr);
143 REPORTER_ASSERT(reporter, gRec[i].fPeekShouldSucceed == success); 143 REPORTER_ASSERT(reporter, gRec[i].fPeekShouldSucceed == success);
144 if (success) { 144 if (success) {
145 REPORTER_ASSERT(reporter, 10 == info.fWidth); 145 REPORTER_ASSERT(reporter, 10 == info.width());
146 REPORTER_ASSERT(reporter, 10 == info.fHeight); 146 REPORTER_ASSERT(reporter, 10 == info.height());
147 REPORTER_ASSERT(reporter, kN32_SkColorType == info.fColorType); 147 REPORTER_ASSERT(reporter, kN32_SkColorType == info.colorType());
148 REPORTER_ASSERT(reporter, kPremul_SkAlphaType == info.fAlphaType || 148 REPORTER_ASSERT(reporter, kPremul_SkAlphaType == info.alphaType() ||
149 kOpaque_SkAlphaType == info.fAlphaType); 149 kOpaque_SkAlphaType == info.alphaType());
150 REPORTER_ASSERT(reporter, info.minRowBytes() <= rowBytes); 150 REPORTER_ASSERT(reporter, info.minRowBytes() <= rowBytes);
151 REPORTER_ASSERT(reporter, pmcolor == *(const SkPMColor*)addr); 151 REPORTER_ASSERT(reporter, pmcolor == *(const SkPMColor*)addr);
152 } 152 }
153 } 153 }
154 } 154 }
155 155
156 static void test_canvaspeek(skiatest::Reporter* reporter, 156 static void test_canvaspeek(skiatest::Reporter* reporter,
157 GrContextFactory* factory) { 157 GrContextFactory* factory) {
158 static const struct { 158 static const struct {
159 SurfaceType fType; 159 SurfaceType fType;
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 TestSurfaceNoCanvas(reporter, kGpuScratch_SurfaceType, context, SkSurface::kDiscard_ContentChangeMode); 464 TestSurfaceNoCanvas(reporter, kGpuScratch_SurfaceType, context, SkSurface::kDiscard_ContentChangeMode);
465 TestSurfaceNoCanvas(reporter, kGpu_SurfaceType, context, SkSurfa ce::kRetain_ContentChangeMode); 465 TestSurfaceNoCanvas(reporter, kGpu_SurfaceType, context, SkSurfa ce::kRetain_ContentChangeMode);
466 TestSurfaceNoCanvas(reporter, kGpuScratch_SurfaceType, context, SkSurface::kRetain_ContentChangeMode); 466 TestSurfaceNoCanvas(reporter, kGpuScratch_SurfaceType, context, SkSurface::kRetain_ContentChangeMode);
467 TestGetTexture(reporter, kGpu_SurfaceType, context); 467 TestGetTexture(reporter, kGpu_SurfaceType, context);
468 TestGetTexture(reporter, kGpuScratch_SurfaceType, context); 468 TestGetTexture(reporter, kGpuScratch_SurfaceType, context);
469 } 469 }
470 } 470 }
471 } 471 }
472 #endif 472 #endif
473 } 473 }
OLDNEW
« no previous file with comments | « tests/SerializationTest.cpp ('k') | tools/LazyDecodeBitmap.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698