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

Side by Side Diff: tests/ImageTest.cpp

Issue 1734043002: Revert of Move Budgeted enum out of SkSurface, use in GrTextureProvider (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 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/ImageNewShaderTest.cpp ('k') | tests/PremulAlphaRoundTripTest.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 2015 Google Inc. 2 * Copyright 2015 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 "DMGpuSupport.h" 9 #include "DMGpuSupport.h"
10 10
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 SkAutoTUnref<SkData> data(create_image_data(&info)); 117 SkAutoTUnref<SkData> data(create_image_data(&info));
118 SkBitmap bitmap; 118 SkBitmap bitmap;
119 bitmap.installPixels(info, data->writable_data(), info.minRowBytes()); 119 bitmap.installPixels(info, data->writable_data(), info.minRowBytes());
120 SkAutoTUnref<SkData> src( 120 SkAutoTUnref<SkData> src(
121 SkImageEncoder::EncodeData(bitmap, SkImageEncoder::kPNG_Type, 100)); 121 SkImageEncoder::EncodeData(bitmap, SkImageEncoder::kPNG_Type, 100));
122 return SkImage::NewFromEncoded(src); 122 return SkImage::NewFromEncoded(src);
123 } 123 }
124 #if SK_SUPPORT_GPU 124 #if SK_SUPPORT_GPU
125 static SkImage* create_gpu_image(GrContext* context) { 125 static SkImage* create_gpu_image(GrContext* context) {
126 const SkImageInfo info = SkImageInfo::MakeN32(20, 20, kOpaque_SkAlphaType); 126 const SkImageInfo info = SkImageInfo::MakeN32(20, 20, kOpaque_SkAlphaType);
127 SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget(context, SkBudget ed::kNo, 127 SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget(context, SkSurfac e::kNo_Budgeted,
128 info)); 128 info));
129 draw_image_test_pattern(surface->getCanvas()); 129 draw_image_test_pattern(surface->getCanvas());
130 return surface->newImageSnapshot(); 130 return surface->newImageSnapshot();
131 } 131 }
132 #endif 132 #endif
133 133
134 static void test_encode(skiatest::Reporter* reporter, SkImage* image) { 134 static void test_encode(skiatest::Reporter* reporter, SkImage* image) {
135 const SkIRect ir = SkIRect::MakeXYWH(5, 5, 10, 10); 135 const SkIRect ir = SkIRect::MakeXYWH(5, 5, 10, 10);
136 SkAutoTUnref<SkData> origEncoded(image->encode()); 136 SkAutoTUnref<SkData> origEncoded(image->encode());
137 REPORTER_ASSERT(reporter, origEncoded); 137 REPORTER_ASSERT(reporter, origEncoded);
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 SkPMColor storage[w * h]; 689 SkPMColor storage[w * h];
690 const SkPMColor expected0 = SkPreMultiplyColor(SK_ColorRED); 690 const SkPMColor expected0 = SkPreMultiplyColor(SK_ColorRED);
691 sk_memset32(storage, expected0, w * h); 691 sk_memset32(storage, expected0, w * h);
692 GrSurfaceDesc desc; 692 GrSurfaceDesc desc;
693 desc.fFlags = kRenderTarget_GrSurfaceFlag; // needs to be a rendertarget fo r readpixels(); 693 desc.fFlags = kRenderTarget_GrSurfaceFlag; // needs to be a rendertarget fo r readpixels();
694 desc.fOrigin = kDefault_GrSurfaceOrigin; 694 desc.fOrigin = kDefault_GrSurfaceOrigin;
695 desc.fWidth = w; 695 desc.fWidth = w;
696 desc.fHeight = h; 696 desc.fHeight = h;
697 desc.fConfig = kSkia8888_GrPixelConfig; 697 desc.fConfig = kSkia8888_GrPixelConfig;
698 desc.fSampleCnt = 0; 698 desc.fSampleCnt = 0;
699 SkAutoTUnref<GrTexture> tex(provider->createTexture(desc, SkBudgeted::kNo, s torage, w * 4)); 699 SkAutoTUnref<GrTexture> tex(provider->createTexture(desc, false, storage, w * 4));
700 if (!tex) { 700 if (!tex) {
701 REPORTER_ASSERT(reporter, false); 701 REPORTER_ASSERT(reporter, false);
702 return; 702 return;
703 } 703 }
704 704
705 GrBackendTextureDesc backendDesc; 705 GrBackendTextureDesc backendDesc;
706 backendDesc.fConfig = kSkia8888_GrPixelConfig; 706 backendDesc.fConfig = kSkia8888_GrPixelConfig;
707 backendDesc.fFlags = kRenderTarget_GrBackendTextureFlag; 707 backendDesc.fFlags = kRenderTarget_GrBackendTextureFlag;
708 backendDesc.fWidth = w; 708 backendDesc.fWidth = w;
709 backendDesc.fHeight = h; 709 backendDesc.fHeight = h;
(...skipping 21 matching lines...) Expand all
731 check_image_color(reporter, refImg, expected1); 731 check_image_color(reporter, refImg, expected1);
732 #endif 732 #endif
733 check_image_color(reporter, cpyImg, expected0); 733 check_image_color(reporter, cpyImg, expected0);
734 734
735 // Now exercise the release proc 735 // Now exercise the release proc
736 REPORTER_ASSERT(reporter, 0 == releaseChecker.fReleaseCount); 736 REPORTER_ASSERT(reporter, 0 == releaseChecker.fReleaseCount);
737 refImg.reset(nullptr); // force a release of the image 737 refImg.reset(nullptr); // force a release of the image
738 REPORTER_ASSERT(reporter, 1 == releaseChecker.fReleaseCount); 738 REPORTER_ASSERT(reporter, 1 == releaseChecker.fReleaseCount);
739 } 739 }
740 #endif 740 #endif
OLDNEW
« no previous file with comments | « tests/ImageNewShaderTest.cpp ('k') | tests/PremulAlphaRoundTripTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698