| 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 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 MailboxInfo& info = m_mailboxes.first(); | 210 MailboxInfo& info = m_mailboxes.first(); |
| 211 info.m_mailbox.textureTarget = GC3D_TEXTURE_RECTANGLE_ARB; | 211 info.m_mailbox.textureTarget = GC3D_TEXTURE_RECTANGLE_ARB; |
| 212 gl->GenMailboxCHROMIUM(info.m_mailbox.name); | 212 gl->GenMailboxCHROMIUM(info.m_mailbox.name); |
| 213 gl->ProduceTextureDirectCHROMIUM(imageInfo.m_textureId, info.m_mailbox.textu
reTarget, info.m_mailbox.name); | 213 gl->ProduceTextureDirectCHROMIUM(imageInfo.m_textureId, info.m_mailbox.textu
reTarget, info.m_mailbox.name); |
| 214 info.m_mailbox.allowOverlay = true; | 214 info.m_mailbox.allowOverlay = true; |
| 215 | 215 |
| 216 const GLuint64 fenceSync = gl->InsertFenceSyncCHROMIUM(); | 216 const GLuint64 fenceSync = gl->InsertFenceSyncCHROMIUM(); |
| 217 gl->Flush(); | 217 gl->Flush(); |
| 218 gl->GenSyncTokenCHROMIUM(fenceSync, info.m_mailbox.syncToken); | 218 gl->GenSyncTokenCHROMIUM(fenceSync, info.m_mailbox.syncToken); |
| 219 info.m_mailbox.validSyncToken = true; | 219 info.m_mailbox.validSyncToken = true; |
| 220 info.m_mailbox.gpuMemoryBufferId = imageInfo.m_gpuMemoryBufferId; |
| 220 | 221 |
| 221 info.m_imageInfo = imageInfo; | 222 info.m_imageInfo = imageInfo; |
| 222 *outMailbox = info.m_mailbox; | 223 *outMailbox = info.m_mailbox; |
| 223 | 224 |
| 224 gl->BindTexture(GC3D_TEXTURE_RECTANGLE_ARB, 0); | 225 gl->BindTexture(GC3D_TEXTURE_RECTANGLE_ARB, 0); |
| 225 | 226 |
| 226 // Because we are changing the texture binding without going through skia, | 227 // Because we are changing the texture binding without going through skia, |
| 227 // we must dirty the context. | 228 // we must dirty the context. |
| 228 grContext->resetContext(kTextureBinding_GrGLBackendState); | 229 grContext->resetContext(kTextureBinding_GrGLBackendState); |
| 229 | 230 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 249 GLuint textureId; | 250 GLuint textureId; |
| 250 gl->GenTextures(1, &textureId); | 251 gl->GenTextures(1, &textureId); |
| 251 GLenum target = GC3D_TEXTURE_RECTANGLE_ARB; | 252 GLenum target = GC3D_TEXTURE_RECTANGLE_ARB; |
| 252 gl->BindTexture(target, textureId); | 253 gl->BindTexture(target, textureId); |
| 253 gl->TexParameteri(target, GL_TEXTURE_MAG_FILTER, getGLFilter()); | 254 gl->TexParameteri(target, GL_TEXTURE_MAG_FILTER, getGLFilter()); |
| 254 gl->TexParameteri(target, GL_TEXTURE_MIN_FILTER, getGLFilter()); | 255 gl->TexParameteri(target, GL_TEXTURE_MIN_FILTER, getGLFilter()); |
| 255 gl->TexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); | 256 gl->TexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
| 256 gl->TexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); | 257 gl->TexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
| 257 gl->BindTexImage2DCHROMIUM(target, imageId); | 258 gl->BindTexImage2DCHROMIUM(target, imageId); |
| 258 | 259 |
| 259 return Canvas2DLayerBridge::ImageInfo(imageId, textureId); | 260 GLint gpuMemoryBufferId = -1; |
| 261 gl->GetImageivCHROMIUM(imageId, GC3D_GPU_MEMORY_BUFFER_ID, &gpuMemoryBufferI
d); |
| 262 DCHECK_NE(-1, gpuMemoryBufferId); |
| 263 |
| 264 return Canvas2DLayerBridge::ImageInfo(imageId, textureId, gpuMemoryBufferId)
; |
| 260 } | 265 } |
| 261 | 266 |
| 262 void Canvas2DLayerBridge::deleteCHROMIUMImage(ImageInfo info) | 267 void Canvas2DLayerBridge::deleteCHROMIUMImage(ImageInfo info) |
| 263 { | 268 { |
| 264 gpu::gles2::GLES2Interface* gl = contextGL(); | 269 gpu::gles2::GLES2Interface* gl = contextGL(); |
| 265 if (!gl) | 270 if (!gl) |
| 266 return; | 271 return; |
| 267 | 272 |
| 268 GLenum target = GC3D_TEXTURE_RECTANGLE_ARB; | 273 GLenum target = GC3D_TEXTURE_RECTANGLE_ARB; |
| 269 gl->BindTexture(target, info.m_textureId); | 274 gl->BindTexture(target, info.m_textureId); |
| (...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 954 getOrCreateSurface()->notifyContentWillChange(SkSurface::kRetain_ContentChan
geMode); | 959 getOrCreateSurface()->notifyContentWillChange(SkSurface::kRetain_ContentChan
geMode); |
| 955 return adoptRef(m_surface->newImageSnapshot()); | 960 return adoptRef(m_surface->newImageSnapshot()); |
| 956 } | 961 } |
| 957 | 962 |
| 958 void Canvas2DLayerBridge::willOverwriteCanvas() | 963 void Canvas2DLayerBridge::willOverwriteCanvas() |
| 959 { | 964 { |
| 960 skipQueuedDrawCommands(); | 965 skipQueuedDrawCommands(); |
| 961 } | 966 } |
| 962 | 967 |
| 963 #if USE_IOSURFACE_FOR_2D_CANVAS | 968 #if USE_IOSURFACE_FOR_2D_CANVAS |
| 964 Canvas2DLayerBridge::ImageInfo::ImageInfo(GLuint imageId, GLuint textureId) : m_
imageId(imageId), m_textureId(textureId) | 969 Canvas2DLayerBridge::ImageInfo::ImageInfo(GLuint imageId, GLuint textureId, GLin
t gpuMemoryBufferId) |
| 970 : m_imageId(imageId) |
| 971 , m_textureId(textureId) |
| 972 , m_gpuMemoryBufferId(gpuMemoryBufferId) |
| 965 { | 973 { |
| 966 ASSERT(imageId); | 974 ASSERT(imageId); |
| 967 ASSERT(textureId); | 975 ASSERT(textureId); |
| 976 DCHECK_NE(-1, gpuMemoryBufferId); |
| 968 } | 977 } |
| 969 | 978 |
| 970 bool Canvas2DLayerBridge::ImageInfo::empty() | 979 bool Canvas2DLayerBridge::ImageInfo::empty() |
| 971 { | 980 { |
| 972 return m_imageId == 0; | 981 return m_imageId == 0; |
| 973 } | 982 } |
| 974 #endif // USE_IOSURFACE_FOR_2D_CANVAS | 983 #endif // USE_IOSURFACE_FOR_2D_CANVAS |
| 975 | 984 |
| 976 Canvas2DLayerBridge::MailboxInfo::MailboxInfo(const MailboxInfo& other) | 985 Canvas2DLayerBridge::MailboxInfo::MailboxInfo(const MailboxInfo& other) |
| 977 { | 986 { |
| 978 memcpy(&m_mailbox, &other.m_mailbox, sizeof(m_mailbox)); | 987 memcpy(&m_mailbox, &other.m_mailbox, sizeof(m_mailbox)); |
| 979 m_image = other.m_image; | 988 m_image = other.m_image; |
| 980 m_parentLayerBridge = other.m_parentLayerBridge; | 989 m_parentLayerBridge = other.m_parentLayerBridge; |
| 981 #if USE_IOSURFACE_FOR_2D_CANVAS | 990 #if USE_IOSURFACE_FOR_2D_CANVAS |
| 982 m_imageInfo = other.m_imageInfo; | 991 m_imageInfo = other.m_imageInfo; |
| 983 #endif // USE_IOSURFACE_FOR_2D_CANVAS | 992 #endif // USE_IOSURFACE_FOR_2D_CANVAS |
| 984 } | 993 } |
| 985 | 994 |
| 986 void Canvas2DLayerBridge::Logger::reportHibernationEvent(HibernationEvent event) | 995 void Canvas2DLayerBridge::Logger::reportHibernationEvent(HibernationEvent event) |
| 987 { | 996 { |
| 988 DEFINE_STATIC_LOCAL(EnumerationHistogram, hibernationHistogram, ("Canvas.Hib
ernationEvents", HibernationEventCount)); | 997 DEFINE_STATIC_LOCAL(EnumerationHistogram, hibernationHistogram, ("Canvas.Hib
ernationEvents", HibernationEventCount)); |
| 989 hibernationHistogram.count(event); | 998 hibernationHistogram.count(event); |
| 990 } | 999 } |
| 991 | 1000 |
| 992 } // namespace blink | 1001 } // namespace blink |
| OLD | NEW |