Chromium Code Reviews| 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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 187 // Invalidate texture state in case the compositor altered it since the copy-on-write. | 188 // Invalidate texture state in case the compositor altered it since the copy-on-write. |
| 188 mailboxInfo->m_image->getTexture()->invalidateCachedState(); | 189 mailboxInfo->m_image->getTexture()->invalidateCachedState(); |
| 189 mailboxInfo->m_image.reset(0); | 190 mailboxInfo->m_image.reset(0); |
| 190 mailboxInfo->m_status = MailboxAvailable; | 191 mailboxInfo->m_status = MailboxAvailable; |
| 191 } | 192 } |
| 192 } | 193 } |
| 193 SkAutoTUnref<SkImage> image(m_canvas->newImageSnapshot()); | 194 SkAutoTUnref<SkImage> image(m_canvas->newImageSnapshot()); |
| 194 // Early exit if canvas was not drawn to since last prepareMailbox | 195 // Early exit if canvas was not drawn to since last prepareMailbox |
| 195 if (image->uniqueID() == m_lastImageId) | 196 if (image->uniqueID() == m_lastImageId) |
| 196 return false; | 197 return false; |
| 198 PlatformInstrumentation::willRasterizeCanvas(); | |
|
Justin Novosad
2013/06/26 21:06:49
This will only measure deferred canvas rendering i
caseq
2013/06/27 17:03:50
Thanks, Justin, it's very helpful! I was originall
| |
| 197 m_lastImageId = image->uniqueID(); | 199 m_lastImageId = image->uniqueID(); |
| 198 | 200 |
| 199 mailboxInfo = createMailboxInfo(); | 201 mailboxInfo = createMailboxInfo(); |
| 200 mailboxInfo->m_status = MailboxInUse; | 202 mailboxInfo->m_status = MailboxInUse; |
| 201 mailboxInfo->m_image.swap(&image); | 203 mailboxInfo->m_image.swap(&image); |
| 202 // Because of texture sharing with the compositor, we must invalidate | 204 // Because of texture sharing with the compositor, we must invalidate |
| 203 // the state cached in skia so that the deferred copy on write | 205 // the state cached in skia so that the deferred copy on write |
| 204 // in SkSurface_Gpu does not make any false assumptions. | 206 // in SkSurface_Gpu does not make any false assumptions. |
| 205 mailboxInfo->m_image->getTexture()->invalidateCachedState(); | 207 mailboxInfo->m_image->getTexture()->invalidateCachedState(); |
| 206 | 208 |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 217 context()->flush(); | 219 context()->flush(); |
| 218 mailboxInfo->m_mailbox.syncPoint = context()->insertSyncPoint(); | 220 mailboxInfo->m_mailbox.syncPoint = context()->insertSyncPoint(); |
| 219 m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, 0); | 221 m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, 0); |
| 220 // Because we are changing the texture binding without going through skia, | 222 // Because we are changing the texture binding without going through skia, |
| 221 // we must dirty the context. | 223 // we must dirty the context. |
| 222 // TODO(piman): expose finer granularity reset. We only really want to | 224 // TODO(piman): expose finer granularity reset. We only really want to |
| 223 // 'dirty' the current texture binding. | 225 // 'dirty' the current texture binding. |
| 224 m_context->grContext()->resetContext(); | 226 m_context->grContext()->resetContext(); |
| 225 | 227 |
| 226 *outMailbox = mailboxInfo->m_mailbox; | 228 *outMailbox = mailboxInfo->m_mailbox; |
| 229 PlatformInstrumentation::didRasterizeCanvas(); | |
| 227 return true; | 230 return true; |
| 228 #else | 231 #else |
| 229 ASSERT_NOT_REACHED(); | 232 ASSERT_NOT_REACHED(); |
| 230 return false; | 233 return false; |
| 231 #endif | 234 #endif |
| 232 } | 235 } |
| 233 | 236 |
| 234 #if ENABLE(CANVAS_USES_MAILBOX) | 237 #if ENABLE(CANVAS_USES_MAILBOX) |
| 235 Canvas2DLayerBridge::MailboxInfo* Canvas2DLayerBridge::createMailboxInfo() { | 238 Canvas2DLayerBridge::MailboxInfo* Canvas2DLayerBridge::createMailboxInfo() { |
| 236 MailboxInfo* mailboxInfo; | 239 MailboxInfo* mailboxInfo; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 300 // This copy constructor should only be used for Vector reallocation | 303 // This copy constructor should only be used for Vector reallocation |
| 301 // Assuming 'other' is to be destroyed, we swap m_image ownership | 304 // Assuming 'other' is to be destroyed, we swap m_image ownership |
| 302 // rather than do a refcount dance. | 305 // rather than do a refcount dance. |
| 303 memcpy(&m_mailbox, &other.m_mailbox, sizeof(m_mailbox)); | 306 memcpy(&m_mailbox, &other.m_mailbox, sizeof(m_mailbox)); |
| 304 m_image.swap(const_cast<SkAutoTUnref<SkImage>*>(&other.m_image)); | 307 m_image.swap(const_cast<SkAutoTUnref<SkImage>*>(&other.m_image)); |
| 305 m_status = other.m_status; | 308 m_status = other.m_status; |
| 306 } | 309 } |
| 307 #endif | 310 #endif |
| 308 | 311 |
| 309 } | 312 } |
| OLD | NEW |