| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "SkBitmapCache.h" | 8 #include "SkBitmapCache.h" |
| 9 #include "SkImage_Gpu.h" | 9 #include "SkImage_Gpu.h" |
| 10 #include "GrCaps.h" | 10 #include "GrCaps.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 | 80 |
| 81 class Texture_GrTextureParamsAdjuster : public GrTextureParamsAdjuster { | 81 class Texture_GrTextureParamsAdjuster : public GrTextureParamsAdjuster { |
| 82 public: | 82 public: |
| 83 Texture_GrTextureParamsAdjuster(const SkImage* image, GrTexture* unstretched
) | 83 Texture_GrTextureParamsAdjuster(const SkImage* image, GrTexture* unstretched
) |
| 84 : INHERITED(image->width(), image->height()) | 84 : INHERITED(image->width(), image->height()) |
| 85 , fImage(image) | 85 , fImage(image) |
| 86 , fOriginal(unstretched) | 86 , fOriginal(unstretched) |
| 87 {} | 87 {} |
| 88 | 88 |
| 89 protected: | 89 protected: |
| 90 GrTexture* peekOriginalTexture() override { return fOriginal; } | |
| 91 | |
| 92 GrTexture* refOriginalTexture(GrContext* ctx) override { | 90 GrTexture* refOriginalTexture(GrContext* ctx) override { |
| 93 return SkRef(fOriginal); | 91 return SkRef(fOriginal); |
| 94 } | 92 } |
| 95 | 93 |
| 96 void makeCopyKey(const CopyParams& copyParams, GrUniqueKey* copyKey) overrid
e { | 94 void makeCopyKey(const CopyParams& copyParams, GrUniqueKey* copyKey) overrid
e { |
| 97 make_raw_texture_stretched_key(fImage->uniqueID(), copyParams, copyKey); | 95 make_raw_texture_stretched_key(fImage->uniqueID(), copyParams, copyKey); |
| 98 } | 96 } |
| 99 | 97 |
| 100 void didCacheCopy(const GrUniqueKey& copyKey) override { | 98 void didCacheCopy(const GrUniqueKey& copyKey) override { |
| 101 as_IB(fImage)->notifyAddedToCache(); | 99 as_IB(fImage)->notifyAddedToCache(); |
| 102 } | 100 } |
| 103 | 101 |
| 104 bool getROBitmap(SkBitmap* bitmap) override { | |
| 105 return as_IB(fImage)->getROPixels(bitmap); | |
| 106 } | |
| 107 | |
| 108 private: | 102 private: |
| 109 const SkImage* fImage; | 103 const SkImage* fImage; |
| 110 GrTexture* fOriginal; | 104 GrTexture* fOriginal; |
| 111 | 105 |
| 112 typedef GrTextureParamsAdjuster INHERITED; | 106 typedef GrTextureParamsAdjuster INHERITED; |
| 113 }; | 107 }; |
| 114 | 108 |
| 115 GrTexture* SkImage_Gpu::asTextureRef(GrContext* ctx, const GrTextureParams& para
ms) const { | 109 GrTexture* SkImage_Gpu::asTextureRef(GrContext* ctx, const GrTextureParams& para
ms) const { |
| 116 return Texture_GrTextureParamsAdjuster(this, fTexture).refTextureForParams(c
tx, params); | 110 return Texture_GrTextureParamsAdjuster(this, fTexture).refTextureForParams(c
tx, params); |
| 117 } | 111 } |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 if (!dst) { | 399 if (!dst) { |
| 406 return nullptr; | 400 return nullptr; |
| 407 } | 401 } |
| 408 | 402 |
| 409 const SkIRect srcR = SkIRect::MakeWH(desc.fWidth, desc.fHeight); | 403 const SkIRect srcR = SkIRect::MakeWH(desc.fWidth, desc.fHeight); |
| 410 const SkIPoint dstP = SkIPoint::Make(0, 0); | 404 const SkIPoint dstP = SkIPoint::Make(0, 0); |
| 411 ctx->copySurface(dst, src, srcR, dstP, GrContext::kFlushWrites_PixelOp); | 405 ctx->copySurface(dst, src, srcR, dstP, GrContext::kFlushWrites_PixelOp); |
| 412 return dst; | 406 return dst; |
| 413 } | 407 } |
| 414 | 408 |
| OLD | NEW |