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

Side by Side Diff: src/core/SkPictureImageGenerator.cpp

Issue 1505333002: SkBitmap::installPixels(const SkPixmap&); (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-12-09 (Wednesday) 13:58:05 EST Created 5 years 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/core/SkBitmap.cpp ('k') | src/core/SkPixmap.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 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 #include "SkImageGenerator.h" 8 #include "SkImageGenerator.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkMatrix.h" 10 #include "SkMatrix.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 const SkPixmap& scaledPixel s) { 101 const SkPixmap& scaledPixel s) {
102 int w = scaledSize.width(); 102 int w = scaledSize.width();
103 int h = scaledSize.height(); 103 int h = scaledSize.height();
104 104
105 const SkScalar scaleX = SkIntToScalar(w) / this->getInfo().width(); 105 const SkScalar scaleX = SkIntToScalar(w) / this->getInfo().width();
106 const SkScalar scaleY = SkIntToScalar(h) / this->getInfo().height(); 106 const SkScalar scaleY = SkIntToScalar(h) / this->getInfo().height();
107 SkMatrix matrix = SkMatrix::MakeScale(scaleX, scaleY); 107 SkMatrix matrix = SkMatrix::MakeScale(scaleX, scaleY);
108 matrix.postTranslate(-SkIntToScalar(scaledOrigin.x()), -SkIntToScalar(scaled Origin.y())); 108 matrix.postTranslate(-SkIntToScalar(scaledOrigin.x()), -SkIntToScalar(scaled Origin.y()));
109 109
110 SkBitmap bitmap; 110 SkBitmap bitmap;
111 if (!bitmap.installPixels(scaledPixels.info(), scaledPixels.writable_addr(), 111 if (!bitmap.installPixels(scaledPixels)) {
112 scaledPixels.rowBytes())) {
113 return false; 112 return false;
114 } 113 }
115 114
116 bitmap.eraseColor(SK_ColorTRANSPARENT); 115 bitmap.eraseColor(SK_ColorTRANSPARENT);
117 SkCanvas canvas(bitmap, SkSurfaceProps(0, kUnknown_SkPixelGeometry)); 116 SkCanvas canvas(bitmap, SkSurfaceProps(0, kUnknown_SkPixelGeometry));
118 matrix.preConcat(fMatrix); 117 matrix.preConcat(fMatrix);
119 canvas.drawPicture(fPicture, &matrix, fPaint.getMaybeNull()); 118 canvas.drawPicture(fPicture, &matrix, fPaint.getMaybeNull());
120 return true; 119 return true;
121 } 120 }
122 121
(...skipping 29 matching lines...) Expand all
152 } 151 }
153 surface->getCanvas()->clear(0); // does NewRenderTarget promise to do this f or us? 152 surface->getCanvas()->clear(0); // does NewRenderTarget promise to do this f or us?
154 surface->getCanvas()->drawPicture(fPicture, &matrix, fPaint.getMaybeNull()); 153 surface->getCanvas()->drawPicture(fPicture, &matrix, fPaint.getMaybeNull());
155 SkAutoTUnref<SkImage> image(surface->newImageSnapshot()); 154 SkAutoTUnref<SkImage> image(surface->newImageSnapshot());
156 if (!image.get()) { 155 if (!image.get()) {
157 return nullptr; 156 return nullptr;
158 } 157 }
159 return SkSafeRef(image->getTexture()); 158 return SkSafeRef(image->getTexture());
160 } 159 }
161 #endif 160 #endif
OLDNEW
« no previous file with comments | « src/core/SkBitmap.cpp ('k') | src/core/SkPixmap.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698