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

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: Comments from kbr. 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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 m_drawFramebufferBinding = fbo; 134 m_drawFramebufferBinding = fbo;
135 break; 135 break;
136 case GL_READ_FRAMEBUFFER: 136 case GL_READ_FRAMEBUFFER:
137 m_readFramebufferBinding = fbo; 137 m_readFramebufferBinding = fbo;
138 break; 138 break;
139 default: 139 default:
140 ASSERT(0); 140 ASSERT(0);
141 } 141 }
142 } 142 }
143 143
144 // The DrawingBuffer needs to track the color mask and clear color so that
145 // it can restore it when needed.
146 void setClearColor(GLfloat* clearColor)
147 {
148 memcpy(m_clearColor, clearColor, 4 * sizeof(GLfloat));
149 }
150
151 void setColorMask(GLboolean* colorMask)
152 {
153 memcpy(m_colorMask, colorMask, 4 * sizeof(GLboolean));
154 }
155
156 // The DrawingBuffer needs to track the currently bound renderbuffer so it
157 // restore the binding when needed.
158 void setRenderbufferBinding(GLuint renderbuffer)
159 {
160 m_renderbufferBinding = renderbuffer;
161 }
162
144 // Track the currently active texture unit. Texture unit 0 is used as host f or a scratch 163 // Track the currently active texture unit. Texture unit 0 is used as host f or a scratch
145 // texture. 164 // texture.
146 void setActiveTextureUnit(GLint textureUnit) { m_activeTextureUnit = texture Unit; } 165 void setActiveTextureUnit(GLint textureUnit) { m_activeTextureUnit = texture Unit; }
147 166
148 bool multisample() const; 167 bool multisample() const;
149 168
150 GLuint framebuffer() const; 169 GLuint framebuffer() const;
151 170
152 bool discardFramebufferSupported() const { return m_discardFramebufferSuppor ted; } 171 bool discardFramebufferSupported() const { return m_discardFramebufferSuppor ted; }
153 172
154 void markContentsChanged(); 173 void markContentsChanged();
155 void setBufferClearNeeded(bool); 174 void setBufferClearNeeded(bool);
156 bool bufferClearNeeded() const; 175 bool bufferClearNeeded() const;
157 void setIsHidden(bool); 176 void setIsHidden(bool);
158 void setFilterQuality(SkFilterQuality); 177 void setFilterQuality(SkFilterQuality);
159 178
179 // Indicates that the currently bound framebuffer has internalformat
180 // GL_RGBA, but is emulating GL_RGB. This happens to the backbuffer when the
181 // client requests alpha:False, but GL_RGB textures are unusable because of
182 // driver bugs.
183 bool requiresRGBEmulation();
184
160 WebLayer* platformLayer(); 185 WebLayer* platformLayer();
161 186
162 gpu::gles2::GLES2Interface* contextGL(); 187 gpu::gles2::GLES2Interface* contextGL();
163 WebGraphicsContext3DProvider* contextProvider(); 188 WebGraphicsContext3DProvider* contextProvider();
164 189
165 // WebExternalTextureLayerClient implementation. 190 // WebExternalTextureLayerClient implementation.
166 bool prepareMailbox(WebExternalTextureMailbox*, WebExternalBitmap*) override ; 191 bool prepareMailbox(WebExternalTextureMailbox*, WebExternalBitmap*) override ;
167 void mailboxReleased(const WebExternalTextureMailbox&, bool lostResource = f alse) override; 192 void mailboxReleased(const WebExternalTextureMailbox&, bool lostResource = f alse) override;
168 193
169 // Destroys the TEXTURE_2D binding for the owned context 194 // Destroys the TEXTURE_2D binding for the owned context
(...skipping 22 matching lines...) Expand all
192 bool premultipliedAlpha, 217 bool premultipliedAlpha,
193 PreserveDrawingBuffer); 218 PreserveDrawingBuffer);
194 219
195 bool initialize(const IntSize&, bool wantDepthBuffer, bool wantStencilBuffer , bool useMultisampling); 220 bool initialize(const IntSize&, bool wantDepthBuffer, bool wantStencilBuffer , bool useMultisampling);
196 221
197 private: 222 private:
198 struct TextureParameters { 223 struct TextureParameters {
199 DISALLOW_NEW(); 224 DISALLOW_NEW();
200 GLenum target; 225 GLenum target;
201 GLenum internalColorFormat; 226 GLenum internalColorFormat;
227
228 // The internal color format used when allocating storage for the
229 // texture. This may be different from internalColorFormat if RGB
230 // emulation is required.
231 GLenum creationInternalColorFormat;
202 GLenum colorFormat; 232 GLenum colorFormat;
203 GLenum internalRenderbufferFormat; 233 GLenum internalRenderbufferFormat;
204 234
205 TextureParameters() 235 TextureParameters()
206 : target(0) 236 : target(0)
207 , internalColorFormat(0) 237 , internalColorFormat(0)
238 , creationInternalColorFormat(0)
208 , colorFormat(0) 239 , colorFormat(0)
209 , internalRenderbufferFormat(0) 240 , internalRenderbufferFormat(0)
210 { 241 {
211 } 242 }
212 }; 243 };
213 244
214 // If we used CHROMIUM_image as the backing storage for our buffers, 245 // If we used CHROMIUM_image as the backing storage for our buffers,
215 // we need to know the mapping from texture id to image. 246 // we need to know the mapping from texture id to image.
216 struct TextureInfo { 247 struct TextureInfo {
217 DISALLOW_NEW(); 248 DISALLOW_NEW();
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 314
284 // Helper function to flip a bitmap vertically. 315 // Helper function to flip a bitmap vertically.
285 void flipVertically(uint8_t* data, int width, int height); 316 void flipVertically(uint8_t* data, int width, int height);
286 317
287 // Helper to texImage2D with pixel==0 case: pixels are initialized to 0. 318 // Helper to texImage2D with pixel==0 case: pixels are initialized to 0.
288 // By default, alignment is 4, the OpenGL default setting. 319 // By default, alignment is 4, the OpenGL default setting.
289 void texImage2DResourceSafe(GLenum target, GLint level, GLenum internalforma t, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, GLin t alignment = 4); 320 void texImage2DResourceSafe(GLenum target, GLint level, GLenum internalforma t, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, GLin t alignment = 4);
290 // Allocate buffer storage to be sent to compositor using either texImage2D or CHROMIUM_image based on available support. 321 // Allocate buffer storage to be sent to compositor using either texImage2D or CHROMIUM_image based on available support.
291 void deleteChromiumImageForTexture(TextureInfo*); 322 void deleteChromiumImageForTexture(TextureInfo*);
292 323
324 // If RGB emulation is required, then the CHROMIUM image's alpha channel
325 // must be immediately cleared after it is bound to a texture. Nothing
326 // should be allowed to change the alpha channel after this.
327 void clearChromiumImageAlpha(const TextureInfo&);
328
293 // Tries to create a CHROMIUM_image backed texture if 329 // Tries to create a CHROMIUM_image backed texture if
294 // RuntimeEnabledFeatures::webGLImageChromiumEnabled() is true. On failure, 330 // RuntimeEnabledFeatures::webGLImageChromiumEnabled() is true. On failure,
295 // or if the flag is false, creates a default texture. 331 // or if the flag is false, creates a default texture.
296 TextureInfo createTextureAndAllocateMemory(const IntSize&); 332 TextureInfo createTextureAndAllocateMemory(const IntSize&);
297 333
298 // Creates and allocates space for a default texture. 334 // Creates and allocates space for a default texture.
299 TextureInfo createDefaultTextureAndAllocateMemory(const IntSize&); 335 TextureInfo createDefaultTextureAndAllocateMemory(const IntSize&);
300 336
301 void resizeTextureMemory(TextureInfo*, const IntSize&); 337 void resizeTextureMemory(TextureInfo*, const IntSize&);
302 338
303 void attachColorBufferToCurrentFBO(); 339 void attachColorBufferToCurrentFBO();
304 340
305 const PreserveDrawingBuffer m_preserveDrawingBuffer; 341 const PreserveDrawingBuffer m_preserveDrawingBuffer;
306 bool m_scissorEnabled; 342 bool m_scissorEnabled;
307 GLuint m_texture2DBinding; 343 GLuint m_texture2DBinding;
308 GLuint m_drawFramebufferBinding; 344 GLuint m_drawFramebufferBinding;
309 GLuint m_readFramebufferBinding; 345 GLuint m_readFramebufferBinding;
346 GLuint m_renderbufferBinding;
310 GLenum m_activeTextureUnit; 347 GLenum m_activeTextureUnit;
348 GLfloat m_clearColor[4];
349 GLboolean m_colorMask[4];
311 350
312 OwnPtr<WebGraphicsContext3DProvider> m_contextProvider; 351 OwnPtr<WebGraphicsContext3DProvider> m_contextProvider;
313 // Lifetime is tied to the m_contextProvider. 352 // Lifetime is tied to the m_contextProvider.
314 gpu::gles2::GLES2Interface* m_gl; 353 gpu::gles2::GLES2Interface* m_gl;
315 OwnPtr<Extensions3DUtil> m_extensionsUtil; 354 OwnPtr<Extensions3DUtil> m_extensionsUtil;
316 IntSize m_size; 355 IntSize m_size;
317 const bool m_discardFramebufferSupported; 356 const bool m_discardFramebufferSupported;
318 const bool m_wantAlphaChannel; 357 const bool m_wantAlphaChannel;
319 const bool m_premultipliedAlpha; 358 const bool m_premultipliedAlpha;
320 bool m_hasImplicitStencilBuffer; 359 bool m_hasImplicitStencilBuffer;
321 GLuint m_fbo; 360 GLuint m_fbo;
322 // DrawingBuffer's output is double-buffered. m_colorBuffer is the back buff er. 361 // DrawingBuffer's output is double-buffered. m_colorBuffer is the back buff er.
323 TextureInfo m_colorBuffer; 362 TextureInfo m_colorBuffer;
324 struct FrontBufferInfo { 363 struct FrontBufferInfo {
325 TextureInfo texInfo; 364 TextureInfo texInfo;
326 WebExternalTextureMailbox mailbox; 365 WebExternalTextureMailbox mailbox;
327 }; 366 };
328 FrontBufferInfo m_frontColorBuffer; 367 FrontBufferInfo m_frontColorBuffer;
329 368
330 OwnPtr<SameThreadClosure> m_newMailboxCallback; 369 OwnPtr<SameThreadClosure> m_newMailboxCallback;
331 370
332 // This is used when the user requests either a depth or stencil buffer. 371 // This is used when the user requests either a depth or stencil buffer.
333 GLuint m_depthStencilBuffer; 372 GLuint m_depthStencilBuffer;
334 373
335 // For multisampling. 374 // For multisampling.
336 GLuint m_multisampleFBO; 375 GLuint m_multisampleFBO;
376 GLuint m_intermediateFBO;
377 GLuint m_intermediateRenderbuffer;
337 GLuint m_multisampleColorBuffer; 378 GLuint m_multisampleColorBuffer;
338 379
339 // True if our contents have been modified since the last presentation of th is buffer. 380 // True if our contents have been modified since the last presentation of th is buffer.
340 bool m_contentsChanged; 381 bool m_contentsChanged;
341 382
342 // True if commit() has been called since the last time markContentsChanged( ) had been called. 383 // True if commit() has been called since the last time markContentsChanged( ) had been called.
343 bool m_contentsChangeCommitted; 384 bool m_contentsChangeCommitted;
344 bool m_bufferClearNeeded; 385 bool m_bufferClearNeeded;
345 386
346 enum AntialiasingMode { 387 enum AntialiasingMode {
(...skipping 26 matching lines...) Expand all
373 // used to resize the Canvas. 414 // used to resize the Canvas.
374 SkBitmap m_resizingBitmap; 415 SkBitmap m_resizingBitmap;
375 416
376 // Used to flip a bitmap vertically. 417 // Used to flip a bitmap vertically.
377 Vector<uint8_t> m_scanline; 418 Vector<uint8_t> m_scanline;
378 }; 419 };
379 420
380 } // namespace blink 421 } // namespace blink
381 422
382 #endif // DrawingBuffer_h 423 #endif // DrawingBuffer_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/BUILD.gn ('k') | third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698