| 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 "SkBitmap.h" | 8 #include "SkBitmap.h" |
| 9 #include "SkBitmapCache.h" | 9 #include "SkBitmapCache.h" |
| 10 #include "SkImage_Base.h" | 10 #include "SkImage_Base.h" |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 } | 268 } |
| 269 return nullptr; | 269 return nullptr; |
| 270 } | 270 } |
| 271 | 271 |
| 272 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 272 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
| 273 | 273 |
| 274 #include "GrTextureParamsAdjuster.h" | 274 #include "GrTextureParamsAdjuster.h" |
| 275 | 275 |
| 276 class Cacherator_GrTextureMaker : public GrTextureMaker { | 276 class Cacherator_GrTextureMaker : public GrTextureMaker { |
| 277 public: | 277 public: |
| 278 Cacherator_GrTextureMaker(SkImageCacherator* cacher, const SkImage* client) | 278 Cacherator_GrTextureMaker(GrContext* context, SkImageCacherator* cacher, con
st SkImage* client) |
| 279 : INHERITED(cacher->info().width(), cacher->info().height()) | 279 : INHERITED(context, cacher->info().width(), cacher->info().height()) |
| 280 , fCacher(cacher) | 280 , fCacher(cacher) |
| 281 , fClient(client) | 281 , fClient(client) { |
| 282 { | |
| 283 if (client) { | 282 if (client) { |
| 284 GrMakeKeyFromImageID(&fOriginalKey, client->uniqueID(), | 283 GrMakeKeyFromImageID(&fOriginalKey, client->uniqueID(), |
| 285 SkIRect::MakeWH(this->width(), this->height()))
; | 284 SkIRect::MakeWH(this->width(), this->height()))
; |
| 286 } | 285 } |
| 287 } | 286 } |
| 288 | 287 |
| 289 protected: | 288 protected: |
| 290 // TODO: consider overriding this, for the case where the underlying generat
or might be | 289 // TODO: consider overriding this, for the case where the underlying generat
or might be |
| 291 // able to efficiently produce a "stretched" texture natively (e.g. pi
cture-backed) | 290 // able to efficiently produce a "stretched" texture natively (e.g. pi
cture-backed) |
| 292 // GrTexture* generateTextureForParams(GrContext*, const SkGrStretch&) ov
erride; | 291 // GrTexture* generateTextureForParams(const CopyParams&) override; |
| 293 | 292 |
| 294 GrTexture* refOriginalTexture(GrContext* ctx) override { | 293 GrTexture* refOriginalTexture() override { |
| 295 return fCacher->lockTexture(ctx, fOriginalKey, fClient); | 294 return fCacher->lockTexture(this->context(), fOriginalKey, fClient); |
| 296 } | 295 } |
| 297 | 296 |
| 298 void makeCopyKey(const CopyParams& stretch, GrUniqueKey* paramsCopyKey) over
ride { | 297 void makeCopyKey(const CopyParams& stretch, GrUniqueKey* paramsCopyKey) over
ride { |
| 299 if (fOriginalKey.isValid()) { | 298 if (fOriginalKey.isValid()) { |
| 300 MakeCopyKeyFromOrigKey(fOriginalKey, stretch, paramsCopyKey); | 299 MakeCopyKeyFromOrigKey(fOriginalKey, stretch, paramsCopyKey); |
| 301 } | 300 } |
| 302 } | 301 } |
| 303 | 302 |
| 304 void didCacheCopy(const GrUniqueKey& copyKey) override { | 303 void didCacheCopy(const GrUniqueKey& copyKey) override { |
| 305 if (fClient) { | 304 if (fClient) { |
| 306 as_IB(fClient)->notifyAddedToCache(); | 305 as_IB(fClient)->notifyAddedToCache(); |
| 307 } | 306 } |
| 308 } | 307 } |
| 309 | 308 |
| 310 private: | 309 private: |
| 311 SkImageCacherator* fCacher; | 310 SkImageCacherator* fCacher; |
| 312 const SkImage* fClient; | 311 const SkImage* fClient; |
| 313 GrUniqueKey fOriginalKey; | 312 GrUniqueKey fOriginalKey; |
| 314 | 313 |
| 315 typedef GrTextureMaker INHERITED; | 314 typedef GrTextureMaker INHERITED; |
| 316 }; | 315 }; |
| 317 | 316 |
| 318 GrTexture* SkImageCacherator::lockAsTexture(GrContext* ctx, const GrTextureParam
s& params, | 317 GrTexture* SkImageCacherator::lockAsTexture(GrContext* ctx, const GrTextureParam
s& params, |
| 319 const SkImage* client) { | 318 const SkImage* client) { |
| 320 if (!ctx) { | 319 if (!ctx) { |
| 321 return nullptr; | 320 return nullptr; |
| 322 } | 321 } |
| 323 | 322 |
| 324 return Cacherator_GrTextureMaker(this, client).refTextureForParams(ctx, para
ms); | 323 return Cacherator_GrTextureMaker(ctx, this, client).refTextureForParams(para
ms); |
| 325 } | 324 } |
| 326 | 325 |
| 327 #else | 326 #else |
| 328 | 327 |
| 329 GrTexture* SkImageCacherator::lockAsTexture(GrContext* ctx, const GrTextureParam
s&, | 328 GrTexture* SkImageCacherator::lockAsTexture(GrContext* ctx, const GrTextureParam
s&, |
| 330 const SkImage* client) { | 329 const SkImage* client) { |
| 331 return nullptr; | 330 return nullptr; |
| 332 } | 331 } |
| 333 | 332 |
| 334 #endif | 333 #endif |
| OLD | NEW |