| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "services/gfx/compositor/backend/gpu_rasterizer.h" | 5 #include "services/gfx/compositor/backend/gpu_rasterizer.h" |
| 6 | 6 |
| 7 #ifndef GL_GLEXT_PROTOTYPES | 7 #ifndef GL_GLEXT_PROTOTYPES |
| 8 #define GL_GLEXT_PROTOTYPES | 8 #define GL_GLEXT_PROTOTYPES |
| 9 #endif | 9 #endif |
| 10 | 10 |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 DCHECK(frame_); | 173 DCHECK(frame_); |
| 174 | 174 |
| 175 gl_context_->MakeCurrent(); | 175 gl_context_->MakeCurrent(); |
| 176 | 176 |
| 177 // Update the viewport. | 177 // Update the viewport. |
| 178 const SkRect& viewport = frame_->viewport(); | 178 const SkRect& viewport = frame_->viewport(); |
| 179 bool stale_surface = false; | 179 bool stale_surface = false; |
| 180 if (!ganesh_surface_ || | 180 if (!ganesh_surface_ || |
| 181 ganesh_surface_->surface()->width() != viewport.width() || | 181 ganesh_surface_->surface()->width() != viewport.width() || |
| 182 ganesh_surface_->surface()->height() != viewport.height()) { | 182 ganesh_surface_->surface()->height() != viewport.height()) { |
| 183 glResizeCHROMIUM(viewport.width(), viewport.height(), 1.0f); |
| 183 glViewport(viewport.x(), viewport.y(), viewport.width(), viewport.height()); | 184 glViewport(viewport.x(), viewport.y(), viewport.width(), viewport.height()); |
| 184 glResizeCHROMIUM(viewport.width(), viewport.height(), 1.0f); | |
| 185 stale_surface = true; | 185 stale_surface = true; |
| 186 } | 186 } |
| 187 | 187 |
| 188 // Paint the frame. | 188 // Paint the frame. |
| 189 { | 189 { |
| 190 mojo::skia::GaneshContext::Scope ganesh_scope(ganesh_context_.get()); | 190 mojo::skia::GaneshContext::Scope ganesh_scope(ganesh_context_.get()); |
| 191 | 191 |
| 192 if (stale_surface) | 192 if (stale_surface) |
| 193 ganesh_surface_.reset( | 193 ganesh_surface_.reset( |
| 194 new mojo::skia::GaneshFramebufferSurface(ganesh_scope)); | 194 new mojo::skia::GaneshFramebufferSurface(ganesh_scope)); |
| 195 | 195 |
| 196 frame_->Paint(ganesh_surface_->canvas()); | 196 frame_->Paint(ganesh_surface_->canvas()); |
| 197 } | 197 } |
| 198 | 198 |
| 199 // Swap buffers and listen for completion. | 199 // Swap buffers and listen for completion. |
| 200 // TODO: Investigate using |MGLSignalSyncPoint| to wait for completion. | 200 // TODO: Investigate using |MGLSignalSyncPoint| to wait for completion. |
| 201 MGLSwapBuffers(); | 201 MGLSwapBuffers(); |
| 202 frame_callback_.Run(true); | 202 frame_callback_.Run(true); |
| 203 frame_callback_.Reset(); | 203 frame_callback_.Reset(); |
| 204 } | 204 } |
| 205 | 205 |
| 206 void GpuRasterizer::PostErrorCallback() { | 206 void GpuRasterizer::PostErrorCallback() { |
| 207 task_runner_->PostTask(FROM_HERE, error_callback_); | 207 task_runner_->PostTask(FROM_HERE, error_callback_); |
| 208 } | 208 } |
| 209 | 209 |
| 210 } // namespace compositor | 210 } // namespace compositor |
| OLD | NEW |