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

Side by Side Diff: src/image/SkImage_Generator.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_Base.h ('k') | src/image/SkImage_Gpu.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 2015 Google Inc. 2 * Copyright 2015 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 "SkData.h" 10 #include "SkData.h"
(...skipping 10 matching lines...) Expand all
21 {} 21 {}
22 22
23 SkSurface* onNewSurface(const SkImageInfo&, const SkSurfaceProps&) const ove rride; 23 SkSurface* onNewSurface(const SkImageInfo&, const SkSurfaceProps&) const ove rride;
24 bool onReadPixels(const SkImageInfo&, void*, size_t, int srcX, int srcY) con st override; 24 bool onReadPixels(const SkImageInfo&, void*, size_t, int srcX, int srcY) con st override;
25 const void* onPeekPixels(SkImageInfo*, size_t* /*rowBytes*/) const override; 25 const void* onPeekPixels(SkImageInfo*, size_t* /*rowBytes*/) const override;
26 SkData* onRefEncoded() const override; 26 SkData* onRefEncoded() const override;
27 bool isOpaque() const override { return fCache->info().isOpaque(); } 27 bool isOpaque() const override { return fCache->info().isOpaque(); }
28 28
29 bool getROPixels(SkBitmap*) const override; 29 bool getROPixels(SkBitmap*) const override;
30 GrTexture* asTextureRef(GrContext*, SkImageUsageType) const override; 30 GrTexture* asTextureRef(GrContext*, SkImageUsageType) const override;
31
32 SkShader* onNewShader(SkShader::TileMode,
33 SkShader::TileMode,
34 const SkMatrix* localMatrix) const override;
35
31 bool onIsLazyGenerated() const override { return true; } 36 bool onIsLazyGenerated() const override { return true; }
32 37
33 private: 38 private:
34 SkAutoTDelete<SkImageCacherator> fCache; 39 SkAutoTDelete<SkImageCacherator> fCache;
35 40
36 typedef SkImage_Base INHERITED; 41 typedef SkImage_Base INHERITED;
37 }; 42 };
38 43
39 /////////////////////////////////////////////////////////////////////////////// 44 ///////////////////////////////////////////////////////////////////////////////
40 45
46 SkShader* SkImage_Generator::onNewShader(SkShader::TileMode tileX, SkShader::Til eMode tileY,
47 const SkMatrix* localMatrix) const {
48 // TODO: need a native Shader that takes Cacherator (or this image) so we ca n natively return
49 // textures as output from the shader.
50 SkBitmap bm;
51 if (this->getROPixels(&bm)) {
52 return SkShader::CreateBitmapShader(bm, tileX, tileY, localMatrix);
53 }
54 return nullptr;
55 }
56
41 SkSurface* SkImage_Generator::onNewSurface(const SkImageInfo& info, 57 SkSurface* SkImage_Generator::onNewSurface(const SkImageInfo& info,
42 const SkSurfaceProps& props) const { 58 const SkSurfaceProps& props) const {
43 return SkSurface::NewRaster(info, &props); 59 return SkSurface::NewRaster(info, &props);
44 } 60 }
45 61
46 bool SkImage_Generator::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels , size_t dstRB, 62 bool SkImage_Generator::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels , size_t dstRB,
47 int srcX, int srcY) const { 63 int srcX, int srcY) const {
48 SkBitmap bm; 64 SkBitmap bm;
49 if (this->getROPixels(&bm)) { 65 if (this->getROPixels(&bm)) {
50 return bm.readPixels(dstInfo, dstPixels, dstRB, srcX, srcY); 66 return bm.readPixels(dstInfo, dstPixels, dstRB, srcX, srcY);
(...skipping 17 matching lines...) Expand all
68 return fCache->lockAsTexture(ctx, usage, this); 84 return fCache->lockAsTexture(ctx, usage, this);
69 } 85 }
70 86
71 SkImage* SkImage::NewFromGenerator(SkImageGenerator* generator, const SkIRect* s ubset) { 87 SkImage* SkImage::NewFromGenerator(SkImageGenerator* generator, const SkIRect* s ubset) {
72 SkImageCacherator* cache = SkImageCacherator::NewFromGenerator(generator, su bset); 88 SkImageCacherator* cache = SkImageCacherator::NewFromGenerator(generator, su bset);
73 if (!cache) { 89 if (!cache) {
74 return nullptr; 90 return nullptr;
75 } 91 }
76 return SkNEW_ARGS(SkImage_Generator, (cache)); 92 return SkNEW_ARGS(SkImage_Generator, (cache));
77 } 93 }
OLDNEW
« no previous file with comments | « src/image/SkImage_Base.h ('k') | src/image/SkImage_Gpu.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698