OLD | NEW |
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> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/debug/trace_event.h" | 13 #include "base/debug/trace_event.h" |
14 #include "base/logging.h" | 14 #include "base/logging.h" |
15 #include "cc/base/math_util.h" | 15 #include "cc/base/math_util.h" |
16 #include "cc/output/compositor_frame.h" | 16 #include "cc/output/compositor_frame.h" |
17 #include "cc/output/compositor_frame_metadata.h" | 17 #include "cc/output/compositor_frame_metadata.h" |
18 #include "cc/output/context_provider.h" | 18 #include "cc/output/context_provider.h" |
19 #include "cc/output/copy_output_request.h" | 19 #include "cc/output/copy_output_request.h" |
20 #include "cc/output/geometry_binding.h" | 20 #include "cc/output/geometry_binding.h" |
21 #include "cc/output/gl_frame_data.h" | 21 #include "cc/output/gl_frame_data.h" |
22 #include "cc/output/output_surface.h" | 22 #include "cc/output/output_surface.h" |
23 #include "cc/output/render_surface_filters.h" | 23 #include "cc/output/render_surface_filters.h" |
24 #include "cc/quads/picture_draw_quad.h" | 24 #include "cc/quads/picture_draw_quad.h" |
25 #include "cc/quads/render_pass.h" | 25 #include "cc/quads/render_pass.h" |
26 #include "cc/quads/stream_video_draw_quad.h" | 26 #include "cc/quads/stream_video_draw_quad.h" |
27 #include "cc/quads/texture_draw_quad.h" | 27 #include "cc/quads/texture_draw_quad.h" |
28 #include "cc/resources/layer_quad.h" | 28 #include "cc/resources/layer_quad.h" |
| 29 #include "cc/resources/scoped_gpu_raster.h" |
29 #include "cc/resources/scoped_resource.h" | 30 #include "cc/resources/scoped_resource.h" |
30 #include "cc/resources/texture_mailbox_deleter.h" | 31 #include "cc/resources/texture_mailbox_deleter.h" |
31 #include "gpu/GLES2/gl2extchromium.h" | 32 #include "gpu/GLES2/gl2extchromium.h" |
32 #include "gpu/command_buffer/client/context_support.h" | 33 #include "gpu/command_buffer/client/context_support.h" |
33 #include "gpu/command_buffer/client/gles2_interface.h" | 34 #include "gpu/command_buffer/client/gles2_interface.h" |
34 #include "gpu/command_buffer/common/gpu_memory_allocation.h" | 35 #include "gpu/command_buffer/common/gpu_memory_allocation.h" |
35 #include "third_party/skia/include/core/SkBitmap.h" | 36 #include "third_party/skia/include/core/SkBitmap.h" |
36 #include "third_party/skia/include/core/SkColor.h" | 37 #include "third_party/skia/include/core/SkColor.h" |
37 #include "third_party/skia/include/core/SkColorFilter.h" | 38 #include "third_party/skia/include/core/SkColorFilter.h" |
38 #include "third_party/skia/include/core/SkImage.h" | 39 #include "third_party/skia/include/core/SkImage.h" |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 return active_unit; | 151 return active_unit; |
151 } | 152 } |
152 | 153 |
153 class GLRenderer::ScopedUseGrContext { | 154 class GLRenderer::ScopedUseGrContext { |
154 public: | 155 public: |
155 static scoped_ptr<ScopedUseGrContext> Create(GLRenderer* renderer, | 156 static scoped_ptr<ScopedUseGrContext> Create(GLRenderer* renderer, |
156 DrawingFrame* frame) { | 157 DrawingFrame* frame) { |
157 return make_scoped_ptr(new ScopedUseGrContext(renderer, frame)); | 158 return make_scoped_ptr(new ScopedUseGrContext(renderer, frame)); |
158 } | 159 } |
159 | 160 |
160 ~ScopedUseGrContext() { PassControlToGLRenderer(); } | 161 ~ScopedUseGrContext() { |
| 162 // Pass context control back to GLrenderer. |
| 163 scoped_gpu_raster_ = nullptr; |
| 164 renderer_->RestoreGLState(); |
| 165 renderer_->RestoreFramebuffer(frame_); |
| 166 } |
161 | 167 |
162 GrContext* context() const { | 168 GrContext* context() const { |
163 return renderer_->output_surface_->context_provider()->GrContext(); | 169 return renderer_->output_surface_->context_provider()->GrContext(); |
164 } | 170 } |
165 | 171 |
166 private: | 172 private: |
167 ScopedUseGrContext(GLRenderer* renderer, DrawingFrame* frame) | 173 ScopedUseGrContext(GLRenderer* renderer, DrawingFrame* frame) |
168 : renderer_(renderer), frame_(frame) { | 174 : scoped_gpu_raster_( |
169 PassControlToSkia(); | 175 new ScopedGpuRaster(renderer->output_surface_->context_provider())), |
| 176 renderer_(renderer), |
| 177 frame_(frame) { |
| 178 // scoped_gpu_raster_ passes context control to Skia. |
170 } | 179 } |
171 | 180 |
172 void PassControlToSkia() { context()->resetContext(); } | 181 scoped_ptr<ScopedGpuRaster> scoped_gpu_raster_; |
173 | |
174 void PassControlToGLRenderer() { | |
175 renderer_->RestoreGLState(); | |
176 renderer_->RestoreFramebuffer(frame_); | |
177 } | |
178 | |
179 GLRenderer* renderer_; | 182 GLRenderer* renderer_; |
180 DrawingFrame* frame_; | 183 DrawingFrame* frame_; |
181 | 184 |
182 DISALLOW_COPY_AND_ASSIGN(ScopedUseGrContext); | 185 DISALLOW_COPY_AND_ASSIGN(ScopedUseGrContext); |
183 }; | 186 }; |
184 | 187 |
185 struct GLRenderer::PendingAsyncReadPixels { | 188 struct GLRenderer::PendingAsyncReadPixels { |
186 PendingAsyncReadPixels() : buffer(0) {} | 189 PendingAsyncReadPixels() : buffer(0) {} |
187 | 190 |
188 scoped_ptr<CopyOutputRequest> copy_request; | 191 scoped_ptr<CopyOutputRequest> copy_request; |
(...skipping 3099 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3288 context_support_->ScheduleOverlayPlane( | 3291 context_support_->ScheduleOverlayPlane( |
3289 overlay.plane_z_order, | 3292 overlay.plane_z_order, |
3290 overlay.transform, | 3293 overlay.transform, |
3291 pending_overlay_resources_.back()->texture_id(), | 3294 pending_overlay_resources_.back()->texture_id(), |
3292 overlay.display_rect, | 3295 overlay.display_rect, |
3293 overlay.uv_rect); | 3296 overlay.uv_rect); |
3294 } | 3297 } |
3295 } | 3298 } |
3296 | 3299 |
3297 } // namespace cc | 3300 } // namespace cc |
OLD | NEW |