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 26 matching lines...) Expand all Loading... |
136 | 131 |
137 bool copyToPlatformTexture(blink::WebGraphicsContext3D*, Platform3DObject te
xture, GLenum internalFormat, | 132 bool copyToPlatformTexture(blink::WebGraphicsContext3D*, Platform3DObject te
xture, GLenum internalFormat, |
138 GLenum destType, GLint level, bool premultiplyAlpha, bool flipY); | 133 GLenum destType, GLint level, bool premultiplyAlpha, bool flipY); |
139 | 134 |
140 void setPackAlignment(GLint param); | 135 void setPackAlignment(GLint param); |
141 | 136 |
142 void paintRenderingResultsToCanvas(ImageBuffer*); | 137 void paintRenderingResultsToCanvas(ImageBuffer*); |
143 PassRefPtr<Uint8ClampedArray> paintRenderingResultsToImageData(int&, int&); | 138 PassRefPtr<Uint8ClampedArray> paintRenderingResultsToImageData(int&, int&); |
144 | 139 |
145 private: | 140 private: |
146 DrawingBuffer(blink::WebGraphicsContext3D*, const IntSize&, bool multisample
ExtensionSupported, | 141 DrawingBuffer(PassOwnPtr<blink::WebGraphicsContext3D>, bool multisampleExten
sionSupported, |
147 bool packedDepthStencilExtensionSupported, PreserveDrawingBuff
er, PassRefPtr<ContextEvictionManager>); | 142 bool packedDepthStencilExtensionSupported, PreserveDrawingBuff
er, PassRefPtr<ContextEvictionManager>); |
148 | 143 |
149 void initialize(const IntSize&); | 144 bool initialize(const IntSize&); |
| 145 void releaseResources(); |
150 | 146 |
151 unsigned createColorTexture(const IntSize& size = IntSize()); | 147 unsigned createColorTexture(const IntSize& size = IntSize()); |
152 // Create the depth/stencil and multisample buffers, if needed. | 148 // Create the depth/stencil and multisample buffers, if needed. |
153 void createSecondaryBuffers(); | 149 void createSecondaryBuffers(); |
154 bool resizeFramebuffer(const IntSize&); | 150 bool resizeFramebuffer(const IntSize&); |
155 bool resizeMultisampleFramebuffer(const IntSize&); | 151 bool resizeMultisampleFramebuffer(const IntSize&); |
156 void resizeDepthStencil(const IntSize&); | 152 void resizeDepthStencil(const IntSize&); |
157 | 153 |
158 // Bind to the m_framebufferBinding if it's not 0. | 154 // Bind to the m_framebufferBinding if it's not 0. |
159 void restoreFramebufferBinding(); | 155 void restoreFramebufferBinding(); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 // Helper to texImage2D with pixel==0 case: pixels are initialized to 0. | 187 // Helper to texImage2D with pixel==0 case: pixels are initialized to 0. |
192 // By default, alignment is 4, the OpenGL default setting. | 188 // By default, alignment is 4, the OpenGL default setting. |
193 void texImage2DResourceSafe(GLenum target, GLint level, GLenum internalforma
t, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, GLin
t alignment = 4); | 189 void texImage2DResourceSafe(GLenum target, GLint level, GLenum internalforma
t, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, GLin
t alignment = 4); |
194 | 190 |
195 PreserveDrawingBuffer m_preserveDrawingBuffer; | 191 PreserveDrawingBuffer m_preserveDrawingBuffer; |
196 bool m_scissorEnabled; | 192 bool m_scissorEnabled; |
197 Platform3DObject m_texture2DBinding; | 193 Platform3DObject m_texture2DBinding; |
198 Platform3DObject m_framebufferBinding; | 194 Platform3DObject m_framebufferBinding; |
199 GLenum m_activeTextureUnit; | 195 GLenum m_activeTextureUnit; |
200 | 196 |
201 blink::WebGraphicsContext3D* m_context; | 197 OwnPtr<blink::WebGraphicsContext3D> m_context; |
202 IntSize m_size; | 198 IntSize m_size; |
203 bool m_multisampleExtensionSupported; | 199 bool m_multisampleExtensionSupported; |
204 bool m_packedDepthStencilExtensionSupported; | 200 bool m_packedDepthStencilExtensionSupported; |
205 Platform3DObject m_fbo; | 201 Platform3DObject m_fbo; |
206 // DrawingBuffer's output is double-buffered. m_colorBuffer is the back buff
er. | 202 // DrawingBuffer's output is double-buffered. m_colorBuffer is the back buff
er. |
207 Platform3DObject m_colorBuffer; | 203 Platform3DObject m_colorBuffer; |
208 Platform3DObject m_frontColorBuffer; | 204 Platform3DObject m_frontColorBuffer; |
209 | 205 |
210 // This is used when we have OES_packed_depth_stencil. | 206 // This is used when we have OES_packed_depth_stencil. |
211 Platform3DObject m_depthStencilBuffer; | 207 Platform3DObject m_depthStencilBuffer; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 // used to resize the Canvas. | 253 // used to resize the Canvas. |
258 SkBitmap m_resizingBitmap; | 254 SkBitmap m_resizingBitmap; |
259 | 255 |
260 // Used to flip a bitmap vertically. | 256 // Used to flip a bitmap vertically. |
261 Vector<uint8_t> m_scanline; | 257 Vector<uint8_t> m_scanline; |
262 }; | 258 }; |
263 | 259 |
264 } // namespace WebCore | 260 } // namespace WebCore |
265 | 261 |
266 #endif // DrawingBuffer_h | 262 #endif // DrawingBuffer_h |
OLD | NEW |