OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2010, Google Inc. All rights reserved. | 2 * Copyright (c) 2010, 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 are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 blink::WebExternalTextureMailbox mailbox; | 72 blink::WebExternalTextureMailbox mailbox; |
73 unsigned textureId; | 73 unsigned textureId; |
74 IntSize size; | 74 IntSize size; |
75 }; | 75 }; |
76 public: | 76 public: |
77 enum PreserveDrawingBuffer { | 77 enum PreserveDrawingBuffer { |
78 Preserve, | 78 Preserve, |
79 Discard | 79 Discard |
80 }; | 80 }; |
81 | 81 |
82 static PassRefPtr<DrawingBuffer> create(PassOwnPtr<blink::WebGraphicsContext
3D>, const IntSize&, PreserveDrawingBuffer, PassRefPtr<ContextEvictionManager>); | 82 static PassRefPtr<DrawingBuffer> create(blink::WebGraphicsContext3D*, const
IntSize&, PreserveDrawingBuffer, PassRefPtr<ContextEvictionManager>); |
83 | 83 |
84 virtual ~DrawingBuffer(); | 84 virtual ~DrawingBuffer(); |
85 | 85 |
| 86 // Clear all resources from this object, as well as context. Called when con
text is destroyed |
| 87 // to prevent invalid accesses to the resources. |
| 88 void releaseResources(); |
| 89 |
86 // Issues a glClear() on all framebuffers associated with this DrawingBuffer
. The caller is responsible for | 90 // Issues a glClear() on all framebuffers associated with this DrawingBuffer
. The caller is responsible for |
87 // making the context current and setting the clear values and masks. Modifi
es the framebuffer binding. | 91 // making the context current and setting the clear values and masks. Modifi
es the framebuffer binding. |
88 void clearFramebuffers(GLbitfield clearMask); | 92 void clearFramebuffers(GLbitfield clearMask); |
89 | 93 |
90 // Given the desired buffer size, provides the largest dimensions that will
fit in the pixel budget. | 94 // Given the desired buffer size, provides the largest dimensions that will
fit in the pixel budget. |
91 IntSize adjustSize(const IntSize&); | 95 IntSize adjustSize(const IntSize&); |
92 bool reset(const IntSize&); | 96 void reset(const IntSize&); |
93 void bind(); | 97 void bind(); |
94 IntSize size() const { return m_size; } | 98 IntSize size() const { return m_size; } |
| 99 bool isZeroSized() const { return m_size.isEmpty(); } |
95 | 100 |
96 // Copies the multisample color buffer to the normal color buffer and leaves
m_fbo bound. | 101 // Copies the multisample color buffer to the normal color buffer and leaves
m_fbo bound. |
97 void commit(long x = 0, long y = 0, long width = -1, long height = -1); | 102 void commit(long x = 0, long y = 0, long width = -1, long height = -1); |
98 | 103 |
99 // commit should copy the full multisample buffer, and not respect the | 104 // commit should copy the full multisample buffer, and not respect the |
100 // current scissor bounds. Track the state of the scissor test so that it | 105 // current scissor bounds. Track the state of the scissor test so that it |
101 // can be disabled during calls to commit. | 106 // can be disabled during calls to commit. |
102 void setScissorEnabled(bool scissorEnabled) { m_scissorEnabled = scissorEnab
led; } | 107 void setScissorEnabled(bool scissorEnabled) { m_scissorEnabled = scissorEnab
led; } |
103 | 108 |
104 // The DrawingBuffer needs to track the texture bound to texture unit 0. | 109 // The DrawingBuffer needs to track the texture bound to texture unit 0. |
(...skipping 26 matching lines...) Expand all Loading... |
131 | 136 |
132 bool copyToPlatformTexture(blink::WebGraphicsContext3D*, Platform3DObject te
xture, GLenum internalFormat, | 137 bool copyToPlatformTexture(blink::WebGraphicsContext3D*, Platform3DObject te
xture, GLenum internalFormat, |
133 GLenum destType, GLint level, bool premultiplyAlpha, bool flipY); | 138 GLenum destType, GLint level, bool premultiplyAlpha, bool flipY); |
134 | 139 |
135 void setPackAlignment(GLint param); | 140 void setPackAlignment(GLint param); |
136 | 141 |
137 void paintRenderingResultsToCanvas(ImageBuffer*); | 142 void paintRenderingResultsToCanvas(ImageBuffer*); |
138 PassRefPtr<Uint8ClampedArray> paintRenderingResultsToImageData(int&, int&); | 143 PassRefPtr<Uint8ClampedArray> paintRenderingResultsToImageData(int&, int&); |
139 | 144 |
140 private: | 145 private: |
141 DrawingBuffer(PassOwnPtr<blink::WebGraphicsContext3D>, bool multisampleExten
sionSupported, | 146 DrawingBuffer(blink::WebGraphicsContext3D*, const IntSize&, bool multisample
ExtensionSupported, |
142 bool packedDepthStencilExtensionSupported, PreserveDrawingBuff
er, PassRefPtr<ContextEvictionManager>); | 147 bool packedDepthStencilExtensionSupported, PreserveDrawingBuff
er, PassRefPtr<ContextEvictionManager>); |
143 | 148 |
144 bool initialize(const IntSize&); | 149 void initialize(const IntSize&); |
145 void releaseResources(); | |
146 | 150 |
147 unsigned createColorTexture(const IntSize& size = IntSize()); | 151 unsigned createColorTexture(const IntSize& size = IntSize()); |
148 // Create the depth/stencil and multisample buffers, if needed. | 152 // Create the depth/stencil and multisample buffers, if needed. |
149 void createSecondaryBuffers(); | 153 void createSecondaryBuffers(); |
150 bool resizeFramebuffer(const IntSize&); | 154 bool resizeFramebuffer(const IntSize&); |
151 bool resizeMultisampleFramebuffer(const IntSize&); | 155 bool resizeMultisampleFramebuffer(const IntSize&); |
152 void resizeDepthStencil(const IntSize&); | 156 void resizeDepthStencil(const IntSize&); |
153 | 157 |
154 // Bind to the m_framebufferBinding if it's not 0. | 158 // Bind to the m_framebufferBinding if it's not 0. |
155 void restoreFramebufferBinding(); | 159 void restoreFramebufferBinding(); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 // Helper to texImage2D with pixel==0 case: pixels are initialized to 0. | 191 // Helper to texImage2D with pixel==0 case: pixels are initialized to 0. |
188 // By default, alignment is 4, the OpenGL default setting. | 192 // By default, alignment is 4, the OpenGL default setting. |
189 void texImage2DResourceSafe(GLenum target, GLint level, GLenum internalforma
t, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, GLin
t alignment = 4); | 193 void texImage2DResourceSafe(GLenum target, GLint level, GLenum internalforma
t, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, GLin
t alignment = 4); |
190 | 194 |
191 PreserveDrawingBuffer m_preserveDrawingBuffer; | 195 PreserveDrawingBuffer m_preserveDrawingBuffer; |
192 bool m_scissorEnabled; | 196 bool m_scissorEnabled; |
193 Platform3DObject m_texture2DBinding; | 197 Platform3DObject m_texture2DBinding; |
194 Platform3DObject m_framebufferBinding; | 198 Platform3DObject m_framebufferBinding; |
195 GLenum m_activeTextureUnit; | 199 GLenum m_activeTextureUnit; |
196 | 200 |
197 OwnPtr<blink::WebGraphicsContext3D> m_context; | 201 blink::WebGraphicsContext3D* m_context; |
198 IntSize m_size; | 202 IntSize m_size; |
199 bool m_multisampleExtensionSupported; | 203 bool m_multisampleExtensionSupported; |
200 bool m_packedDepthStencilExtensionSupported; | 204 bool m_packedDepthStencilExtensionSupported; |
201 Platform3DObject m_fbo; | 205 Platform3DObject m_fbo; |
202 // DrawingBuffer's output is double-buffered. m_colorBuffer is the back buff
er. | 206 // DrawingBuffer's output is double-buffered. m_colorBuffer is the back buff
er. |
203 Platform3DObject m_colorBuffer; | 207 Platform3DObject m_colorBuffer; |
204 Platform3DObject m_frontColorBuffer; | 208 Platform3DObject m_frontColorBuffer; |
205 | 209 |
206 // This is used when we have OES_packed_depth_stencil. | 210 // This is used when we have OES_packed_depth_stencil. |
207 Platform3DObject m_depthStencilBuffer; | 211 Platform3DObject m_depthStencilBuffer; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 // used to resize the Canvas. | 257 // used to resize the Canvas. |
254 SkBitmap m_resizingBitmap; | 258 SkBitmap m_resizingBitmap; |
255 | 259 |
256 // Used to flip a bitmap vertically. | 260 // Used to flip a bitmap vertically. |
257 Vector<uint8_t> m_scanline; | 261 Vector<uint8_t> m_scanline; |
258 }; | 262 }; |
259 | 263 |
260 } // namespace WebCore | 264 } // namespace WebCore |
261 | 265 |
262 #endif // DrawingBuffer_h | 266 #endif // DrawingBuffer_h |
OLD | NEW |