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

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

Issue 1784563002: unify peekPixels around pixmap parameter (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: update GrUploadPixmapToTexture to know about the new desc if readPixels was called 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/gpu/SkGr.cpp ('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 "SkBitmap.h" 8 #include "SkBitmap.h"
9 #include "SkBitmapCache.h" 9 #include "SkBitmapCache.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 18 matching lines...) Expand all
29 29
30 SkImage::SkImage(int width, int height, uint32_t uniqueID) 30 SkImage::SkImage(int width, int height, uint32_t uniqueID)
31 : fWidth(width) 31 : fWidth(width)
32 , fHeight(height) 32 , fHeight(height)
33 , fUniqueID(kNeedNewImageUniqueID == uniqueID ? SkNextID::ImageID() : unique ID) 33 , fUniqueID(kNeedNewImageUniqueID == uniqueID ? SkNextID::ImageID() : unique ID)
34 { 34 {
35 SkASSERT(width > 0); 35 SkASSERT(width > 0);
36 SkASSERT(height > 0); 36 SkASSERT(height > 0);
37 } 37 }
38 38
39 bool SkImage::peekPixels(SkPixmap* pm) const {
40 SkPixmap tmp;
41 if (!pm) {
42 pm = &tmp;
43 }
44 return as_IB(this)->onPeekPixels(pm);
45 }
46
47 #ifdef SK_SUPPORT_LEGACY_PEEKPIXELS_PARMS
39 const void* SkImage::peekPixels(SkImageInfo* info, size_t* rowBytes) const { 48 const void* SkImage::peekPixels(SkImageInfo* info, size_t* rowBytes) const {
40 SkImageInfo infoStorage; 49 SkPixmap pm;
41 size_t rowBytesStorage; 50 if (this->peekPixels(&pm)) {
42 if (nullptr == info) { 51 if (info) {
43 info = &infoStorage; 52 *info = pm.info();
53 }
54 if (rowBytes) {
55 *rowBytes = pm.rowBytes();
56 }
57 return pm.addr();
44 } 58 }
45 if (nullptr == rowBytes) { 59 return nullptr;
46 rowBytes = &rowBytesStorage;
47 }
48 return as_IB(this)->onPeekPixels(info, rowBytes);
49 } 60 }
61 #endif
50 62
51 bool SkImage::readPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dst RowBytes, 63 bool SkImage::readPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dst RowBytes,
52 int srcX, int srcY, CachingHint chint) const { 64 int srcX, int srcY, CachingHint chint) const {
53 SkReadPixelsRec rec(dstInfo, dstPixels, dstRowBytes, srcX, srcY); 65 SkReadPixelsRec rec(dstInfo, dstPixels, dstRowBytes, srcX, srcY);
54 if (!rec.trim(this->width(), this->height())) { 66 if (!rec.trim(this->width(), this->height())) {
55 return false; 67 return false;
56 } 68 }
57 return as_IB(this)->onReadPixels(rec.fInfo, rec.fPixels, rec.fRowBytes, rec. fX, rec.fY, chint); 69 return as_IB(this)->onReadPixels(rec.fInfo, rec.fPixels, rec.fRowBytes, rec. fX, rec.fY, chint);
58 } 70 }
59 71
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 246
235 SkPaint paint; 247 SkPaint paint;
236 paint.setXfermodeMode(SkXfermode::kSrc_Mode); 248 paint.setXfermodeMode(SkXfermode::kSrc_Mode);
237 canvas.drawImage(this, -SkIntToScalar(srcX), -SkIntToScalar(srcY), &paint); 249 canvas.drawImage(this, -SkIntToScalar(srcX), -SkIntToScalar(srcY), &paint);
238 250
239 return true; 251 return true;
240 } 252 }
241 253
242 //////////////////////////////////////////////////////////////////////////////// /////////////////// 254 //////////////////////////////////////////////////////////////////////////////// ///////////////////
243 255
244 bool SkImage::peekPixels(SkPixmap* pmap) const {
245 SkImageInfo info;
246 size_t rowBytes;
247 const void* pixels = this->peekPixels(&info, &rowBytes);
248 if (pixels) {
249 if (pmap) {
250 pmap->reset(info, pixels, rowBytes);
251 }
252 return true;
253 }
254 return false;
255 }
256
257 bool SkImage::readPixels(const SkPixmap& pmap, int srcX, int srcY, CachingHint c hint) const { 256 bool SkImage::readPixels(const SkPixmap& pmap, int srcX, int srcY, CachingHint c hint) const {
258 return this->readPixels(pmap.info(), pmap.writable_addr(), pmap.rowBytes(), srcX, srcY, chint); 257 return this->readPixels(pmap.info(), pmap.writable_addr(), pmap.rowBytes(), srcX, srcY, chint);
259 } 258 }
260 259
261 #if SK_SUPPORT_GPU 260 #if SK_SUPPORT_GPU
262 #include "GrTextureToYUVPlanes.h" 261 #include "GrTextureToYUVPlanes.h"
263 #endif 262 #endif
264 263
265 #include "SkRGBAToYUV.h" 264 #include "SkRGBAToYUV.h"
266 265
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 357
359 SkImage* SkImage::NewFromTextureCopy(GrContext*, const GrBackendTextureDesc&, Sk AlphaType) { 358 SkImage* SkImage::NewFromTextureCopy(GrContext*, const GrBackendTextureDesc&, Sk AlphaType) {
360 return nullptr; 359 return nullptr;
361 } 360 }
362 361
363 SkImage* SkImage::newTextureImage(GrContext*) const { 362 SkImage* SkImage::newTextureImage(GrContext*) const {
364 return nullptr; 363 return nullptr;
365 } 364 }
366 365
367 #endif 366 #endif
OLDNEW
« no previous file with comments | « src/gpu/SkGr.cpp ('k') | src/image/SkImage_Base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698