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 21 matching lines...) Expand all Loading... |
32 #include "platform/graphics/ExpensiveCanvasHeuristicParameters.h" | 32 #include "platform/graphics/ExpensiveCanvasHeuristicParameters.h" |
33 #include "platform/graphics/GraphicsLayer.h" | 33 #include "platform/graphics/GraphicsLayer.h" |
34 #include "platform/graphics/ImageBuffer.h" | 34 #include "platform/graphics/ImageBuffer.h" |
35 #include "platform/graphics/gpu/SharedContextRateLimiter.h" | 35 #include "platform/graphics/gpu/SharedContextRateLimiter.h" |
36 #include "public/platform/Platform.h" | 36 #include "public/platform/Platform.h" |
37 #include "public/platform/WebCompositorSupport.h" | 37 #include "public/platform/WebCompositorSupport.h" |
38 #include "public/platform/WebGraphicsContext3D.h" | 38 #include "public/platform/WebGraphicsContext3D.h" |
39 #include "public/platform/WebGraphicsContext3DProvider.h" | 39 #include "public/platform/WebGraphicsContext3DProvider.h" |
40 #include "public/platform/WebScheduler.h" | 40 #include "public/platform/WebScheduler.h" |
41 #include "public/platform/WebTraceLocation.h" | 41 #include "public/platform/WebTraceLocation.h" |
| 42 #include "skia/ext/texture_handle.h" |
42 #include "third_party/skia/include/core/SkData.h" | 43 #include "third_party/skia/include/core/SkData.h" |
43 #include "third_party/skia/include/core/SkPictureRecorder.h" | 44 #include "third_party/skia/include/core/SkPictureRecorder.h" |
44 #include "third_party/skia/include/core/SkSurface.h" | 45 #include "third_party/skia/include/core/SkSurface.h" |
45 #include "third_party/skia/include/gpu/GrContext.h" | 46 #include "third_party/skia/include/gpu/GrContext.h" |
| 47 #include "third_party/skia/include/gpu/gl/GrGLTypes.h" |
46 #include "wtf/RefCountedLeakCounter.h" | 48 #include "wtf/RefCountedLeakCounter.h" |
47 | 49 |
48 namespace { | 50 namespace { |
49 enum { | 51 enum { |
50 InvalidMailboxIndex = -1, | 52 InvalidMailboxIndex = -1, |
51 MaxCanvasAnimationBacklog = 2, // Make sure the the GPU is never more than t
wo animation frames behind. | 53 MaxCanvasAnimationBacklog = 2, // Make sure the the GPU is never more than t
wo animation frames behind. |
52 }; | 54 }; |
53 | 55 |
54 #ifndef NDEBUG | 56 #ifndef NDEBUG |
55 WTF::RefCountedLeakCounter& canvas2DLayerBridgeInstanceCounter() | 57 WTF::RefCountedLeakCounter& canvas2DLayerBridgeInstanceCounter() |
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
629 | 631 |
630 mailboxInfo.m_mailbox.nearestNeighbor = filter == GL_NEAREST; | 632 mailboxInfo.m_mailbox.nearestNeighbor = filter == GL_NEAREST; |
631 | 633 |
632 GrContext* grContext = m_contextProvider->grContext(); | 634 GrContext* grContext = m_contextProvider->grContext(); |
633 if (!grContext) | 635 if (!grContext) |
634 return true; // for testing: skip gl stuff when using a mock graphics co
ntext. | 636 return true; // for testing: skip gl stuff when using a mock graphics co
ntext. |
635 | 637 |
636 if (RuntimeEnabledFeatures::forceDisable2dCanvasCopyOnWriteEnabled()) | 638 if (RuntimeEnabledFeatures::forceDisable2dCanvasCopyOnWriteEnabled()) |
637 m_surface->notifyContentWillChange(SkSurface::kRetain_ContentChangeMode)
; | 639 m_surface->notifyContentWillChange(SkSurface::kRetain_ContentChangeMode)
; |
638 | 640 |
639 // Need to flush skia's internal queue because texture is about to be access
ed directly | |
640 grContext->flush(); | |
641 | |
642 // Because of texture sharing with the compositor, we must invalidate | 641 // Because of texture sharing with the compositor, we must invalidate |
643 // the state cached in skia so that the deferred copy on write | 642 // the state cached in skia so that the deferred copy on write |
644 // in SkSurface_Gpu does not make any false assumptions. | 643 // in SkSurface_Gpu does not make any false assumptions. |
645 mailboxInfo.m_image->getTexture()->textureParamsModified(); | 644 mailboxInfo.m_image->getTexture()->textureParamsModified(); |
646 mailboxInfo.m_mailbox.textureTarget = GL_TEXTURE_2D; | 645 mailboxInfo.m_mailbox.textureTarget = GL_TEXTURE_2D; |
647 | 646 |
648 webContext->bindTexture(GL_TEXTURE_2D, mailboxInfo.m_image->getTexture()->ge
tTextureHandle()); | 647 // Passing true because we need to flush skia's internal queue since texture
is about to be accessed directly |
| 648 GLuint textureID = skia::GrBackendObjectToGrGLTextureInfo(mailboxInfo.m_imag
e->getTextureHandle(true))->fID; |
| 649 webContext->bindTexture(GL_TEXTURE_2D, textureID); |
649 webContext->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter); | 650 webContext->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter); |
650 webContext->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter); | 651 webContext->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter); |
651 webContext->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE
); | 652 webContext->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE
); |
652 webContext->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE
); | 653 webContext->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE
); |
653 | 654 |
654 // Re-use the texture's existing mailbox, if there is one. | 655 // Re-use the texture's existing mailbox, if there is one. |
655 if (image->getTexture()->getCustomData()) { | 656 if (image->getTexture()->getCustomData()) { |
656 ASSERT(image->getTexture()->getCustomData()->size() == sizeof(mailboxInf
o.m_mailbox.name)); | 657 ASSERT(image->getTexture()->getCustomData()->size() == sizeof(mailboxInf
o.m_mailbox.name)); |
657 memcpy(&mailboxInfo.m_mailbox.name[0], image->getTexture()->getCustomDat
a()->data(), sizeof(mailboxInfo.m_mailbox.name)); | 658 memcpy(&mailboxInfo.m_mailbox.name[0], image->getTexture()->getCustomDat
a()->data(), sizeof(mailboxInfo.m_mailbox.name)); |
658 } else { | 659 } else { |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
829 m_parentLayerBridge = other.m_parentLayerBridge; | 830 m_parentLayerBridge = other.m_parentLayerBridge; |
830 } | 831 } |
831 | 832 |
832 void Canvas2DLayerBridge::Logger::reportHibernationEvent(HibernationEvent event) | 833 void Canvas2DLayerBridge::Logger::reportHibernationEvent(HibernationEvent event) |
833 { | 834 { |
834 DEFINE_STATIC_LOCAL(EnumerationHistogram, hibernationHistogram, ("Canvas.Hib
ernationEvents", HibernationEventCount)); | 835 DEFINE_STATIC_LOCAL(EnumerationHistogram, hibernationHistogram, ("Canvas.Hib
ernationEvents", HibernationEventCount)); |
835 hibernationHistogram.count(event); | 836 hibernationHistogram.count(event); |
836 } | 837 } |
837 | 838 |
838 } // namespace blink | 839 } // namespace blink |
OLD | NEW |