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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
83 if (surface) { | 83 if (surface) { |
84 if (opacityMode == Opaque) { | 84 if (opacityMode == Opaque) { |
85 surface->getCanvas()->clear(SK_ColorBLACK); | 85 surface->getCanvas()->clear(SK_ColorBLACK); |
86 } else { | 86 } else { |
87 surface->getCanvas()->clear(SK_ColorTRANSPARENT); | 87 surface->getCanvas()->clear(SK_ColorTRANSPARENT); |
88 } | 88 } |
89 } | 89 } |
90 return fromSkSp(surface); | 90 return fromSkSp(surface); |
91 } | 91 } |
92 | 92 |
93 PassRefPtr<Canvas2DLayerBridge> Canvas2DLayerBridge::create(const IntSize& size, int msaaSampleCount, OpacityMode opacityMode, AccelerationMode accelerationMode ) | |
94 { | |
95 TRACE_EVENT_INSTANT0("test_gpu", "Canvas2DLayerBridgeCreation", TRACE_EVENT_ SCOPE_GLOBAL); | |
96 std::unique_ptr<WebGraphicsContext3DProvider> contextProvider = wrapUnique(P latform::current()->createSharedOffscreenGraphicsContext3DProvider()); | |
97 if (!contextProvider) | |
98 return nullptr; | |
99 RefPtr<Canvas2DLayerBridge> layerBridge; | |
100 layerBridge = adoptRef(new Canvas2DLayerBridge(std::move(contextProvider), s ize, msaaSampleCount, opacityMode, accelerationMode)); | |
101 return layerBridge.release(); | |
102 } | |
103 | |
104 Canvas2DLayerBridge::Canvas2DLayerBridge(std::unique_ptr<WebGraphicsContext3DPro vider> contextProvider, const IntSize& size, int msaaSampleCount, OpacityMode op acityMode, AccelerationMode accelerationMode) | 93 Canvas2DLayerBridge::Canvas2DLayerBridge(std::unique_ptr<WebGraphicsContext3DPro vider> contextProvider, const IntSize& size, int msaaSampleCount, OpacityMode op acityMode, AccelerationMode accelerationMode) |
105 : m_contextProvider(std::move(contextProvider)) | 94 : m_contextProvider(std::move(contextProvider)) |
106 , m_logger(wrapUnique(new Logger)) | 95 , m_logger(wrapUnique(new Logger)) |
107 , m_weakPtrFactory(this) | 96 , m_weakPtrFactory(this) |
108 , m_imageBuffer(0) | 97 , m_imageBuffer(0) |
109 , m_msaaSampleCount(msaaSampleCount) | 98 , m_msaaSampleCount(msaaSampleCount) |
110 , m_bytesAllocated(0) | 99 , m_bytesAllocated(0) |
111 , m_haveRecordedDrawCommands(false) | 100 , m_haveRecordedDrawCommands(false) |
112 , m_destructionInProgress(false) | 101 , m_destructionInProgress(false) |
113 , m_filterQuality(kLow_SkFilterQuality) | 102 , m_filterQuality(kLow_SkFilterQuality) |
(...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
796 // context that it can use (each time it tries it loses our context). | 785 // context that it can use (each time it tries it loses our context). |
797 // But checkSurfaceValid() returns true even tho there is a GL error | 786 // But checkSurfaceValid() returns true even tho there is a GL error |
798 // sometimes.. so not sure if just checking for a GL error is right here | 787 // sometimes.. so not sure if just checking for a GL error is right here |
799 // or what. | 788 // or what. |
800 if (useSharedMemory) { | 789 if (useSharedMemory) { |
801 // Since we're going to software compositing, this class will soon be | 790 // Since we're going to software compositing, this class will soon be |
802 // destroyed for software mode canvas. | 791 // destroyed for software mode canvas. |
803 return false; | 792 return false; |
804 } | 793 } |
805 | 794 |
795 // If the context is lost, we don't know if we should be producing GPU or | |
danakj
2016/08/22 22:57:44
I made Canvas2DLB check for context loss explicitl
| |
796 // software frames, until we get a new context, since the compositor will | |
797 // be trying to get a new context and may change modes. | |
798 if (m_contextProvider->contextGL()->GetGraphicsResetStatusKHR() != GL_NO_ERR OR) | |
799 return false; | |
800 | |
806 RefPtr<SkImage> image = newImageSnapshot(PreferAcceleration, SnapshotReasonU nknown); | 801 RefPtr<SkImage> image = newImageSnapshot(PreferAcceleration, SnapshotReasonU nknown); |
807 if (!image || !image->getTexture()) | 802 if (!image || !image->getTexture()) |
808 return false; | 803 return false; |
809 | 804 |
810 // Early exit if canvas was not drawn to since last prepareMailbox. | 805 // Early exit if canvas was not drawn to since last prepareMailbox. |
811 GLenum filter = getGLFilter(); | 806 GLenum filter = getGLFilter(); |
812 if (image->uniqueID() == m_lastImageId && filter == m_lastFilter) | 807 if (image->uniqueID() == m_lastImageId && filter == m_lastFilter) |
813 return false; | 808 return false; |
814 m_lastImageId = image->uniqueID(); | 809 m_lastImageId = image->uniqueID(); |
815 m_lastFilter = filter; | 810 m_lastFilter = filter; |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1002 Canvas2DLayerBridge::MailboxInfo::MailboxInfo() = default; | 997 Canvas2DLayerBridge::MailboxInfo::MailboxInfo() = default; |
1003 Canvas2DLayerBridge::MailboxInfo::MailboxInfo(const MailboxInfo& other) = defaul t; | 998 Canvas2DLayerBridge::MailboxInfo::MailboxInfo(const MailboxInfo& other) = defaul t; |
1004 | 999 |
1005 void Canvas2DLayerBridge::Logger::reportHibernationEvent(HibernationEvent event) | 1000 void Canvas2DLayerBridge::Logger::reportHibernationEvent(HibernationEvent event) |
1006 { | 1001 { |
1007 DEFINE_STATIC_LOCAL(EnumerationHistogram, hibernationHistogram, ("Canvas.Hib ernationEvents", HibernationEventCount)); | 1002 DEFINE_STATIC_LOCAL(EnumerationHistogram, hibernationHistogram, ("Canvas.Hib ernationEvents", HibernationEventCount)); |
1008 hibernationHistogram.count(event); | 1003 hibernationHistogram.count(event); |
1009 } | 1004 } |
1010 | 1005 |
1011 } // namespace blink | 1006 } // namespace blink |
OLD | NEW |