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

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

Issue 2822743003: Preserve alpha channel of 1.0 when emulating RGB back buffer.
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
« no previous file with comments | « third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 GetMultisampledRenderbufferFormat() == GL_RGBA8_OES; 225 GetMultisampledRenderbufferFormat() == GL_RGBA8_OES;
226 } 226 }
227 227
228 bool rgb_emulation = 228 bool rgb_emulation =
229 ContextProvider()->GetCapabilities().emulate_rgb_buffer_with_rgba || 229 ContextProvider()->GetCapabilities().emulate_rgb_buffer_with_rgba ||
230 (ShouldUseChromiumImage() && 230 (ShouldUseChromiumImage() &&
231 ContextProvider()->GetCapabilities().chromium_image_rgb_emulation); 231 ContextProvider()->GetCapabilities().chromium_image_rgb_emulation);
232 return !want_alpha_channel_ && rgb_emulation; 232 return !want_alpha_channel_ && rgb_emulation;
233 } 233 }
234 234
235 void DrawingBuffer::MarkBlitFramebufferUsedThisFrame() {
236 blit_framebuffer_used_this_frame_ = true;
237 }
238
235 std::unique_ptr<cc::SharedBitmap> DrawingBuffer::CreateOrRecycleBitmap() { 239 std::unique_ptr<cc::SharedBitmap> DrawingBuffer::CreateOrRecycleBitmap() {
236 auto it = std::remove_if( 240 auto it = std::remove_if(
237 recycled_bitmaps_.begin(), recycled_bitmaps_.end(), 241 recycled_bitmaps_.begin(), recycled_bitmaps_.end(),
238 [this](const RecycledBitmap& bitmap) { return bitmap.size != size_; }); 242 [this](const RecycledBitmap& bitmap) { return bitmap.size != size_; });
239 recycled_bitmaps_.Shrink(it - recycled_bitmaps_.begin()); 243 recycled_bitmaps_.Shrink(it - recycled_bitmaps_.begin());
240 244
241 if (!recycled_bitmaps_.IsEmpty()) { 245 if (!recycled_bitmaps_.IsEmpty()) {
242 RecycledBitmap recycled = std::move(recycled_bitmaps_.back()); 246 RecycledBitmap recycled = std::move(recycled_bitmaps_.back());
243 recycled_bitmaps_.pop_back(); 247 recycled_bitmaps_.pop_back();
244 DCHECK(recycled.size == size_); 248 DCHECK(recycled.size == size_);
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 WTF::Bind(&DrawingBuffer::MailboxReleasedGpu, 410 WTF::Bind(&DrawingBuffer::MailboxReleasedGpu,
407 RefPtr<DrawingBuffer>(this), color_buffer_for_mailbox); 411 RefPtr<DrawingBuffer>(this), color_buffer_for_mailbox);
408 *out_release_callback = cc::SingleReleaseCallback::Create( 412 *out_release_callback = cc::SingleReleaseCallback::Create(
409 ConvertToBaseCallback(std::move(func))); 413 ConvertToBaseCallback(std::move(func)));
410 } 414 }
411 415
412 // Point |m_frontColorBuffer| to the buffer that we are now presenting. 416 // Point |m_frontColorBuffer| to the buffer that we are now presenting.
413 front_color_buffer_ = color_buffer_for_mailbox; 417 front_color_buffer_ = color_buffer_for_mailbox;
414 418
415 contents_changed_ = false; 419 contents_changed_ = false;
420 blit_framebuffer_used_this_frame_ = false;
416 SetBufferClearNeeded(true); 421 SetBufferClearNeeded(true);
417 return true; 422 return true;
418 } 423 }
419 424
420 void DrawingBuffer::MailboxReleasedGpu(RefPtr<ColorBuffer> color_buffer, 425 void DrawingBuffer::MailboxReleasedGpu(RefPtr<ColorBuffer> color_buffer,
421 const gpu::SyncToken& sync_token, 426 const gpu::SyncToken& sync_token,
422 bool lost_resource) { 427 bool lost_resource) {
423 // If the mailbox has been returned by the compositor then it is no 428 // If the mailbox has been returned by the compositor then it is no
424 // longer being presented, and so is no longer the front buffer. 429 // longer being presented, and so is no longer the front buffer.
425 if (color_buffer == front_color_buffer_) 430 if (color_buffer == front_color_buffer_)
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after
1012 } 1017 }
1013 1018
1014 gl_->BindFramebuffer(GL_FRAMEBUFFER, fbo_); 1019 gl_->BindFramebuffer(GL_FRAMEBUFFER, fbo_);
1015 if (anti_aliasing_mode_ == kScreenSpaceAntialiasing) 1020 if (anti_aliasing_mode_ == kScreenSpaceAntialiasing)
1016 gl_->ApplyScreenSpaceAntialiasingCHROMIUM(); 1021 gl_->ApplyScreenSpaceAntialiasingCHROMIUM();
1017 } 1022 }
1018 1023
1019 void DrawingBuffer::ResolveIfNeeded() { 1024 void DrawingBuffer::ResolveIfNeeded() {
1020 if (anti_aliasing_mode_ != kNone) 1025 if (anti_aliasing_mode_ != kNone)
1021 ResolveMultisampleFramebufferInternal(); 1026 ResolveMultisampleFramebufferInternal();
1027
1028 // If the user performed a manual BlitFramebuffer to the default
1029 // back buffer, they may have populated the alpha channel with
1030 // values not equal to 1.0. Must undo this.
1031 if (DefaultBufferRequiresAlphaChannelToBePreserved() &&
1032 blit_framebuffer_used_this_frame_) {
1033 // Avoid repeating this work if it's already been done.
1034 if (anti_aliasing_mode_ != kNone &&
1035 ContextProvider()
1036 ->GetCapabilities()
1037 .disable_multisampling_color_mask_usage) {
1038 // Do nothing.
1039 } else {
1040 DCHECK(state_restorer_);
1041 state_restorer_->SetClearStateDirty();
1042 gl_->ClearColor(0, 0, 0, 1);
1043 gl_->ColorMask(false, false, false, true);
1044 gl_->Clear(GL_COLOR_BUFFER_BIT);
1045 }
1046 }
1047
1022 contents_change_resolved_ = true; 1048 contents_change_resolved_ = true;
1023 } 1049 }
1024 1050
1025 void DrawingBuffer::RestoreFramebufferBindings() { 1051 void DrawingBuffer::RestoreFramebufferBindings() {
1026 client_->DrawingBufferClientRestoreFramebufferBinding(); 1052 client_->DrawingBufferClientRestoreFramebufferBinding();
1027 } 1053 }
1028 1054
1029 void DrawingBuffer::RestoreAllState() { 1055 void DrawingBuffer::RestoreAllState() {
1030 client_->DrawingBufferClientRestoreScissorTest(); 1056 client_->DrawingBufferClientRestoreScissorTest();
1031 client_->DrawingBufferClientRestoreMaskAndClearValues(); 1057 client_->DrawingBufferClientRestoreMaskAndClearValues();
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
1301 if (pixel_unpack_buffer_binding_dirty_) 1327 if (pixel_unpack_buffer_binding_dirty_)
1302 client->DrawingBufferClientRestorePixelUnpackBufferBinding(); 1328 client->DrawingBufferClientRestorePixelUnpackBufferBinding();
1303 } 1329 }
1304 1330
1305 bool DrawingBuffer::ShouldUseChromiumImage() { 1331 bool DrawingBuffer::ShouldUseChromiumImage() {
1306 return RuntimeEnabledFeatures::webGLImageChromiumEnabled() && 1332 return RuntimeEnabledFeatures::webGLImageChromiumEnabled() &&
1307 chromium_image_usage_ == kAllowChromiumImage; 1333 chromium_image_usage_ == kAllowChromiumImage;
1308 } 1334 }
1309 1335
1310 } // namespace blink 1336 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698