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

Side by Side Diff: tests/SurfaceTest.cpp

Issue 1199473002: change old picture serialization to really handle images (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 6 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 /* 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 "SkDevice.h" 10 #include "SkDevice.h"
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 SkAutoTUnref<SkSurface> surf( 244 SkAutoTUnref<SkSurface> surf(
245 SkSurface::NewRenderTarget(context, SkSurface::kNo_Budgeted, inf o, 0)); 245 SkSurface::NewRenderTarget(context, SkSurface::kNo_Budgeted, inf o, 0));
246 surf->getCanvas()->clear(color); 246 surf->getCanvas()->clear(color);
247 return surf->newImageSnapshot(); 247 return surf->newImageSnapshot();
248 } 248 }
249 case kCodec_ImageType: { 249 case kCodec_ImageType: {
250 SkBitmap bitmap; 250 SkBitmap bitmap;
251 bitmap.installPixels(info, addr, rowBytes); 251 bitmap.installPixels(info, addr, rowBytes);
252 SkAutoTUnref<SkData> src( 252 SkAutoTUnref<SkData> src(
253 SkImageEncoder::EncodeData(bitmap, SkImageEncoder::kPNG_Type, 1 00)); 253 SkImageEncoder::EncodeData(bitmap, SkImageEncoder::kPNG_Type, 1 00));
254 return SkImage::NewFromData(src); 254 return SkImage::NewFromEncoded(src);
255 } 255 }
256 } 256 }
257 SkASSERT(false); 257 SkASSERT(false);
258 return NULL; 258 return NULL;
259 } 259 }
260 260
261 static void set_pixels(SkPMColor pixels[], int count, SkPMColor color) { 261 static void set_pixels(SkPMColor pixels[], int count, SkPMColor color) {
262 sk_memset32(pixels, color, count); 262 sk_memset32(pixels, color, count);
263 } 263 }
264 static bool has_pixels(const SkPMColor pixels[], int count, SkPMColor expected) { 264 static bool has_pixels(const SkPMColor pixels[], int count, SkPMColor expected) {
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after
860 // We expect the ref'd image to see the new color, but cpy'd one should stil l see the old color 860 // We expect the ref'd image to see the new color, but cpy'd one should stil l see the old color
861 test_image_color(reporter, refImg, expected1); 861 test_image_color(reporter, refImg, expected1);
862 test_image_color(reporter, cpyImg, expected0); 862 test_image_color(reporter, cpyImg, expected0);
863 863
864 // Now exercise the release proc 864 // Now exercise the release proc
865 REPORTER_ASSERT(reporter, !releaseCtx.fIsReleased); 865 REPORTER_ASSERT(reporter, !releaseCtx.fIsReleased);
866 refImg.reset(NULL); // force a release of the image 866 refImg.reset(NULL); // force a release of the image
867 REPORTER_ASSERT(reporter, releaseCtx.fIsReleased); 867 REPORTER_ASSERT(reporter, releaseCtx.fIsReleased);
868 } 868 }
869 #endif 869 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698