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

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

Issue 1370223002: Revert[4] 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
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 "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 10 matching lines...) Expand all
21 , fCache(cache) // take ownership 21 , fCache(cache) // take ownership
22 {} 22 {}
23 23
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 SkImage* onNewSubset(const SkIRect&) const override; 28 SkImage* onNewSubset(const SkIRect&) const override;
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
36 bool onIsLazyGenerated() const override { return true; } 31 bool onIsLazyGenerated() const override { return true; }
37 32
38 private: 33 private:
39 SkAutoTDelete<SkImageCacherator> fCache; 34 SkAutoTDelete<SkImageCacherator> fCache;
40 35
41 typedef SkImage_Base INHERITED; 36 typedef SkImage_Base INHERITED;
42 }; 37 };
43 38
44 /////////////////////////////////////////////////////////////////////////////// 39 ///////////////////////////////////////////////////////////////////////////////
45 40
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
57 bool SkImage_Generator::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels , size_t dstRB, 41 bool SkImage_Generator::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels , size_t dstRB,
58 int srcX, int srcY) const { 42 int srcX, int srcY) const {
59 SkBitmap bm; 43 SkBitmap bm;
60 if (this->getROPixels(&bm)) { 44 if (this->getROPixels(&bm)) {
61 return bm.readPixels(dstInfo, dstPixels, dstRB, srcX, srcY); 45 return bm.readPixels(dstInfo, dstPixels, dstRB, srcX, srcY);
62 } 46 }
63 return false; 47 return false;
64 } 48 }
65 49
66 const void* SkImage_Generator::onPeekPixels(SkImageInfo* infoPtr, size_t* rowByt esPtr) const { 50 const void* SkImage_Generator::onPeekPixels(SkImageInfo* infoPtr, size_t* rowByt esPtr) const {
(...skipping 28 matching lines...) Expand all
95 return surface->newImageSnapshot(); 79 return surface->newImageSnapshot();
96 } 80 }
97 81
98 SkImage* SkImage::NewFromGenerator(SkImageGenerator* generator, const SkIRect* s ubset) { 82 SkImage* SkImage::NewFromGenerator(SkImageGenerator* generator, const SkIRect* s ubset) {
99 SkImageCacherator* cache = SkImageCacherator::NewFromGenerator(generator, su bset); 83 SkImageCacherator* cache = SkImageCacherator::NewFromGenerator(generator, su bset);
100 if (!cache) { 84 if (!cache) {
101 return nullptr; 85 return nullptr;
102 } 86 }
103 return new SkImage_Generator(cache); 87 return new SkImage_Generator(cache);
104 } 88 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698