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

Side by Side Diff: cc/output/gl_renderer.cc

Issue 609663003: cc: Remove use of PassAs() and constructor-casting with scoped_ptr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cc-passas: PassAs-presubmit-warning Created 6 years, 2 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 | « cc/output/delegating_renderer_unittest.cc ('k') | cc/output/gl_renderer_unittest.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 2010 The Chromium Authors. All rights reserved. 1 // Copyright 2010 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 "cc/output/gl_renderer.h" 5 #include "cc/output/gl_renderer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 GLint active_unit = 0; 138 GLint active_unit = 0;
139 gl->GetIntegerv(GL_ACTIVE_TEXTURE, &active_unit); 139 gl->GetIntegerv(GL_ACTIVE_TEXTURE, &active_unit);
140 return active_unit; 140 return active_unit;
141 } 141 }
142 142
143 class GLRenderer::ScopedUseGrContext { 143 class GLRenderer::ScopedUseGrContext {
144 public: 144 public:
145 static scoped_ptr<ScopedUseGrContext> Create(GLRenderer* renderer, 145 static scoped_ptr<ScopedUseGrContext> Create(GLRenderer* renderer,
146 DrawingFrame* frame) { 146 DrawingFrame* frame) {
147 if (!renderer->output_surface_->context_provider()->GrContext()) 147 if (!renderer->output_surface_->context_provider()->GrContext())
148 return scoped_ptr<ScopedUseGrContext>(); 148 return nullptr;
149 return make_scoped_ptr(new ScopedUseGrContext(renderer, frame)); 149 return make_scoped_ptr(new ScopedUseGrContext(renderer, frame));
150 } 150 }
151 151
152 ~ScopedUseGrContext() { PassControlToGLRenderer(); } 152 ~ScopedUseGrContext() { PassControlToGLRenderer(); }
153 153
154 GrContext* context() const { 154 GrContext* context() const {
155 return renderer_->output_surface_->context_provider()->GrContext(); 155 return renderer_->output_surface_->context_provider()->GrContext();
156 } 156 }
157 157
158 private: 158 private:
(...skipping 802 matching lines...) Expand 10 before | Expand all | Expand 10 after
961 CopyTextureToFramebuffer(frame, 961 CopyTextureToFramebuffer(frame,
962 filtered_device_background_texture_id, 962 filtered_device_background_texture_id,
963 window_rect, 963 window_rect,
964 device_to_framebuffer_transform, 964 device_to_framebuffer_transform,
965 flip_vertically); 965 flip_vertically);
966 } 966 }
967 967
968 UseRenderPass(frame, target_render_pass); 968 UseRenderPass(frame, target_render_pass);
969 969
970 if (!using_background_texture) 970 if (!using_background_texture)
971 return scoped_ptr<ScopedResource>(); 971 return nullptr;
972 return background_texture.Pass(); 972 return background_texture.Pass();
973 } 973 }
974 974
975 void GLRenderer::DrawRenderPassQuad(DrawingFrame* frame, 975 void GLRenderer::DrawRenderPassQuad(DrawingFrame* frame,
976 const RenderPassDrawQuad* quad) { 976 const RenderPassDrawQuad* quad) {
977 SetBlendEnabled(quad->ShouldDrawWithBlending()); 977 SetBlendEnabled(quad->ShouldDrawWithBlending());
978 978
979 ScopedResource* contents_texture = 979 ScopedResource* contents_texture =
980 render_pass_textures_.get(quad->render_pass_id); 980 render_pass_textures_.get(quad->render_pass_id);
981 if (!contents_texture || !contents_texture->id()) 981 if (!contents_texture || !contents_texture->id())
(...skipping 1178 matching lines...) Expand 10 before | Expand all | Expand 10 after
2160 GLC(gl_, gl_->BindTexture(GL_TEXTURE_RECTANGLE_ARB, 0)); 2160 GLC(gl_, gl_->BindTexture(GL_TEXTURE_RECTANGLE_ARB, 0));
2161 } 2161 }
2162 2162
2163 void GLRenderer::FinishDrawingFrame(DrawingFrame* frame) { 2163 void GLRenderer::FinishDrawingFrame(DrawingFrame* frame) {
2164 if (use_sync_query_) { 2164 if (use_sync_query_) {
2165 DCHECK(current_sync_query_); 2165 DCHECK(current_sync_query_);
2166 current_sync_query_->End(); 2166 current_sync_query_->End();
2167 pending_sync_queries_.push_back(current_sync_query_.Pass()); 2167 pending_sync_queries_.push_back(current_sync_query_.Pass());
2168 } 2168 }
2169 2169
2170 current_framebuffer_lock_.reset(); 2170 current_framebuffer_lock_ = nullptr;
2171 swap_buffer_rect_.Union(gfx::ToEnclosingRect(frame->root_damage_rect)); 2171 swap_buffer_rect_.Union(gfx::ToEnclosingRect(frame->root_damage_rect));
2172 2172
2173 GLC(gl_, gl_->Disable(GL_BLEND)); 2173 GLC(gl_, gl_->Disable(GL_BLEND));
2174 blend_shadow_ = false; 2174 blend_shadow_ = false;
2175 2175
2176 ScheduleOverlays(frame); 2176 ScheduleOverlays(frame);
2177 } 2177 }
2178 2178
2179 void GLRenderer::FinishDrawingQuadList() { FlushTextureQuadCache(); } 2179 void GLRenderer::FinishDrawingQuadList() { FlushTextureQuadCache(); }
2180 2180
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
2638 const ScopedResource* texture, 2638 const ScopedResource* texture,
2639 const gfx::Rect& viewport_rect) { 2639 const gfx::Rect& viewport_rect) {
2640 DCHECK(texture->id()); 2640 DCHECK(texture->id());
2641 frame->current_render_pass = NULL; 2641 frame->current_render_pass = NULL;
2642 frame->current_texture = texture; 2642 frame->current_texture = texture;
2643 2643
2644 return BindFramebufferToTexture(frame, texture, viewport_rect); 2644 return BindFramebufferToTexture(frame, texture, viewport_rect);
2645 } 2645 }
2646 2646
2647 void GLRenderer::BindFramebufferToOutputSurface(DrawingFrame* frame) { 2647 void GLRenderer::BindFramebufferToOutputSurface(DrawingFrame* frame) {
2648 current_framebuffer_lock_.reset(); 2648 current_framebuffer_lock_ = nullptr;
2649 output_surface_->BindFramebuffer(); 2649 output_surface_->BindFramebuffer();
2650 2650
2651 if (output_surface_->HasExternalStencilTest()) { 2651 if (output_surface_->HasExternalStencilTest()) {
2652 SetStencilEnabled(true); 2652 SetStencilEnabled(true);
2653 GLC(gl_, gl_->StencilFunc(GL_EQUAL, 1, 1)); 2653 GLC(gl_, gl_->StencilFunc(GL_EQUAL, 1, 1));
2654 } else { 2654 } else {
2655 SetStencilEnabled(false); 2655 SetStencilEnabled(false);
2656 } 2656 }
2657 } 2657 }
2658 2658
2659 bool GLRenderer::BindFramebufferToTexture(DrawingFrame* frame, 2659 bool GLRenderer::BindFramebufferToTexture(DrawingFrame* frame,
2660 const ScopedResource* texture, 2660 const ScopedResource* texture,
2661 const gfx::Rect& target_rect) { 2661 const gfx::Rect& target_rect) {
2662 DCHECK(texture->id()); 2662 DCHECK(texture->id());
2663 2663
2664 current_framebuffer_lock_.reset(); 2664 current_framebuffer_lock_ = nullptr;
2665 2665
2666 SetStencilEnabled(false); 2666 SetStencilEnabled(false);
2667 GLC(gl_, gl_->BindFramebuffer(GL_FRAMEBUFFER, offscreen_framebuffer_id_)); 2667 GLC(gl_, gl_->BindFramebuffer(GL_FRAMEBUFFER, offscreen_framebuffer_id_));
2668 current_framebuffer_lock_ = 2668 current_framebuffer_lock_ =
2669 make_scoped_ptr(new ResourceProvider::ScopedWriteLockGL( 2669 make_scoped_ptr(new ResourceProvider::ScopedWriteLockGL(
2670 resource_provider_, texture->id())); 2670 resource_provider_, texture->id()));
2671 unsigned texture_id = current_framebuffer_lock_->texture_id(); 2671 unsigned texture_id = current_framebuffer_lock_->texture_id();
2672 GLC(gl_, 2672 GLC(gl_,
2673 gl_->FramebufferTexture2D( 2673 gl_->FramebufferTexture2D(
2674 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture_id, 0)); 2674 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture_id, 0));
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
3075 &video_stream_texture_program_[precision]; 3075 &video_stream_texture_program_[precision];
3076 if (!program->initialized()) { 3076 if (!program->initialized()) {
3077 TRACE_EVENT0("cc", "GLRenderer::streamTextureProgram::initialize"); 3077 TRACE_EVENT0("cc", "GLRenderer::streamTextureProgram::initialize");
3078 program->Initialize( 3078 program->Initialize(
3079 output_surface_->context_provider(), precision, SamplerTypeExternalOES); 3079 output_surface_->context_provider(), precision, SamplerTypeExternalOES);
3080 } 3080 }
3081 return program; 3081 return program;
3082 } 3082 }
3083 3083
3084 void GLRenderer::CleanupSharedObjects() { 3084 void GLRenderer::CleanupSharedObjects() {
3085 shared_geometry_.reset(); 3085 shared_geometry_ = nullptr;
3086 3086
3087 for (int i = 0; i < NumTexCoordPrecisions; ++i) { 3087 for (int i = 0; i < NumTexCoordPrecisions; ++i) {
3088 for (int j = 0; j < NumSamplerTypes; ++j) { 3088 for (int j = 0; j < NumSamplerTypes; ++j) {
3089 tile_program_[i][j].Cleanup(gl_); 3089 tile_program_[i][j].Cleanup(gl_);
3090 tile_program_opaque_[i][j].Cleanup(gl_); 3090 tile_program_opaque_[i][j].Cleanup(gl_);
3091 tile_program_swizzle_[i][j].Cleanup(gl_); 3091 tile_program_swizzle_[i][j].Cleanup(gl_);
3092 tile_program_swizzle_opaque_[i][j].Cleanup(gl_); 3092 tile_program_swizzle_opaque_[i][j].Cleanup(gl_);
3093 tile_program_aa_[i][j].Cleanup(gl_); 3093 tile_program_aa_[i][j].Cleanup(gl_);
3094 tile_program_swizzle_aa_[i][j].Cleanup(gl_); 3094 tile_program_swizzle_aa_[i][j].Cleanup(gl_);
3095 } 3095 }
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
3203 context_support_->ScheduleOverlayPlane( 3203 context_support_->ScheduleOverlayPlane(
3204 overlay.plane_z_order, 3204 overlay.plane_z_order,
3205 overlay.transform, 3205 overlay.transform,
3206 pending_overlay_resources_.back()->texture_id(), 3206 pending_overlay_resources_.back()->texture_id(),
3207 overlay.display_rect, 3207 overlay.display_rect,
3208 overlay.uv_rect); 3208 overlay.uv_rect);
3209 } 3209 }
3210 } 3210 }
3211 3211
3212 } // namespace cc 3212 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/delegating_renderer_unittest.cc ('k') | cc/output/gl_renderer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698