| 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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 bitmap->reset(); | 164 bitmap->reset(); |
| 165 return false; | 165 return false; |
| 166 } | 166 } |
| 167 | 167 |
| 168 if (!bitmap->tryAllocPixels(fInfo)) { | 168 if (!bitmap->tryAllocPixels(fInfo)) { |
| 169 bitmap->reset(); | 169 bitmap->reset(); |
| 170 return false; | 170 return false; |
| 171 } | 171 } |
| 172 | 172 |
| 173 const uint32_t pixelOpsFlags = 0; | 173 const uint32_t pixelOpsFlags = 0; |
| 174 if (!tex->readPixels(0, 0, bitmap->width(), bitmap->height(), | 174 if (!tex->readPixels(0, 0, bitmap->width(), bitmap->height(), SkImageInfo2Gr
PixelConfig(fInfo), |
| 175 SkImageInfo2GrPixelConfig(fInfo, *tex->getContext()->ca
ps()), | |
| 176 bitmap->getPixels(), bitmap->rowBytes(), pixelOpsFlags)
) { | 175 bitmap->getPixels(), bitmap->rowBytes(), pixelOpsFlags)
) { |
| 177 bitmap->reset(); | 176 bitmap->reset(); |
| 178 return false; | 177 return false; |
| 179 } | 178 } |
| 180 | 179 |
| 181 bitmap->pixelRef()->setImmutableWithID(fUniqueID); | 180 bitmap->pixelRef()->setImmutableWithID(fUniqueID); |
| 182 if (SkImage::kAllow_CachingHint == chint) { | 181 if (SkImage::kAllow_CachingHint == chint) { |
| 183 SkBitmapCache::Add(fUniqueID, *bitmap); | 182 SkBitmapCache::Add(fUniqueID, *bitmap); |
| 184 if (client) { | 183 if (client) { |
| 185 as_IB(client)->notifyAddedToCache(); | 184 as_IB(client)->notifyAddedToCache(); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 { | 266 { |
| 268 ScopedGenerator generator(this); | 267 ScopedGenerator generator(this); |
| 269 SkIRect subset = SkIRect::MakeXYWH(fOrigin.x(), fOrigin.y(), fInfo.width
(), fInfo.height()); | 268 SkIRect subset = SkIRect::MakeXYWH(fOrigin.x(), fOrigin.y(), fInfo.width
(), fInfo.height()); |
| 270 if (GrTexture* tex = generator->generateTexture(ctx, &subset)) { | 269 if (GrTexture* tex = generator->generateTexture(ctx, &subset)) { |
| 271 SK_HISTOGRAM_ENUMERATION("LockTexturePath", kNative_LockTexturePath, | 270 SK_HISTOGRAM_ENUMERATION("LockTexturePath", kNative_LockTexturePath, |
| 272 kLockTexturePathCount); | 271 kLockTexturePathCount); |
| 273 return set_key_and_return(tex, key); | 272 return set_key_and_return(tex, key); |
| 274 } | 273 } |
| 275 } | 274 } |
| 276 | 275 |
| 277 const GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(fInfo, *ctx->caps()); | 276 const GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(fInfo); |
| 278 | 277 |
| 279 // 3. Ask the generator to return a compressed form that the GPU might suppo
rt | 278 // 3. Ask the generator to return a compressed form that the GPU might suppo
rt |
| 280 SkAutoTUnref<SkData> data(this->refEncoded(ctx)); | 279 SkAutoTUnref<SkData> data(this->refEncoded(ctx)); |
| 281 if (data) { | 280 if (data) { |
| 282 GrTexture* tex = load_compressed_into_texture(ctx, data, desc); | 281 GrTexture* tex = load_compressed_into_texture(ctx, data, desc); |
| 283 if (tex) { | 282 if (tex) { |
| 284 SK_HISTOGRAM_ENUMERATION("LockTexturePath", kCompressed_LockTextureP
ath, | 283 SK_HISTOGRAM_ENUMERATION("LockTexturePath", kCompressed_LockTextureP
ath, |
| 285 kLockTexturePathCount); | 284 kLockTexturePathCount); |
| 286 return set_key_and_return(tex, key); | 285 return set_key_and_return(tex, key); |
| 287 } | 286 } |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 } | 332 } |
| 334 | 333 |
| 335 #else | 334 #else |
| 336 | 335 |
| 337 GrTexture* SkImageCacherator::lockAsTexture(GrContext* ctx, const GrTextureParam
s&, | 336 GrTexture* SkImageCacherator::lockAsTexture(GrContext* ctx, const GrTextureParam
s&, |
| 338 const SkImage* client, SkImage::Cach
ingHint) { | 337 const SkImage* client, SkImage::Cach
ingHint) { |
| 339 return nullptr; | 338 return nullptr; |
| 340 } | 339 } |
| 341 | 340 |
| 342 #endif | 341 #endif |
| OLD | NEW |