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

Side by Side Diff: tests/SurfaceTest.cpp

Issue 1225923010: Refugee from Dead Machine 4: MDB Monster Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Last update from dead machine Created 4 years, 7 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/SRGBReadWritePixelsTest.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 "SkCanvas.h" 8 #include "SkCanvas.h"
9 #include "SkData.h" 9 #include "SkData.h"
10 #include "SkDevice.h" 10 #include "SkDevice.h"
(...skipping 984 matching lines...) Expand 10 before | Expand all | Expand 10 after
995 desc.fWidth = w; 995 desc.fWidth = w;
996 desc.fHeight = h; 996 desc.fHeight = h;
997 desc.fConfig = kSkia8888_GrPixelConfig; 997 desc.fConfig = kSkia8888_GrPixelConfig;
998 desc.fSampleCnt = 0; 998 desc.fSampleCnt = 0;
999 999
1000 SkAutoTUnref<GrTexture> tex(provider->createTexture(desc, false, storage, w * 4)); 1000 SkAutoTUnref<GrTexture> tex(provider->createTexture(desc, false, storage, w * 4));
1001 if (!tex) { 1001 if (!tex) {
1002 REPORTER_ASSERT(reporter, false); 1002 REPORTER_ASSERT(reporter, false);
1003 return; 1003 return;
1004 } 1004 }
1005
1006 // TODO: this should actually be okay
1007 tex->setFromRawPixels(false);
1008
1009 SkAutoTUnref<GrDrawContext> dc(ctx->drawContext(tex->asRenderTarget()));
1010 if (!dc) {
1011 REPORTER_ASSERT(reporter, false);
1012 return;
1013 }
1005 1014
1006 GrBackendObject srcTex = tex->getTextureHandle(); 1015 GrBackendObject srcTex = tex->getTextureHandle();
1007 ReleaseTextureContext releaseCtx(reporter); 1016 ReleaseTextureContext releaseCtx(reporter);
1008 1017
1009 SkAutoTUnref<SkImage> refImg(make_desc_image(ctx, w, h, srcTex, &releaseCtx) ); 1018 SkAutoTUnref<SkImage> refImg(make_desc_image(ctx, w, h, srcTex, &releaseCtx) );
1010 SkAutoTUnref<SkImage> cpyImg(make_desc_image(ctx, w, h, srcTex, nullptr)); 1019 SkAutoTUnref<SkImage> cpyImg(make_desc_image(ctx, w, h, srcTex, nullptr));
1011 1020
1012 test_image_color(reporter, refImg, expected0); 1021 test_image_color(reporter, refImg, expected0);
1013 test_image_color(reporter, cpyImg, expected0); 1022 test_image_color(reporter, cpyImg, expected0);
1014 1023
1015 // Now lets jam new colors into our "external" texture, and see if the image s notice 1024 // Now lets jam new colors into our "external" texture, and see if the image s notice
1016 const SkPMColor expected1 = SkPreMultiplyColor(SK_ColorBLUE); 1025 const SkPMColor expected1 = SkPreMultiplyColor(SK_ColorBLUE);
1017 sk_memset32(storage, expected1, w * h); 1026 sk_memset32(storage, expected1, w * h);
1018 tex->writePixels(0, 0, w, h, kSkia8888_GrPixelConfig, storage, GrContext::kF lushWrites_PixelOp); 1027 tex->writePixels(dc, 0, 0, w, h, kSkia8888_GrPixelConfig, storage, GrContext ::kFlushWrites_PixelOp);
1019 1028
1020 // The cpy'd one should still see the old color 1029 // The cpy'd one should still see the old color
1021 #if 0 1030 #if 0
1022 // There is no guarantee that refImg sees the new color. We are free to have made a copy. Our 1031 // There is no guarantee that refImg sees the new color. We are free to have made a copy. Our
1023 // write pixels call violated the contract with refImg and refImg is now und efined. 1032 // write pixels call violated the contract with refImg and refImg is now und efined.
1024 test_image_color(reporter, refImg, expected1); 1033 test_image_color(reporter, refImg, expected1);
1025 #endif 1034 #endif
1026 test_image_color(reporter, cpyImg, expected0); 1035 test_image_color(reporter, cpyImg, expected0);
1027 1036
1028 // Now exercise the release proc 1037 // Now exercise the release proc
1029 REPORTER_ASSERT(reporter, !releaseCtx.fIsReleased); 1038 REPORTER_ASSERT(reporter, !releaseCtx.fIsReleased);
1030 refImg.reset(nullptr); // force a release of the image 1039 refImg.reset(nullptr); // force a release of the image
1031 REPORTER_ASSERT(reporter, releaseCtx.fIsReleased); 1040 REPORTER_ASSERT(reporter, releaseCtx.fIsReleased);
1032 } 1041 }
1033 #endif 1042 #endif
OLDNEW
« no previous file with comments | « tests/SRGBReadWritePixelsTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698