| 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 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 Canvas2DLayerBridge::ImageInfo Canvas2DLayerBridge::createIOSurfaceBackedTexture
() | 246 Canvas2DLayerBridge::ImageInfo Canvas2DLayerBridge::createIOSurfaceBackedTexture
() |
| 247 { | 247 { |
| 248 if (!m_imageInfoCache.isEmpty()) { | 248 if (!m_imageInfoCache.isEmpty()) { |
| 249 Canvas2DLayerBridge::ImageInfo info = m_imageInfoCache.last(); | 249 Canvas2DLayerBridge::ImageInfo info = m_imageInfoCache.last(); |
| 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 = webContext->createGpuMemoryBufferImageCHROMIUM(m_size.width
(), m_size.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 GLuint textureId= webContext->createTexture(); |
| 261 if (!textureId) { | 261 if (!textureId) { |
| 262 webContext->destroyImageCHROMIUM(imageId); | 262 gl->DestroyImageCHROMIUM(imageId); |
| 263 return Canvas2DLayerBridge::ImageInfo(); | 263 return Canvas2DLayerBridge::ImageInfo(); |
| 264 } | 264 } |
| 265 | 265 |
| 266 GLenum target = GC3D_TEXTURE_RECTANGLE_ARB; | 266 GLenum target = GC3D_TEXTURE_RECTANGLE_ARB; |
| 267 gl->BindTexture(target, textureId); | 267 gl->BindTexture(target, textureId); |
| 268 webContext->texParameteri(target, GL_TEXTURE_MAG_FILTER, getGLFilter()); | 268 gl->TexParameteri(target, GL_TEXTURE_MAG_FILTER, getGLFilter()); |
| 269 webContext->texParameteri(target, GL_TEXTURE_MIN_FILTER, getGLFilter()); | 269 gl->TexParameteri(target, GL_TEXTURE_MIN_FILTER, getGLFilter()); |
| 270 webContext->texParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); | 270 gl->TexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
| 271 webContext->texParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); | 271 gl->TexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
| 272 webContext->bindTexImage2DCHROMIUM(target, imageId); | 272 gl->BindTexImage2DCHROMIUM(target, imageId); |
| 273 | 273 |
| 274 return Canvas2DLayerBridge::ImageInfo(imageId, textureId); | 274 return Canvas2DLayerBridge::ImageInfo(imageId, textureId); |
| 275 } | 275 } |
| 276 | 276 |
| 277 void Canvas2DLayerBridge::deleteCHROMIUMImage(ImageInfo info) | 277 void Canvas2DLayerBridge::deleteCHROMIUMImage(ImageInfo info) |
| 278 { | 278 { |
| 279 WebGraphicsContext3D* webContext = context(); | 279 WebGraphicsContext3D* webContext = context(); |
| 280 gpu::gles2::GLES2Interface* gl = contextGL(); | 280 gpu::gles2::GLES2Interface* gl = contextGL(); |
| 281 if (gl->GetGraphicsResetStatusKHR() != GL_NO_ERROR) | 281 if (gl->GetGraphicsResetStatusKHR() != GL_NO_ERROR) |
| 282 return; | 282 return; |
| 283 | 283 |
| 284 GLenum target = GC3D_TEXTURE_RECTANGLE_ARB; | 284 GLenum target = GC3D_TEXTURE_RECTANGLE_ARB; |
| 285 gl->BindTexture(target, info.m_textureId); | 285 gl->BindTexture(target, info.m_textureId); |
| 286 webContext->releaseTexImage2DCHROMIUM(target, info.m_imageId); | 286 gl->ReleaseTexImage2DCHROMIUM(target, info.m_imageId); |
| 287 webContext->destroyImageCHROMIUM(info.m_imageId); | 287 gl->DestroyImageCHROMIUM(info.m_imageId); |
| 288 webContext->deleteTexture(info.m_textureId); | 288 webContext->deleteTexture(info.m_textureId); |
| 289 gl->BindTexture(target, 0); | 289 gl->BindTexture(target, 0); |
| 290 | 290 |
| 291 resetSkiaTextureBinding(); | 291 resetSkiaTextureBinding(); |
| 292 } | 292 } |
| 293 | 293 |
| 294 void Canvas2DLayerBridge::clearCHROMIUMImageCache() | 294 void Canvas2DLayerBridge::clearCHROMIUMImageCache() |
| 295 { | 295 { |
| 296 for (const auto& it : m_imageInfoCache) { | 296 for (const auto& it : m_imageInfoCache) { |
| 297 deleteCHROMIUMImage(it); | 297 deleteCHROMIUMImage(it); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 // Because of texture sharing with the compositor, we must invalidate | 340 // Because of texture sharing with the compositor, we must invalidate |
| 341 // the state cached in skia so that the deferred copy on write | 341 // the state cached in skia so that the deferred copy on write |
| 342 // in SkSurface_Gpu does not make any false assumptions. | 342 // in SkSurface_Gpu does not make any false assumptions. |
| 343 mailboxInfo.m_image->getTexture()->textureParamsModified(); | 343 mailboxInfo.m_image->getTexture()->textureParamsModified(); |
| 344 mailboxInfo.m_mailbox.textureTarget = GL_TEXTURE_2D; | 344 mailboxInfo.m_mailbox.textureTarget = GL_TEXTURE_2D; |
| 345 | 345 |
| 346 WebGraphicsContext3D* webContext = context(); | 346 WebGraphicsContext3D* webContext = context(); |
| 347 gpu::gles2::GLES2Interface* gl = contextGL(); | 347 gpu::gles2::GLES2Interface* gl = contextGL(); |
| 348 GLuint textureID = skia::GrBackendObjectToGrGLTextureInfo(mailboxInfo.m_imag
e->getTextureHandle(true))->fID; | 348 GLuint textureID = skia::GrBackendObjectToGrGLTextureInfo(mailboxInfo.m_imag
e->getTextureHandle(true))->fID; |
| 349 gl->BindTexture(GL_TEXTURE_2D, textureID); | 349 gl->BindTexture(GL_TEXTURE_2D, textureID); |
| 350 webContext->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, getGLFilter(
)); | 350 gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, getGLFilter()); |
| 351 webContext->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, getGLFilter(
)); | 351 gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, getGLFilter()); |
| 352 webContext->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE
); | 352 gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
| 353 webContext->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE
); | 353 gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
| 354 | 354 |
| 355 // Re-use the texture's existing mailbox, if there is one. | 355 // Re-use the texture's existing mailbox, if there is one. |
| 356 if (mailboxInfo.m_image->getTexture()->getCustomData()) { | 356 if (mailboxInfo.m_image->getTexture()->getCustomData()) { |
| 357 ASSERT(mailboxInfo.m_image->getTexture()->getCustomData()->size() == siz
eof(mailboxInfo.m_mailbox.name)); | 357 ASSERT(mailboxInfo.m_image->getTexture()->getCustomData()->size() == siz
eof(mailboxInfo.m_mailbox.name)); |
| 358 memcpy(&mailboxInfo.m_mailbox.name[0], mailboxInfo.m_image->getTexture()
->getCustomData()->data(), sizeof(mailboxInfo.m_mailbox.name)); | 358 memcpy(&mailboxInfo.m_mailbox.name[0], mailboxInfo.m_image->getTexture()
->getCustomData()->data(), sizeof(mailboxInfo.m_mailbox.name)); |
| 359 } else { | 359 } else { |
| 360 gl->GenMailboxCHROMIUM(mailboxInfo.m_mailbox.name); | 360 gl->GenMailboxCHROMIUM(mailboxInfo.m_mailbox.name); |
| 361 RefPtr<SkData> mailboxNameData = adoptRef(SkData::NewWithCopy(&mailboxIn
fo.m_mailbox.name[0], sizeof(mailboxInfo.m_mailbox.name))); | 361 RefPtr<SkData> mailboxNameData = adoptRef(SkData::NewWithCopy(&mailboxIn
fo.m_mailbox.name[0], sizeof(mailboxInfo.m_mailbox.name))); |
| 362 mailboxInfo.m_image->getTexture()->setCustomData(mailboxNameData.get()); | 362 mailboxInfo.m_image->getTexture()->setCustomData(mailboxNameData.get()); |
| 363 gl->ProduceTextureCHROMIUM(GL_TEXTURE_2D, mailboxInfo.m_mailbox.name); | 363 gl->ProduceTextureCHROMIUM(GL_TEXTURE_2D, mailboxInfo.m_mailbox.name); |
| (...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1006 #endif // USE_IOSURFACE_FOR_2D_CANVAS | 1006 #endif // USE_IOSURFACE_FOR_2D_CANVAS |
| 1007 } | 1007 } |
| 1008 | 1008 |
| 1009 void Canvas2DLayerBridge::Logger::reportHibernationEvent(HibernationEvent event) | 1009 void Canvas2DLayerBridge::Logger::reportHibernationEvent(HibernationEvent event) |
| 1010 { | 1010 { |
| 1011 DEFINE_STATIC_LOCAL(EnumerationHistogram, hibernationHistogram, ("Canvas.Hib
ernationEvents", HibernationEventCount)); | 1011 DEFINE_STATIC_LOCAL(EnumerationHistogram, hibernationHistogram, ("Canvas.Hib
ernationEvents", HibernationEventCount)); |
| 1012 hibernationHistogram.count(event); | 1012 hibernationHistogram.count(event); |
| 1013 } | 1013 } |
| 1014 | 1014 |
| 1015 } // namespace blink | 1015 } // namespace blink |
| OLD | NEW |