OLD | NEW |
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 <stdio.h> | 7 #include <stdio.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <list> | 10 #include <list> |
(...skipping 2964 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2975 if (framebuffer != NULL) { | 2975 if (framebuffer != NULL) { |
2976 return framebuffer->GetColorAttachmentFormat(); | 2976 return framebuffer->GetColorAttachmentFormat(); |
2977 } else if (offscreen_target_frame_buffer_.get()) { | 2977 } else if (offscreen_target_frame_buffer_.get()) { |
2978 return offscreen_target_color_format_; | 2978 return offscreen_target_color_format_; |
2979 } else { | 2979 } else { |
2980 return back_buffer_color_format_; | 2980 return back_buffer_color_format_; |
2981 } | 2981 } |
2982 } | 2982 } |
2983 | 2983 |
2984 void GLES2DecoderImpl::UpdateParentTextureInfo() { | 2984 void GLES2DecoderImpl::UpdateParentTextureInfo() { |
2985 if (parent_) { | 2985 if (parent_.get()) { |
2986 // Update the info about the offscreen saved color texture in the parent. | 2986 // Update the info about the offscreen saved color texture in the parent. |
2987 // The reference to the parent is a weak pointer and will become null if the | 2987 // The reference to the parent is a weak pointer and will become null if the |
2988 // parent is later destroyed. | 2988 // parent is later destroyed. |
2989 GLenum target = offscreen_saved_color_texture_info_->texture()->target(); | 2989 GLenum target = offscreen_saved_color_texture_info_->texture()->target(); |
2990 TextureManager* parent_texture_manager = parent_->texture_manager(); | 2990 TextureManager* parent_texture_manager = parent_->texture_manager(); |
2991 glBindTexture(target, offscreen_saved_color_texture_info_->service_id()); | 2991 glBindTexture(target, offscreen_saved_color_texture_info_->service_id()); |
2992 parent_texture_manager->SetLevelInfo( | 2992 parent_texture_manager->SetLevelInfo( |
2993 offscreen_saved_color_texture_info_.get(), | 2993 offscreen_saved_color_texture_info_.get(), |
2994 GL_TEXTURE_2D, | 2994 GL_TEXTURE_2D, |
2995 0, // level | 2995 0, // level |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3240 } | 3240 } |
3241 | 3241 |
3242 bool GLES2DecoderImpl::SetParent(GLES2Decoder* new_parent, | 3242 bool GLES2DecoderImpl::SetParent(GLES2Decoder* new_parent, |
3243 uint32 new_parent_texture_id) { | 3243 uint32 new_parent_texture_id) { |
3244 if (!offscreen_saved_color_texture_.get()) | 3244 if (!offscreen_saved_color_texture_.get()) |
3245 return false; | 3245 return false; |
3246 | 3246 |
3247 // Remove the saved frame buffer mapping from the parent decoder. The | 3247 // Remove the saved frame buffer mapping from the parent decoder. The |
3248 // parent pointer is a weak pointer so it will be null if the parent has | 3248 // parent pointer is a weak pointer so it will be null if the parent has |
3249 // already been destroyed. | 3249 // already been destroyed. |
3250 if (parent_) { | 3250 if (parent_.get()) { |
3251 ChildList::iterator it = std::find( | 3251 ChildList::iterator it = |
3252 parent_->children_.begin(), | 3252 std::find(parent_->children_.begin(), parent_->children_.end(), this); |
3253 parent_->children_.end(), | |
3254 this); | |
3255 DCHECK(it != parent_->children_.end()); | 3253 DCHECK(it != parent_->children_.end()); |
3256 parent_->children_.erase(it); | 3254 parent_->children_.erase(it); |
3257 // First check the texture has been mapped into the parent. This might not | 3255 // First check the texture has been mapped into the parent. This might not |
3258 // be the case if initialization failed midway through. | 3256 // be the case if initialization failed midway through. |
3259 if (offscreen_saved_color_texture_info_.get() && | 3257 if (offscreen_saved_color_texture_info_.get() && |
3260 offscreen_saved_color_texture_info_->client_id()) { | 3258 offscreen_saved_color_texture_info_->client_id()) { |
3261 parent_->texture_manager()->RemoveTexture( | 3259 parent_->texture_manager()->RemoveTexture( |
3262 offscreen_saved_color_texture_info_->client_id()); | 3260 offscreen_saved_color_texture_info_->client_id()); |
3263 } | 3261 } |
3264 } | 3262 } |
(...skipping 5774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9039 // Only loses the context once. | 9037 // Only loses the context once. |
9040 if (reset_status_ != GL_NO_ERROR) { | 9038 if (reset_status_ != GL_NO_ERROR) { |
9041 return; | 9039 return; |
9042 } | 9040 } |
9043 | 9041 |
9044 // Marks this context as lost. | 9042 // Marks this context as lost. |
9045 reset_status_ = reset_status; | 9043 reset_status_ = reset_status; |
9046 current_decoder_error_ = error::kLostContext; | 9044 current_decoder_error_ = error::kLostContext; |
9047 | 9045 |
9048 // Loses the parent's context. | 9046 // Loses the parent's context. |
9049 if (parent_) { | 9047 if (parent_.get()) { |
9050 parent_->LoseContext(reset_status); | 9048 parent_->LoseContext(reset_status); |
9051 } | 9049 } |
9052 | 9050 |
9053 // Loses any child contexts. | 9051 // Loses any child contexts. |
9054 for (ChildList::iterator it = children_.begin(); | 9052 for (ChildList::iterator it = children_.begin(); |
9055 it != children_.end(); | 9053 it != children_.end(); |
9056 ++it) { | 9054 ++it) { |
9057 (*it)->LoseContext(reset_status); | 9055 (*it)->LoseContext(reset_status); |
9058 } | 9056 } |
9059 } | 9057 } |
(...skipping 1314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10374 return error::kNoError; | 10372 return error::kNoError; |
10375 } | 10373 } |
10376 | 10374 |
10377 // Include the auto-generated part of this file. We split this because it means | 10375 // Include the auto-generated part of this file. We split this because it means |
10378 // we can easily edit the non-auto generated parts right here in this file | 10376 // we can easily edit the non-auto generated parts right here in this file |
10379 // instead of having to edit some template or the code generator. | 10377 // instead of having to edit some template or the code generator. |
10380 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 10378 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
10381 | 10379 |
10382 } // namespace gles2 | 10380 } // namespace gles2 |
10383 } // namespace gpu | 10381 } // namespace gpu |
OLD | NEW |