OLD | NEW |
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" |
11 #include "SkData.h" | 11 #include "SkData.h" |
12 #include "SkImageCacherator.h" | 12 #include "SkImageCacherator.h" |
13 #include "SkImagePriv.h" | 13 #include "SkImagePriv.h" |
14 #include "SkPixelRef.h" | 14 #include "SkPixelRef.h" |
15 #include "SkSurface.h" | 15 #include "SkSurface.h" |
16 | 16 |
17 class SkImage_Generator : public SkImage_Base { | 17 class SkImage_Generator : public SkImage_Base { |
18 public: | 18 public: |
19 SkImage_Generator(SkImageCacherator* cache) | 19 SkImage_Generator(SkImageCacherator* cache) |
20 : INHERITED(cache->info().width(), cache->info().height(), cache->unique
ID()) | 20 : INHERITED(cache->info().width(), cache->info().height(), cache->unique
ID()) |
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, Cac
hingHint) const override; | 24 bool onReadPixels(const SkImageInfo&, void*, size_t, int srcX, int srcY, Cac
hingHint) const override; |
25 const void* onPeekPixels(SkImageInfo*, size_t* /*rowBytes*/) const override; | 25 const void* onPeekPixels(SkImageInfo*, size_t* /*rowBytes*/) const override; |
| 26 SkImageCacherator* peekCacherator() const override { return fCache; } |
26 SkData* onRefEncoded() const override; | 27 SkData* onRefEncoded() const override; |
27 bool isOpaque() const override { return fCache->info().isOpaque(); } | 28 bool isOpaque() const override { return fCache->info().isOpaque(); } |
28 SkImage* onNewSubset(const SkIRect&) const override; | 29 SkImage* onNewSubset(const SkIRect&) const override; |
29 bool getROPixels(SkBitmap*, CachingHint) const override; | 30 bool getROPixels(SkBitmap*, CachingHint) const override; |
30 GrTexture* asTextureRef(GrContext*, const GrTextureParams&) const override; | 31 GrTexture* asTextureRef(GrContext*, const GrTextureParams&) const override; |
31 bool onIsLazyGenerated() const override { return true; } | 32 bool onIsLazyGenerated() const override { return true; } |
32 | 33 |
33 private: | 34 private: |
34 SkAutoTDelete<SkImageCacherator> fCache; | 35 SkAutoTDelete<SkImageCacherator> fCache; |
35 | 36 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 return surface->newImageSnapshot(); | 94 return surface->newImageSnapshot(); |
94 } | 95 } |
95 | 96 |
96 SkImage* SkImage::NewFromGenerator(SkImageGenerator* generator, const SkIRect* s
ubset) { | 97 SkImage* SkImage::NewFromGenerator(SkImageGenerator* generator, const SkIRect* s
ubset) { |
97 SkImageCacherator* cache = SkImageCacherator::NewFromGenerator(generator, su
bset); | 98 SkImageCacherator* cache = SkImageCacherator::NewFromGenerator(generator, su
bset); |
98 if (!cache) { | 99 if (!cache) { |
99 return nullptr; | 100 return nullptr; |
100 } | 101 } |
101 return new SkImage_Generator(cache); | 102 return new SkImage_Generator(cache); |
102 } | 103 } |
OLD | NEW |