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

Side by Side Diff: src/image/SkImage_Raster.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 | « src/image/SkImage_Generator.cpp ('k') | src/image/SkSurface.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 "SkImage_Base.h" 8 #include "SkImage_Base.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 // TODO : could consider heurist of sharing pixels, if subset is pretty clos e to complete 176 // TODO : could consider heurist of sharing pixels, if subset is pretty clos e to complete
177 177
178 SkImageInfo info = SkImageInfo::MakeN32(subset.width(), subset.height(), fBi tmap.alphaType()); 178 SkImageInfo info = SkImageInfo::MakeN32(subset.width(), subset.height(), fBi tmap.alphaType());
179 SkAutoTUnref<SkSurface> surface(SkSurface::NewRaster(info)); 179 SkAutoTUnref<SkSurface> surface(SkSurface::NewRaster(info));
180 if (!surface) { 180 if (!surface) {
181 return nullptr; 181 return nullptr;
182 } 182 }
183 surface->getCanvas()->clear(0); 183 surface->getCanvas()->clear(0);
184 surface->getCanvas()->drawImage(this, SkIntToScalar(-subset.x()), SkIntToSca lar(-subset.y()), 184 surface->getCanvas()->drawImage(this, SkIntToScalar(-subset.x()), SkIntToSca lar(-subset.y()),
185 nullptr); 185 nullptr);
186 return sk_sp<SkImage>(surface->newImageSnapshot()); 186 return surface->makeImageSnapshot();
187 } 187 }
188 188
189 /////////////////////////////////////////////////////////////////////////////// 189 ///////////////////////////////////////////////////////////////////////////////
190 190
191 sk_sp<SkImage> SkImage::MakeRasterCopy(const SkPixmap& pmap) { 191 sk_sp<SkImage> SkImage::MakeRasterCopy(const SkPixmap& pmap) {
192 size_t size; 192 size_t size;
193 if (!SkImage_Raster::ValidArgs(pmap.info(), pmap.rowBytes(), 193 if (!SkImage_Raster::ValidArgs(pmap.info(), pmap.rowBytes(),
194 pmap.ctable() != nullptr, &size) || !pmap.add r()) { 194 pmap.ctable() != nullptr, &size) || !pmap.add r()) {
195 return nullptr; 195 return nullptr;
196 } 196 }
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 // pixelref since the caller might call setImmutable() themselves 278 // pixelref since the caller might call setImmutable() themselves
279 // (thus changing our state). 279 // (thus changing our state).
280 if (fBitmap.isImmutable()) { 280 if (fBitmap.isImmutable()) {
281 bitmap->setInfo(fBitmap.info(), fBitmap.rowBytes()); 281 bitmap->setInfo(fBitmap.info(), fBitmap.rowBytes());
282 bitmap->setPixelRef(fBitmap.pixelRef(), fBitmap.pixelRefOrigin()); 282 bitmap->setPixelRef(fBitmap.pixelRef(), fBitmap.pixelRefOrigin());
283 return true; 283 return true;
284 } 284 }
285 } 285 }
286 return this->INHERITED::onAsLegacyBitmap(bitmap, mode); 286 return this->INHERITED::onAsLegacyBitmap(bitmap, mode);
287 } 287 }
OLDNEW
« no previous file with comments | « src/image/SkImage_Generator.cpp ('k') | src/image/SkSurface.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698