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> |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 << "Requested Skia GPU backend, but can't use it."; | 118 << "Requested Skia GPU backend, but can't use it."; |
119 } | 119 } |
120 | 120 |
121 return renderer.Pass(); | 121 return renderer.Pass(); |
122 } | 122 } |
123 | 123 |
124 GLRenderer::GLRenderer(RendererClient* client, | 124 GLRenderer::GLRenderer(RendererClient* client, |
125 OutputSurface* output_surface, | 125 OutputSurface* output_surface, |
126 ResourceProvider* resource_provider, | 126 ResourceProvider* resource_provider, |
127 int highp_threshold_min) | 127 int highp_threshold_min) |
128 : DirectRenderer(client, resource_provider), | 128 : DirectRenderer(client, output_surface, resource_provider), |
129 offscreen_framebuffer_id_(0), | 129 offscreen_framebuffer_id_(0), |
130 shared_geometry_quad_(gfx::RectF(-0.5f, -0.5f, 1.0f, 1.0f)), | 130 shared_geometry_quad_(gfx::RectF(-0.5f, -0.5f, 1.0f, 1.0f)), |
131 output_surface_(output_surface), | |
132 context_(output_surface->context3d()), | 131 context_(output_surface->context3d()), |
133 is_viewport_changed_(false), | |
134 is_backbuffer_discarded_(false), | 132 is_backbuffer_discarded_(false), |
135 discard_backbuffer_when_not_visible_(false), | 133 discard_backbuffer_when_not_visible_(false), |
136 is_using_bind_uniform_(false), | 134 is_using_bind_uniform_(false), |
137 visible_(true), | 135 visible_(true), |
138 is_scissor_enabled_(false), | 136 is_scissor_enabled_(false), |
139 highp_threshold_min_(highp_threshold_min), | 137 highp_threshold_min_(highp_threshold_min), |
140 highp_threshold_cache_(0), | 138 highp_threshold_cache_(0), |
141 on_demand_tile_raster_resource_id_(0) { | 139 on_demand_tile_raster_resource_id_(0) { |
142 DCHECK(context_); | 140 DCHECK(context_); |
143 } | 141 } |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 stats.bytesVisible = bytes_visible; | 266 stats.bytesVisible = bytes_visible; |
269 stats.bytesVisibleAndNearby = bytes_visible_and_nearby; | 267 stats.bytesVisibleAndNearby = bytes_visible_and_nearby; |
270 stats.bytesAllocated = bytes_allocated; | 268 stats.bytesAllocated = bytes_allocated; |
271 stats.backbufferRequested = !is_backbuffer_discarded_; | 269 stats.backbufferRequested = !is_backbuffer_discarded_; |
272 context_->sendManagedMemoryStatsCHROMIUM(&stats); | 270 context_->sendManagedMemoryStatsCHROMIUM(&stats); |
273 } | 271 } |
274 | 272 |
275 void GLRenderer::ReleaseRenderPassTextures() { render_pass_textures_.clear(); } | 273 void GLRenderer::ReleaseRenderPassTextures() { render_pass_textures_.clear(); } |
276 | 274 |
277 void GLRenderer::ViewportChanged() { | 275 void GLRenderer::ViewportChanged() { |
278 is_viewport_changed_ = true; | |
279 ReinitializeGrCanvas(); | 276 ReinitializeGrCanvas(); |
280 } | 277 } |
281 | 278 |
282 void GLRenderer::ClearFramebuffer(DrawingFrame* frame) { | 279 void GLRenderer::ClearFramebuffer(DrawingFrame* frame) { |
283 // On DEBUG builds, opaque render passes are cleared to blue to easily see | 280 // On DEBUG builds, opaque render passes are cleared to blue to easily see |
284 // regions that were not drawn on the screen. | 281 // regions that were not drawn on the screen. |
285 if (frame->current_render_pass->has_transparent_background) | 282 if (frame->current_render_pass->has_transparent_background) |
286 GLC(context_, context_->clearColor(0, 0, 0, 0)); | 283 GLC(context_, context_->clearColor(0, 0, 0, 0)); |
287 else | 284 else |
288 GLC(context_, context_->clearColor(0, 0, 1, 1)); | 285 GLC(context_, context_->clearColor(0, 0, 1, 1)); |
289 | 286 |
290 bool always_clear = false; | 287 bool always_clear = false; |
291 #ifndef NDEBUG | 288 #ifndef NDEBUG |
292 always_clear = true; | 289 always_clear = true; |
293 #endif | 290 #endif |
294 if (always_clear || frame->current_render_pass->has_transparent_background) { | 291 if (always_clear || frame->current_render_pass->has_transparent_background) { |
295 GLbitfield clear_bits = GL_COLOR_BUFFER_BIT; | 292 GLbitfield clear_bits = GL_COLOR_BUFFER_BIT; |
296 // Only the Skia GPU backend uses the stencil buffer. No need to clear it | 293 // Only the Skia GPU backend uses the stencil buffer. No need to clear it |
297 // otherwise. | 294 // otherwise. |
298 if (CanUseSkiaGPUBackend()) | 295 if (CanUseSkiaGPUBackend()) |
299 clear_bits |= GL_STENCIL_BUFFER_BIT; | 296 clear_bits |= GL_STENCIL_BUFFER_BIT; |
300 context_->clear(clear_bits); | 297 context_->clear(clear_bits); |
301 } | 298 } |
302 } | 299 } |
303 | 300 |
304 void GLRenderer::BeginDrawingFrame(DrawingFrame* frame) { | 301 void GLRenderer::BeginDrawingFrame(DrawingFrame* frame) { |
305 // FIXME: Remove this once backbuffer is automatically recreated on first use | 302 // FIXME: Remove this once backbuffer is automatically recreated on first use |
306 EnsureBackbuffer(); | 303 EnsureBackbuffer(); |
307 | 304 |
308 if (ViewportSize().IsEmpty()) | 305 if (client_->DeviceViewport().IsEmpty()) |
309 return; | 306 return; |
310 | 307 |
311 TRACE_EVENT0("cc", "GLRenderer::DrawLayers"); | 308 TRACE_EVENT0("cc", "GLRenderer::DrawLayers"); |
312 if (is_viewport_changed_) { | |
313 // Only reshape when we know we are going to draw. Otherwise, the reshape | |
314 // can leave the window at the wrong size if we never draw and the proper | |
315 // viewport size is never set. | |
316 is_viewport_changed_ = false; | |
317 output_surface_->Reshape(gfx::Size(ViewportWidth(), ViewportHeight()), | |
318 DeviceScaleFactor()); | |
319 } | |
320 | 309 |
321 MakeContextCurrent(); | 310 MakeContextCurrent(); |
322 | 311 |
323 ReinitializeGLState(); | 312 ReinitializeGLState(); |
324 } | 313 } |
325 | 314 |
326 void GLRenderer::DoNoOp() { | 315 void GLRenderer::DoNoOp() { |
327 GLC(context_, context_->bindFramebuffer(GL_FRAMEBUFFER, 0)); | 316 GLC(context_, context_->bindFramebuffer(GL_FRAMEBUFFER, 0)); |
328 GLC(context_, context_->flush()); | 317 GLC(context_, context_->flush()); |
329 } | 318 } |
(...skipping 1166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1496 // Reset the canvas matrix to identity because the clip rect is in target | 1485 // Reset the canvas matrix to identity because the clip rect is in target |
1497 // space. | 1486 // space. |
1498 SkMatrix sk_identity; | 1487 SkMatrix sk_identity; |
1499 sk_identity.setIdentity(); | 1488 sk_identity.setIdentity(); |
1500 sk_canvas_->setMatrix(sk_identity); | 1489 sk_canvas_->setMatrix(sk_identity); |
1501 | 1490 |
1502 if (is_scissor_enabled_) { | 1491 if (is_scissor_enabled_) { |
1503 sk_canvas_->clipRect(gfx::RectToSkRect(scissor_rect_), | 1492 sk_canvas_->clipRect(gfx::RectToSkRect(scissor_rect_), |
1504 SkRegion::kReplace_Op); | 1493 SkRegion::kReplace_Op); |
1505 } else { | 1494 } else { |
1506 sk_canvas_->clipRect(gfx::RectToSkRect(gfx::Rect(ViewportSize())), | 1495 sk_canvas_->clipRect(gfx::RectToSkRect(client_->DeviceViewport()), |
1507 SkRegion::kReplace_Op); | 1496 SkRegion::kReplace_Op); |
1508 } | 1497 } |
1509 | 1498 |
1510 gfx::Transform contents_device_transform = frame->window_matrix * | 1499 gfx::Transform contents_device_transform = frame->window_matrix * |
1511 frame->projection_matrix * quad->quadTransform(); | 1500 frame->projection_matrix * quad->quadTransform(); |
1512 contents_device_transform.Translate(quad->rect.x(), | 1501 contents_device_transform.Translate(quad->rect.x(), |
1513 quad->rect.y()); | 1502 quad->rect.y()); |
1514 contents_device_transform.FlattenTo2d(); | 1503 contents_device_transform.FlattenTo2d(); |
1515 SkMatrix sk_device_matrix; | 1504 SkMatrix sk_device_matrix; |
1516 gfx::TransformToFlattenedSkMatrix(contents_device_transform, | 1505 gfx::TransformToFlattenedSkMatrix(contents_device_transform, |
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1963 void GLRenderer::SwapBuffers(const ui::LatencyInfo& latency_info) { | 1952 void GLRenderer::SwapBuffers(const ui::LatencyInfo& latency_info) { |
1964 DCHECK(visible_); | 1953 DCHECK(visible_); |
1965 DCHECK(!is_backbuffer_discarded_); | 1954 DCHECK(!is_backbuffer_discarded_); |
1966 | 1955 |
1967 TRACE_EVENT0("cc", "GLRenderer::SwapBuffers"); | 1956 TRACE_EVENT0("cc", "GLRenderer::SwapBuffers"); |
1968 // We're done! Time to swapbuffers! | 1957 // We're done! Time to swapbuffers! |
1969 | 1958 |
1970 if (capabilities_.using_partial_swap && client_->AllowPartialSwap()) { | 1959 if (capabilities_.using_partial_swap && client_->AllowPartialSwap()) { |
1971 // If supported, we can save significant bandwidth by only swapping the | 1960 // If supported, we can save significant bandwidth by only swapping the |
1972 // damaged/scissored region (clamped to the viewport) | 1961 // damaged/scissored region (clamped to the viewport) |
1973 swap_buffer_rect_.Intersect(gfx::Rect(ViewportSize())); | 1962 swap_buffer_rect_.Intersect(client_->DeviceViewport()); |
1974 int flipped_y_pos_of_rect_bottom = | 1963 int flipped_y_pos_of_rect_bottom = |
1975 ViewportHeight() - swap_buffer_rect_.y() - swap_buffer_rect_.height(); | 1964 client_->DeviceViewport().height() - swap_buffer_rect_.y() - |
| 1965 swap_buffer_rect_.height(); |
1976 output_surface_->PostSubBuffer(gfx::Rect(swap_buffer_rect_.x(), | 1966 output_surface_->PostSubBuffer(gfx::Rect(swap_buffer_rect_.x(), |
1977 flipped_y_pos_of_rect_bottom, | 1967 flipped_y_pos_of_rect_bottom, |
1978 swap_buffer_rect_.width(), | 1968 swap_buffer_rect_.width(), |
1979 swap_buffer_rect_.height()), | 1969 swap_buffer_rect_.height()), |
1980 latency_info); | 1970 latency_info); |
1981 } else { | 1971 } else { |
1982 output_surface_->SwapBuffers(latency_info); | 1972 output_surface_->SwapBuffers(latency_info); |
1983 } | 1973 } |
1984 | 1974 |
1985 swap_buffer_rect_ = gfx::Rect(); | 1975 swap_buffer_rect_ = gfx::Rect(); |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2119 | 2109 |
2120 // This is an asyncronous call since the callback is not null. | 2110 // This is an asyncronous call since the callback is not null. |
2121 DoGetFramebufferPixels(pixels, rect, flipped_y, cleanup_callback); | 2111 DoGetFramebufferPixels(pixels, rect, flipped_y, cleanup_callback); |
2122 } | 2112 } |
2123 | 2113 |
2124 void GLRenderer::DoGetFramebufferPixels( | 2114 void GLRenderer::DoGetFramebufferPixels( |
2125 uint8* dest_pixels, | 2115 uint8* dest_pixels, |
2126 gfx::Rect rect, | 2116 gfx::Rect rect, |
2127 bool flipped_y, | 2117 bool flipped_y, |
2128 const AsyncGetFramebufferPixelsCleanupCallback& cleanup_callback) { | 2118 const AsyncGetFramebufferPixelsCleanupCallback& cleanup_callback) { |
2129 DCHECK(rect.right() <= ViewportWidth()); | 2119 gfx::Rect window_rect = MoveFromDrawToWindowSpace(rect, flipped_y); |
2130 DCHECK(rect.bottom() <= ViewportHeight()); | 2120 DCHECK_LE(window_rect.right(), current_surface_size_.width()); |
| 2121 DCHECK_LE(window_rect.bottom(), current_surface_size_.height()); |
2131 | 2122 |
2132 bool is_async = !cleanup_callback.is_null(); | 2123 bool is_async = !cleanup_callback.is_null(); |
2133 | 2124 |
2134 MakeContextCurrent(); | 2125 MakeContextCurrent(); |
2135 | 2126 |
2136 bool do_workaround = NeedsIOSurfaceReadbackWorkaround(); | 2127 bool do_workaround = NeedsIOSurfaceReadbackWorkaround(); |
2137 | 2128 |
2138 unsigned temporary_texture = 0; | 2129 unsigned temporary_texture = 0; |
2139 unsigned temporary_fbo = 0; | 2130 unsigned temporary_fbo = 0; |
2140 | 2131 |
(...skipping 19 matching lines...) Expand all Loading... |
2160 context_->texParameteri( | 2151 context_->texParameteri( |
2161 GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)); | 2152 GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)); |
2162 // Copy the contents of the current (IOSurface-backed) framebuffer into a | 2153 // Copy the contents of the current (IOSurface-backed) framebuffer into a |
2163 // temporary texture. | 2154 // temporary texture. |
2164 GLC(context_, | 2155 GLC(context_, |
2165 context_->copyTexImage2D(GL_TEXTURE_2D, | 2156 context_->copyTexImage2D(GL_TEXTURE_2D, |
2166 0, | 2157 0, |
2167 GL_RGBA, | 2158 GL_RGBA, |
2168 0, | 2159 0, |
2169 0, | 2160 0, |
2170 current_framebuffer_size_.width(), | 2161 current_surface_size_.width(), |
2171 current_framebuffer_size_.height(), | 2162 current_surface_size_.height(), |
2172 0)); | 2163 0)); |
2173 temporary_fbo = context_->createFramebuffer(); | 2164 temporary_fbo = context_->createFramebuffer(); |
2174 // Attach this texture to an FBO, and perform the readback from that FBO. | 2165 // Attach this texture to an FBO, and perform the readback from that FBO. |
2175 GLC(context_, context_->bindFramebuffer(GL_FRAMEBUFFER, temporary_fbo)); | 2166 GLC(context_, context_->bindFramebuffer(GL_FRAMEBUFFER, temporary_fbo)); |
2176 GLC(context_, | 2167 GLC(context_, |
2177 context_->framebufferTexture2D(GL_FRAMEBUFFER, | 2168 context_->framebufferTexture2D(GL_FRAMEBUFFER, |
2178 GL_COLOR_ATTACHMENT0, | 2169 GL_COLOR_ATTACHMENT0, |
2179 GL_TEXTURE_2D, | 2170 GL_TEXTURE_2D, |
2180 temporary_texture, | 2171 temporary_texture, |
2181 0)); | 2172 0)); |
2182 | 2173 |
2183 DCHECK(context_->checkFramebufferStatus(GL_FRAMEBUFFER) == | 2174 DCHECK(context_->checkFramebufferStatus(GL_FRAMEBUFFER) == |
2184 GL_FRAMEBUFFER_COMPLETE); | 2175 GL_FRAMEBUFFER_COMPLETE); |
2185 } | 2176 } |
2186 | 2177 |
2187 unsigned buffer = context_->createBuffer(); | 2178 unsigned buffer = context_->createBuffer(); |
2188 GLC(context_, context_->bindBuffer(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, | 2179 GLC(context_, context_->bindBuffer(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, |
2189 buffer)); | 2180 buffer)); |
2190 GLC(context_, context_->bufferData(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, | 2181 GLC(context_, context_->bufferData(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, |
2191 4 * rect.size().GetArea(), | 2182 4 * rect.size().GetArea(), |
2192 NULL, | 2183 NULL, |
2193 GL_STREAM_READ)); | 2184 GL_STREAM_READ)); |
2194 | 2185 |
2195 GLC(context_, | 2186 GLC(context_, |
2196 context_->readPixels(rect.x(), | 2187 context_->readPixels(window_rect.x(), |
2197 current_framebuffer_size_.height() - rect.bottom(), | 2188 window_rect.y(), |
2198 rect.width(), | 2189 window_rect.width(), |
2199 rect.height(), | 2190 window_rect.height(), |
2200 GL_RGBA, | 2191 GL_RGBA, |
2201 GL_UNSIGNED_BYTE, | 2192 GL_UNSIGNED_BYTE, |
2202 NULL)); | 2193 NULL)); |
2203 | 2194 |
2204 GLC(context_, context_->bindBuffer(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, | 2195 GLC(context_, context_->bindBuffer(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, |
2205 0)); | 2196 0)); |
2206 | 2197 |
2207 if (do_workaround) { | 2198 if (do_workaround) { |
2208 // Clean up. | 2199 // Clean up. |
2209 GLC(context_, context_->bindFramebuffer(GL_FRAMEBUFFER, 0)); | 2200 GLC(context_, context_->bindFramebuffer(GL_FRAMEBUFFER, 0)); |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2341 return BindFramebufferToTexture(frame, texture, viewport_rect); | 2332 return BindFramebufferToTexture(frame, texture, viewport_rect); |
2342 } | 2333 } |
2343 | 2334 |
2344 void GLRenderer::BindFramebufferToOutputSurface(DrawingFrame* frame) { | 2335 void GLRenderer::BindFramebufferToOutputSurface(DrawingFrame* frame) { |
2345 current_framebuffer_lock_.reset(); | 2336 current_framebuffer_lock_.reset(); |
2346 output_surface_->BindFramebuffer(); | 2337 output_surface_->BindFramebuffer(); |
2347 } | 2338 } |
2348 | 2339 |
2349 bool GLRenderer::BindFramebufferToTexture(DrawingFrame* frame, | 2340 bool GLRenderer::BindFramebufferToTexture(DrawingFrame* frame, |
2350 const ScopedResource* texture, | 2341 const ScopedResource* texture, |
2351 gfx::Rect framebuffer_rect) { | 2342 gfx::Rect target_rect) { |
2352 DCHECK(texture->id()); | 2343 DCHECK(texture->id()); |
2353 | 2344 |
2354 current_framebuffer_lock_.reset(); | 2345 current_framebuffer_lock_.reset(); |
2355 | 2346 |
2356 GLC(context_, | 2347 GLC(context_, |
2357 context_->bindFramebuffer(GL_FRAMEBUFFER, offscreen_framebuffer_id_)); | 2348 context_->bindFramebuffer(GL_FRAMEBUFFER, offscreen_framebuffer_id_)); |
2358 current_framebuffer_lock_ = | 2349 current_framebuffer_lock_ = |
2359 make_scoped_ptr(new ResourceProvider::ScopedWriteLockGL( | 2350 make_scoped_ptr(new ResourceProvider::ScopedWriteLockGL( |
2360 resource_provider_, texture->id())); | 2351 resource_provider_, texture->id())); |
2361 unsigned texture_id = current_framebuffer_lock_->texture_id(); | 2352 unsigned texture_id = current_framebuffer_lock_->texture_id(); |
2362 GLC(context_, | 2353 GLC(context_, |
2363 context_->framebufferTexture2D( | 2354 context_->framebufferTexture2D( |
2364 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture_id, 0)); | 2355 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture_id, 0)); |
2365 | 2356 |
2366 DCHECK(context_->checkFramebufferStatus(GL_FRAMEBUFFER) == | 2357 DCHECK(context_->checkFramebufferStatus(GL_FRAMEBUFFER) == |
2367 GL_FRAMEBUFFER_COMPLETE || IsContextLost()); | 2358 GL_FRAMEBUFFER_COMPLETE || IsContextLost()); |
2368 | 2359 |
2369 InitializeMatrices(frame, framebuffer_rect, false); | 2360 InitializeViewport(frame, |
2370 SetDrawViewportSize(framebuffer_rect.size()); | 2361 target_rect, |
2371 | 2362 gfx::Rect(target_rect.size()), |
| 2363 target_rect.size(), |
| 2364 false); |
2372 return true; | 2365 return true; |
2373 } | 2366 } |
2374 | 2367 |
2375 void GLRenderer::SetScissorTestRect(gfx::Rect scissor_rect) { | 2368 void GLRenderer::SetScissorTestRect(gfx::Rect scissor_rect) { |
2376 EnsureScissorTestEnabled(); | 2369 EnsureScissorTestEnabled(); |
2377 | 2370 |
2378 // Don't unnecessarily ask the context to change the scissor, because it | 2371 // Don't unnecessarily ask the context to change the scissor, because it |
2379 // may cause undesired GPU pipeline flushes. | 2372 // may cause undesired GPU pipeline flushes. |
2380 if (scissor_rect == scissor_rect_) | 2373 if (scissor_rect == scissor_rect_) |
2381 return; | 2374 return; |
2382 | 2375 |
2383 scissor_rect_ = scissor_rect; | 2376 scissor_rect_ = scissor_rect; |
2384 FlushTextureQuadCache(); | 2377 FlushTextureQuadCache(); |
2385 GLC(context_, | 2378 GLC(context_, |
2386 context_->scissor(scissor_rect.x(), | 2379 context_->scissor(scissor_rect.x(), |
2387 scissor_rect.y(), | 2380 scissor_rect.y(), |
2388 scissor_rect.width(), | 2381 scissor_rect.width(), |
2389 scissor_rect.height())); | 2382 scissor_rect.height())); |
2390 } | 2383 } |
2391 | 2384 |
2392 void GLRenderer::SetDrawViewportSize(gfx::Size viewport_size) { | 2385 void GLRenderer::SetDrawViewport(gfx::Rect window_space_viewport) { |
2393 current_framebuffer_size_ = viewport_size; | 2386 GLC(context_, context_->viewport(window_space_viewport.x(), |
2394 GLC(context_, | 2387 window_space_viewport.y(), |
2395 context_->viewport(0, 0, viewport_size.width(), viewport_size.height())); | 2388 window_space_viewport.width(), |
| 2389 window_space_viewport.height())); |
2396 } | 2390 } |
2397 | 2391 |
2398 bool GLRenderer::MakeContextCurrent() { return context_->makeContextCurrent(); } | 2392 bool GLRenderer::MakeContextCurrent() { return context_->makeContextCurrent(); } |
2399 | 2393 |
2400 bool GLRenderer::InitializeSharedObjects() { | 2394 bool GLRenderer::InitializeSharedObjects() { |
2401 TRACE_EVENT0("cc", "GLRenderer::InitializeSharedObjects"); | 2395 TRACE_EVENT0("cc", "GLRenderer::InitializeSharedObjects"); |
2402 MakeContextCurrent(); | 2396 MakeContextCurrent(); |
2403 | 2397 |
2404 // Create an FBO for doing offscreen rendering. | 2398 // Create an FBO for doing offscreen rendering. |
2405 GLC(context_, offscreen_framebuffer_id_ = context_->createFramebuffer()); | 2399 GLC(context_, offscreen_framebuffer_id_ = context_->createFramebuffer()); |
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2859 resource_provider_->DeleteResource(on_demand_tile_raster_resource_id_); | 2853 resource_provider_->DeleteResource(on_demand_tile_raster_resource_id_); |
2860 | 2854 |
2861 ReleaseRenderPassTextures(); | 2855 ReleaseRenderPassTextures(); |
2862 } | 2856 } |
2863 | 2857 |
2864 void GLRenderer::ReinitializeGrCanvas() { | 2858 void GLRenderer::ReinitializeGrCanvas() { |
2865 if (!CanUseSkiaGPUBackend()) | 2859 if (!CanUseSkiaGPUBackend()) |
2866 return; | 2860 return; |
2867 | 2861 |
2868 GrBackendRenderTargetDesc desc; | 2862 GrBackendRenderTargetDesc desc; |
2869 desc.fWidth = ViewportWidth(); | 2863 desc.fWidth = client_->DeviceViewport().width(); |
2870 desc.fHeight = ViewportHeight(); | 2864 desc.fHeight = client_->DeviceViewport().height(); |
2871 desc.fConfig = kRGBA_8888_GrPixelConfig; | 2865 desc.fConfig = kRGBA_8888_GrPixelConfig; |
2872 desc.fOrigin = kTopLeft_GrSurfaceOrigin; | 2866 desc.fOrigin = kTopLeft_GrSurfaceOrigin; |
2873 desc.fSampleCnt = 1; | 2867 desc.fSampleCnt = 1; |
2874 desc.fStencilBits = 8; | 2868 desc.fStencilBits = 8; |
2875 desc.fRenderTargetHandle = 0; | 2869 desc.fRenderTargetHandle = 0; |
2876 | 2870 |
2877 skia::RefPtr<GrSurface> surface( | 2871 skia::RefPtr<GrSurface> surface( |
2878 skia::AdoptRef(gr_context_->wrapBackendRenderTarget(desc))); | 2872 skia::AdoptRef(gr_context_->wrapBackendRenderTarget(desc))); |
2879 skia::RefPtr<SkDevice> device( | 2873 skia::RefPtr<SkDevice> device( |
2880 skia::AdoptRef(SkGpuDevice::Create(surface.get()))); | 2874 skia::AdoptRef(SkGpuDevice::Create(surface.get()))); |
(...skipping 23 matching lines...) Expand all Loading... |
2904 // The Skia GPU backend requires a stencil buffer. See ReinitializeGrCanvas | 2898 // The Skia GPU backend requires a stencil buffer. See ReinitializeGrCanvas |
2905 // implementation. | 2899 // implementation. |
2906 return gr_context_ && context_->getContextAttributes().stencil; | 2900 return gr_context_ && context_->getContextAttributes().stencil; |
2907 } | 2901 } |
2908 | 2902 |
2909 bool GLRenderer::IsContextLost() { | 2903 bool GLRenderer::IsContextLost() { |
2910 return (context_->getGraphicsResetStatusARB() != GL_NO_ERROR); | 2904 return (context_->getGraphicsResetStatusARB() != GL_NO_ERROR); |
2911 } | 2905 } |
2912 | 2906 |
2913 } // namespace cc | 2907 } // namespace cc |
OLD | NEW |