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

Side by Side Diff: src/image/SkImage_Raster.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/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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 if (minSize) { 60 if (minSize) {
61 *minSize = size; 61 *minSize = size;
62 } 62 }
63 return true; 63 return true;
64 } 64 }
65 65
66 SkImage_Raster(const SkImageInfo&, SkData*, size_t rb, SkColorTable*); 66 SkImage_Raster(const SkImageInfo&, SkData*, size_t rb, SkColorTable*);
67 virtual ~SkImage_Raster(); 67 virtual ~SkImage_Raster();
68 68
69 bool onReadPixels(const SkImageInfo&, void*, size_t, int srcX, int srcY, Cac hingHint) const override; 69 bool onReadPixels(const SkImageInfo&, void*, size_t, int srcX, int srcY, Cac hingHint) const override;
70 const void* onPeekPixels(SkImageInfo*, size_t* /*rowBytes*/) const override; 70 bool onPeekPixels(SkPixmap*) const override;
71 SkData* onRefEncoded(GrContext*) const override; 71 SkData* onRefEncoded(GrContext*) const override;
72 bool getROPixels(SkBitmap*, CachingHint) const override; 72 bool getROPixels(SkBitmap*, CachingHint) const override;
73 GrTexture* asTextureRef(GrContext*, const GrTextureParams&) const override; 73 GrTexture* asTextureRef(GrContext*, const GrTextureParams&) const override;
74 SkImage* onNewSubset(const SkIRect&) const override; 74 SkImage* onNewSubset(const SkIRect&) const override;
75 75
76 // exposed for SkSurface_Raster via SkNewImageFromPixelRef 76 // exposed for SkSurface_Raster via SkNewImageFromPixelRef
77 SkImage_Raster(const SkImageInfo&, SkPixelRef*, const SkIPoint& origin, size _t rowBytes); 77 SkImage_Raster(const SkImageInfo&, SkPixelRef*, const SkIPoint& origin, size _t rowBytes);
78 78
79 SkPixelRef* getPixelRef() const { return fBitmap.pixelRef(); } 79 SkPixelRef* getPixelRef() const { return fBitmap.pixelRef(); }
80 80
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 } 133 }
134 134
135 SkImage_Raster::~SkImage_Raster() {} 135 SkImage_Raster::~SkImage_Raster() {}
136 136
137 bool SkImage_Raster::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, s ize_t dstRowBytes, 137 bool SkImage_Raster::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, s ize_t dstRowBytes,
138 int srcX, int srcY, CachingHint) const { 138 int srcX, int srcY, CachingHint) const {
139 SkBitmap shallowCopy(fBitmap); 139 SkBitmap shallowCopy(fBitmap);
140 return shallowCopy.readPixels(dstInfo, dstPixels, dstRowBytes, srcX, srcY); 140 return shallowCopy.readPixels(dstInfo, dstPixels, dstRowBytes, srcX, srcY);
141 } 141 }
142 142
143 const void* SkImage_Raster::onPeekPixels(SkImageInfo* infoPtr, size_t* rowBytesP tr) const { 143 bool SkImage_Raster::onPeekPixels(SkPixmap* pm) const {
144 const SkImageInfo info = fBitmap.info(); 144 return fBitmap.peekPixels(pm);
145 if ((kUnknown_SkColorType == info.colorType()) || !fBitmap.getPixels()) {
146 return nullptr;
147 }
148 *infoPtr = info;
149 *rowBytesPtr = fBitmap.rowBytes();
150 return fBitmap.getPixels();
151 } 145 }
152 146
153 SkData* SkImage_Raster::onRefEncoded(GrContext*) const { 147 SkData* SkImage_Raster::onRefEncoded(GrContext*) const {
154 SkPixelRef* pr = fBitmap.pixelRef(); 148 SkPixelRef* pr = fBitmap.pixelRef();
155 const SkImageInfo prInfo = pr->info(); 149 const SkImageInfo prInfo = pr->info();
156 const SkImageInfo bmInfo = fBitmap.info(); 150 const SkImageInfo bmInfo = fBitmap.info();
157 151
158 // we only try if we (the image) cover the entire area of the pixelRef 152 // we only try if we (the image) cover the entire area of the pixelRef
159 if (prInfo.width() == bmInfo.width() && prInfo.height() == bmInfo.height()) { 153 if (prInfo.width() == bmInfo.width() && prInfo.height() == bmInfo.height()) {
160 return pr->refEncodedData(); 154 return pr->refEncodedData();
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 // pixelref since the caller might call setImmutable() themselves 279 // pixelref since the caller might call setImmutable() themselves
286 // (thus changing our state). 280 // (thus changing our state).
287 if (fBitmap.isImmutable()) { 281 if (fBitmap.isImmutable()) {
288 bitmap->setInfo(fBitmap.info(), fBitmap.rowBytes()); 282 bitmap->setInfo(fBitmap.info(), fBitmap.rowBytes());
289 bitmap->setPixelRef(fBitmap.pixelRef(), fBitmap.pixelRefOrigin()); 283 bitmap->setPixelRef(fBitmap.pixelRef(), fBitmap.pixelRefOrigin());
290 return true; 284 return true;
291 } 285 }
292 } 286 }
293 return this->INHERITED::onAsLegacyBitmap(bitmap, mode); 287 return this->INHERITED::onAsLegacyBitmap(bitmap, mode);
294 } 288 }
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