| 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 #ifndef SkImage_Gpu_DEFINED | 8 #ifndef SkImage_Gpu_DEFINED |
| 9 #define SkImage_Gpu_DEFINED | 9 #define SkImage_Gpu_DEFINED |
| 10 | 10 |
| 11 #include "SkAtomics.h" | 11 #include "SkAtomics.h" |
| 12 #include "GrTexture.h" | 12 #include "GrTexture.h" |
| 13 #include "GrGpuResourcePriv.h" | 13 #include "GrGpuResourcePriv.h" |
| 14 #include "SkBitmap.h" | 14 #include "SkBitmap.h" |
| 15 #include "SkImage_Base.h" | 15 #include "SkImage_Base.h" |
| 16 #include "SkImagePriv.h" | 16 #include "SkImagePriv.h" |
| 17 #include "SkSurface.h" | 17 #include "SkSurface.h" |
| 18 | 18 |
| 19 class SkImage_Gpu : public SkImage_Base { | 19 class SkImage_Gpu : public SkImage_Base { |
| 20 public: | 20 public: |
| 21 /** | 21 /** |
| 22 * An "image" can be a subset/window into a larger texture, so we explicit
take the | 22 * An "image" can be a subset/window into a larger texture, so we explicit
take the |
| 23 * width and height. | 23 * width and height. |
| 24 */ | 24 */ |
| 25 SkImage_Gpu(int w, int h, uint32_t uniqueID, SkAlphaType, GrTexture*, SkBudg
eted); | 25 SkImage_Gpu(int w, int h, uint32_t uniqueID, SkAlphaType, GrTexture*, SkBudg
eted); |
| 26 ~SkImage_Gpu() override; | 26 ~SkImage_Gpu() override; |
| 27 | 27 |
| 28 void applyBudgetDecision() const { | 28 void applyBudgetDecision() const { |
| 29 GrTexture* tex = this->getTexture(); | |
| 30 SkASSERT(tex); | |
| 31 if (SkBudgeted::kYes == fBudgeted) { | 29 if (SkBudgeted::kYes == fBudgeted) { |
| 32 tex->resourcePriv().makeBudgeted(); | 30 fTexture->resourcePriv().makeBudgeted(); |
| 33 } else { | 31 } else { |
| 34 tex->resourcePriv().makeUnbudgeted(); | 32 fTexture->resourcePriv().makeUnbudgeted(); |
| 35 } | 33 } |
| 36 } | 34 } |
| 37 | 35 |
| 38 bool getROPixels(SkBitmap*, CachingHint) const override; | 36 bool getROPixels(SkBitmap*, CachingHint) const override; |
| 39 GrTexture* asTextureRef(GrContext* ctx, const GrTextureParams& params) const
override; | 37 GrTexture* asTextureRef(GrContext* ctx, const GrTextureParams& params) const
override; |
| 40 SkImage* onNewSubset(const SkIRect&) const override; | 38 SkImage* onNewSubset(const SkIRect&) const override; |
| 41 | 39 |
| 42 GrTexture* peekTexture() const override { return fTexture; } | 40 GrTexture* peekTexture() const override { return fTexture; } |
| 43 bool isOpaque() const override; | 41 bool isOpaque() const override; |
| 44 bool onReadPixels(const SkImageInfo&, void* dstPixels, size_t dstRowBytes, | 42 bool onReadPixels(const SkImageInfo&, void* dstPixels, size_t dstRowBytes, |
| 45 int srcX, int srcY, CachingHint) const override; | 43 int srcX, int srcY, CachingHint) const override; |
| 46 | 44 |
| 47 SkSurface* onNewSurface(const SkImageInfo& info) const override { | 45 SkSurface* onNewSurface(const SkImageInfo& info) const override { |
| 48 return SkSurface::NewRenderTarget(fTexture->getContext(), SkBudgeted::kN
o, info); | 46 return SkSurface::NewRenderTarget(fTexture->getContext(), SkBudgeted::kN
o, info); |
| 49 } | 47 } |
| 50 | 48 |
| 51 bool asBitmapForImageFilters(SkBitmap* bitmap) const override; | 49 bool asBitmapForImageFilters(SkBitmap* bitmap) const override; |
| 52 | 50 |
| 53 private: | 51 private: |
| 54 SkAutoTUnref<GrTexture> fTexture; | 52 SkAutoTUnref<GrTexture> fTexture; |
| 55 const SkAlphaType fAlphaType; | 53 const SkAlphaType fAlphaType; |
| 56 const SkBudgeted fBudgeted; | 54 const SkBudgeted fBudgeted; |
| 57 mutable SkAtomic<bool> fAddedRasterVersionToCache; | 55 mutable SkAtomic<bool> fAddedRasterVersionToCache; |
| 58 | 56 |
| 59 | 57 |
| 60 typedef SkImage_Base INHERITED; | 58 typedef SkImage_Base INHERITED; |
| 61 }; | 59 }; |
| 62 | 60 |
| 63 #endif | 61 #endif |
| OLD | NEW |