|
Lines 1-6
Source/WebCore/platform/graphics/efl/GraphicsContext3DPrivate.cpp_sec1
|
| 1 |
/* |
1 |
/* |
| 2 |
Copyright (C) 2012 Samsung Electronics |
2 |
Copyright (C) 2012 Samsung Electronics |
| 3 |
Copyright (C) 2012 Intel Corporation. |
3 |
Copyright (C) 2012 Intel Corporation. All rights reserved. |
| 4 |
|
4 |
|
| 5 |
This library is free software; you can redistribute it and/or |
5 |
This library is free software; you can redistribute it and/or |
| 6 |
modify it under the terms of the GNU Library General Public |
6 |
modify it under the terms of the GNU Library General Public |
|
Lines 28-85
Source/WebCore/platform/graphics/efl/GraphicsContext3DPrivate.cpp_sec2
|
| 28 |
|
28 |
|
| 29 |
namespace WebCore { |
29 |
namespace WebCore { |
| 30 |
|
30 |
|
| 31 |
GraphicsContext3DPrivate::GraphicsContext3DPrivate(GraphicsContext3D* context, HostWindow* hostWindow, GraphicsContext3D::RenderStyle renderStyle) |
31 |
PassOwnPtr<GraphicsContext3DPrivate> GraphicsContext3DPrivate::create(GraphicsContext3D* context, HostWindow* hostWindow) |
|
|
32 |
{ |
| 33 |
OwnPtr<GraphicsContext3DPrivate> platformLayer = adoptPtr(new GraphicsContext3DPrivate(context, hostWindow)); |
| 34 |
|
| 35 |
if (platformLayer && platformLayer->initialize()) |
| 36 |
return platformLayer.release(); |
| 37 |
|
| 38 |
return nullptr; |
| 39 |
} |
| 40 |
|
| 41 |
GraphicsContext3DPrivate::GraphicsContext3DPrivate(GraphicsContext3D* context, HostWindow* hostWindow) |
| 32 |
: m_context(context) |
42 |
: m_context(context) |
| 33 |
, m_hostWindow(hostWindow) |
43 |
, m_hostWindow(hostWindow) |
| 34 |
, m_pendingSurfaceResize(false) |
|
|
| 35 |
{ |
44 |
{ |
|
|
45 |
} |
| 46 |
|
| 47 |
bool GraphicsContext3DPrivate::initialize() |
| 48 |
{ |
| 49 |
if (m_context->m_renderStyle == GraphicsContext3D::RenderDirectlyToHostWindow) |
| 50 |
return false; |
| 51 |
|
| 36 |
if (m_hostWindow && m_hostWindow->platformPageClient()) { |
52 |
if (m_hostWindow && m_hostWindow->platformPageClient()) { |
| 37 |
// FIXME: Implement this code path for WebKit1. |
53 |
// FIXME: Implement this code path for WebKit1. |
| 38 |
// Get Evas object from platformPageClient and set EvasGL related members. |
54 |
// Get Evas object from platformPageClient and set EvasGL related members. |
| 39 |
return; |
55 |
return false; |
| 40 |
} |
56 |
} |
| 41 |
|
57 |
|
| 42 |
m_platformContext = GLPlatformContext::createContext(renderStyle); |
58 |
m_offScreenContext = GLPlatformContext::createContext(m_context->m_renderStyle); |
| 43 |
if (!m_platformContext) |
59 |
if (!m_offScreenContext) |
| 44 |
return; |
60 |
return false; |
| 45 |
|
61 |
|
| 46 |
if (renderStyle == GraphicsContext3D::RenderOffscreen) { |
62 |
if (m_context->m_renderStyle == GraphicsContext3D::RenderOffscreen) { |
| 47 |
#if USE(GRAPHICS_SURFACE) |
63 |
#if USE(GRAPHICS_SURFACE) |
| 48 |
m_platformSurface = GLPlatformSurface::createTransportSurface(); |
64 |
m_sharedSurface = GLPlatformSurface::createTransportSurface(); |
| 49 |
#else |
65 |
if (!m_sharedSurface) |
| 50 |
m_platformSurface = GLPlatformSurface::createOffscreenSurface(); |
66 |
return false; |
|
|
67 |
|
| 68 |
m_sharedContext = GLPlatformContext::createContext(m_context->m_renderStyle); |
| 69 |
if (!m_sharedContext) |
| 70 |
return false; |
| 51 |
#endif |
71 |
#endif |
| 52 |
if (!m_platformSurface) { |
|
|
| 53 |
m_platformContext = nullptr; |
| 54 |
return; |
| 55 |
} |
| 56 |
|
72 |
|
| 57 |
if (!m_platformContext->initialize(m_platformSurface.get()) || !m_platformContext->makeCurrent(m_platformSurface.get())) { |
73 |
m_offScreenSurface = GLPlatformSurface::createOffScreenSurface(); |
| 58 |
releaseResources(); |
74 |
|
| 59 |
m_platformContext = nullptr; |
75 |
if (!m_offScreenSurface) |
| 60 |
m_platformSurface = nullptr; |
76 |
return false; |
|
|
77 |
|
| 78 |
if (!m_offScreenContext->initialize(m_offScreenSurface.get())) |
| 79 |
return false; |
| 80 |
|
| 61 |
#if USE(GRAPHICS_SURFACE) |
81 |
#if USE(GRAPHICS_SURFACE) |
| 62 |
} else |
82 |
if (!m_sharedContext->initialize(m_sharedSurface.get(), m_offScreenContext->handle())) |
| 63 |
m_surfaceHandle = GraphicsSurfaceToken(m_platformSurface->handle()); |
83 |
return false; |
| 64 |
#else |
84 |
|
| 65 |
} |
85 |
if (!makeSharedContextCurrent()) |
|
|
86 |
return false; |
| 87 |
|
| 88 |
m_surfaceHandle = GraphicsSurfaceToken(m_sharedSurface->handle()); |
| 66 |
#endif |
89 |
#endif |
| 67 |
} |
90 |
} |
|
|
91 |
|
| 92 |
if (!makeContextCurrent()) |
| 93 |
return false; |
| 94 |
|
| 95 |
return true; |
| 68 |
} |
96 |
} |
| 69 |
|
97 |
|
| 70 |
GraphicsContext3DPrivate::~GraphicsContext3DPrivate() |
98 |
GraphicsContext3DPrivate::~GraphicsContext3DPrivate() |
| 71 |
{ |
99 |
{ |
|
|
100 |
releaseResources(); |
| 72 |
} |
101 |
} |
| 73 |
|
102 |
|
| 74 |
void GraphicsContext3DPrivate::releaseResources() |
103 |
void GraphicsContext3DPrivate::releaseResources() |
| 75 |
{ |
104 |
{ |
|
|
105 |
if (m_context->m_renderStyle == GraphicsContext3D::RenderToCurrentGLContext) |
| 106 |
return; |
| 107 |
|
| 76 |
// Release the current context and drawable only after destroying any associated gl resources. |
108 |
// Release the current context and drawable only after destroying any associated gl resources. |
| 77 |
if (m_platformSurface) |
109 |
#if USE(GRAPHICS_SURFACE) |
| 78 |
m_platformSurface->destroy(); |
110 |
if (m_sharedContext && m_sharedContext->handle() && m_sharedSurface) |
|
|
111 |
makeSharedContextCurrent(); |
| 112 |
|
| 113 |
if (m_sharedSurface) |
| 114 |
m_sharedSurface->destroy(); |
| 79 |
|
115 |
|
| 80 |
if (m_platformContext) { |
116 |
if (m_sharedContext) { |
| 81 |
m_platformContext->destroy(); |
117 |
m_sharedContext->destroy(); |
| 82 |
m_platformContext->releaseCurrent(); |
118 |
m_sharedContext->releaseCurrent(); |
|
|
119 |
} |
| 120 |
#endif |
| 121 |
if (m_offScreenSurface) |
| 122 |
m_offScreenSurface->destroy(); |
| 123 |
|
| 124 |
if (m_offScreenContext) { |
| 125 |
m_offScreenContext->destroy(); |
| 126 |
m_offScreenContext->releaseCurrent(); |
| 83 |
} |
127 |
} |
| 84 |
} |
128 |
} |
| 85 |
|
129 |
|
|
Lines 96-145
void GraphicsContext3DPrivate::setContextLostCallback(PassOwnPtr<GraphicsContext
Source/WebCore/platform/graphics/efl/GraphicsContext3DPrivate.cpp_sec3
|
| 96 |
|
140 |
|
| 97 |
PlatformGraphicsContext3D GraphicsContext3DPrivate::platformGraphicsContext3D() const |
141 |
PlatformGraphicsContext3D GraphicsContext3DPrivate::platformGraphicsContext3D() const |
| 98 |
{ |
142 |
{ |
| 99 |
return m_platformContext->handle(); |
143 |
return m_offScreenContext->handle(); |
| 100 |
} |
144 |
} |
| 101 |
|
145 |
|
| 102 |
bool GraphicsContext3DPrivate::makeContextCurrent() |
146 |
bool GraphicsContext3DPrivate::makeContextCurrent() const |
| 103 |
{ |
147 |
{ |
| 104 |
bool success = m_platformContext->makeCurrent(m_platformSurface.get()); |
148 |
bool success = m_offScreenContext->makeCurrent(m_offScreenSurface.get()); |
| 105 |
|
149 |
|
| 106 |
if (!m_platformContext->isValid()) { |
150 |
if (!m_offScreenContext->isValid()) { |
| 107 |
// FIXME: Restore context |
151 |
// FIXME: Restore context |
| 108 |
if (m_contextLostCallback) |
152 |
if (m_contextLostCallback) |
| 109 |
m_contextLostCallback->onContextLost(); |
153 |
m_contextLostCallback->onContextLost(); |
| 110 |
|
154 |
|
| 111 |
success = false; |
155 |
return false; |
| 112 |
} |
156 |
} |
| 113 |
|
157 |
|
| 114 |
return success; |
158 |
return success; |
| 115 |
} |
159 |
} |
| 116 |
|
160 |
|
| 117 |
#if USE(TEXTURE_MAPPER_GL) |
161 |
bool GraphicsContext3DPrivate::prepareBuffer() const |
| 118 |
void GraphicsContext3DPrivate::paintToTextureMapper(TextureMapper*, const FloatRect& /* target */, const TransformationMatrix&, float /* opacity */, BitmapTexture* /* mask */) |
|
|
| 119 |
{ |
162 |
{ |
| 120 |
notImplemented(); |
163 |
if (!makeContextCurrent()) |
| 121 |
} |
164 |
return false; |
| 122 |
#endif |
|
|
| 123 |
|
| 124 |
#if USE(GRAPHICS_SURFACE) |
| 125 |
void GraphicsContext3DPrivate::didResizeCanvas(const IntSize& size) |
| 126 |
{ |
| 127 |
m_pendingSurfaceResize = true; |
| 128 |
m_size = size; |
| 129 |
} |
| 130 |
|
| 131 |
uint32_t GraphicsContext3DPrivate::copyToGraphicsSurface() |
| 132 |
{ |
| 133 |
if (!m_platformContext || !makeContextCurrent()) |
| 134 |
return 0; |
| 135 |
|
165 |
|
| 136 |
m_context->markLayerComposited(); |
166 |
m_context->markLayerComposited(); |
| 137 |
|
167 |
|
| 138 |
if (m_pendingSurfaceResize) { |
|
|
| 139 |
m_pendingSurfaceResize = false; |
| 140 |
m_platformSurface->setGeometry(IntRect(0, 0, m_context->m_currentWidth, m_context->m_currentHeight)); |
| 141 |
} |
| 142 |
|
| 143 |
if (m_context->m_attrs.antialias) { |
168 |
if (m_context->m_attrs.antialias) { |
| 144 |
bool enableScissorTest = false; |
169 |
bool enableScissorTest = false; |
| 145 |
int width = m_context->m_currentWidth; |
170 |
int width = m_context->m_currentWidth; |
|
Lines 161-168
uint32_t GraphicsContext3DPrivate::copyToGraphicsSurface()
Source/WebCore/platform/graphics/efl/GraphicsContext3DPrivate.cpp_sec4
|
| 161 |
m_context->enable(GraphicsContext3D::SCISSOR_TEST); |
186 |
m_context->enable(GraphicsContext3D::SCISSOR_TEST); |
| 162 |
} |
187 |
} |
| 163 |
|
188 |
|
| 164 |
m_platformSurface->updateContents(m_context->m_texture, m_context->m_boundFBO, m_context->m_boundTexture0); |
189 |
return true; |
|
|
190 |
} |
| 191 |
|
| 192 |
#if USE(TEXTURE_MAPPER_GL) |
| 193 |
void GraphicsContext3DPrivate::paintToTextureMapper(TextureMapper*, const FloatRect& /* target */, const TransformationMatrix&, float /* opacity */, BitmapTexture* /* mask */) |
| 194 |
{ |
| 195 |
notImplemented(); |
| 196 |
} |
| 197 |
#endif |
| 198 |
|
| 199 |
#if USE(GRAPHICS_SURFACE) |
| 200 |
bool GraphicsContext3DPrivate::makeSharedContextCurrent() const |
| 201 |
{ |
| 202 |
bool success = m_sharedContext->makeCurrent(m_sharedSurface.get()); |
| 203 |
|
| 204 |
if (!m_sharedContext->isValid()) { |
| 205 |
// FIXME: Restore context |
| 206 |
if (m_contextLostCallback) |
| 207 |
m_contextLostCallback->onContextLost(); |
| 208 |
|
| 209 |
success = false; |
| 210 |
} |
| 211 |
|
| 212 |
return success; |
| 213 |
} |
| 165 |
|
214 |
|
|
|
215 |
void GraphicsContext3DPrivate::didResizeCanvas(const IntSize& size) |
| 216 |
{ |
| 217 |
m_size = size; |
| 218 |
m_sharedSurface->setGeometry(IntRect(0, 0, m_size.width(), m_size.height())); |
| 219 |
} |
| 220 |
|
| 221 |
uint32_t GraphicsContext3DPrivate::copyToGraphicsSurface() |
| 222 |
{ |
| 223 |
if (m_context->m_layerComposited || !prepareBuffer() || !makeSharedContextCurrent()) |
| 224 |
return 0; |
| 225 |
|
| 226 |
m_sharedSurface->updateContents(m_context->m_texture); |
| 227 |
makeContextCurrent(); |
| 228 |
glBindFramebuffer(GL_FRAMEBUFFER, m_context->m_boundFBO); |
| 166 |
return 0; |
229 |
return 0; |
| 167 |
} |
230 |
} |
| 168 |
|
231 |
|
|
Lines 175-181
IntSize GraphicsContext3DPrivate::platformLayerSize() const
Source/WebCore/platform/graphics/efl/GraphicsContext3DPrivate.cpp_sec5
|
| 175 |
{ |
238 |
{ |
| 176 |
return m_size; |
239 |
return m_size; |
| 177 |
} |
240 |
} |
| 178 |
|
|
|
| 179 |
#endif |
241 |
#endif |
| 180 |
|
242 |
|
| 181 |
} // namespace WebCore |
243 |
} // namespace WebCore |