| 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 12 matching lines...) Expand all Loading... |
| 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #include "config.h" | 26 #include "config.h" |
| 27 | 27 |
| 28 #include "core/platform/graphics/chromium/Canvas2DLayerBridge.h" | 28 #include "core/platform/graphics/chromium/Canvas2DLayerBridge.h" |
| 29 | 29 |
| 30 #include "GrContext.h" | 30 #include "GrContext.h" |
| 31 #include "SkDevice.h" | 31 #include "SkDevice.h" |
| 32 #include "SkSurface.h" | 32 #include "SkSurface.h" |
| 33 #include "core/platform/PlatformInstrumentation.h" |
| 33 #include "core/platform/chromium/TraceEvent.h" | 34 #include "core/platform/chromium/TraceEvent.h" |
| 34 #include "core/platform/graphics/GraphicsContext3D.h" | 35 #include "core/platform/graphics/GraphicsContext3D.h" |
| 35 #include "core/platform/graphics/GraphicsLayer.h" | 36 #include "core/platform/graphics/GraphicsLayer.h" |
| 36 #include "core/platform/graphics/chromium/Canvas2DLayerManager.h" | 37 #include "core/platform/graphics/chromium/Canvas2DLayerManager.h" |
| 37 #include "public/platform/Platform.h" | 38 #include "public/platform/Platform.h" |
| 38 #include "public/platform/WebCompositorSupport.h" | 39 #include "public/platform/WebCompositorSupport.h" |
| 39 #include "public/platform/WebGraphicsContext3D.h" | 40 #include "public/platform/WebGraphicsContext3D.h" |
| 40 | 41 |
| 41 using WebKit::WebExternalTextureLayer; | 42 using WebKit::WebExternalTextureLayer; |
| 42 using WebKit::WebGraphicsContext3D; | 43 using WebKit::WebGraphicsContext3D; |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 // Invalidate texture state in case the compositor altered it since
the copy-on-write. | 187 // Invalidate texture state in case the compositor altered it since
the copy-on-write. |
| 187 mailboxInfo->m_image->getTexture()->invalidateCachedState(); | 188 mailboxInfo->m_image->getTexture()->invalidateCachedState(); |
| 188 mailboxInfo->m_image.reset(0); | 189 mailboxInfo->m_image.reset(0); |
| 189 mailboxInfo->m_status = MailboxAvailable; | 190 mailboxInfo->m_status = MailboxAvailable; |
| 190 } | 191 } |
| 191 } | 192 } |
| 192 SkAutoTUnref<SkImage> image(m_canvas->newImageSnapshot()); | 193 SkAutoTUnref<SkImage> image(m_canvas->newImageSnapshot()); |
| 193 // Early exit if canvas was not drawn to since last prepareMailbox | 194 // Early exit if canvas was not drawn to since last prepareMailbox |
| 194 if (image->uniqueID() == m_lastImageId) | 195 if (image->uniqueID() == m_lastImageId) |
| 195 return false; | 196 return false; |
| 197 PlatformInstrumentation::willRasterizeCanvas(); |
| 196 m_lastImageId = image->uniqueID(); | 198 m_lastImageId = image->uniqueID(); |
| 197 | 199 |
| 198 mailboxInfo = createMailboxInfo(); | 200 mailboxInfo = createMailboxInfo(); |
| 199 mailboxInfo->m_status = MailboxInUse; | 201 mailboxInfo->m_status = MailboxInUse; |
| 200 mailboxInfo->m_image.swap(&image); | 202 mailboxInfo->m_image.swap(&image); |
| 201 // Because of texture sharing with the compositor, we must invalidate | 203 // Because of texture sharing with the compositor, we must invalidate |
| 202 // the state cached in skia so that the deferred copy on write | 204 // the state cached in skia so that the deferred copy on write |
| 203 // in SkSurface_Gpu does not make any false assumptions. | 205 // in SkSurface_Gpu does not make any false assumptions. |
| 204 mailboxInfo->m_image->getTexture()->invalidateCachedState(); | 206 mailboxInfo->m_image->getTexture()->invalidateCachedState(); |
| 205 | 207 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 216 m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::T
EXTURE_MAG_FILTER, GraphicsContext3D::LINEAR); | 218 m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::T
EXTURE_MAG_FILTER, GraphicsContext3D::LINEAR); |
| 217 m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::T
EXTURE_MIN_FILTER, GraphicsContext3D::LINEAR); | 219 m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::T
EXTURE_MIN_FILTER, GraphicsContext3D::LINEAR); |
| 218 m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::T
EXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE); | 220 m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::T
EXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE); |
| 219 m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::T
EXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE); | 221 m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::T
EXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE); |
| 220 context()->produceTextureCHROMIUM(GraphicsContext3D::TEXTURE_2D, mailboxInfo
->m_mailbox.name); | 222 context()->produceTextureCHROMIUM(GraphicsContext3D::TEXTURE_2D, mailboxInfo
->m_mailbox.name); |
| 221 context()->flush(); | 223 context()->flush(); |
| 222 mailboxInfo->m_mailbox.syncPoint = context()->insertSyncPoint(); | 224 mailboxInfo->m_mailbox.syncPoint = context()->insertSyncPoint(); |
| 223 m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, savedTexBinding); | 225 m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, savedTexBinding); |
| 224 | 226 |
| 225 *outMailbox = mailboxInfo->m_mailbox; | 227 *outMailbox = mailboxInfo->m_mailbox; |
| 228 PlatformInstrumentation::didRasterizeCanvas(); |
| 226 return true; | 229 return true; |
| 227 #else | 230 #else |
| 228 ASSERT_NOT_REACHED(); | 231 ASSERT_NOT_REACHED(); |
| 229 return false; | 232 return false; |
| 230 #endif | 233 #endif |
| 231 } | 234 } |
| 232 | 235 |
| 233 #if ENABLE(CANVAS_USES_MAILBOX) | 236 #if ENABLE(CANVAS_USES_MAILBOX) |
| 234 Canvas2DLayerBridge::MailboxInfo* Canvas2DLayerBridge::createMailboxInfo() { | 237 Canvas2DLayerBridge::MailboxInfo* Canvas2DLayerBridge::createMailboxInfo() { |
| 235 MailboxInfo* mailboxInfo; | 238 MailboxInfo* mailboxInfo; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 // This copy constructor should only be used for Vector reallocation | 302 // This copy constructor should only be used for Vector reallocation |
| 300 // Assuming 'other' is to be destroyed, we swap m_image ownership | 303 // Assuming 'other' is to be destroyed, we swap m_image ownership |
| 301 // rather than do a refcount dance. | 304 // rather than do a refcount dance. |
| 302 memcpy(&m_mailbox, &other.m_mailbox, sizeof(m_mailbox)); | 305 memcpy(&m_mailbox, &other.m_mailbox, sizeof(m_mailbox)); |
| 303 m_image.swap(const_cast<SkAutoTUnref<SkImage>*>(&other.m_image)); | 306 m_image.swap(const_cast<SkAutoTUnref<SkImage>*>(&other.m_image)); |
| 304 m_status = other.m_status; | 307 m_status = other.m_status; |
| 305 } | 308 } |
| 306 #endif | 309 #endif |
| 307 | 310 |
| 308 } | 311 } |
| OLD | NEW |