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 24 matching lines...) Expand all Loading... |
35 #include "cc/trees/damage_tracker.h" | 35 #include "cc/trees/damage_tracker.h" |
36 #include "cc/trees/proxy.h" | 36 #include "cc/trees/proxy.h" |
37 #include "cc/trees/single_thread_proxy.h" | 37 #include "cc/trees/single_thread_proxy.h" |
38 #include "gpu/GLES2/gl2extchromium.h" | 38 #include "gpu/GLES2/gl2extchromium.h" |
39 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3
D.h" | 39 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3
D.h" |
40 #include "third_party/khronos/GLES2/gl2.h" | 40 #include "third_party/khronos/GLES2/gl2.h" |
41 #include "third_party/khronos/GLES2/gl2ext.h" | 41 #include "third_party/khronos/GLES2/gl2ext.h" |
42 #include "third_party/skia/include/core/SkBitmap.h" | 42 #include "third_party/skia/include/core/SkBitmap.h" |
43 #include "third_party/skia/include/core/SkColor.h" | 43 #include "third_party/skia/include/core/SkColor.h" |
44 #include "third_party/skia/include/core/SkColorFilter.h" | 44 #include "third_party/skia/include/core/SkColorFilter.h" |
| 45 #include "third_party/skia/include/core/SkSurface.h" |
45 #include "third_party/skia/include/gpu/GrContext.h" | 46 #include "third_party/skia/include/gpu/GrContext.h" |
46 #include "third_party/skia/include/gpu/GrTexture.h" | 47 #include "third_party/skia/include/gpu/GrTexture.h" |
47 #include "third_party/skia/include/gpu/SkGpuDevice.h" | 48 #include "third_party/skia/include/gpu/SkGpuDevice.h" |
48 #include "third_party/skia/include/gpu/SkGrTexturePixelRef.h" | 49 #include "third_party/skia/include/gpu/SkGrTexturePixelRef.h" |
| 50 #include "third_party/skia/include/gpu/gl/GrGLInterface.h" |
49 #include "ui/gfx/quad_f.h" | 51 #include "ui/gfx/quad_f.h" |
50 #include "ui/gfx/rect_conversions.h" | 52 #include "ui/gfx/rect_conversions.h" |
51 | 53 |
52 using WebKit::WebGraphicsContext3D; | 54 using WebKit::WebGraphicsContext3D; |
53 using WebKit::WebGraphicsMemoryAllocation; | 55 using WebKit::WebGraphicsMemoryAllocation; |
54 | 56 |
55 namespace cc { | 57 namespace cc { |
56 | 58 |
57 namespace { | 59 namespace { |
58 | 60 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 base::CancelableClosure finished_read_pixels_callback; | 98 base::CancelableClosure finished_read_pixels_callback; |
97 unsigned buffer; | 99 unsigned buffer; |
98 | 100 |
99 private: | 101 private: |
100 DISALLOW_COPY_AND_ASSIGN(PendingAsyncReadPixels); | 102 DISALLOW_COPY_AND_ASSIGN(PendingAsyncReadPixels); |
101 }; | 103 }; |
102 | 104 |
103 scoped_ptr<GLRenderer> GLRenderer::Create(RendererClient* client, | 105 scoped_ptr<GLRenderer> GLRenderer::Create(RendererClient* client, |
104 OutputSurface* output_surface, | 106 OutputSurface* output_surface, |
105 ResourceProvider* resource_provider, | 107 ResourceProvider* resource_provider, |
106 int highp_threshold_min) { | 108 int highp_threshold_min, |
| 109 bool use_skia_gpu_backend) { |
107 scoped_ptr<GLRenderer> renderer(new GLRenderer( | 110 scoped_ptr<GLRenderer> renderer(new GLRenderer( |
108 client, output_surface, resource_provider, highp_threshold_min)); | 111 client, output_surface, resource_provider, highp_threshold_min)); |
109 if (!renderer->Initialize()) | 112 if (!renderer->Initialize()) |
110 return scoped_ptr<GLRenderer>(); | 113 return scoped_ptr<GLRenderer>(); |
| 114 if (use_skia_gpu_backend) { |
| 115 renderer->InitializeGrContext(); |
| 116 DCHECK(renderer->CanUseSkiaGPUBackend()) |
| 117 << "Requested Skia GPU backend, but can't use it."; |
| 118 } |
111 | 119 |
112 return renderer.Pass(); | 120 return renderer.Pass(); |
113 } | 121 } |
114 | 122 |
115 GLRenderer::GLRenderer(RendererClient* client, | 123 GLRenderer::GLRenderer(RendererClient* client, |
116 OutputSurface* output_surface, | 124 OutputSurface* output_surface, |
117 ResourceProvider* resource_provider, | 125 ResourceProvider* resource_provider, |
118 int highp_threshold_min) | 126 int highp_threshold_min) |
119 : DirectRenderer(client, resource_provider), | 127 : DirectRenderer(client, resource_provider), |
120 offscreen_framebuffer_id_(0), | 128 offscreen_framebuffer_id_(0), |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 // Check for texture fast paths. Currently we always use MO8 textures, | 194 // Check for texture fast paths. Currently we always use MO8 textures, |
187 // so we only need to avoid POT textures if we have an NPOT fast-path. | 195 // so we only need to avoid POT textures if we have an NPOT fast-path. |
188 capabilities_.avoid_pow2_textures = | 196 capabilities_.avoid_pow2_textures = |
189 extensions.count("GL_CHROMIUM_fast_NPOT_MO8_textures") > 0; | 197 extensions.count("GL_CHROMIUM_fast_NPOT_MO8_textures") > 0; |
190 | 198 |
191 capabilities_.using_offscreen_context3d = true; | 199 capabilities_.using_offscreen_context3d = true; |
192 | 200 |
193 is_using_bind_uniform_ = | 201 is_using_bind_uniform_ = |
194 extensions.count("GL_CHROMIUM_bind_uniform_location") > 0; | 202 extensions.count("GL_CHROMIUM_bind_uniform_location") > 0; |
195 | 203 |
196 // Make sure scissoring starts as disabled. | |
197 GLC(context_, context_->disable(GL_SCISSOR_TEST)); | |
198 DCHECK(!is_scissor_enabled_); | |
199 | |
200 if (!InitializeSharedObjects()) | 204 if (!InitializeSharedObjects()) |
201 return false; | 205 return false; |
202 | 206 |
203 // Make sure the viewport and context gets initialized, even if it is to zero. | 207 // Make sure the viewport and context gets initialized, even if it is to zero. |
204 ViewportChanged(); | 208 ViewportChanged(); |
205 return true; | 209 return true; |
206 } | 210 } |
207 | 211 |
| 212 void GLRenderer::InitializeGrContext() { |
| 213 skia::RefPtr<GrGLInterface> interface = skia::AdoptRef( |
| 214 context_->createGrGLInterface()); |
| 215 if (!interface) |
| 216 return; |
| 217 |
| 218 gr_context_ = skia::AdoptRef(GrContext::Create( |
| 219 kOpenGL_GrBackend, |
| 220 reinterpret_cast<GrBackendContext>(interface.get()))); |
| 221 ReinitializeGrCanvas(); |
| 222 } |
| 223 |
208 GLRenderer::~GLRenderer() { | 224 GLRenderer::~GLRenderer() { |
209 while (!pending_async_read_pixels_.empty()) { | 225 while (!pending_async_read_pixels_.empty()) { |
210 pending_async_read_pixels_.back()->finished_read_pixels_callback.Cancel(); | 226 pending_async_read_pixels_.back()->finished_read_pixels_callback.Cancel(); |
211 pending_async_read_pixels_.back()->copy_callback.Run( | 227 pending_async_read_pixels_.back()->copy_callback.Run( |
212 scoped_ptr<SkBitmap>()); | 228 scoped_ptr<SkBitmap>()); |
213 pending_async_read_pixels_.pop_back(); | 229 pending_async_read_pixels_.pop_back(); |
214 } | 230 } |
215 | 231 |
216 context_->setMemoryAllocationChangedCallbackCHROMIUM(NULL); | 232 context_->setMemoryAllocationChangedCallbackCHROMIUM(NULL); |
217 CleanupSharedObjects(); | 233 CleanupSharedObjects(); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 WebKit::WebGraphicsManagedMemoryStats stats; | 270 WebKit::WebGraphicsManagedMemoryStats stats; |
255 stats.bytesVisible = bytes_visible; | 271 stats.bytesVisible = bytes_visible; |
256 stats.bytesVisibleAndNearby = bytes_visible_and_nearby; | 272 stats.bytesVisibleAndNearby = bytes_visible_and_nearby; |
257 stats.bytesAllocated = bytes_allocated; | 273 stats.bytesAllocated = bytes_allocated; |
258 stats.backbufferRequested = !is_backbuffer_discarded_; | 274 stats.backbufferRequested = !is_backbuffer_discarded_; |
259 context_->sendManagedMemoryStatsCHROMIUM(&stats); | 275 context_->sendManagedMemoryStatsCHROMIUM(&stats); |
260 } | 276 } |
261 | 277 |
262 void GLRenderer::ReleaseRenderPassTextures() { render_pass_textures_.clear(); } | 278 void GLRenderer::ReleaseRenderPassTextures() { render_pass_textures_.clear(); } |
263 | 279 |
264 void GLRenderer::ViewportChanged() { is_viewport_changed_ = true; } | 280 void GLRenderer::ViewportChanged() { |
| 281 is_viewport_changed_ = true; |
| 282 ReinitializeGrCanvas(); |
| 283 } |
265 | 284 |
266 void GLRenderer::ClearFramebuffer(DrawingFrame* frame) { | 285 void GLRenderer::ClearFramebuffer(DrawingFrame* frame) { |
267 // On DEBUG builds, opaque render passes are cleared to blue to easily see | 286 // On DEBUG builds, opaque render passes are cleared to blue to easily see |
268 // regions that were not drawn on the screen. | 287 // regions that were not drawn on the screen. |
269 if (frame->current_render_pass->has_transparent_background) | 288 if (frame->current_render_pass->has_transparent_background) |
270 GLC(context_, context_->clearColor(0, 0, 0, 0)); | 289 GLC(context_, context_->clearColor(0, 0, 0, 0)); |
271 else | 290 else |
272 GLC(context_, context_->clearColor(0, 0, 1, 1)); | 291 GLC(context_, context_->clearColor(0, 0, 1, 1)); |
273 | 292 |
274 #ifdef NDEBUG | 293 bool always_clear = false; |
275 if (frame->current_render_pass->has_transparent_background) | 294 #ifndef NDEBUG |
| 295 always_clear = true; |
276 #endif | 296 #endif |
277 context_->clear(GL_COLOR_BUFFER_BIT); | 297 if (always_clear || frame->current_render_pass->has_transparent_background) { |
| 298 GLbitfield clear_bits = GL_COLOR_BUFFER_BIT; |
| 299 // Only the Skia GPU backend uses the stencil buffer. No need to clear it |
| 300 // otherwise. |
| 301 if (CanUseSkiaGPUBackend()) |
| 302 clear_bits |= GL_STENCIL_BUFFER_BIT; |
| 303 context_->clear(clear_bits); |
| 304 } |
278 } | 305 } |
279 | 306 |
280 void GLRenderer::BeginDrawingFrame(DrawingFrame* frame) { | 307 void GLRenderer::BeginDrawingFrame(DrawingFrame* frame) { |
281 // FIXME: Remove this once backbuffer is automatically recreated on first use | 308 // FIXME: Remove this once backbuffer is automatically recreated on first use |
282 EnsureBackbuffer(); | 309 EnsureBackbuffer(); |
283 | 310 |
284 if (ViewportSize().IsEmpty()) | 311 if (ViewportSize().IsEmpty()) |
285 return; | 312 return; |
286 | 313 |
287 TRACE_EVENT0("cc", "GLRenderer::DrawLayers"); | 314 TRACE_EVENT0("cc", "GLRenderer::DrawLayers"); |
288 if (is_viewport_changed_) { | 315 if (is_viewport_changed_) { |
289 // Only reshape when we know we are going to draw. Otherwise, the reshape | 316 // Only reshape when we know we are going to draw. Otherwise, the reshape |
290 // can leave the window at the wrong size if we never draw and the proper | 317 // can leave the window at the wrong size if we never draw and the proper |
291 // viewport size is never set. | 318 // viewport size is never set. |
292 is_viewport_changed_ = false; | 319 is_viewport_changed_ = false; |
293 output_surface_->Reshape(gfx::Size(ViewportWidth(), ViewportHeight())); | 320 output_surface_->Reshape(gfx::Size(ViewportWidth(), ViewportHeight())); |
294 } | 321 } |
295 | 322 |
296 MakeContextCurrent(); | 323 MakeContextCurrent(); |
297 // Bind the common vertex attributes used for drawing all the layers. | |
298 shared_geometry_->PrepareForDraw(); | |
299 | 324 |
300 GLC(context_, context_->disable(GL_DEPTH_TEST)); | 325 ReinitializeGLState(); |
301 GLC(context_, context_->disable(GL_CULL_FACE)); | |
302 GLC(context_, context_->colorMask(true, true, true, true)); | |
303 GLC(context_, context_->enable(GL_BLEND)); | |
304 blend_shadow_ = true; | |
305 GLC(context_, context_->blendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA)); | |
306 GLC(Context(), Context()->activeTexture(GL_TEXTURE0)); | |
307 program_shadow_ = 0; | |
308 } | 326 } |
309 | 327 |
310 void GLRenderer::DoNoOp() { | 328 void GLRenderer::DoNoOp() { |
311 GLC(context_, context_->bindFramebuffer(GL_FRAMEBUFFER, 0)); | 329 GLC(context_, context_->bindFramebuffer(GL_FRAMEBUFFER, 0)); |
312 GLC(context_, context_->flush()); | 330 GLC(context_, context_->flush()); |
313 } | 331 } |
314 | 332 |
315 void GLRenderer::DoDrawQuad(DrawingFrame* frame, const DrawQuad* quad) { | 333 void GLRenderer::DoDrawQuad(DrawingFrame* frame, const DrawQuad* quad) { |
316 DCHECK(quad->rect.Contains(quad->visible_rect)); | 334 DCHECK(quad->rect.Contains(quad->visible_rect)); |
317 if (quad->material != DrawQuad::TEXTURE_CONTENT) { | 335 if (quad->material != DrawQuad::TEXTURE_CONTENT) { |
(...skipping 1142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1460 Context()->uniform1i(program->fragment_shader().sampler_location(), 0)); | 1478 Context()->uniform1i(program->fragment_shader().sampler_location(), 0)); |
1461 | 1479 |
1462 SetShaderOpacity(quad->opacity(), | 1480 SetShaderOpacity(quad->opacity(), |
1463 program->fragment_shader().alpha_location()); | 1481 program->fragment_shader().alpha_location()); |
1464 DrawQuadGeometry(frame, | 1482 DrawQuadGeometry(frame, |
1465 quad->quadTransform(), | 1483 quad->quadTransform(), |
1466 quad->rect, | 1484 quad->rect, |
1467 program->vertex_shader().matrix_location()); | 1485 program->vertex_shader().matrix_location()); |
1468 } | 1486 } |
1469 | 1487 |
| 1488 void GLRenderer::DrawPictureQuadDirectToBackbuffer( |
| 1489 const DrawingFrame* frame, |
| 1490 const PictureDrawQuad* quad) { |
| 1491 DCHECK(CanUseSkiaGPUBackend()); |
| 1492 DCHECK_EQ(quad->opacity(), 1.f) << "Need to composite to a bitmap or a " |
| 1493 "render surface for non-1 opacity quads"; |
| 1494 |
| 1495 // TODO(enne): This should be done more lazily / efficiently. |
| 1496 gr_context_->resetContext(); |
| 1497 |
| 1498 // Reset the canvas matrix to identity because the clip rect is in target |
| 1499 // space. |
| 1500 SkMatrix sk_identity; |
| 1501 sk_identity.setIdentity(); |
| 1502 sk_canvas_->setMatrix(sk_identity); |
| 1503 |
| 1504 if (is_scissor_enabled_) { |
| 1505 sk_canvas_->clipRect(gfx::RectToSkRect(scissor_rect_), |
| 1506 SkRegion::kReplace_Op); |
| 1507 } else { |
| 1508 sk_canvas_->clipRect(gfx::RectToSkRect(gfx::Rect(ViewportSize())), |
| 1509 SkRegion::kReplace_Op); |
| 1510 } |
| 1511 |
| 1512 gfx::Transform contents_device_transform = frame->window_matrix * |
| 1513 frame->projection_matrix * quad->quadTransform(); |
| 1514 contents_device_transform.Translate(quad->rect.x(), |
| 1515 quad->rect.y()); |
| 1516 contents_device_transform.FlattenTo2d(); |
| 1517 SkMatrix sk_device_matrix; |
| 1518 gfx::TransformToFlattenedSkMatrix(contents_device_transform, |
| 1519 &sk_device_matrix); |
| 1520 sk_canvas_->setMatrix(sk_device_matrix); |
| 1521 |
| 1522 quad->picture_pile->RasterDirect( |
| 1523 sk_canvas_.get(), quad->content_rect, quad->contents_scale, NULL); |
| 1524 |
| 1525 // Flush any drawing buffers that have been deferred. |
| 1526 sk_canvas_->flush(); |
| 1527 |
| 1528 // TODO(enne): This should be done more lazily / efficiently. |
| 1529 ReinitializeGLState(); |
| 1530 } |
| 1531 |
1470 void GLRenderer::DrawPictureQuad(const DrawingFrame* frame, | 1532 void GLRenderer::DrawPictureQuad(const DrawingFrame* frame, |
1471 const PictureDrawQuad* quad) { | 1533 const PictureDrawQuad* quad) { |
| 1534 if (quad->can_draw_direct_to_backbuffer && CanUseSkiaGPUBackend()) { |
| 1535 DrawPictureQuadDirectToBackbuffer(frame, quad); |
| 1536 return; |
| 1537 } |
| 1538 |
1472 if (on_demand_tile_raster_bitmap_.width() != quad->texture_size.width() || | 1539 if (on_demand_tile_raster_bitmap_.width() != quad->texture_size.width() || |
1473 on_demand_tile_raster_bitmap_.height() != quad->texture_size.height()) { | 1540 on_demand_tile_raster_bitmap_.height() != quad->texture_size.height()) { |
1474 on_demand_tile_raster_bitmap_.setConfig( | 1541 on_demand_tile_raster_bitmap_.setConfig( |
1475 SkBitmap::kARGB_8888_Config, | 1542 SkBitmap::kARGB_8888_Config, |
1476 quad->texture_size.width(), | 1543 quad->texture_size.width(), |
1477 quad->texture_size.height()); | 1544 quad->texture_size.height()); |
1478 on_demand_tile_raster_bitmap_.allocPixels(); | 1545 on_demand_tile_raster_bitmap_.allocPixels(); |
1479 | 1546 |
1480 if (on_demand_tile_raster_resource_id_) | 1547 if (on_demand_tile_raster_resource_id_) |
1481 resource_provider_->DeleteResource(on_demand_tile_raster_resource_id_); | 1548 resource_provider_->DeleteResource(on_demand_tile_raster_resource_id_); |
1482 | 1549 |
1483 on_demand_tile_raster_resource_id_ = resource_provider_->CreateGLTexture( | 1550 on_demand_tile_raster_resource_id_ = resource_provider_->CreateGLTexture( |
1484 quad->texture_size, | 1551 quad->texture_size, |
1485 GL_RGBA, | 1552 GL_RGBA, |
1486 GL_TEXTURE_POOL_UNMANAGED_CHROMIUM, | 1553 GL_TEXTURE_POOL_UNMANAGED_CHROMIUM, |
1487 ResourceProvider::TextureUsageAny); | 1554 ResourceProvider::TextureUsageAny); |
1488 } | 1555 } |
1489 | 1556 |
1490 SkDevice device(on_demand_tile_raster_bitmap_); | 1557 SkDevice device(on_demand_tile_raster_bitmap_); |
1491 SkCanvas canvas(&device); | 1558 SkCanvas canvas(&device); |
1492 | 1559 |
1493 quad->picture_pile->Raster(&canvas, quad->content_rect, quad->contents_scale, | 1560 quad->picture_pile->RasterToBitmap(&canvas, quad->content_rect, |
1494 NULL); | 1561 quad->contents_scale, NULL); |
1495 | 1562 |
1496 resource_provider_->SetPixels( | 1563 resource_provider_->SetPixels( |
1497 on_demand_tile_raster_resource_id_, | 1564 on_demand_tile_raster_resource_id_, |
1498 reinterpret_cast<uint8_t*>(on_demand_tile_raster_bitmap_.getPixels()), | 1565 reinterpret_cast<uint8_t*>(on_demand_tile_raster_bitmap_.getPixels()), |
1499 gfx::Rect(quad->texture_size), | 1566 gfx::Rect(quad->texture_size), |
1500 gfx::Rect(quad->texture_size), | 1567 gfx::Rect(quad->texture_size), |
1501 gfx::Vector2d()); | 1568 gfx::Vector2d()); |
1502 | 1569 |
1503 DrawContentQuad(frame, quad, on_demand_tile_raster_resource_id_); | 1570 DrawContentQuad(frame, quad, on_demand_tile_raster_resource_id_); |
1504 } | 1571 } |
(...skipping 1286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2791 | 2858 |
2792 if (offscreen_framebuffer_id_) | 2859 if (offscreen_framebuffer_id_) |
2793 GLC(context_, context_->deleteFramebuffer(offscreen_framebuffer_id_)); | 2860 GLC(context_, context_->deleteFramebuffer(offscreen_framebuffer_id_)); |
2794 | 2861 |
2795 if (on_demand_tile_raster_resource_id_) | 2862 if (on_demand_tile_raster_resource_id_) |
2796 resource_provider_->DeleteResource(on_demand_tile_raster_resource_id_); | 2863 resource_provider_->DeleteResource(on_demand_tile_raster_resource_id_); |
2797 | 2864 |
2798 ReleaseRenderPassTextures(); | 2865 ReleaseRenderPassTextures(); |
2799 } | 2866 } |
2800 | 2867 |
| 2868 void GLRenderer::ReinitializeGrCanvas() { |
| 2869 if (!CanUseSkiaGPUBackend()) |
| 2870 return; |
| 2871 |
| 2872 GrBackendRenderTargetDesc desc; |
| 2873 desc.fWidth = ViewportWidth(); |
| 2874 desc.fHeight = ViewportHeight(); |
| 2875 desc.fConfig = kRGBA_8888_GrPixelConfig; |
| 2876 desc.fOrigin = kTopLeft_GrSurfaceOrigin; |
| 2877 desc.fSampleCnt = 1; |
| 2878 desc.fStencilBits = 8; |
| 2879 desc.fRenderTargetHandle = 0; |
| 2880 |
| 2881 skia::RefPtr<GrSurface> surface( |
| 2882 skia::AdoptRef(gr_context_->wrapBackendRenderTarget(desc))); |
| 2883 skia::RefPtr<SkDevice> device( |
| 2884 skia::AdoptRef(SkGpuDevice::Create(surface.get()))); |
| 2885 sk_canvas_ = skia::AdoptRef(new SkCanvas(device.get())); |
| 2886 } |
| 2887 |
| 2888 void GLRenderer::ReinitializeGLState() { |
| 2889 // Bind the common vertex attributes used for drawing all the layers. |
| 2890 shared_geometry_->PrepareForDraw(); |
| 2891 |
| 2892 GLC(context_, context_->disable(GL_STENCIL_TEST)); |
| 2893 GLC(context_, context_->disable(GL_DEPTH_TEST)); |
| 2894 GLC(context_, context_->disable(GL_CULL_FACE)); |
| 2895 GLC(context_, context_->colorMask(true, true, true, true)); |
| 2896 GLC(context_, context_->enable(GL_BLEND)); |
| 2897 blend_shadow_ = true; |
| 2898 GLC(context_, context_->blendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA)); |
| 2899 GLC(context_, context_->activeTexture(GL_TEXTURE0)); |
| 2900 program_shadow_ = 0; |
| 2901 |
| 2902 // Make sure scissoring starts as disabled. |
| 2903 is_scissor_enabled_ = false; |
| 2904 GLC(context_, context_->disable(GL_SCISSOR_TEST)); |
| 2905 } |
| 2906 |
| 2907 bool GLRenderer::CanUseSkiaGPUBackend() const { |
| 2908 // The Skia GPU backend requires a stencil buffer. See ReinitializeGrCanvas |
| 2909 // implementation. |
| 2910 return gr_context_ && context_->getContextAttributes().stencil; |
| 2911 } |
| 2912 |
2801 bool GLRenderer::IsContextLost() { | 2913 bool GLRenderer::IsContextLost() { |
2802 return (context_->getGraphicsResetStatusARB() != GL_NO_ERROR); | 2914 return (context_->getGraphicsResetStatusARB() != GL_NO_ERROR); |
2803 } | 2915 } |
2804 | 2916 |
2805 } // namespace cc | 2917 } // namespace cc |
OLD | NEW |