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

Side by Side Diff: gm/imagefromyuvtextures.cpp

Issue 1810813003: update callsites for Make image factories (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: start to take advantage of sk_sp drawImage 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 | « gm/imagefilterstransformed.cpp ('k') | gm/imagescalealigned.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 /* 2 /*
3 * Copyright 2015 Google Inc. 3 * Copyright 2015 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 // This test only works with the GPU backend. 9 // This test only works with the GPU backend.
10 10
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 for (int c = 0; c < 3; ++c) { 83 for (int c = 0; c < 3; ++c) {
84 rgb[c] /= 4; 84 rgb[c] /= 4;
85 } 85 }
86 int uvIndex = j * kBmpSize / 2 + i; 86 int uvIndex = j * kBmpSize / 2 + i;
87 uvPixels[0][uvIndex] = static_cast<signed char>( 87 uvPixels[0][uvIndex] = static_cast<signed char>(
88 ((-38 * rgb[0] - 74 * rgb[1] + 112 * rgb[2] + 128) >> 8) + 128); 88 ((-38 * rgb[0] - 74 * rgb[1] + 112 * rgb[2] + 128) >> 8) + 128);
89 uvPixels[1][uvIndex] = static_cast<signed char>( 89 uvPixels[1][uvIndex] = static_cast<signed char>(
90 ((112 * rgb[0] - 94 * rgb[1] - 18 * rgb[2] + 128) >> 8) + 128); 90 ((112 * rgb[0] - 94 * rgb[1] - 18 * rgb[2] + 128) >> 8) + 128);
91 } 91 }
92 } 92 }
93 fRGBImage.reset(SkImage::NewRasterCopy(rgbBmp.info(), rgbColors, rgbBmp. rowBytes())); 93 fRGBImage = SkImage::MakeRasterCopy(SkPixmap(rgbBmp.info(), rgbColors, r gbBmp.rowBytes()));
94 } 94 }
95 95
96 void createYUVTextures(GrContext* context, GrBackendObject yuvHandles[3]) { 96 void createYUVTextures(GrContext* context, GrBackendObject yuvHandles[3]) {
97 GrGpu* gpu = context->getGpu(); 97 GrGpu* gpu = context->getGpu();
98 if (!gpu) { 98 if (!gpu) {
99 return; 99 return;
100 } 100 }
101 101
102 for (int i = 0; i < 3; ++i) { 102 for (int i = 0; i < 3; ++i) {
103 SkASSERT(fYUVBmps[i].width() == SkToInt(fYUVBmps[i].rowBytes())); 103 SkASSERT(fYUVBmps[i].width() == SkToInt(fYUVBmps[i].rowBytes()));
(...skipping 30 matching lines...) Expand all
134 GrBackendObject yuvHandles[3]; 134 GrBackendObject yuvHandles[3];
135 this->createYUVTextures(context, yuvHandles); 135 this->createYUVTextures(context, yuvHandles);
136 136
137 static const SkScalar kPad = 10.f; 137 static const SkScalar kPad = 10.f;
138 138
139 SkISize sizes[] = { 139 SkISize sizes[] = {
140 { fYUVBmps[0].width(), fYUVBmps[0].height()}, 140 { fYUVBmps[0].width(), fYUVBmps[0].height()},
141 { fYUVBmps[1].width(), fYUVBmps[1].height()}, 141 { fYUVBmps[1].width(), fYUVBmps[1].height()},
142 { fYUVBmps[2].width(), fYUVBmps[2].height()}, 142 { fYUVBmps[2].width(), fYUVBmps[2].height()},
143 }; 143 };
144 SkTArray<SkImage*> images; 144 SkTArray<sk_sp<SkImage>> images;
145 images.push_back(SkRef(fRGBImage.get())); 145 images.push_back(fRGBImage);
146 for (int space = kJPEG_SkYUVColorSpace; space <= kLastEnum_SkYUVColorSpa ce; ++space) { 146 for (int space = kJPEG_SkYUVColorSpace; space <= kLastEnum_SkYUVColorSpa ce; ++space) {
147 images.push_back(SkImage::NewFromYUVTexturesCopy(context, 147 images.push_back(SkImage::MakeFromYUVTexturesCopy(context,
148 static_cast<SkYUVCo lorSpace>(space), 148 static_cast<SkYUVC olorSpace>(space),
149 yuvHandles, sizes, 149 yuvHandles, sizes,
150 kTopLeft_GrSurfaceO rigin)); 150 kTopLeft_GrSurface Origin));
151 } 151 }
152 this->deleteYUVTextures(context, yuvHandles); 152 this->deleteYUVTextures(context, yuvHandles);
153 for (int i = 0; i < images.count(); ++ i) { 153 for (int i = 0; i < images.count(); ++ i) {
154 SkScalar y = (i + 1) * kPad + i * fYUVBmps[0].height(); 154 SkScalar y = (i + 1) * kPad + i * fYUVBmps[0].height();
155 SkScalar x = kPad; 155 SkScalar x = kPad;
156 156
157 canvas->drawImage(images[i], x, y); 157 canvas->drawImage(images[i].get(), x, y);
158 images[i]->unref();
159 images[i] = nullptr;
160 } 158 }
161 } 159 }
162 160
163 private: 161 private:
164 SkAutoTUnref<SkImage> fRGBImage; 162 sk_sp<SkImage> fRGBImage;
165 SkBitmap fYUVBmps[3]; 163 SkBitmap fYUVBmps[3];
166 164
167 static const int kBmpSize = 32; 165 static const int kBmpSize = 32;
168 166
169 typedef GM INHERITED; 167 typedef GM INHERITED;
170 }; 168 };
171 169
172 DEF_GM(return new ImageFromYUVTextures;) 170 DEF_GM(return new ImageFromYUVTextures;)
173 } 171 }
174 172
175 #endif 173 #endif
OLDNEW
« no previous file with comments | « gm/imagefilterstransformed.cpp ('k') | gm/imagescalealigned.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698