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 } | |
190 return GrRefCachedBitmapTexture(ctx, fBitmap, params); | 176 return GrRefCachedBitmapTexture(ctx, fBitmap, params); |
191 #endif | 177 #endif |
192 | 178 |
193 return nullptr; | 179 return nullptr; |
194 } | 180 } |
195 | 181 |
196 SkImage* SkImage_Raster::onNewSubset(const SkIRect& subset) const { | 182 SkImage* SkImage_Raster::onNewSubset(const SkIRect& subset) const { |
197 // TODO : could consider heurist of sharing pixels, if subset is pretty clos
e to complete | 183 // TODO : could consider heurist of sharing pixels, if subset is pretty clos
e to complete |
198 | 184 |
199 SkImageInfo info = SkImageInfo::MakeN32(subset.width(), subset.height(), fBi
tmap.alphaType()); | 185 SkImageInfo info = SkImageInfo::MakeN32(subset.width(), subset.height(), fBi
tmap.alphaType()); |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 // pixelref since the caller might call setImmutable() themselves | 285 // pixelref since the caller might call setImmutable() themselves |
300 // (thus changing our state). | 286 // (thus changing our state). |
301 if (fBitmap.isImmutable()) { | 287 if (fBitmap.isImmutable()) { |
302 bitmap->setInfo(fBitmap.info(), fBitmap.rowBytes()); | 288 bitmap->setInfo(fBitmap.info(), fBitmap.rowBytes()); |
303 bitmap->setPixelRef(fBitmap.pixelRef(), fBitmap.pixelRefOrigin()); | 289 bitmap->setPixelRef(fBitmap.pixelRef(), fBitmap.pixelRefOrigin()); |
304 return true; | 290 return true; |
305 } | 291 } |
306 } | 292 } |
307 return this->INHERITED::onAsLegacyBitmap(bitmap, mode); | 293 return this->INHERITED::onAsLegacyBitmap(bitmap, mode); |
308 } | 294 } |
OLD | NEW |