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

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

Issue 1355863002: Revert of add ImageShader, sharing code with its Bitmap cousin (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 3 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 SkData* onRefEncoded() const override; 73 SkData* onRefEncoded() const override;
74 bool getROPixels(SkBitmap*) const override; 74 bool getROPixels(SkBitmap*) const override;
75 GrTexture* asTextureRef(GrContext*, SkImageUsageType) const override; 75 GrTexture* asTextureRef(GrContext*, SkImageUsageType) 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
83 bool isOpaque() const override; 87 bool isOpaque() const override;
84 bool onAsLegacyBitmap(SkBitmap*, LegacyBitmapMode) const override; 88 bool onAsLegacyBitmap(SkBitmap*, LegacyBitmapMode) const override;
85 89
86 SkImage_Raster(const SkBitmap& bm, const SkSurfaceProps* props) 90 SkImage_Raster(const SkBitmap& bm, const SkSurfaceProps* props)
87 : INHERITED(bm.width(), bm.height(), bm.getGenerationID(), props) 91 : INHERITED(bm.width(), bm.height(), bm.getGenerationID(), props)
88 , fBitmap(bm) 92 , fBitmap(bm)
89 { 93 {
90 if (bm.pixelRef()->isPreLocked()) { 94 if (bm.pixelRef()->isPreLocked()) {
91 // we only preemptively lock if there is no chance of triggering som ething expensive 95 // we only preemptively lock if there is no chance of triggering som ething expensive
92 // like a lazy decode or imagegenerator. PreLocked means it is flat pixels already. 96 // 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
133 : INHERITED(info.width(), info.height(), pr->getGenerationID(), props) 137 : INHERITED(info.width(), info.height(), pr->getGenerationID(), props)
134 { 138 {
135 fBitmap.setInfo(info, rowBytes); 139 fBitmap.setInfo(info, rowBytes);
136 fBitmap.setPixelRef(pr, pixelRefOrigin); 140 fBitmap.setPixelRef(pr, pixelRefOrigin);
137 fBitmap.lockPixels(); 141 fBitmap.lockPixels();
138 SkASSERT(fBitmap.isImmutable()); 142 SkASSERT(fBitmap.isImmutable());
139 } 143 }
140 144
141 SkImage_Raster::~SkImage_Raster() {} 145 SkImage_Raster::~SkImage_Raster() {}
142 146
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
143 SkSurface* SkImage_Raster::onNewSurface(const SkImageInfo& info, const SkSurface Props& props) const { 152 SkSurface* SkImage_Raster::onNewSurface(const SkImageInfo& info, const SkSurface Props& props) const {
144 return SkSurface::NewRaster(info, &props); 153 return SkSurface::NewRaster(info, &props);
145 } 154 }
146 155
147 bool SkImage_Raster::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, s ize_t dstRowBytes, 156 bool SkImage_Raster::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, s ize_t dstRowBytes,
148 int srcX, int srcY) const { 157 int srcX, int srcY) const {
149 SkBitmap shallowCopy(fBitmap); 158 SkBitmap shallowCopy(fBitmap);
150 return shallowCopy.readPixels(dstInfo, dstPixels, dstRowBytes, srcX, srcY); 159 return shallowCopy.readPixels(dstInfo, dstPixels, dstRowBytes, srcX, srcY);
151 } 160 }
152 161
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 // pixelref since the caller might call setImmutable() themselves 305 // pixelref since the caller might call setImmutable() themselves
297 // (thus changing our state). 306 // (thus changing our state).
298 if (fBitmap.isImmutable()) { 307 if (fBitmap.isImmutable()) {
299 bitmap->setInfo(fBitmap.info(), fBitmap.rowBytes()); 308 bitmap->setInfo(fBitmap.info(), fBitmap.rowBytes());
300 bitmap->setPixelRef(fBitmap.pixelRef(), fBitmap.pixelRefOrigin()); 309 bitmap->setPixelRef(fBitmap.pixelRef(), fBitmap.pixelRefOrigin());
301 return true; 310 return true;
302 } 311 }
303 } 312 }
304 return this->INHERITED::onAsLegacyBitmap(bitmap, mode); 313 return this->INHERITED::onAsLegacyBitmap(bitmap, mode);
305 } 314 }
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