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