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

Side by Side Diff: gpu/command_buffer/service/gles2_cmd_decoder.cc

Issue 1583283004: Ensure alpha channel in backbuffer is correct with DirectComposition. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 | « no previous file | gpu/command_buffer/service/gles2_cmd_decoder_unittest_framebuffers.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
6 6
7 #include <limits.h> 7 #include <limits.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 #include <stdio.h> 10 #include <stdio.h>
(...skipping 1961 matching lines...) Expand 10 before | Expand all | Expand 10 after
1972 // TODO(zmo): when ES3 APIs are exposed to Nacl, make sure read_buffer_ 1972 // TODO(zmo): when ES3 APIs are exposed to Nacl, make sure read_buffer_
1973 // setting is set correctly when SwapBuffers(). 1973 // setting is set correctly when SwapBuffers().
1974 GLenum back_buffer_read_buffer_; 1974 GLenum back_buffer_read_buffer_;
1975 GLenum back_buffer_draw_buffer_; 1975 GLenum back_buffer_draw_buffer_;
1976 1976
1977 bool surfaceless_; 1977 bool surfaceless_;
1978 1978
1979 // Backbuffer attachments that are currently undefined. 1979 // Backbuffer attachments that are currently undefined.
1980 uint32_t backbuffer_needs_clear_bits_; 1980 uint32_t backbuffer_needs_clear_bits_;
1981 1981
1982 uint64_t swaps_since_resize_;
1983
1982 // The current decoder error communicates the decoder error through command 1984 // The current decoder error communicates the decoder error through command
1983 // processing functions that do not return the error value. Should be set only 1985 // processing functions that do not return the error value. Should be set only
1984 // if not returning an error. 1986 // if not returning an error.
1985 error::Error current_decoder_error_; 1987 error::Error current_decoder_error_;
1986 1988
1987 scoped_refptr<ShaderTranslatorInterface> vertex_translator_; 1989 scoped_refptr<ShaderTranslatorInterface> vertex_translator_;
1988 scoped_refptr<ShaderTranslatorInterface> fragment_translator_; 1990 scoped_refptr<ShaderTranslatorInterface> fragment_translator_;
1989 1991
1990 DisallowedFeatures disallowed_features_; 1992 DisallowedFeatures disallowed_features_;
1991 1993
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after
2517 offscreen_target_samples_(0), 2519 offscreen_target_samples_(0),
2518 offscreen_target_buffer_preserved_(true), 2520 offscreen_target_buffer_preserved_(true),
2519 offscreen_saved_color_format_(0), 2521 offscreen_saved_color_format_(0),
2520 back_buffer_color_format_(0), 2522 back_buffer_color_format_(0),
2521 back_buffer_has_depth_(false), 2523 back_buffer_has_depth_(false),
2522 back_buffer_has_stencil_(false), 2524 back_buffer_has_stencil_(false),
2523 back_buffer_read_buffer_(GL_BACK), 2525 back_buffer_read_buffer_(GL_BACK),
2524 back_buffer_draw_buffer_(GL_BACK), 2526 back_buffer_draw_buffer_(GL_BACK),
2525 surfaceless_(false), 2527 surfaceless_(false),
2526 backbuffer_needs_clear_bits_(0), 2528 backbuffer_needs_clear_bits_(0),
2529 swaps_since_resize_(0),
2527 current_decoder_error_(error::kNoError), 2530 current_decoder_error_(error::kNoError),
2528 validators_(group_->feature_info()->validators()), 2531 validators_(group_->feature_info()->validators()),
2529 feature_info_(group_->feature_info()), 2532 feature_info_(group_->feature_info()),
2530 frame_number_(0), 2533 frame_number_(0),
2531 has_robustness_extension_(false), 2534 has_robustness_extension_(false),
2532 context_lost_reason_(error::kUnknown), 2535 context_lost_reason_(error::kUnknown),
2533 context_was_lost_(false), 2536 context_was_lost_(false),
2534 reset_by_robustness_extension_(false), 2537 reset_by_robustness_extension_(false),
2535 supports_post_sub_buffer_(false), 2538 supports_post_sub_buffer_(false),
2536 supports_commit_overlay_planes_(false), 2539 supports_commit_overlay_planes_(false),
(...skipping 1098 matching lines...) Expand 10 before | Expand all | Expand 10 after
3635 OnFboChanged(); 3638 OnFboChanged();
3636 } 3639 }
3637 3640
3638 bool GLES2DecoderImpl::CheckFramebufferValid( 3641 bool GLES2DecoderImpl::CheckFramebufferValid(
3639 Framebuffer* framebuffer, 3642 Framebuffer* framebuffer,
3640 GLenum target, const char* func_name) { 3643 GLenum target, const char* func_name) {
3641 if (!framebuffer) { 3644 if (!framebuffer) {
3642 if (surfaceless_) 3645 if (surfaceless_)
3643 return false; 3646 return false;
3644 if (backbuffer_needs_clear_bits_) { 3647 if (backbuffer_needs_clear_bits_) {
3645 glClearColor(0, 0, 0, (GLES2Util::GetChannelsForFormat( 3648 glClearColor(0, 0, 0, BackBufferHasAlpha() ? 0 : 1.f);
3646 offscreen_target_color_format_) & 0x0008) != 0 ? 0 : 1.f);
3647 state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 3649 state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
3648 glClearStencil(0); 3650 glClearStencil(0);
3649 state_.SetDeviceStencilMaskSeparate(GL_FRONT, kDefaultStencilMask); 3651 state_.SetDeviceStencilMaskSeparate(GL_FRONT, kDefaultStencilMask);
3650 state_.SetDeviceStencilMaskSeparate(GL_BACK, kDefaultStencilMask); 3652 state_.SetDeviceStencilMaskSeparate(GL_BACK, kDefaultStencilMask);
3651 glClearDepth(1.0f); 3653 glClearDepth(1.0f);
3652 state_.SetDeviceDepthMask(GL_TRUE); 3654 state_.SetDeviceDepthMask(GL_TRUE);
3653 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false); 3655 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false);
3654 bool reset_draw_buffer = false; 3656 bool reset_draw_buffer = false;
3655 if ((backbuffer_needs_clear_bits_ & GL_COLOR_BUFFER_BIT) != 0 && 3657 if ((backbuffer_needs_clear_bits_ & GL_COLOR_BUFFER_BIT) != 0 &&
3656 back_buffer_draw_buffer_ == GL_NONE) { 3658 back_buffer_draw_buffer_ == GL_NONE) {
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after
4331 !!has_alpha)) { 4333 !!has_alpha)) {
4332 LOG(ERROR) << "GLES2DecoderImpl: Context lost because resize failed."; 4334 LOG(ERROR) << "GLES2DecoderImpl: Context lost because resize failed.";
4333 return error::kLostContext; 4335 return error::kLostContext;
4334 } 4336 }
4335 DCHECK(context_->IsCurrent(surface_.get())); 4337 DCHECK(context_->IsCurrent(surface_.get()));
4336 if (!context_->IsCurrent(surface_.get())) { 4338 if (!context_->IsCurrent(surface_.get())) {
4337 LOG(ERROR) << "GLES2DecoderImpl: Context lost because context no longer " 4339 LOG(ERROR) << "GLES2DecoderImpl: Context lost because context no longer "
4338 << "current after resize callback."; 4340 << "current after resize callback.";
4339 return error::kLostContext; 4341 return error::kLostContext;
4340 } 4342 }
4343 if (surface_->BuffersFlipped()) {
4344 backbuffer_needs_clear_bits_ |= GL_COLOR_BUFFER_BIT;
4345 }
4341 } 4346 }
4342 4347
4348 swaps_since_resize_ = 0;
4349
4343 return error::kNoError; 4350 return error::kNoError;
4344 } 4351 }
4345 4352
4346 const char* GLES2DecoderImpl::GetCommandName(unsigned int command_id) const { 4353 const char* GLES2DecoderImpl::GetCommandName(unsigned int command_id) const {
4347 if (command_id > kStartPoint && command_id < kNumCommands) { 4354 if (command_id > kStartPoint && command_id < kNumCommands) {
4348 return gles2::GetCommandName(static_cast<CommandId>(command_id)); 4355 return gles2::GetCommandName(static_cast<CommandId>(command_id));
4349 } 4356 }
4350 return GetCommonCommandName(static_cast<cmd::CommandId>(command_id)); 4357 return GetCommonCommandName(static_cast<cmd::CommandId>(command_id));
4351 } 4358 }
4352 4359
(...skipping 7833 matching lines...) Expand 10 before | Expand all | Expand 10 after
12186 } 12193 }
12187 12194
12188 void GLES2DecoderImpl::FinishSwapBuffers(gfx::SwapResult result) { 12195 void GLES2DecoderImpl::FinishSwapBuffers(gfx::SwapResult result) {
12189 if (result == gfx::SwapResult::SWAP_FAILED) { 12196 if (result == gfx::SwapResult::SWAP_FAILED) {
12190 LOG(ERROR) << "Context lost because SwapBuffers failed."; 12197 LOG(ERROR) << "Context lost because SwapBuffers failed.";
12191 if (!CheckResetStatus()) { 12198 if (!CheckResetStatus()) {
12192 MarkContextLost(error::kUnknown); 12199 MarkContextLost(error::kUnknown);
12193 group_->LoseContexts(error::kUnknown); 12200 group_->LoseContexts(error::kUnknown);
12194 } 12201 }
12195 } 12202 }
12203 ++swaps_since_resize_;
12204 if (swaps_since_resize_ == 1 && surface_->BuffersFlipped()) {
12205 // The second buffer after a resize is new and needs to be cleared to
12206 // known values.
12207 backbuffer_needs_clear_bits_ |= GL_COLOR_BUFFER_BIT;
12208 }
12196 } 12209 }
12197 12210
12198 void GLES2DecoderImpl::DoCommitOverlayPlanes() { 12211 void GLES2DecoderImpl::DoCommitOverlayPlanes() {
12199 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCommitOverlayPlanes"); 12212 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCommitOverlayPlanes");
12200 if (supports_async_swap_) { 12213 if (supports_async_swap_) {
12201 surface_->CommitOverlayPlanesAsync(base::Bind( 12214 surface_->CommitOverlayPlanesAsync(base::Bind(
12202 &GLES2DecoderImpl::FinishSwapBuffers, base::AsWeakPtr(this))); 12215 &GLES2DecoderImpl::FinishSwapBuffers, base::AsWeakPtr(this)));
12203 } else { 12216 } else {
12204 FinishSwapBuffers(surface_->CommitOverlayPlanes()); 12217 FinishSwapBuffers(surface_->CommitOverlayPlanes());
12205 } 12218 }
(...skipping 3349 matching lines...) Expand 10 before | Expand all | Expand 10 after
15555 } 15568 }
15556 15569
15557 // Include the auto-generated part of this file. We split this because it means 15570 // Include the auto-generated part of this file. We split this because it means
15558 // we can easily edit the non-auto generated parts right here in this file 15571 // we can easily edit the non-auto generated parts right here in this file
15559 // instead of having to edit some template or the code generator. 15572 // instead of having to edit some template or the code generator.
15560 #include "base/macros.h" 15573 #include "base/macros.h"
15561 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 15574 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
15562 15575
15563 } // namespace gles2 15576 } // namespace gles2
15564 } // namespace gpu 15577 } // namespace gpu
OLDNEW
« no previous file with comments | « no previous file | gpu/command_buffer/service/gles2_cmd_decoder_unittest_framebuffers.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698