Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(278)

Side by Side Diff: third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.h

Issue 1856933002: WebGL GL_RGB emulation to support IOSurfaces on Mac. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Clean up. Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 m_drawFramebufferBinding = fbo; 136 m_drawFramebufferBinding = fbo;
137 break; 137 break;
138 case GL_READ_FRAMEBUFFER: 138 case GL_READ_FRAMEBUFFER:
139 m_readFramebufferBinding = fbo; 139 m_readFramebufferBinding = fbo;
140 break; 140 break;
141 default: 141 default:
142 ASSERT(0); 142 ASSERT(0);
143 } 143 }
144 } 144 }
145 145
146 // The DrawingBuffer needs to track the currently bound renderbuffer so it
147 // restore the binding when needed.
148 void setRenderbufferBinding(GLuint renderbuffer)
149 {
150 m_renderbufferBinding = renderbuffer;
151 }
152
153
146 // Track the currently active texture unit. Texture unit 0 is used as host f or a scratch 154 // Track the currently active texture unit. Texture unit 0 is used as host f or a scratch
147 // texture. 155 // texture.
148 void setActiveTextureUnit(GLint textureUnit) { m_activeTextureUnit = texture Unit; } 156 void setActiveTextureUnit(GLint textureUnit) { m_activeTextureUnit = texture Unit; }
149 157
150 bool multisample() const; 158 bool multisample() const;
151 159
152 GLuint framebuffer() const; 160 GLuint framebuffer() const;
153 161
154 bool discardFramebufferSupported() const { return m_discardFramebufferSuppor ted; } 162 bool discardFramebufferSupported() const { return m_discardFramebufferSuppor ted; }
155 163
156 void markContentsChanged(); 164 void markContentsChanged();
157 void setBufferClearNeeded(bool); 165 void setBufferClearNeeded(bool);
158 bool bufferClearNeeded() const; 166 bool bufferClearNeeded() const;
159 void setIsHidden(bool); 167 void setIsHidden(bool);
160 void setFilterQuality(SkFilterQuality); 168 void setFilterQuality(SkFilterQuality);
161 169
170 // Indicates that the currently bound framebuffer has internalformat
171 // GL_RGBA, but is emulating GL_RGB. This happens to the backbuffer when the
172 // client requests alpha:False, but GL_RGB textures are unusable because of
173 // driver bugs.
174 bool requiresRGBEmulation();
175
162 WebLayer* platformLayer(); 176 WebLayer* platformLayer();
163 177
164 WebGraphicsContext3D* context(); 178 WebGraphicsContext3D* context();
165 gpu::gles2::GLES2Interface* contextGL(); 179 gpu::gles2::GLES2Interface* contextGL();
166 WebGraphicsContext3DProvider* contextProvider(); 180 WebGraphicsContext3DProvider* contextProvider();
167 181
168 // WebExternalTextureLayerClient implementation. 182 // WebExternalTextureLayerClient implementation.
169 bool prepareMailbox(WebExternalTextureMailbox*, WebExternalBitmap*) override ; 183 bool prepareMailbox(WebExternalTextureMailbox*, WebExternalBitmap*) override ;
170 void mailboxReleased(const WebExternalTextureMailbox&, bool lostResource = f alse) override; 184 void mailboxReleased(const WebExternalTextureMailbox&, bool lostResource = f alse) override;
171 185
(...skipping 23 matching lines...) Expand all
195 bool premultipliedAlpha, 209 bool premultipliedAlpha,
196 PreserveDrawingBuffer); 210 PreserveDrawingBuffer);
197 211
198 bool initialize(const IntSize&, bool wantDepthBuffer, bool wantStencilBuffer , bool useMultisampling); 212 bool initialize(const IntSize&, bool wantDepthBuffer, bool wantStencilBuffer , bool useMultisampling);
199 213
200 private: 214 private:
201 struct TextureParameters { 215 struct TextureParameters {
202 DISALLOW_NEW(); 216 DISALLOW_NEW();
203 GLenum target; 217 GLenum target;
204 GLenum internalColorFormat; 218 GLenum internalColorFormat;
219
220 // The internal color format used when allocating storage for the
221 // texture. This may be different from internalColorFormat if RGB
222 // emulation is required.
223 GLenum creationInternalColorFormat;
205 GLenum colorFormat; 224 GLenum colorFormat;
206 GLenum internalRenderbufferFormat; 225 GLenum internalRenderbufferFormat;
207 226
208 TextureParameters() 227 TextureParameters()
209 : target(0) 228 : target(0)
210 , internalColorFormat(0) 229 , internalColorFormat(0)
230 , creationInternalColorFormat(0)
211 , colorFormat(0) 231 , colorFormat(0)
212 , internalRenderbufferFormat(0) 232 , internalRenderbufferFormat(0)
213 { 233 {
214 } 234 }
215 }; 235 };
216 236
217 // If we used CHROMIUM_image as the backing storage for our buffers, 237 // If we used CHROMIUM_image as the backing storage for our buffers,
218 // we need to know the mapping from texture id to image. 238 // we need to know the mapping from texture id to image.
219 struct TextureInfo { 239 struct TextureInfo {
220 DISALLOW_NEW(); 240 DISALLOW_NEW();
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 306
287 // Helper function to flip a bitmap vertically. 307 // Helper function to flip a bitmap vertically.
288 void flipVertically(uint8_t* data, int width, int height); 308 void flipVertically(uint8_t* data, int width, int height);
289 309
290 // Helper to texImage2D with pixel==0 case: pixels are initialized to 0. 310 // Helper to texImage2D with pixel==0 case: pixels are initialized to 0.
291 // By default, alignment is 4, the OpenGL default setting. 311 // By default, alignment is 4, the OpenGL default setting.
292 void texImage2DResourceSafe(GLenum target, GLint level, GLenum internalforma t, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, GLin t alignment = 4); 312 void texImage2DResourceSafe(GLenum target, GLint level, GLenum internalforma t, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, GLin t alignment = 4);
293 // Allocate buffer storage to be sent to compositor using either texImage2D or CHROMIUM_image based on available support. 313 // Allocate buffer storage to be sent to compositor using either texImage2D or CHROMIUM_image based on available support.
294 void deleteChromiumImageForTexture(TextureInfo*); 314 void deleteChromiumImageForTexture(TextureInfo*);
295 315
316 // If RGB emulation is required, then the CHROMIUM image must be immediately
317 // cleared after it is bound to a texture.
318 void clearChromiumImageIfNecessary(const TextureInfo&);
319
296 // Tries to create a CHROMIUM_image backed texture if 320 // Tries to create a CHROMIUM_image backed texture if
297 // RuntimeEnabledFeatures::webGLImageChromiumEnabled() is true. On failure, 321 // RuntimeEnabledFeatures::webGLImageChromiumEnabled() is true. On failure,
298 // or if the flag is false, creates a default texture. 322 // or if the flag is false, creates a default texture.
299 TextureInfo createTextureAndAllocateMemory(const IntSize&); 323 TextureInfo createTextureAndAllocateMemory(const IntSize&);
300 324
301 // Creates and allocates space for a default texture. 325 // Creates and allocates space for a default texture.
302 TextureInfo createDefaultTextureAndAllocateMemory(const IntSize&); 326 TextureInfo createDefaultTextureAndAllocateMemory(const IntSize&);
303 327
304 void resizeTextureMemory(TextureInfo*, const IntSize&); 328 void resizeTextureMemory(TextureInfo*, const IntSize&);
305 329
306 void attachColorBufferToCurrentFBO(); 330 void attachColorBufferToCurrentFBO();
307 331
308 const PreserveDrawingBuffer m_preserveDrawingBuffer; 332 const PreserveDrawingBuffer m_preserveDrawingBuffer;
309 bool m_scissorEnabled; 333 bool m_scissorEnabled;
310 GLuint m_texture2DBinding; 334 GLuint m_texture2DBinding;
311 GLuint m_drawFramebufferBinding; 335 GLuint m_drawFramebufferBinding;
312 GLuint m_readFramebufferBinding; 336 GLuint m_readFramebufferBinding;
337 GLuint m_renderbufferBinding;
313 GLenum m_activeTextureUnit; 338 GLenum m_activeTextureUnit;
314 339
315 OwnPtr<WebGraphicsContext3DProvider> m_contextProvider; 340 OwnPtr<WebGraphicsContext3DProvider> m_contextProvider;
316 WebGraphicsContext3D* m_context; // Lifetime is tied to the m_contextProvide r. 341 WebGraphicsContext3D* m_context; // Lifetime is tied to the m_contextProvide r.
317 gpu::gles2::GLES2Interface* m_gl; // Lifetime is tied to the m_contextProvid er. 342 gpu::gles2::GLES2Interface* m_gl; // Lifetime is tied to the m_contextProvid er.
318 OwnPtr<Extensions3DUtil> m_extensionsUtil; 343 OwnPtr<Extensions3DUtil> m_extensionsUtil;
319 IntSize m_size; 344 IntSize m_size;
320 const bool m_discardFramebufferSupported; 345 const bool m_discardFramebufferSupported;
321 const bool m_wantAlphaChannel; 346 const bool m_wantAlphaChannel;
322 const bool m_premultipliedAlpha; 347 const bool m_premultipliedAlpha;
323 bool m_hasImplicitStencilBuffer; 348 bool m_hasImplicitStencilBuffer;
324 GLuint m_fbo; 349 GLuint m_fbo;
325 // DrawingBuffer's output is double-buffered. m_colorBuffer is the back buff er. 350 // DrawingBuffer's output is double-buffered. m_colorBuffer is the back buff er.
326 TextureInfo m_colorBuffer; 351 TextureInfo m_colorBuffer;
327 struct FrontBufferInfo { 352 struct FrontBufferInfo {
328 TextureInfo texInfo; 353 TextureInfo texInfo;
329 WebExternalTextureMailbox mailbox; 354 WebExternalTextureMailbox mailbox;
330 }; 355 };
331 FrontBufferInfo m_frontColorBuffer; 356 FrontBufferInfo m_frontColorBuffer;
332 357
333 OwnPtr<SameThreadClosure> m_newMailboxCallback; 358 OwnPtr<SameThreadClosure> m_newMailboxCallback;
334 359
335 // This is used when the user requests either a depth or stencil buffer. 360 // This is used when the user requests either a depth or stencil buffer.
336 GLuint m_depthStencilBuffer; 361 GLuint m_depthStencilBuffer;
337 362
338 // For multisampling. 363 // For multisampling.
339 GLuint m_multisampleFBO; 364 GLuint m_multisampleFBO;
365 GLuint m_multisampleIntermediateFBO;
366 GLuint m_multisampleIntermediateRenderbuffer;
340 GLuint m_multisampleColorBuffer; 367 GLuint m_multisampleColorBuffer;
341 368
342 // True if our contents have been modified since the last presentation of th is buffer. 369 // True if our contents have been modified since the last presentation of th is buffer.
343 bool m_contentsChanged; 370 bool m_contentsChanged;
344 371
345 // True if commit() has been called since the last time markContentsChanged( ) had been called. 372 // True if commit() has been called since the last time markContentsChanged( ) had been called.
346 bool m_contentsChangeCommitted; 373 bool m_contentsChangeCommitted;
347 bool m_bufferClearNeeded; 374 bool m_bufferClearNeeded;
348 375
349 enum AntialiasingMode { 376 enum AntialiasingMode {
(...skipping 26 matching lines...) Expand all
376 // used to resize the Canvas. 403 // used to resize the Canvas.
377 SkBitmap m_resizingBitmap; 404 SkBitmap m_resizingBitmap;
378 405
379 // Used to flip a bitmap vertically. 406 // Used to flip a bitmap vertically.
380 Vector<uint8_t> m_scanline; 407 Vector<uint8_t> m_scanline;
381 }; 408 };
382 409
383 } // namespace blink 410 } // namespace blink
384 411
385 #endif // DrawingBuffer_h 412 #endif // DrawingBuffer_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698