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

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

Issue 2841573002: Revert of Fix blits from multisampled renderbuffers to alpha:false WebGL back buffer. (Closed)
Patch Set: Created 3 years, 8 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 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 // Rebind the read and draw framebuffers that WebGL is expecting. 225 // Rebind the read and draw framebuffers that WebGL is expecting.
226 void RestoreFramebufferBindings(); 226 void RestoreFramebufferBindings();
227 227
228 // Restore all state that may have been dirtied by any call. 228 // Restore all state that may have been dirtied by any call.
229 void RestoreAllState(); 229 void RestoreAllState();
230 230
231 void AddNewMailboxCallback(std::unique_ptr<WTF::Closure> closure) { 231 void AddNewMailboxCallback(std::unique_ptr<WTF::Closure> closure) {
232 new_mailbox_callback_ = std::move(closure); 232 new_mailbox_callback_ = std::move(closure);
233 } 233 }
234 234
235 // This class helps implement correct semantics for BlitFramebuffer
236 // when the DrawingBuffer is using a CHROMIUM image for its backing
237 // store and RGB emulation is in use (basically, macOS only).
238 class PLATFORM_EXPORT ScopedRGBEmulationForBlitFramebuffer {
239 public:
240 ScopedRGBEmulationForBlitFramebuffer(DrawingBuffer*);
241 ~ScopedRGBEmulationForBlitFramebuffer();
242
243 private:
244 RefPtr<DrawingBuffer> drawing_buffer_;
245 bool doing_work_ = false;
246 };
247
248 protected: // For unittests 235 protected: // For unittests
249 DrawingBuffer(std::unique_ptr<WebGraphicsContext3DProvider>, 236 DrawingBuffer(std::unique_ptr<WebGraphicsContext3DProvider>,
250 std::unique_ptr<Extensions3DUtil>, 237 std::unique_ptr<Extensions3DUtil>,
251 Client*, 238 Client*,
252 bool discard_framebuffer_supported, 239 bool discard_framebuffer_supported,
253 bool want_alpha_channel, 240 bool want_alpha_channel,
254 bool premultiplied_alpha, 241 bool premultiplied_alpha,
255 PreserveDrawingBuffer, 242 PreserveDrawingBuffer,
256 WebGLVersion, 243 WebGLVersion,
257 bool wants_depth, 244 bool wants_depth,
258 bool wants_stencil, 245 bool wants_stencil,
259 ChromiumImageUsage, 246 ChromiumImageUsage,
260 const CanvasColorParams&); 247 const CanvasColorParams&);
261 248
262 bool Initialize(const IntSize&, bool use_multisampling); 249 bool Initialize(const IntSize&, bool use_multisampling);
263 250
264 // Shared memory bitmaps that were released by the compositor and can be used 251 // Shared memory bitmaps that were released by the compositor and can be used
265 // again by this DrawingBuffer. 252 // again by this DrawingBuffer.
266 struct RecycledBitmap { 253 struct RecycledBitmap {
267 std::unique_ptr<cc::SharedBitmap> bitmap; 254 std::unique_ptr<cc::SharedBitmap> bitmap;
268 IntSize size; 255 IntSize size;
269 }; 256 };
270 Vector<RecycledBitmap> recycled_bitmaps_; 257 Vector<RecycledBitmap> recycled_bitmaps_;
271 258
272 private: 259 private:
273 friend class ScopedRGBEmulationForBlitFramebuffer;
274 friend class ScopedStateRestorer; 260 friend class ScopedStateRestorer;
275 friend class ColorBuffer; 261 friend class ColorBuffer;
276 262
277 // This structure should wrap all public entrypoints that may modify GL state. 263 // This structure should wrap all public entrypoints that may modify GL state.
278 // It will restore all state when it drops out of scope. 264 // It will restore all state when it drops out of scope.
279 class ScopedStateRestorer { 265 class ScopedStateRestorer {
280 public: 266 public:
281 ScopedStateRestorer(DrawingBuffer*); 267 ScopedStateRestorer(DrawingBuffer*);
282 ~ScopedStateRestorer(); 268 ~ScopedStateRestorer();
283 269
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 // ColorBuffers. 310 // ColorBuffers.
325 RefPtr<DrawingBuffer> drawing_buffer; 311 RefPtr<DrawingBuffer> drawing_buffer;
326 312
327 const ColorBufferParameters parameters; 313 const ColorBufferParameters parameters;
328 const IntSize size; 314 const IntSize size;
329 315
330 const GLuint texture_id = 0; 316 const GLuint texture_id = 0;
331 const GLuint image_id = 0; 317 const GLuint image_id = 0;
332 std::unique_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer; 318 std::unique_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer;
333 319
334 // If we're emulating an RGB back buffer using an RGBA Chromium
335 // image (essentially macOS only), then when performing
336 // BlitFramebuffer calls, we have to swap in an RGB texture in
337 // place of the RGBA texture bound to the image. The reason is
338 // that BlitFramebuffer requires the internal formats of the
339 // source and destination to match (e.g. RGB8 on both sides).
340 // There are bugs in the semantics of RGB8 textures in this
341 // situation (the alpha channel is zeroed), requiring more fixups.
342 GLuint rgb_workaround_texture_id = 0;
343
344 // The mailbox used to send this buffer to the compositor. 320 // The mailbox used to send this buffer to the compositor.
345 gpu::Mailbox mailbox; 321 gpu::Mailbox mailbox;
346 322
347 // The sync token for when this buffer was sent to the compositor. 323 // The sync token for when this buffer was sent to the compositor.
348 gpu::SyncToken produce_sync_token; 324 gpu::SyncToken produce_sync_token;
349 325
350 // The sync token for when this buffer was received back from the 326 // The sync token for when this buffer was received back from the
351 // compositor. 327 // compositor.
352 gpu::SyncToken receive_sync_token; 328 gpu::SyncToken receive_sync_token;
353 329
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 // implemented by forwarding all draw operations to a multisample 421 // implemented by forwarding all draw operations to a multisample
446 // renderbuffer, which is resolved before any read operations or swaps. 422 // renderbuffer, which is resolved before any read operations or swaps.
447 bool WantExplicitResolve(); 423 bool WantExplicitResolve();
448 424
449 // Whether the WebGL client wants a depth or stencil buffer. 425 // Whether the WebGL client wants a depth or stencil buffer.
450 bool WantDepthOrStencil(); 426 bool WantDepthOrStencil();
451 427
452 // The format to use when creating a multisampled renderbuffer. 428 // The format to use when creating a multisampled renderbuffer.
453 GLenum GetMultisampledRenderbufferFormat(); 429 GLenum GetMultisampledRenderbufferFormat();
454 430
455 // Helpers to ensure correct behavior of BlitFramebuffer when using
456 // an emulated RGB CHROMIUM_image back buffer.
457 bool SetupRGBEmulationForBlitFramebuffer();
458 void CleanupRGBEmulationForBlitFramebuffer();
459
460 // Weak, reset by beginDestruction. 431 // Weak, reset by beginDestruction.
461 Client* client_ = nullptr; 432 Client* client_ = nullptr;
462 433
463 const PreserveDrawingBuffer preserve_drawing_buffer_; 434 const PreserveDrawingBuffer preserve_drawing_buffer_;
464 const WebGLVersion web_gl_version_; 435 const WebGLVersion web_gl_version_;
465 436
466 std::unique_ptr<WebGraphicsContext3DProviderWrapper> context_provider_; 437 std::unique_ptr<WebGraphicsContext3DProviderWrapper> context_provider_;
467 // Lifetime is tied to the m_contextProvider. 438 // Lifetime is tied to the m_contextProvider.
468 gpu::gles2::GLES2Interface* gl_; 439 gpu::gles2::GLES2Interface* gl_;
469 std::unique_ptr<Extensions3DUtil> extensions_util_; 440 std::unique_ptr<Extensions3DUtil> extensions_util_;
470 IntSize size_ = {-1, -1}; 441 IntSize size_ = {-1, -1};
471 const bool discard_framebuffer_supported_; 442 const bool discard_framebuffer_supported_;
472 const bool want_alpha_channel_; 443 const bool want_alpha_channel_;
473 const bool premultiplied_alpha_; 444 const bool premultiplied_alpha_;
474 const bool software_rendering_; 445 const bool software_rendering_;
475 bool has_implicit_stencil_buffer_ = false; 446 bool has_implicit_stencil_buffer_ = false;
476 bool storage_texture_supported_ = false; 447 bool storage_texture_supported_ = false;
477 448
478 std::unique_ptr<WTF::Closure> new_mailbox_callback_; 449 std::unique_ptr<WTF::Closure> new_mailbox_callback_;
479 450
480 // The current state restorer, which is used to track state dirtying. It is an 451 // The current state restorer, which is used to track state dirtying. It is in
481 // error to dirty state shared with WebGL while there is no existing state 452 // error to dirty state shared with WebGL while there is no existing state
482 // restorer. 453 // restorer. It is also in error to instantiate two state restorers at once.
483 ScopedStateRestorer* state_restorer_ = nullptr; 454 ScopedStateRestorer* state_restorer_ = nullptr;
484 455
485 // This is used when the user requests either a depth or stencil buffer. 456 // This is used when the user requests either a depth or stencil buffer.
486 GLuint depth_stencil_buffer_ = 0; 457 GLuint depth_stencil_buffer_ = 0;
487 458
488 // When wantExplicitResolve() returns true, the target of all draw 459 // When wantExplicitResolve() returns true, the target of all draw
489 // operations. 460 // operations.
490 GLuint multisample_fbo_ = 0; 461 GLuint multisample_fbo_ = 0;
491 462
492 // The id of the renderbuffer storage for |m_multisampleFBO|. 463 // The id of the renderbuffer storage for |m_multisampleFBO|.
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 // RuntimeEnabledFeatures::webGLImageChromiumEnabled() call with 525 // RuntimeEnabledFeatures::webGLImageChromiumEnabled() call with
555 // shouldUseChromiumImage() calls, and set m_chromiumImageUsage to 526 // shouldUseChromiumImage() calls, and set m_chromiumImageUsage to
556 // DisallowChromiumImage in the case of OffscreenCanvas. 527 // DisallowChromiumImage in the case of OffscreenCanvas.
557 ChromiumImageUsage chromium_image_usage_; 528 ChromiumImageUsage chromium_image_usage_;
558 bool ShouldUseChromiumImage(); 529 bool ShouldUseChromiumImage();
559 }; 530 };
560 531
561 } // namespace blink 532 } // namespace blink
562 533
563 #endif // DrawingBuffer_h 534 #endif // DrawingBuffer_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698