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

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

Issue 741763002: add SkImage::newSurface (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: another warning fix Created 6 years, 1 month 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/SkImagePriv.h ('k') | src/image/SkImage_Base.h » ('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 "SkImagePriv.h" 8 #include "SkImagePriv.h"
9 #include "SkImage_Base.h"
9 #include "SkCanvas.h" 10 #include "SkCanvas.h"
10 #include "SkPicture.h" 11 #include "SkPicture.h"
11 12
12 SkImage* SkNewImageFromBitmap(const SkBitmap& bm, bool canSharePixelRef) { 13 SkImage* SkNewImageFromBitmap(const SkBitmap& bm, bool canSharePixelRef,
14 const SkSurfaceProps* props) {
13 const SkImageInfo info = bm.info(); 15 const SkImageInfo info = bm.info();
14 if (kUnknown_SkColorType == info.colorType()) { 16 if (kUnknown_SkColorType == info.colorType()) {
15 return NULL; 17 return NULL;
16 } 18 }
17 19
18 SkImage* image = NULL; 20 SkImage* image = NULL;
19 if (canSharePixelRef || bm.isImmutable()) { 21 if (canSharePixelRef || bm.isImmutable()) {
20 image = SkNewImageFromPixelRef(info, bm.pixelRef(), bm.rowBytes()); 22 image = SkNewImageFromPixelRef(info, bm.pixelRef(), bm.rowBytes(), props );
21 } else { 23 } else {
22 bm.lockPixels(); 24 bm.lockPixels();
23 if (bm.getPixels()) { 25 if (bm.getPixels()) {
24 image = SkImage::NewRasterCopy(info, bm.getPixels(), bm.rowBytes()); 26 image = SkImage::NewRasterCopy(info, bm.getPixels(), bm.rowBytes());
25 } 27 }
26 bm.unlockPixels(); 28 bm.unlockPixels();
29
30 // we don't expose props to NewRasterCopy (need a private vers) so post- init it here
31 if (image && props) {
32 as_IB(image)->initWithProps(*props);
33 }
27 } 34 }
28 return image; 35 return image;
29 } 36 }
OLDNEW
« no previous file with comments | « src/image/SkImagePriv.h ('k') | src/image/SkImage_Base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698