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

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

Issue 1556333004: take gr-context parameter to refEncoded, indicating a desire for only gpu-specific formats (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: update dox Created 4 years, 11 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/images/SkDecodingImageGenerator.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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 const void* onPeekPixels(SkImageInfo*, size_t* /*rowBytes*/) const override;
71 SkData* onRefEncoded() 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
81 bool isOpaque() const override; 81 bool isOpaque() const override;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 const void* SkImage_Raster::onPeekPixels(SkImageInfo* infoPtr, size_t* rowBytesP tr) const { 143 const void* SkImage_Raster::onPeekPixels(SkImageInfo* infoPtr, size_t* rowBytesP tr) const {
144 const SkImageInfo info = fBitmap.info(); 144 const SkImageInfo info = fBitmap.info();
145 if ((kUnknown_SkColorType == info.colorType()) || !fBitmap.getPixels()) { 145 if ((kUnknown_SkColorType == info.colorType()) || !fBitmap.getPixels()) {
146 return nullptr; 146 return nullptr;
147 } 147 }
148 *infoPtr = info; 148 *infoPtr = info;
149 *rowBytesPtr = fBitmap.rowBytes(); 149 *rowBytesPtr = fBitmap.rowBytes();
150 return fBitmap.getPixels(); 150 return fBitmap.getPixels();
151 } 151 }
152 152
153 SkData* SkImage_Raster::onRefEncoded() const { 153 SkData* SkImage_Raster::onRefEncoded(GrContext*) const {
154 SkPixelRef* pr = fBitmap.pixelRef(); 154 SkPixelRef* pr = fBitmap.pixelRef();
155 const SkImageInfo prInfo = pr->info(); 155 const SkImageInfo prInfo = pr->info();
156 const SkImageInfo bmInfo = fBitmap.info(); 156 const SkImageInfo bmInfo = fBitmap.info();
157 157
158 // we only try if we (the image) cover the entire area of the pixelRef 158 // we only try if we (the image) cover the entire area of the pixelRef
159 if (prInfo.width() == bmInfo.width() && prInfo.height() == bmInfo.height()) { 159 if (prInfo.width() == bmInfo.width() && prInfo.height() == bmInfo.height()) {
160 return pr->refEncodedData(); 160 return pr->refEncodedData();
161 } 161 }
162 return nullptr; 162 return nullptr;
163 } 163 }
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 // pixelref since the caller might call setImmutable() themselves 285 // pixelref since the caller might call setImmutable() themselves
286 // (thus changing our state). 286 // (thus changing our state).
287 if (fBitmap.isImmutable()) { 287 if (fBitmap.isImmutable()) {
288 bitmap->setInfo(fBitmap.info(), fBitmap.rowBytes()); 288 bitmap->setInfo(fBitmap.info(), fBitmap.rowBytes());
289 bitmap->setPixelRef(fBitmap.pixelRef(), fBitmap.pixelRefOrigin()); 289 bitmap->setPixelRef(fBitmap.pixelRef(), fBitmap.pixelRefOrigin());
290 return true; 290 return true;
291 } 291 }
292 } 292 }
293 return this->INHERITED::onAsLegacyBitmap(bitmap, mode); 293 return this->INHERITED::onAsLegacyBitmap(bitmap, mode);
294 } 294 }
OLDNEW
« no previous file with comments | « src/image/SkImage_Generator.cpp ('k') | src/images/SkDecodingImageGenerator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698