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

Side by Side Diff: tests/PictureTest.cpp

Issue 1790353002: Revert of more shader-->sp conversions (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/PictureShaderTest.cpp ('k') | tests/RecorderTest.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 2012 Google Inc. 2 * Copyright 2012 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 "SkBBoxHierarchy.h" 8 #include "SkBBoxHierarchy.h"
9 #include "SkBlurImageFilter.h" 9 #include "SkBlurImageFilter.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 72
73 canvas = recorder.beginRecording(100, 100); 73 canvas = recorder.beginRecording(100, 100);
74 { 74 {
75 SkPaint paint; 75 SkPaint paint;
76 // CreateBitmapShader is too smart for us; an empty (or 1x1) bitmap shad er 76 // CreateBitmapShader is too smart for us; an empty (or 1x1) bitmap shad er
77 // gets optimized into a non-bitmap form, so we create a 2x2 bitmap here . 77 // gets optimized into a non-bitmap form, so we create a 2x2 bitmap here .
78 SkBitmap bitmap; 78 SkBitmap bitmap;
79 bitmap.allocPixels(SkImageInfo::MakeN32Premul(2, 2)); 79 bitmap.allocPixels(SkImageInfo::MakeN32Premul(2, 2));
80 bitmap.eraseColor(SK_ColorBLUE); 80 bitmap.eraseColor(SK_ColorBLUE);
81 *(bitmap.getAddr32(0, 0)) = SK_ColorGREEN; 81 *(bitmap.getAddr32(0, 0)) = SK_ColorGREEN;
82 paint.setShader(SkShader::MakeBitmapShader(bitmap, SkShader::kClamp_Tile Mode, 82 SkShader* shader = SkShader::CreateBitmapShader(bitmap, SkShader::kClamp _TileMode,
83 SkShader::kClamp_TileMode)); 83 SkShader::kClamp_TileMod e);
84 REPORTER_ASSERT(reporter, paint.getShader()->isABitmap()); 84 paint.setShader(shader)->unref();
85 REPORTER_ASSERT(reporter, shader->isABitmap());
85 86
86 canvas->drawRect(SkRect::MakeWH(10, 10), paint); 87 canvas->drawRect(SkRect::MakeWH(10, 10), paint);
87 } 88 }
88 picture.reset(recorder.endRecording()); 89 picture.reset(recorder.endRecording());
89 REPORTER_ASSERT(reporter, picture->willPlayBackBitmaps()); 90 REPORTER_ASSERT(reporter, picture->willPlayBackBitmaps());
90 } 91 }
91 92
92 93
93 #ifdef SK_DEBUG 94 #ifdef SK_DEBUG
94 // Ensure that deleting an empty SkPicture does not assert. Asserts only fire 95 // Ensure that deleting an empty SkPicture does not assert. Asserts only fire
(...skipping 1286 matching lines...) Expand 10 before | Expand all | Expand 10 after
1381 rec.beginRecording(100, 100); 1382 rec.beginRecording(100, 100);
1382 REPORTER_ASSERT(r, rec.getRecordingCanvas()); 1383 REPORTER_ASSERT(r, rec.getRecordingCanvas());
1383 rec.endRecording()->unref(); 1384 rec.endRecording()->unref();
1384 REPORTER_ASSERT(r, !rec.getRecordingCanvas()); 1385 REPORTER_ASSERT(r, !rec.getRecordingCanvas());
1385 } 1386 }
1386 } 1387 }
1387 1388
1388 DEF_TEST(MiniRecorderLeftHanging, r) { 1389 DEF_TEST(MiniRecorderLeftHanging, r) {
1389 // Any shader or other ref-counted effect will do just fine here. 1390 // Any shader or other ref-counted effect will do just fine here.
1390 SkPaint paint; 1391 SkPaint paint;
1391 paint.setShader(SkShader::MakeColorShader(SK_ColorRED)); 1392 paint.setShader(SkShader::CreateColorShader(SK_ColorRED))->unref();
1392 1393
1393 SkMiniRecorder rec; 1394 SkMiniRecorder rec;
1394 REPORTER_ASSERT(r, rec.drawRect(SkRect::MakeWH(20,30), paint)); 1395 REPORTER_ASSERT(r, rec.drawRect(SkRect::MakeWH(20,30), paint));
1395 // Don't call rec.detachPicture(). Test succeeds by not asserting or leakin g the shader. 1396 // Don't call rec.detachPicture(). Test succeeds by not asserting or leakin g the shader.
1396 } 1397 }
1397 1398
1398 DEF_TEST(Picture_preserveCullRect, r) { 1399 DEF_TEST(Picture_preserveCullRect, r) {
1399 SkPictureRecorder recorder; 1400 SkPictureRecorder recorder;
1400 1401
1401 SkCanvas* c = recorder.beginRecording(SkRect::MakeLTRB(1, 2, 3, 4)); 1402 SkCanvas* c = recorder.beginRecording(SkRect::MakeLTRB(1, 2, 3, 4));
1402 c->clear(SK_ColorCYAN); 1403 c->clear(SK_ColorCYAN);
1403 1404
1404 SkAutoTUnref<SkPicture> picture(recorder.endRecording()); 1405 SkAutoTUnref<SkPicture> picture(recorder.endRecording());
1405 SkDynamicMemoryWStream wstream; 1406 SkDynamicMemoryWStream wstream;
1406 picture->serialize(&wstream); 1407 picture->serialize(&wstream);
1407 1408
1408 SkAutoTDelete<SkStream> rstream(wstream.detachAsStream()); 1409 SkAutoTDelete<SkStream> rstream(wstream.detachAsStream());
1409 SkAutoTUnref<SkPicture> deserializedPicture(SkPicture::CreateFromStream(rstr eam)); 1410 SkAutoTUnref<SkPicture> deserializedPicture(SkPicture::CreateFromStream(rstr eam));
1410 1411
1411 REPORTER_ASSERT(r, SkToBool(deserializedPicture)); 1412 REPORTER_ASSERT(r, SkToBool(deserializedPicture));
1412 REPORTER_ASSERT(r, deserializedPicture->cullRect().left() == 1); 1413 REPORTER_ASSERT(r, deserializedPicture->cullRect().left() == 1);
1413 REPORTER_ASSERT(r, deserializedPicture->cullRect().top() == 2); 1414 REPORTER_ASSERT(r, deserializedPicture->cullRect().top() == 2);
1414 REPORTER_ASSERT(r, deserializedPicture->cullRect().right() == 3); 1415 REPORTER_ASSERT(r, deserializedPicture->cullRect().right() == 3);
1415 REPORTER_ASSERT(r, deserializedPicture->cullRect().bottom() == 4); 1416 REPORTER_ASSERT(r, deserializedPicture->cullRect().bottom() == 4);
1416 } 1417 }
OLDNEW
« no previous file with comments | « tests/PictureShaderTest.cpp ('k') | tests/RecorderTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698