| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 m_imageInfoCache.removeLast(); | 250 m_imageInfoCache.removeLast(); |
| 251 return info; | 251 return info; |
| 252 } | 252 } |
| 253 | 253 |
| 254 WebGraphicsContext3D* webContext = context(); | 254 WebGraphicsContext3D* webContext = context(); |
| 255 gpu::gles2::GLES2Interface* gl = contextGL(); | 255 gpu::gles2::GLES2Interface* gl = contextGL(); |
| 256 GLuint imageId = gl->CreateGpuMemoryBufferImageCHROMIUM(m_size.width(), m_si
ze.height(), GL_BGRA_EXT, GC3D_SCANOUT_CHROMIUM); | 256 GLuint imageId = gl->CreateGpuMemoryBufferImageCHROMIUM(m_size.width(), m_si
ze.height(), GL_BGRA_EXT, GC3D_SCANOUT_CHROMIUM); |
| 257 if (!imageId) | 257 if (!imageId) |
| 258 return Canvas2DLayerBridge::ImageInfo(); | 258 return Canvas2DLayerBridge::ImageInfo(); |
| 259 | 259 |
| 260 GLuint textureId= webContext->createTexture(); | 260 uint32_t textureId; |
| 261 if (!textureId) { | 261 gl->GenTextures(1, &textureId); |
| 262 gl->DestroyImageCHROMIUM(imageId); | |
| 263 return Canvas2DLayerBridge::ImageInfo(); | |
| 264 } | |
| 265 | |
| 266 GLenum target = GC3D_TEXTURE_RECTANGLE_ARB; | 262 GLenum target = GC3D_TEXTURE_RECTANGLE_ARB; |
| 267 gl->BindTexture(target, textureId); | 263 gl->BindTexture(target, textureId); |
| 268 gl->TexParameteri(target, GL_TEXTURE_MAG_FILTER, getGLFilter()); | 264 gl->TexParameteri(target, GL_TEXTURE_MAG_FILTER, getGLFilter()); |
| 269 gl->TexParameteri(target, GL_TEXTURE_MIN_FILTER, getGLFilter()); | 265 gl->TexParameteri(target, GL_TEXTURE_MIN_FILTER, getGLFilter()); |
| 270 gl->TexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); | 266 gl->TexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
| 271 gl->TexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); | 267 gl->TexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
| 272 gl->BindTexImage2DCHROMIUM(target, imageId); | 268 gl->BindTexImage2DCHROMIUM(target, imageId); |
| 273 | 269 |
| 274 return Canvas2DLayerBridge::ImageInfo(imageId, textureId); | 270 return Canvas2DLayerBridge::ImageInfo(imageId, textureId); |
| 275 } | 271 } |
| 276 | 272 |
| 277 void Canvas2DLayerBridge::deleteCHROMIUMImage(ImageInfo info) | 273 void Canvas2DLayerBridge::deleteCHROMIUMImage(ImageInfo info) |
| 278 { | 274 { |
| 279 WebGraphicsContext3D* webContext = context(); | 275 WebGraphicsContext3D* webContext = context(); |
| 280 gpu::gles2::GLES2Interface* gl = contextGL(); | 276 gpu::gles2::GLES2Interface* gl = contextGL(); |
| 281 if (gl->GetGraphicsResetStatusKHR() != GL_NO_ERROR) | 277 if (gl->GetGraphicsResetStatusKHR() != GL_NO_ERROR) |
| 282 return; | 278 return; |
| 283 | 279 |
| 284 GLenum target = GC3D_TEXTURE_RECTANGLE_ARB; | 280 GLenum target = GC3D_TEXTURE_RECTANGLE_ARB; |
| 285 gl->BindTexture(target, info.m_textureId); | 281 gl->BindTexture(target, info.m_textureId); |
| 286 gl->ReleaseTexImage2DCHROMIUM(target, info.m_imageId); | 282 gl->ReleaseTexImage2DCHROMIUM(target, info.m_imageId); |
| 287 gl->DestroyImageCHROMIUM(info.m_imageId); | 283 gl->DestroyImageCHROMIUM(info.m_imageId); |
| 288 webContext->deleteTexture(info.m_textureId); | 284 gl->DeleteTextures(1, &info.m_textureId); |
| 289 gl->BindTexture(target, 0); | 285 gl->BindTexture(target, 0); |
| 290 | 286 |
| 291 resetSkiaTextureBinding(); | 287 resetSkiaTextureBinding(); |
| 292 } | 288 } |
| 293 | 289 |
| 294 void Canvas2DLayerBridge::clearCHROMIUMImageCache() | 290 void Canvas2DLayerBridge::clearCHROMIUMImageCache() |
| 295 { | 291 { |
| 296 for (const auto& it : m_imageInfoCache) { | 292 for (const auto& it : m_imageInfoCache) { |
| 297 deleteCHROMIUMImage(it); | 293 deleteCHROMIUMImage(it); |
| 298 } | 294 } |
| (...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1006 #endif // USE_IOSURFACE_FOR_2D_CANVAS | 1002 #endif // USE_IOSURFACE_FOR_2D_CANVAS |
| 1007 } | 1003 } |
| 1008 | 1004 |
| 1009 void Canvas2DLayerBridge::Logger::reportHibernationEvent(HibernationEvent event) | 1005 void Canvas2DLayerBridge::Logger::reportHibernationEvent(HibernationEvent event) |
| 1010 { | 1006 { |
| 1011 DEFINE_STATIC_LOCAL(EnumerationHistogram, hibernationHistogram, ("Canvas.Hib
ernationEvents", HibernationEventCount)); | 1007 DEFINE_STATIC_LOCAL(EnumerationHistogram, hibernationHistogram, ("Canvas.Hib
ernationEvents", HibernationEventCount)); |
| 1012 hibernationHistogram.count(event); | 1008 hibernationHistogram.count(event); |
| 1013 } | 1009 } |
| 1014 | 1010 |
| 1015 } // namespace blink | 1011 } // namespace blink |
| OLD | NEW |