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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 , m_isRegisteredTaskObserver(false) | 105 , m_isRegisteredTaskObserver(false) |
106 , m_renderingTaskCompletedForCurrentFrame(false) | 106 , m_renderingTaskCompletedForCurrentFrame(false) |
107 , m_softwareRenderingWhileHidden(false) | 107 , m_softwareRenderingWhileHidden(false) |
108 , m_lastImageId(0) | 108 , m_lastImageId(0) |
109 , m_lastFilter(GL_LINEAR) | 109 , m_lastFilter(GL_LINEAR) |
110 , m_accelerationMode(accelerationMode) | 110 , m_accelerationMode(accelerationMode) |
111 , m_opacityMode(opacityMode) | 111 , m_opacityMode(opacityMode) |
112 , m_size(size) | 112 , m_size(size) |
113 { | 113 { |
114 DCHECK(m_contextProvider); | 114 DCHECK(m_contextProvider); |
| 115 DCHECK(!m_contextProvider->isSoftwareRendering()); |
115 // Used by browser tests to detect the use of a Canvas2DLayerBridge. | 116 // Used by browser tests to detect the use of a Canvas2DLayerBridge. |
116 TRACE_EVENT_INSTANT0("test_gpu", "Canvas2DLayerBridgeCreation", TRACE_EVENT_
SCOPE_GLOBAL); | 117 TRACE_EVENT_INSTANT0("test_gpu", "Canvas2DLayerBridgeCreation", TRACE_EVENT_
SCOPE_GLOBAL); |
117 startRecording(); | 118 startRecording(); |
118 } | 119 } |
119 | 120 |
120 Canvas2DLayerBridge::~Canvas2DLayerBridge() | 121 Canvas2DLayerBridge::~Canvas2DLayerBridge() |
121 { | 122 { |
122 DCHECK(m_destructionInProgress); | 123 DCHECK(m_destructionInProgress); |
123 #if USE_IOSURFACE_FOR_2D_CANVAS | 124 #if USE_IOSURFACE_FOR_2D_CANVAS |
124 clearCHROMIUMImageCache(); | 125 clearCHROMIUMImageCache(); |
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
755 } | 756 } |
756 } | 757 } |
757 if (m_imageBuffer) | 758 if (m_imageBuffer) |
758 m_imageBuffer->updateGPUMemoryUsage(); | 759 m_imageBuffer->updateGPUMemoryUsage(); |
759 | 760 |
760 return m_surface.get(); | 761 return m_surface.get(); |
761 } | 762 } |
762 | 763 |
763 bool Canvas2DLayerBridge::PrepareTextureMailbox( | 764 bool Canvas2DLayerBridge::PrepareTextureMailbox( |
764 cc::TextureMailbox* outMailbox, | 765 cc::TextureMailbox* outMailbox, |
765 std::unique_ptr<cc::SingleReleaseCallback>* outReleaseCallback, | 766 std::unique_ptr<cc::SingleReleaseCallback>* outReleaseCallback) |
766 bool useSharedMemory) | |
767 { | 767 { |
768 if (m_destructionInProgress) { | 768 if (m_destructionInProgress) { |
769 // It can be hit in the following sequence. | 769 // It can be hit in the following sequence. |
770 // 1. Canvas draws something. | 770 // 1. Canvas draws something. |
771 // 2. The compositor begins the frame. | 771 // 2. The compositor begins the frame. |
772 // 3. Javascript makes a context be lost. | 772 // 3. Javascript makes a context be lost. |
773 // 4. Here. | 773 // 4. Here. |
774 return false; | 774 return false; |
775 } | 775 } |
776 DCHECK(isAccelerated() || isHibernating() || m_softwareRenderingWhileHidden)
; | 776 DCHECK(isAccelerated() || isHibernating() || m_softwareRenderingWhileHidden)
; |
777 | 777 |
778 // if hibernating but not hidden, we want to wake up from | 778 // if hibernating but not hidden, we want to wake up from |
779 // hibernation | 779 // hibernation |
780 if ((isHibernating() || m_softwareRenderingWhileHidden) && isHidden()) | 780 if ((isHibernating() || m_softwareRenderingWhileHidden) && isHidden()) |
781 return false; | 781 return false; |
782 | 782 |
783 // TODO(danakj): This means the compositor has dropped to software | |
784 // compositing. Our context should already be lost if cc can't make a | |
785 // context that it can use (each time it tries it loses our context). | |
786 // But checkSurfaceValid() returns true even tho there is a GL error | |
787 // sometimes.. so not sure if just checking for a GL error is right here | |
788 // or what. | |
789 if (useSharedMemory) { | |
790 // Since we're going to software compositing, this class will soon be | |
791 // destroyed for software mode canvas. | |
792 return false; | |
793 } | |
794 | |
795 // If the context is lost, we don't know if we should be producing GPU or | 783 // If the context is lost, we don't know if we should be producing GPU or |
796 // software frames, until we get a new context, since the compositor will | 784 // software frames, until we get a new context, since the compositor will |
797 // be trying to get a new context and may change modes. | 785 // be trying to get a new context and may change modes. |
798 if (m_contextProvider->contextGL()->GetGraphicsResetStatusKHR() != GL_NO_ERR
OR) | 786 if (m_contextProvider->contextGL()->GetGraphicsResetStatusKHR() != GL_NO_ERR
OR) |
799 return false; | 787 return false; |
800 | 788 |
801 RefPtr<SkImage> image = newImageSnapshot(PreferAcceleration, SnapshotReasonU
nknown); | 789 RefPtr<SkImage> image = newImageSnapshot(PreferAcceleration, SnapshotReasonU
nknown); |
802 if (!image || !image->getTexture()) | 790 if (!image || !image->getTexture()) |
803 return false; | 791 return false; |
804 | 792 |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
997 Canvas2DLayerBridge::MailboxInfo::MailboxInfo() = default; | 985 Canvas2DLayerBridge::MailboxInfo::MailboxInfo() = default; |
998 Canvas2DLayerBridge::MailboxInfo::MailboxInfo(const MailboxInfo& other) = defaul
t; | 986 Canvas2DLayerBridge::MailboxInfo::MailboxInfo(const MailboxInfo& other) = defaul
t; |
999 | 987 |
1000 void Canvas2DLayerBridge::Logger::reportHibernationEvent(HibernationEvent event) | 988 void Canvas2DLayerBridge::Logger::reportHibernationEvent(HibernationEvent event) |
1001 { | 989 { |
1002 DEFINE_STATIC_LOCAL(EnumerationHistogram, hibernationHistogram, ("Canvas.Hib
ernationEvents", HibernationEventCount)); | 990 DEFINE_STATIC_LOCAL(EnumerationHistogram, hibernationHistogram, ("Canvas.Hib
ernationEvents", HibernationEventCount)); |
1003 hibernationHistogram.count(event); | 991 hibernationHistogram.count(event); |
1004 } | 992 } |
1005 | 993 |
1006 } // namespace blink | 994 } // namespace blink |
OLD | NEW |