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 // This test only works with the GPU backend. | 8 // This test only works with the GPU backend. |
9 | 9 |
10 #include "gm.h" | 10 #include "gm.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 for (int i = 0; i < 3; ++i) { | 62 for (int i = 0; i < 3; ++i) { |
63 const size_t nbBytes = fBmp[i].rowBytes() * fBmp[i].height(); | 63 const size_t nbBytes = fBmp[i].rowBytes() * fBmp[i].height(); |
64 for (size_t j = 0; j < nbBytes; ++j) { | 64 for (size_t j = 0; j < nbBytes; ++j) { |
65 pixels[i][j] = (unsigned char)color[i]; | 65 pixels[i][j] = (unsigned char)color[i]; |
66 color[i] = (color[i] == limit[i]) ? invl[i] : color[i] + inc[i]; | 66 color[i] = (color[i] == limit[i]) ? invl[i] : color[i] + inc[i]; |
67 } | 67 } |
68 } | 68 } |
69 } | 69 } |
70 | 70 |
71 void onDraw(SkCanvas* canvas) override { | 71 void onDraw(SkCanvas* canvas) override { |
72 GrRenderTarget* rt = canvas->internal_private_accessTopLayerRenderTarget
(); | 72 GrDrawContext* drawContext = canvas->internal_private_accessTopLayerDraw
Context(); |
73 if (nullptr == rt) { | 73 if (!drawContext) { |
74 return; | 74 skiagm::GM::DrawGpuOnlyMessage(canvas); |
| 75 return; |
75 } | 76 } |
76 GrContext* context = rt->getContext(); | 77 |
77 if (nullptr == context) { | 78 GrContext* context = canvas->getGrContext(); |
78 skiagm::GM::DrawGpuOnlyMessage(canvas); | 79 if (!context) { |
79 return; | 80 return; |
80 } | 81 } |
81 | 82 |
82 sk_sp<GrDrawContext> drawContext(context->drawContext(sk_ref_sp(rt))); | |
83 if (!drawContext) { | |
84 return; | |
85 } | |
86 | |
87 SkAutoTUnref<GrTexture> texture[3]; | 83 SkAutoTUnref<GrTexture> texture[3]; |
88 texture[0].reset(GrRefCachedBitmapTexture(context, fBmp[0], | 84 texture[0].reset(GrRefCachedBitmapTexture(context, fBmp[0], |
89 GrTextureParams::ClampBilerp()
)); | 85 GrTextureParams::ClampBilerp()
)); |
90 texture[1].reset(GrRefCachedBitmapTexture(context, fBmp[1], | 86 texture[1].reset(GrRefCachedBitmapTexture(context, fBmp[1], |
91 GrTextureParams::ClampBilerp()
)); | 87 GrTextureParams::ClampBilerp()
)); |
92 texture[2].reset(GrRefCachedBitmapTexture(context, fBmp[2], | 88 texture[2].reset(GrRefCachedBitmapTexture(context, fBmp[2], |
93 GrTextureParams::ClampBilerp()
)); | 89 GrTextureParams::ClampBilerp()
)); |
94 | 90 |
95 if (!texture[0] || !texture[1] || !texture[2]) { | 91 if (!texture[0] || !texture[1] || !texture[2]) { |
96 return; | 92 return; |
(...skipping 22 matching lines...) Expand all Loading... |
119 GrPorterDuffXPFactory::Create(SkXfermode::kSrc_Mode))->unref
(); | 115 GrPorterDuffXPFactory::Create(SkXfermode::kSrc_Mode))->unref
(); |
120 SkAutoTUnref<const GrFragmentProcessor> fp( | 116 SkAutoTUnref<const GrFragmentProcessor> fp( |
121 GrYUVEffect::CreateYUVToRGB(texture[indices[i][0]], | 117 GrYUVEffect::CreateYUVToRGB(texture[indices[i][0]], |
122 texture[indices[i][1]], | 118 texture[indices[i][1]], |
123 texture[indices[i][2]], | 119 texture[indices[i][2]], |
124 sizes, | 120 sizes, |
125 static_cast<SkYUVColorSp
ace>(space))); | 121 static_cast<SkYUVColorSp
ace>(space))); |
126 if (fp) { | 122 if (fp) { |
127 SkMatrix viewMatrix; | 123 SkMatrix viewMatrix; |
128 viewMatrix.setTranslate(x, y); | 124 viewMatrix.setTranslate(x, y); |
129 pipelineBuilder.setRenderTarget(rt); | 125 pipelineBuilder.setRenderTarget(drawContext->accessRenderTar
get()); |
130 pipelineBuilder.addColorFragmentProcessor(fp); | 126 pipelineBuilder.addColorFragmentProcessor(fp); |
131 SkAutoTUnref<GrDrawBatch> batch( | 127 SkAutoTUnref<GrDrawBatch> batch( |
132 GrRectBatchFactory::CreateNonAAFill(GrColor_WHITE, v
iewMatrix, | 128 GrRectBatchFactory::CreateNonAAFill(GrColor_WHITE, v
iewMatrix, |
133 renderRect, null
ptr, nullptr)); | 129 renderRect, null
ptr, nullptr)); |
134 drawContext->drawContextPriv().testingOnly_drawBatch(pipelin
eBuilder, batch); | 130 drawContext->drawContextPriv().testingOnly_drawBatch(pipelin
eBuilder, batch); |
135 } | 131 } |
136 x += renderRect.width() + kTestPad; | 132 x += renderRect.width() + kTestPad; |
137 } | 133 } |
138 } | 134 } |
139 } | 135 } |
140 | 136 |
141 private: | 137 private: |
142 SkBitmap fBmp[3]; | 138 SkBitmap fBmp[3]; |
143 | 139 |
144 typedef GM INHERITED; | 140 typedef GM INHERITED; |
145 }; | 141 }; |
146 | 142 |
147 DEF_GM(return new YUVtoRGBEffect;) | 143 DEF_GM(return new YUVtoRGBEffect;) |
148 } | 144 } |
149 | 145 |
150 #endif | 146 #endif |
OLD | NEW |