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

Side by Side Diff: src/image/SkImage.cpp

Issue 920513003: Make filters use SkImage instead of SkBitmap Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 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 | « src/gpu/SkGpuDevice.cpp ('k') | src/pdf/SkPDFDevice.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 * Copyright 2012 Google Inc. 2 * Copyright 2012 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 "SkBitmap.h" 8 #include "SkBitmap.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkImageGenerator.h" 10 #include "SkImageGenerator.h"
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 surface->getCanvas()->scale(newWidth / src.width(), newHeight / src.height() ); 171 surface->getCanvas()->scale(newWidth / src.width(), newHeight / src.height() );
172 surface->getCanvas()->translate(-src.x(), -src.y()); 172 surface->getCanvas()->translate(-src.x(), -src.y());
173 173
174 SkPaint paint; 174 SkPaint paint;
175 paint.setXfermodeMode(SkXfermode::kSrc_Mode); 175 paint.setXfermodeMode(SkXfermode::kSrc_Mode);
176 paint.setFilterQuality(quality); 176 paint.setFilterQuality(quality);
177 surface->getCanvas()->drawImage(this, 0, 0, &paint); 177 surface->getCanvas()->drawImage(this, 0, 0, &paint);
178 return surface->newImageSnapshot(); 178 return surface->newImageSnapshot();
179 } 179 }
180 180
181 inline static bool read_image_as_n32_bitmap(const SkImage* image, SkBitmap* bitm ap) {
182 SkBitmap tmp;
183 if (!as_IB(image)->getROPixels(&tmp)) {
184 return false;
185 }
186 if (tmp.colorType() != kN32_SkColorType) {
187 return false;
188 }
181 189
190 tmp.lockPixels();
191 bitmap->swap(tmp);
192 return true;
193 }
194
195 SkAutoAdoptImageAsN32Bitmap::SkAutoAdoptImageAsN32Bitmap(SkAutoTUnref<const SkIm age>& image,
196 SkBitmap* bitmap)
197 : fBitmap(NULL) {
198 if (read_image_as_n32_bitmap(image, bitmap)) {
199 fBitmap = bitmap;
200 image.reset(NULL);
201 }
202 }
203
204 SkAutoImageAsN32Bitmap::SkAutoImageAsN32Bitmap(const SkImage* image, SkBitmap* b itmap)
205 : fBitmap(NULL) {
206 if (read_image_as_n32_bitmap(image, bitmap)) {
207 fBitmap = bitmap;
208 }
209 }
210
211
212
OLDNEW
« no previous file with comments | « src/gpu/SkGpuDevice.cpp ('k') | src/pdf/SkPDFDevice.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698