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 "SkData.h" | 10 #include "SkData.h" |
11 #include "SkImageCacherator.h" | 11 #include "SkImageCacherator.h" |
12 #include "SkImagePriv.h" | 12 #include "SkImagePriv.h" |
13 #include "SkPixelRef.h" | 13 #include "SkPixelRef.h" |
14 #include "SkSurface.h" | 14 #include "SkSurface.h" |
15 | 15 |
16 class SkImage_Generator : public SkImage_Base { | 16 class SkImage_Generator : public SkImage_Base { |
17 public: | 17 public: |
18 SkImage_Generator(SkImageCacherator* cache) | 18 SkImage_Generator(SkImageCacherator* cache) |
19 : INHERITED(cache->info().width(), cache->info().height(), kNeedNewImage
UniqueID, NULL) | 19 : INHERITED(cache->info().width(), cache->info().height(), cache->unique
ID(), NULL) |
20 , fCache(cache) // take ownership | 20 , fCache(cache) // take ownership |
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; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 return fCache->lockAsTexture(ctx, usage); | 84 return fCache->lockAsTexture(ctx, usage); |
85 } | 85 } |
86 | 86 |
87 SkImage* SkImage::NewFromGenerator(SkImageGenerator* generator, const SkIRect* s
ubset) { | 87 SkImage* SkImage::NewFromGenerator(SkImageGenerator* generator, const SkIRect* s
ubset) { |
88 SkImageCacherator* cache = SkImageCacherator::NewFromGenerator(generator, su
bset); | 88 SkImageCacherator* cache = SkImageCacherator::NewFromGenerator(generator, su
bset); |
89 if (!cache) { | 89 if (!cache) { |
90 return nullptr; | 90 return nullptr; |
91 } | 91 } |
92 return SkNEW_ARGS(SkImage_Generator, (cache)); | 92 return SkNEW_ARGS(SkImage_Generator, (cache)); |
93 } | 93 } |
OLD | NEW |