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

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

Issue 1352293002: Revert[2] of add ImageShader, sharing code with its Bitmap cousin (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 2 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_Gpu.cpp ('k') | no next file » | 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 bool getROPixels(SkBitmap*) const override; 73 bool getROPixels(SkBitmap*) const override;
74 GrTexture* asTextureRef(GrContext*, SkImageUsageType) const override; 74 GrTexture* asTextureRef(GrContext*, SkImageUsageType) const override;
75 SkImage* onNewSubset(const SkIRect&) const override; 75 SkImage* onNewSubset(const SkIRect&) const override;
76 76
77 // exposed for SkSurface_Raster via SkNewImageFromPixelRef 77 // exposed for SkSurface_Raster via SkNewImageFromPixelRef
78 SkImage_Raster(const SkImageInfo&, SkPixelRef*, const SkIPoint& pixelRefOrig in, size_t rowBytes, 78 SkImage_Raster(const SkImageInfo&, SkPixelRef*, const SkIPoint& pixelRefOrig in, size_t rowBytes,
79 const SkSurfaceProps*); 79 const SkSurfaceProps*);
80 80
81 SkPixelRef* getPixelRef() const { return fBitmap.pixelRef(); } 81 SkPixelRef* getPixelRef() const { return fBitmap.pixelRef(); }
82 82
83 SkShader* onNewShader(SkShader::TileMode,
84 SkShader::TileMode,
85 const SkMatrix* localMatrix) const override;
86
87 bool isOpaque() const override; 83 bool isOpaque() const override;
88 bool onAsLegacyBitmap(SkBitmap*, LegacyBitmapMode) const override; 84 bool onAsLegacyBitmap(SkBitmap*, LegacyBitmapMode) const override;
89 85
90 SkImage_Raster(const SkBitmap& bm, const SkSurfaceProps* props) 86 SkImage_Raster(const SkBitmap& bm, const SkSurfaceProps* props)
91 : INHERITED(bm.width(), bm.height(), bm.getGenerationID(), props) 87 : INHERITED(bm.width(), bm.height(), bm.getGenerationID(), props)
92 , fBitmap(bm) 88 , fBitmap(bm)
93 { 89 {
94 if (bm.pixelRef()->isPreLocked()) { 90 if (bm.pixelRef()->isPreLocked()) {
95 // we only preemptively lock if there is no chance of triggering som ething expensive 91 // we only preemptively lock if there is no chance of triggering som ething expensive
96 // like a lazy decode or imagegenerator. PreLocked means it is flat pixels already. 92 // like a lazy decode or imagegenerator. PreLocked means it is flat pixels already.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 : INHERITED(info.width(), info.height(), pr->getGenerationID(), props) 133 : INHERITED(info.width(), info.height(), pr->getGenerationID(), props)
138 { 134 {
139 fBitmap.setInfo(info, rowBytes); 135 fBitmap.setInfo(info, rowBytes);
140 fBitmap.setPixelRef(pr, pixelRefOrigin); 136 fBitmap.setPixelRef(pr, pixelRefOrigin);
141 fBitmap.lockPixels(); 137 fBitmap.lockPixels();
142 SkASSERT(fBitmap.isImmutable()); 138 SkASSERT(fBitmap.isImmutable());
143 } 139 }
144 140
145 SkImage_Raster::~SkImage_Raster() {} 141 SkImage_Raster::~SkImage_Raster() {}
146 142
147 SkShader* SkImage_Raster::onNewShader(SkShader::TileMode tileX, SkShader::TileMo de tileY,
148 const SkMatrix* localMatrix) const {
149 return SkShader::CreateBitmapShader(fBitmap, tileX, tileY, localMatrix);
150 }
151
152 bool SkImage_Raster::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, s ize_t dstRowBytes, 143 bool SkImage_Raster::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, s ize_t dstRowBytes,
153 int srcX, int srcY) const { 144 int srcX, int srcY) const {
154 SkBitmap shallowCopy(fBitmap); 145 SkBitmap shallowCopy(fBitmap);
155 return shallowCopy.readPixels(dstInfo, dstPixels, dstRowBytes, srcX, srcY); 146 return shallowCopy.readPixels(dstInfo, dstPixels, dstRowBytes, srcX, srcY);
156 } 147 }
157 148
158 const void* SkImage_Raster::onPeekPixels(SkImageInfo* infoPtr, size_t* rowBytesP tr) const { 149 const void* SkImage_Raster::onPeekPixels(SkImageInfo* infoPtr, size_t* rowBytesP tr) const {
159 const SkImageInfo info = fBitmap.info(); 150 const SkImageInfo info = fBitmap.info();
160 if ((kUnknown_SkColorType == info.colorType()) || !fBitmap.getPixels()) { 151 if ((kUnknown_SkColorType == info.colorType()) || !fBitmap.getPixels()) {
161 return nullptr; 152 return nullptr;
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 // pixelref since the caller might call setImmutable() themselves 306 // pixelref since the caller might call setImmutable() themselves
316 // (thus changing our state). 307 // (thus changing our state).
317 if (fBitmap.isImmutable()) { 308 if (fBitmap.isImmutable()) {
318 bitmap->setInfo(fBitmap.info(), fBitmap.rowBytes()); 309 bitmap->setInfo(fBitmap.info(), fBitmap.rowBytes());
319 bitmap->setPixelRef(fBitmap.pixelRef(), fBitmap.pixelRefOrigin()); 310 bitmap->setPixelRef(fBitmap.pixelRef(), fBitmap.pixelRefOrigin());
320 return true; 311 return true;
321 } 312 }
322 } 313 }
323 return this->INHERITED::onAsLegacyBitmap(bitmap, mode); 314 return this->INHERITED::onAsLegacyBitmap(bitmap, mode);
324 } 315 }
OLDNEW
« no previous file with comments | « src/image/SkImage_Gpu.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698