Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(160)

Side by Side Diff: src/core/SkImageCacherator.cpp

Issue 1510903002: Stop wrapping images backed by generators as bitmaps in SkGpuDevice (except when tiling) (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: comment Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/core/SkImageCacherator.h ('k') | src/gpu/GrImageIDTextureAdjuster.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "SkImageCacherator.h" 11 #include "SkImageCacherator.h"
12 #include "SkMallocPixelRef.h" 12 #include "SkMallocPixelRef.h"
13 #include "SkNextID.h" 13 #include "SkNextID.h"
14 #include "SkPixelRef.h" 14 #include "SkPixelRef.h"
15 #include "SkResourceCache.h" 15 #include "SkResourceCache.h"
16 16
17 #if SK_SUPPORT_GPU 17 #if SK_SUPPORT_GPU
18 #include "GrContext.h" 18 #include "GrContext.h"
19 #include "GrGpuResourcePriv.h" 19 #include "GrGpuResourcePriv.h"
20 #include "GrImageIDTextureAdjuster.h"
20 #include "GrResourceKey.h" 21 #include "GrResourceKey.h"
21 #include "GrTextureParams.h" 22 #include "GrTextureParams.h"
22 #include "GrYUVProvider.h" 23 #include "GrYUVProvider.h"
23 #include "SkGr.h" 24 #include "SkGr.h"
24 #include "SkGrPriv.h" 25 #include "SkGrPriv.h"
25 #endif 26 #endif
26 27
27 SkImageCacherator* SkImageCacherator::NewFromGenerator(SkImageGenerator* gen, 28 SkImageCacherator* SkImageCacherator::NewFromGenerator(SkImageGenerator* gen,
28 const SkIRect* subset) { 29 const SkIRect* subset) {
29 if (!gen) { 30 if (!gen) {
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 GrTexture* tex = GrUploadBitmapToTexture(ctx, bitmap); 283 GrTexture* tex = GrUploadBitmapToTexture(ctx, bitmap);
283 if (tex) { 284 if (tex) {
284 return set_key_and_return(tex, key); 285 return set_key_and_return(tex, key);
285 } 286 }
286 } 287 }
287 return nullptr; 288 return nullptr;
288 } 289 }
289 290
290 //////////////////////////////////////////////////////////////////////////////// /////////////////// 291 //////////////////////////////////////////////////////////////////////////////// ///////////////////
291 292
292 #include "GrTextureParamsAdjuster.h"
293
294 class Cacherator_GrTextureMaker : public GrTextureMaker {
295 public:
296 Cacherator_GrTextureMaker(GrContext* context, SkImageCacherator* cacher, con st SkImage* client,
297 SkImage::CachingHint chint)
298 : INHERITED(context, cacher->info().width(), cacher->info().height())
299 , fCacher(cacher)
300 , fClient(client)
301 , fCachingHint(chint)
302 {
303 if (client) {
304 GrMakeKeyFromImageID(&fOriginalKey, client->uniqueID(),
305 SkIRect::MakeWH(this->width(), this->height())) ;
306 }
307 }
308
309 protected:
310 // TODO: consider overriding this, for the case where the underlying generat or might be
311 // able to efficiently produce a "stretched" texture natively (e.g. pi cture-backed)
312 // GrTexture* generateTextureForParams(const CopyParams&) override;
313
314 GrTexture* refOriginalTexture() override {
315 return fCacher->lockTexture(this->context(), fOriginalKey, fClient, fCac hingHint);
316 }
317
318 void makeCopyKey(const CopyParams& stretch, GrUniqueKey* paramsCopyKey) over ride {
319 if (fOriginalKey.isValid()) {
320 MakeCopyKeyFromOrigKey(fOriginalKey, stretch, paramsCopyKey);
321 }
322 }
323
324 void didCacheCopy(const GrUniqueKey& copyKey) override {
325 if (fClient) {
326 as_IB(fClient)->notifyAddedToCache();
327 }
328 }
329
330 private:
331 SkImageCacherator* fCacher;
332 const SkImage* fClient;
333 GrUniqueKey fOriginalKey;
334 SkImage::CachingHint fCachingHint;
335
336 typedef GrTextureMaker INHERITED;
337 };
338
339 GrTexture* SkImageCacherator::lockAsTexture(GrContext* ctx, const GrTextureParam s& params, 293 GrTexture* SkImageCacherator::lockAsTexture(GrContext* ctx, const GrTextureParam s& params,
340 const SkImage* client, SkImage::Cach ingHint chint) { 294 const SkImage* client, SkImage::Cach ingHint chint) {
341 if (!ctx) { 295 if (!ctx) {
342 return nullptr; 296 return nullptr;
343 } 297 }
344 298
345 return Cacherator_GrTextureMaker(ctx, this, client, chint).refTextureForPara ms(params); 299 return GrImageTextureMaker(ctx, this, client, chint).refTextureForParams(par ams);
346 } 300 }
347 301
348 #else 302 #else
349 303
350 GrTexture* SkImageCacherator::lockAsTexture(GrContext* ctx, const GrTextureParam s&, 304 GrTexture* SkImageCacherator::lockAsTexture(GrContext* ctx, const GrTextureParam s&,
351 const SkImage* client, SkImage::Cach ingHint) { 305 const SkImage* client, SkImage::Cach ingHint) {
352 return nullptr; 306 return nullptr;
353 } 307 }
354 308
355 #endif 309 #endif
OLDNEW
« no previous file with comments | « src/core/SkImageCacherator.h ('k') | src/gpu/GrImageIDTextureAdjuster.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698