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

Side by Side Diff: tests/PictureShaderTest.cpp

Issue 1789633002: 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
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 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 "SkPicture.h" 9 #include "SkPicture.h"
10 #include "SkPictureRecorder.h" 10 #include "SkPictureRecorder.h"
11 #include "SkShader.h" 11 #include "SkShader.h"
12 #include "Test.h" 12 #include "Test.h"
13 13
14 // Test that attempting to create a picture shader with a nullptr picture or 14 // Test that attempting to create a picture shader with a nullptr picture or
15 // empty picture returns a shader that draws nothing. 15 // empty picture returns a shader that draws nothing.
16 DEF_TEST(PictureShader_empty, reporter) { 16 DEF_TEST(PictureShader_empty, reporter) {
17 SkPaint paint; 17 SkPaint paint;
18 18
19 SkBitmap bitmap; 19 SkBitmap bitmap;
20 bitmap.allocN32Pixels(1,1); 20 bitmap.allocN32Pixels(1,1);
21 21
22 SkCanvas canvas(bitmap); 22 SkCanvas canvas(bitmap);
23 canvas.clear(SK_ColorGREEN); 23 canvas.clear(SK_ColorGREEN);
24 24
25 SkShader* shader = SkShader::CreatePictureShader( 25 paint.setShader(SkShader::MakePictureShader(
26 nullptr, SkShader::kClamp_TileMode, SkShader::kClamp_TileMode, nullp tr, nullptr); 26 nullptr, SkShader::kClamp_TileMode, SkShader::kClamp_TileMode, nullp tr, nullptr));
27 paint.setShader(shader)->unref();
28 27
29 canvas.drawRect(SkRect::MakeWH(1,1), paint); 28 canvas.drawRect(SkRect::MakeWH(1,1), paint);
30 REPORTER_ASSERT(reporter, *bitmap.getAddr32(0,0) == SK_ColorGREEN); 29 REPORTER_ASSERT(reporter, *bitmap.getAddr32(0,0) == SK_ColorGREEN);
31 30
32 31
33 SkPictureRecorder factory; 32 SkPictureRecorder factory;
34 factory.beginRecording(0, 0, nullptr, 0); 33 factory.beginRecording(0, 0, nullptr, 0);
35 SkAutoTUnref<SkPicture> picture(factory.endRecording()); 34 sk_sp<SkPicture> picture(factory.endRecording());
36 shader = SkShader::CreatePictureShader( 35 paint.setShader(SkShader::MakePictureShader(std::move(picture), SkShader::kC lamp_TileMode,
37 picture.get(), SkShader::kClamp_TileMode, SkShader::kClamp_TileMode, nullptr, nullptr); 36 SkShader::kClamp_TileMode, nullp tr, nullptr));
38 paint.setShader(shader)->unref();
39 37
40 canvas.drawRect(SkRect::MakeWH(1,1), paint); 38 canvas.drawRect(SkRect::MakeWH(1,1), paint);
41 REPORTER_ASSERT(reporter, *bitmap.getAddr32(0,0) == SK_ColorGREEN); 39 REPORTER_ASSERT(reporter, *bitmap.getAddr32(0,0) == SK_ColorGREEN);
42 } 40 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698