Lines Matching refs:bitmap

106 void TextureCache::operator()(SkBitmap*& bitmap, Texture*& texture) {
124 Texture* TextureCache::get(SkBitmap* bitmap) {
125 Texture* texture = mCache.get(bitmap);
128 if (bitmap->width() > mMaxTextureSize || bitmap->height() > mMaxTextureSize) {
130 bitmap->width(), bitmap->height(), mMaxTextureSize, mMaxTextureSize);
134 const uint32_t size = bitmap->rowBytes() * bitmap->height();
135 // Don't even try to cache a bitmap that's bigger than the cache
144 generateTexture(bitmap, texture, false);
149 bitmap, texture->id, size, mSize);
153 mCache.put(bitmap, texture);
157 } else if (bitmap->getGenerationID() != texture->generation) {
158 generateTexture(bitmap, texture, true);
164 Texture* TextureCache::getTransient(SkBitmap* bitmap) {
166 texture->bitmapSize = bitmap->rowBytes() * bitmap->height();
169 generateTexture(bitmap, texture, false);
174 void TextureCache::remove(SkBitmap* bitmap) {
175 mCache.remove(bitmap);
178 void TextureCache::removeDeferred(SkBitmap* bitmap) {
180 mGarbage.push(bitmap);
212 void TextureCache::generateTexture(SkBitmap* bitmap, Texture* texture, bool regenerate) {
213 SkAutoLockPixels alp(*bitmap);
215 if (!bitmap->readyToDraw()) {
216 ALOGE("Cannot generate texture from bitmap");
220 // We could also enable mipmapping if both bitmap dimensions are powers
226 const bool resize = !regenerate || bitmap->width() != int(texture->width) ||
227 bitmap->height() != int(texture->height) ||
228 (regenerate && canMipMap && texture->mipMap && !bitmap->hasHardwareMipMap());
234 texture->generation = bitmap->getGenerationID();
235 texture->width = bitmap->width();
236 texture->height = bitmap->height();
240 switch (bitmap->getConfig()) {
243 uploadToTexture(resize, GL_ALPHA, bitmap->rowBytesAsPixels(), texture->height,
244 GL_UNSIGNED_BYTE, bitmap->getPixels());
248 glPixelStorei(GL_UNPACK_ALIGNMENT, bitmap->bytesPerPixel());
249 uploadToTexture(resize, GL_RGB, bitmap->rowBytesAsPixels(), texture->height,
250 GL_UNSIGNED_SHORT_5_6_5, bitmap->getPixels());
254 glPixelStorei(GL_UNPACK_ALIGNMENT, bitmap->bytesPerPixel());
255 uploadToTexture(resize, GL_RGBA, bitmap->rowBytesAsPixels(), texture->height,
256 GL_UNSIGNED_BYTE, bitmap->getPixels());
259 texture->blend = !bitmap->isOpaque();
263 glPixelStorei(GL_UNPACK_ALIGNMENT, bitmap->bytesPerPixel());
264 uploadLoFiTexture(resize, bitmap, texture->width, texture->height);
265 texture->blend = !bitmap->isOpaque();
268 ALOGW("Unsupported bitmap config: %d", bitmap->getConfig());
273 texture->mipMap = bitmap->hasHardwareMipMap();
285 void TextureCache::uploadLoFiTexture(bool resize, SkBitmap* bitmap,
291 rgbaBitmap.setIsOpaque(bitmap->isOpaque());
294 canvas.drawBitmap(*bitmap, 0.0f, 0.0f, NULL);