|
1 /* |
|
2 * Copyright (C) 2010 Google Inc. All rights reserved. |
|
3 * |
|
4 * Redistribution and use in source and binary forms, with or without |
|
5 * modification, are permitted provided that the following conditions are |
|
6 * met: |
|
7 * |
|
8 * * Redistributions of source code must retain the above copyright |
|
9 * notice, this list of conditions and the following disclaimer. |
|
10 * * Redistributions in binary form must reproduce the above |
|
11 * copyright notice, this list of conditions and the following disclaimer |
|
12 * in the documentation and/or other materials provided with the |
|
13 * distribution. |
|
14 * * Neither the name of Google Inc. nor the names of its |
|
15 * contributors may be used to endorse or promote products derived from |
|
16 * this software without specific prior written permission. |
|
17 * |
|
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
|
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
|
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
|
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
29 */ |
|
30 |
|
31 #include "config.h" |
|
32 |
|
33 #include "GLES2Context.h" |
|
34 #include "GLES2ContextInternal.h" |
|
35 #include "IntSize.h" |
|
36 #include "WebGLES2Context.h" |
|
37 #include "WebKit.h" |
|
38 #include "WebKitClient.h" |
|
39 #include "WebViewImpl.h" |
|
40 #include <wtf/OwnPtr.h> |
|
41 |
|
42 // There are two levels of delegation in this file: |
|
43 // |
|
44 // 1. GLES2Context delegates to GLES2ContextInternal. This is done |
|
45 // so that we have some place to store data members common among |
|
46 // implementations. |
|
47 // |
|
48 // 2. GLES2ContextInternal delegates to an implementation of |
|
49 // WebGLES2Context. This is done so we have a place to inject an |
|
50 // implementation which creates the GL ES context. |
|
51 |
|
52 using namespace WebKit; |
|
53 |
|
54 namespace WebCore { |
|
55 |
|
56 PassOwnPtr<GLES2ContextInternal> GLES2ContextInternal::create(WebGLES2Context* impl, bool owns) |
|
57 { |
|
58 PassOwnPtr<GLES2ContextInternal> result = new GLES2ContextInternal(impl, owns); |
|
59 return result; |
|
60 } |
|
61 |
|
62 PassOwnPtr<GLES2Context> GLES2Context::create(PassOwnPtr<GLES2ContextInternal> internal) |
|
63 { |
|
64 PassOwnPtr<GLES2Context> result = new GLES2Context(); |
|
65 result->m_internal = internal; |
|
66 return result; |
|
67 } |
|
68 |
|
69 GLES2Context::GLES2Context() |
|
70 { |
|
71 } |
|
72 |
|
73 GLES2Context::~GLES2Context() |
|
74 { |
|
75 } |
|
76 |
|
77 bool GLES2Context::makeCurrent() |
|
78 { |
|
79 WebGLES2Context* webContext = m_internal->getWebGLES2Context(); |
|
80 if (!webContext) |
|
81 return false; |
|
82 return webContext->makeCurrent(); |
|
83 } |
|
84 |
|
85 bool GLES2Context::destroy() |
|
86 { |
|
87 WebGLES2Context* webContext = m_internal->getWebGLES2Context(); |
|
88 if (!webContext) |
|
89 return false; |
|
90 return webContext->destroy(); |
|
91 } |
|
92 |
|
93 bool GLES2Context::swapBuffers() |
|
94 { |
|
95 WebGLES2Context* webContext = m_internal->getWebGLES2Context(); |
|
96 if (!webContext) |
|
97 return false; |
|
98 return webContext->swapBuffers(); |
|
99 } |
|
100 |
|
101 void GLES2Context::resizeOffscreenContent(const IntSize& size) |
|
102 { |
|
103 WebGLES2Context* webContext = m_internal->getWebGLES2Context(); |
|
104 ASSERT(webContext); |
|
105 webContext->resizeOffscreenContent(size); |
|
106 } |
|
107 |
|
108 unsigned GLES2Context::getOffscreenContentParentTextureId() |
|
109 { |
|
110 WebGLES2Context* webContext = m_internal->getWebGLES2Context(); |
|
111 ASSERT(webContext); |
|
112 return webContext->getOffscreenContentParentTextureId(); |
|
113 } |
|
114 |
|
115 } // namespace WebCore |