OLD | NEW |
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 "SkImage.h" | 9 #include "SkImage.h" |
10 #include "SkShader.h" | 10 #include "SkShader.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 SkIntToScalar(1), | 38 SkIntToScalar(1), |
39 SkIntToScalar(sourceSurface->height())); | 39 SkIntToScalar(sourceSurface->height())); |
40 | 40 |
41 sourceCanvas->drawRect(rect, paintColor); | 41 sourceCanvas->drawRect(rect, paintColor); |
42 } | 42 } |
43 | 43 |
44 void runShaderTest(skiatest::Reporter* reporter, SkSurface* sourceSurface, SkSur
face* destinationSurface, SkImageInfo& info) { | 44 void runShaderTest(skiatest::Reporter* reporter, SkSurface* sourceSurface, SkSur
face* destinationSurface, SkImageInfo& info) { |
45 paintSource(sourceSurface); | 45 paintSource(sourceSurface); |
46 | 46 |
47 SkAutoTUnref<SkImage> sourceImage(sourceSurface->newImageSnapshot()); | 47 SkAutoTUnref<SkImage> sourceImage(sourceSurface->newImageSnapshot()); |
48 SkAutoTUnref<SkShader> sourceShader(sourceImage->newShader( | 48 sk_sp<SkShader> sourceShader = sourceImage->makeShader( |
49 SkShader::kRepeat_TileMode, | 49 SkShader::kRepeat_TileMode, |
50 SkShader::kRepeat_TileMode)); | 50 SkShader::kRepeat_TileMode); |
51 | 51 |
52 SkPaint paint; | 52 SkPaint paint; |
53 paint.setShader(sourceShader); | 53 paint.setShader(sourceShader); |
54 | 54 |
55 SkCanvas* destinationCanvas = destinationSurface->getCanvas(); | 55 SkCanvas* destinationCanvas = destinationSurface->getCanvas(); |
56 destinationCanvas->clear(SK_ColorTRANSPARENT); | 56 destinationCanvas->clear(SK_ColorTRANSPARENT); |
57 destinationCanvas->drawPaint(paint); | 57 destinationCanvas->drawPaint(paint); |
58 | 58 |
59 SkIRect rect = info.bounds(); | 59 SkIRect rect = info.bounds(); |
60 | 60 |
61 SkBitmap bmOrig; | 61 SkBitmap bmOrig; |
62 sourceSurface->getCanvas()->readPixels(rect, &bmOrig); | 62 sourceSurface->getCanvas()->readPixels(rect, &bmOrig); |
63 | 63 |
64 | 64 |
65 SkBitmap bm; | 65 SkBitmap bm; |
66 destinationCanvas->readPixels(rect, &bm); | 66 destinationCanvas->readPixels(rect, &bm); |
67 | 67 |
68 testBitmapEquality(reporter, bmOrig, bm); | 68 testBitmapEquality(reporter, bmOrig, bm); |
69 | 69 |
70 | 70 |
71 | 71 |
72 // Test with a translated shader | 72 // Test with a translated shader |
73 SkMatrix matrix; | 73 SkMatrix matrix; |
74 matrix.setTranslate(SkIntToScalar(-1), SkIntToScalar(0)); | 74 matrix.setTranslate(SkIntToScalar(-1), SkIntToScalar(0)); |
75 | 75 |
76 SkAutoTUnref<SkShader> sourceShaderTranslated(sourceImage->newShader( | 76 sk_sp<SkShader> sourceShaderTranslated = sourceImage->makeShader( |
77 SkShader::kRepeat_TileMode, | 77 SkShader::kRepeat_TileMode, |
78 SkShader::kRepeat_TileMode, | 78 SkShader::kRepeat_TileMode, |
79 &matrix)); | 79 &matrix); |
80 | 80 |
81 destinationCanvas->clear(SK_ColorTRANSPARENT); | 81 destinationCanvas->clear(SK_ColorTRANSPARENT); |
82 | 82 |
83 SkPaint paintTranslated; | 83 SkPaint paintTranslated; |
84 paintTranslated.setShader(sourceShaderTranslated); | 84 paintTranslated.setShader(sourceShaderTranslated); |
85 | 85 |
86 destinationCanvas->drawPaint(paintTranslated); | 86 destinationCanvas->drawPaint(paintTranslated); |
87 | 87 |
88 SkBitmap bmt; | 88 SkBitmap bmt; |
89 destinationCanvas->readPixels(rect, &bmt); | 89 destinationCanvas->readPixels(rect, &bmt); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 gpuToGpu(reporter, context); | 148 gpuToGpu(reporter, context); |
149 | 149 |
150 // GPU -> RASTER | 150 // GPU -> RASTER |
151 gpuToRaster(reporter, context); | 151 gpuToRaster(reporter, context); |
152 | 152 |
153 // RASTER -> GPU | 153 // RASTER -> GPU |
154 rasterToGpu(reporter, context); | 154 rasterToGpu(reporter, context); |
155 } | 155 } |
156 | 156 |
157 #endif | 157 #endif |
OLD | NEW |