OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 context->resetContext(); | 122 context->resetContext(); |
123 } | 123 } |
124 | 124 |
125 void onDraw(SkCanvas* canvas) override { | 125 void onDraw(SkCanvas* canvas) override { |
126 GrContext* context = canvas->getGrContext(); | 126 GrContext* context = canvas->getGrContext(); |
127 if (!context) { | 127 if (!context) { |
128 skiagm::GM::DrawGpuOnlyMessage(canvas); | 128 skiagm::GM::DrawGpuOnlyMessage(canvas); |
129 return; | 129 return; |
130 } | 130 } |
131 | 131 |
132 GrBackendObject yuvHandles[3]; | |
133 this->createYUVTextures(context, yuvHandles); | |
134 | 132 |
135 static const SkScalar kPad = 10.f; | 133 static const SkScalar kPad = 10.f; |
136 | 134 |
137 SkISize sizes[] = { | 135 SkISize sizes[] = { |
138 { fYUVBmps[0].width(), fYUVBmps[0].height()}, | 136 { fYUVBmps[0].width(), fYUVBmps[0].height()}, |
139 { fYUVBmps[1].width(), fYUVBmps[1].height()}, | 137 { fYUVBmps[1].width(), fYUVBmps[1].height()}, |
140 { fYUVBmps[2].width(), fYUVBmps[2].height()}, | 138 { fYUVBmps[2].width(), fYUVBmps[2].height()}, |
141 }; | 139 }; |
142 SkTArray<sk_sp<SkImage>> images; | 140 SkTArray<sk_sp<SkImage>> images; |
143 images.push_back(fRGBImage); | 141 images.push_back(fRGBImage); |
144 for (int space = kJPEG_SkYUVColorSpace; space <= kLastEnum_SkYUVColorSpa
ce; ++space) { | 142 for (int space = kJPEG_SkYUVColorSpace; space <= kLastEnum_SkYUVColorSpa
ce; ++space) { |
| 143 GrBackendObject yuvHandles[3]; |
| 144 this->createYUVTextures(context, yuvHandles); |
145 images.push_back(SkImage::MakeFromYUVTexturesCopy(context, | 145 images.push_back(SkImage::MakeFromYUVTexturesCopy(context, |
146 static_cast<SkYUVC
olorSpace>(space), | 146 static_cast<SkYUVC
olorSpace>(space), |
147 yuvHandles, sizes, | 147 yuvHandles, sizes, |
148 kTopLeft_GrSurface
Origin)); | 148 kTopLeft_GrSurface
Origin)); |
| 149 this->deleteYUVTextures(context, yuvHandles); |
149 } | 150 } |
150 this->deleteYUVTextures(context, yuvHandles); | |
151 for (int i = 0; i < images.count(); ++ i) { | 151 for (int i = 0; i < images.count(); ++ i) { |
152 SkScalar y = (i + 1) * kPad + i * fYUVBmps[0].height(); | 152 SkScalar y = (i + 1) * kPad + i * fYUVBmps[0].height(); |
153 SkScalar x = kPad; | 153 SkScalar x = kPad; |
154 | 154 |
155 canvas->drawImage(images[i].get(), x, y); | 155 canvas->drawImage(images[i].get(), x, y); |
156 } | 156 } |
157 } | 157 } |
158 | 158 |
159 private: | 159 private: |
160 sk_sp<SkImage> fRGBImage; | 160 sk_sp<SkImage> fRGBImage; |
161 SkBitmap fYUVBmps[3]; | 161 SkBitmap fYUVBmps[3]; |
162 | 162 |
163 static const int kBmpSize = 32; | 163 static const int kBmpSize = 32; |
164 | 164 |
165 typedef GM INHERITED; | 165 typedef GM INHERITED; |
166 }; | 166 }; |
167 | 167 |
168 DEF_GM(return new ImageFromYUVTextures;) | 168 DEF_GM(return new ImageFromYUVTextures;) |
169 } | 169 } |
170 | 170 |
171 #endif | 171 #endif |
OLD | NEW |