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