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 "SkImage_Base.h" | 8 #include "SkImage_Base.h" |
9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 *dst = fBitmap; | 166 *dst = fBitmap; |
167 return true; | 167 return true; |
168 } | 168 } |
169 | 169 |
170 GrTexture* SkImage_Raster::asTextureRef(GrContext* ctx, const GrTextureParams& p
arams) const { | 170 GrTexture* SkImage_Raster::asTextureRef(GrContext* ctx, const GrTextureParams& p
arams) const { |
171 #if SK_SUPPORT_GPU | 171 #if SK_SUPPORT_GPU |
172 if (!ctx) { | 172 if (!ctx) { |
173 return nullptr; | 173 return nullptr; |
174 } | 174 } |
175 | 175 |
| 176 // textures (at least the texture-key) only support 16bit dimensions, so abo
rt early |
| 177 // if we're too big. |
| 178 if (fBitmap.width() > 0xFFFF || fBitmap.height() > 0xFFFF) { |
| 179 return nullptr; |
| 180 } |
| 181 |
| 182 GrUniqueKey key; |
| 183 GrMakeKeyFromImageID(&key, fBitmap.getGenerationID(), |
| 184 SkIRect::MakeWH(fBitmap.width(), fBitmap.height()), |
| 185 *ctx->caps(), params); |
| 186 |
| 187 if (GrTexture* tex = ctx->textureProvider()->findAndRefTextureByUniqueKey(ke
y)) { |
| 188 return tex; |
| 189 } |
176 return GrRefCachedBitmapTexture(ctx, fBitmap, params); | 190 return GrRefCachedBitmapTexture(ctx, fBitmap, params); |
177 #endif | 191 #endif |
178 | 192 |
179 return nullptr; | 193 return nullptr; |
180 } | 194 } |
181 | 195 |
182 SkImage* SkImage_Raster::onNewSubset(const SkIRect& subset) const { | 196 SkImage* SkImage_Raster::onNewSubset(const SkIRect& subset) const { |
183 // TODO : could consider heurist of sharing pixels, if subset is pretty clos
e to complete | 197 // TODO : could consider heurist of sharing pixels, if subset is pretty clos
e to complete |
184 | 198 |
185 SkImageInfo info = SkImageInfo::MakeN32(subset.width(), subset.height(), fBi
tmap.alphaType()); | 199 SkImageInfo info = SkImageInfo::MakeN32(subset.width(), subset.height(), fBi
tmap.alphaType()); |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 // pixelref since the caller might call setImmutable() themselves | 299 // pixelref since the caller might call setImmutable() themselves |
286 // (thus changing our state). | 300 // (thus changing our state). |
287 if (fBitmap.isImmutable()) { | 301 if (fBitmap.isImmutable()) { |
288 bitmap->setInfo(fBitmap.info(), fBitmap.rowBytes()); | 302 bitmap->setInfo(fBitmap.info(), fBitmap.rowBytes()); |
289 bitmap->setPixelRef(fBitmap.pixelRef(), fBitmap.pixelRefOrigin()); | 303 bitmap->setPixelRef(fBitmap.pixelRef(), fBitmap.pixelRefOrigin()); |
290 return true; | 304 return true; |
291 } | 305 } |
292 } | 306 } |
293 return this->INHERITED::onAsLegacyBitmap(bitmap, mode); | 307 return this->INHERITED::onAsLegacyBitmap(bitmap, mode); |
294 } | 308 } |
OLD | NEW |