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_ganesh) { | |
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_ganesh) | |
115 renderer->InitializeGrContext(); | |
111 | 116 |
112 return renderer.Pass(); | 117 return renderer.Pass(); |
113 } | 118 } |
114 | 119 |
115 GLRenderer::GLRenderer(RendererClient* client, | 120 GLRenderer::GLRenderer(RendererClient* client, |
116 OutputSurface* output_surface, | 121 OutputSurface* output_surface, |
117 ResourceProvider* resource_provider, | 122 ResourceProvider* resource_provider, |
118 int highp_threshold_min) | 123 int highp_threshold_min) |
119 : DirectRenderer(client, resource_provider), | 124 : DirectRenderer(client, resource_provider), |
120 offscreen_framebuffer_id_(0), | 125 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, | 191 // 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. | 192 // so we only need to avoid POT textures if we have an NPOT fast-path. |
188 capabilities_.avoid_pow2_textures = | 193 capabilities_.avoid_pow2_textures = |
189 extensions.count("GL_CHROMIUM_fast_NPOT_MO8_textures") > 0; | 194 extensions.count("GL_CHROMIUM_fast_NPOT_MO8_textures") > 0; |
190 | 195 |
191 capabilities_.using_offscreen_context3d = true; | 196 capabilities_.using_offscreen_context3d = true; |
192 | 197 |
193 is_using_bind_uniform_ = | 198 is_using_bind_uniform_ = |
194 extensions.count("GL_CHROMIUM_bind_uniform_location") > 0; | 199 extensions.count("GL_CHROMIUM_bind_uniform_location") > 0; |
195 | 200 |
196 // Make sure scissoring starts as disabled. | |
197 GLC(context_, context_->disable(GL_SCISSOR_TEST)); | |
198 DCHECK(!is_scissor_enabled_); | |
199 | |
200 if (!InitializeSharedObjects()) | 201 if (!InitializeSharedObjects()) |
201 return false; | 202 return false; |
202 | 203 |
203 // Make sure the viewport and context gets initialized, even if it is to zero. | 204 // Make sure the viewport and context gets initialized, even if it is to zero. |
204 ViewportChanged(); | 205 ViewportChanged(); |
205 return true; | 206 return true; |
206 } | 207 } |
207 | 208 |
209 void GLRenderer::InitializeGrContext() { | |
210 skia::RefPtr<GrGLInterface> interface = skia::AdoptRef( | |
211 context_->createGrGLInterface()); | |
212 if (!interface) | |
213 return; | |
214 | |
215 gr_context_ = skia::AdoptRef(GrContext::Create( | |
216 kOpenGL_GrBackend, | |
217 reinterpret_cast<GrBackendContext>(interface.get()))); | |
218 ReinitializeGrCanvas(); | |
219 } | |
220 | |
208 GLRenderer::~GLRenderer() { | 221 GLRenderer::~GLRenderer() { |
209 while (!pending_async_read_pixels_.empty()) { | 222 while (!pending_async_read_pixels_.empty()) { |
210 pending_async_read_pixels_.back()->finished_read_pixels_callback.Cancel(); | 223 pending_async_read_pixels_.back()->finished_read_pixels_callback.Cancel(); |
211 pending_async_read_pixels_.back()->copy_callback.Run( | 224 pending_async_read_pixels_.back()->copy_callback.Run( |
212 scoped_ptr<SkBitmap>()); | 225 scoped_ptr<SkBitmap>()); |
213 pending_async_read_pixels_.pop_back(); | 226 pending_async_read_pixels_.pop_back(); |
214 } | 227 } |
215 | 228 |
216 context_->setMemoryAllocationChangedCallbackCHROMIUM(NULL); | 229 context_->setMemoryAllocationChangedCallbackCHROMIUM(NULL); |
217 CleanupSharedObjects(); | 230 CleanupSharedObjects(); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
254 WebKit::WebGraphicsManagedMemoryStats stats; | 267 WebKit::WebGraphicsManagedMemoryStats stats; |
255 stats.bytesVisible = bytes_visible; | 268 stats.bytesVisible = bytes_visible; |
256 stats.bytesVisibleAndNearby = bytes_visible_and_nearby; | 269 stats.bytesVisibleAndNearby = bytes_visible_and_nearby; |
257 stats.bytesAllocated = bytes_allocated; | 270 stats.bytesAllocated = bytes_allocated; |
258 stats.backbufferRequested = !is_backbuffer_discarded_; | 271 stats.backbufferRequested = !is_backbuffer_discarded_; |
259 context_->sendManagedMemoryStatsCHROMIUM(&stats); | 272 context_->sendManagedMemoryStatsCHROMIUM(&stats); |
260 } | 273 } |
261 | 274 |
262 void GLRenderer::ReleaseRenderPassTextures() { render_pass_textures_.clear(); } | 275 void GLRenderer::ReleaseRenderPassTextures() { render_pass_textures_.clear(); } |
263 | 276 |
264 void GLRenderer::ViewportChanged() { is_viewport_changed_ = true; } | 277 void GLRenderer::ViewportChanged() { |
278 is_viewport_changed_ = true; | |
279 ReinitializeGrCanvas(); | |
280 } | |
265 | 281 |
266 void GLRenderer::ClearFramebuffer(DrawingFrame* frame) { | 282 void GLRenderer::ClearFramebuffer(DrawingFrame* frame) { |
267 // On DEBUG builds, opaque render passes are cleared to blue to easily see | 283 // On DEBUG builds, opaque render passes are cleared to blue to easily see |
268 // regions that were not drawn on the screen. | 284 // regions that were not drawn on the screen. |
269 if (frame->current_render_pass->has_transparent_background) | 285 if (frame->current_render_pass->has_transparent_background) |
270 GLC(context_, context_->clearColor(0, 0, 0, 0)); | 286 GLC(context_, context_->clearColor(0, 0, 0, 0)); |
271 else | 287 else |
272 GLC(context_, context_->clearColor(0, 0, 1, 1)); | 288 GLC(context_, context_->clearColor(0, 0, 1, 1)); |
273 | 289 |
274 #ifdef NDEBUG | 290 bool always_clear = false; |
275 if (frame->current_render_pass->has_transparent_background) | 291 #ifndef NDEBUG |
292 always_clear = true; | |
276 #endif | 293 #endif |
277 context_->clear(GL_COLOR_BUFFER_BIT); | 294 if (always_clear || frame->current_render_pass->has_transparent_background) { |
295 GLbitfield clear_bits = GL_COLOR_BUFFER_BIT; | |
296 // Only Ganesh uses the stencil buffer. No need to clear it otherwise. | |
297 if (CanUseGanesh()) | |
298 clear_bits |= GL_STENCIL_BUFFER_BIT; | |
299 context_->clear(clear_bits); | |
300 } | |
278 } | 301 } |
279 | 302 |
280 void GLRenderer::BeginDrawingFrame(DrawingFrame* frame) { | 303 void GLRenderer::BeginDrawingFrame(DrawingFrame* frame) { |
281 // FIXME: Remove this once backbuffer is automatically recreated on first use | 304 // FIXME: Remove this once backbuffer is automatically recreated on first use |
282 EnsureBackbuffer(); | 305 EnsureBackbuffer(); |
283 | 306 |
284 if (ViewportSize().IsEmpty()) | 307 if (ViewportSize().IsEmpty()) |
285 return; | 308 return; |
286 | 309 |
287 TRACE_EVENT0("cc", "GLRenderer::DrawLayers"); | 310 TRACE_EVENT0("cc", "GLRenderer::DrawLayers"); |
288 if (is_viewport_changed_) { | 311 if (is_viewport_changed_) { |
289 // Only reshape when we know we are going to draw. Otherwise, the reshape | 312 // 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 | 313 // can leave the window at the wrong size if we never draw and the proper |
291 // viewport size is never set. | 314 // viewport size is never set. |
292 is_viewport_changed_ = false; | 315 is_viewport_changed_ = false; |
293 output_surface_->Reshape(gfx::Size(ViewportWidth(), ViewportHeight())); | 316 output_surface_->Reshape(gfx::Size(ViewportWidth(), ViewportHeight())); |
294 } | 317 } |
295 | 318 |
296 MakeContextCurrent(); | 319 MakeContextCurrent(); |
297 // Bind the common vertex attributes used for drawing all the layers. | |
298 shared_geometry_->PrepareForDraw(); | |
299 | 320 |
300 GLC(context_, context_->disable(GL_DEPTH_TEST)); | 321 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 } | 322 } |
309 | 323 |
310 void GLRenderer::DoNoOp() { | 324 void GLRenderer::DoNoOp() { |
311 GLC(context_, context_->bindFramebuffer(GL_FRAMEBUFFER, 0)); | 325 GLC(context_, context_->bindFramebuffer(GL_FRAMEBUFFER, 0)); |
312 GLC(context_, context_->flush()); | 326 GLC(context_, context_->flush()); |
313 } | 327 } |
314 | 328 |
315 void GLRenderer::DoDrawQuad(DrawingFrame* frame, const DrawQuad* quad) { | 329 void GLRenderer::DoDrawQuad(DrawingFrame* frame, const DrawQuad* quad) { |
316 DCHECK(quad->rect.Contains(quad->visible_rect)); | 330 DCHECK(quad->rect.Contains(quad->visible_rect)); |
317 if (quad->material != DrawQuad::TEXTURE_CONTENT) { | 331 if (quad->material != DrawQuad::TEXTURE_CONTENT) { |
(...skipping 1143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1461 Context()->uniform1i(program->fragment_shader().sampler_location(), 0)); | 1475 Context()->uniform1i(program->fragment_shader().sampler_location(), 0)); |
1462 | 1476 |
1463 SetShaderOpacity(quad->opacity(), | 1477 SetShaderOpacity(quad->opacity(), |
1464 program->fragment_shader().alpha_location()); | 1478 program->fragment_shader().alpha_location()); |
1465 DrawQuadGeometry(frame, | 1479 DrawQuadGeometry(frame, |
1466 quad->quadTransform(), | 1480 quad->quadTransform(), |
1467 quad->rect, | 1481 quad->rect, |
1468 program->vertex_shader().matrix_location()); | 1482 program->vertex_shader().matrix_location()); |
1469 } | 1483 } |
1470 | 1484 |
1485 void GLRenderer::DrawPictureQuadDirectToBackbuffer( | |
1486 const DrawingFrame* frame, | |
1487 const PictureDrawQuad* quad) { | |
1488 DCHECK(CanUseGanesh()); | |
1489 DCHECK_EQ(quad->opacity(), 1.f) << "Need to composite to a bitmap or a " | |
danakj
2013/05/16 15:17:55
Hm, so this is only true if there are overlapping
enne (OOO)
2013/05/16 20:34:11
Your assumption about overlapping quads is incorre
danakj
2013/05/17 23:36:31
I see thanks for this explanation.
| |
1490 "render surface for non-1 opacity quads"; | |
1491 | |
1492 // TODO(enne): Only do this if we've set some state since the last time | |
1493 // Ganesh drew anything. | |
1494 gr_context_->resetContext(); | |
1495 | |
1496 // Reset the canvas matrix to identity because the clip rect is in target | |
1497 // space. | |
1498 SkMatrix sk_identity; | |
1499 sk_identity.setIdentity(); | |
1500 sk_canvas_->setMatrix(sk_identity); | |
1501 | |
1502 if (is_scissor_enabled_) { | |
1503 sk_canvas_->clipRect(gfx::RectToSkRect(scissor_rect_), | |
1504 SkRegion::kReplace_Op); | |
1505 } else { | |
1506 sk_canvas_->clipRect(gfx::RectToSkRect(gfx::Rect(ViewportSize())), | |
1507 SkRegion::kReplace_Op); | |
1508 } | |
1509 | |
1510 gfx::Transform contents_device_transform = frame->window_matrix * | |
1511 frame->projection_matrix * quad->quadTransform(); | |
1512 contents_device_transform.Translate(quad->rect.x(), | |
1513 quad->rect.y()); | |
1514 contents_device_transform.FlattenTo2d(); | |
1515 SkMatrix sk_device_matrix; | |
1516 gfx::TransformToFlattenedSkMatrix(contents_device_transform, | |
1517 &sk_device_matrix); | |
1518 sk_canvas_->setMatrix(sk_device_matrix); | |
1519 | |
1520 quad->picture_pile->RasterDirect( | |
1521 sk_canvas_.get(), quad->content_rect, quad->contents_scale, NULL); | |
1522 | |
1523 // Flush any drawing buffers that have been deferred. | |
1524 sk_canvas_->flush(); | |
1525 ReinitializeGLState(); | |
danakj
2013/05/16 15:17:55
I think I'd like another TODO here like above.. Ju
enne (OOO)
2013/05/16 20:34:11
Done.
| |
1526 } | |
1527 | |
1471 void GLRenderer::DrawPictureQuad(const DrawingFrame* frame, | 1528 void GLRenderer::DrawPictureQuad(const DrawingFrame* frame, |
1472 const PictureDrawQuad* quad) { | 1529 const PictureDrawQuad* quad) { |
1530 if (quad->draw_direct_to_backbuffer && CanUseGanesh()) { | |
1531 DrawPictureQuadDirectToBackbuffer(frame, quad); | |
1532 return; | |
1533 } | |
1534 | |
1473 if (on_demand_tile_raster_bitmap_.width() != quad->texture_size.width() || | 1535 if (on_demand_tile_raster_bitmap_.width() != quad->texture_size.width() || |
1474 on_demand_tile_raster_bitmap_.height() != quad->texture_size.height()) { | 1536 on_demand_tile_raster_bitmap_.height() != quad->texture_size.height()) { |
1475 on_demand_tile_raster_bitmap_.setConfig( | 1537 on_demand_tile_raster_bitmap_.setConfig( |
1476 SkBitmap::kARGB_8888_Config, | 1538 SkBitmap::kARGB_8888_Config, |
1477 quad->texture_size.width(), | 1539 quad->texture_size.width(), |
1478 quad->texture_size.height()); | 1540 quad->texture_size.height()); |
1479 on_demand_tile_raster_bitmap_.allocPixels(); | 1541 on_demand_tile_raster_bitmap_.allocPixels(); |
1480 | 1542 |
1481 if (on_demand_tile_raster_resource_id_) | 1543 if (on_demand_tile_raster_resource_id_) |
1482 resource_provider_->DeleteResource(on_demand_tile_raster_resource_id_); | 1544 resource_provider_->DeleteResource(on_demand_tile_raster_resource_id_); |
1483 | 1545 |
1484 on_demand_tile_raster_resource_id_ = resource_provider_->CreateGLTexture( | 1546 on_demand_tile_raster_resource_id_ = resource_provider_->CreateGLTexture( |
1485 quad->texture_size, | 1547 quad->texture_size, |
1486 GL_RGBA, | 1548 GL_RGBA, |
1487 GL_TEXTURE_POOL_UNMANAGED_CHROMIUM, | 1549 GL_TEXTURE_POOL_UNMANAGED_CHROMIUM, |
1488 ResourceProvider::TextureUsageAny); | 1550 ResourceProvider::TextureUsageAny); |
1489 } | 1551 } |
1490 | 1552 |
1491 SkDevice device(on_demand_tile_raster_bitmap_); | 1553 SkDevice device(on_demand_tile_raster_bitmap_); |
1492 SkCanvas canvas(&device); | 1554 SkCanvas canvas(&device); |
1493 | 1555 |
1494 quad->picture_pile->Raster(&canvas, quad->content_rect, quad->contents_scale, | 1556 quad->picture_pile->RasterToBitmap(&canvas, quad->content_rect, |
danakj
2013/05/16 15:17:55
nit: one arg per line or all on one line
enne (OOO)
2013/05/16 20:34:11
nit nit: That is not in the style guide.
| |
1495 NULL); | 1557 quad->contents_scale, NULL); |
1496 | 1558 |
1497 resource_provider_->SetPixels( | 1559 resource_provider_->SetPixels( |
1498 on_demand_tile_raster_resource_id_, | 1560 on_demand_tile_raster_resource_id_, |
1499 reinterpret_cast<uint8_t*>(on_demand_tile_raster_bitmap_.getPixels()), | 1561 reinterpret_cast<uint8_t*>(on_demand_tile_raster_bitmap_.getPixels()), |
1500 gfx::Rect(quad->texture_size), | 1562 gfx::Rect(quad->texture_size), |
1501 gfx::Rect(quad->texture_size), | 1563 gfx::Rect(quad->texture_size), |
1502 gfx::Vector2d()); | 1564 gfx::Vector2d()); |
1503 | 1565 |
1504 DrawContentQuad(frame, quad, on_demand_tile_raster_resource_id_); | 1566 DrawContentQuad(frame, quad, on_demand_tile_raster_resource_id_); |
1505 } | 1567 } |
(...skipping 1286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2792 | 2854 |
2793 if (offscreen_framebuffer_id_) | 2855 if (offscreen_framebuffer_id_) |
2794 GLC(context_, context_->deleteFramebuffer(offscreen_framebuffer_id_)); | 2856 GLC(context_, context_->deleteFramebuffer(offscreen_framebuffer_id_)); |
2795 | 2857 |
2796 if (on_demand_tile_raster_resource_id_) | 2858 if (on_demand_tile_raster_resource_id_) |
2797 resource_provider_->DeleteResource(on_demand_tile_raster_resource_id_); | 2859 resource_provider_->DeleteResource(on_demand_tile_raster_resource_id_); |
2798 | 2860 |
2799 ReleaseRenderPassTextures(); | 2861 ReleaseRenderPassTextures(); |
2800 } | 2862 } |
2801 | 2863 |
2864 void GLRenderer::ReinitializeGrCanvas() { | |
2865 if (!CanUseGanesh()) | |
2866 return; | |
2867 | |
2868 GrBackendRenderTargetDesc desc; | |
2869 desc.fWidth = ViewportWidth(); | |
2870 desc.fHeight = ViewportHeight(); | |
2871 desc.fConfig = kRGBA_8888_GrPixelConfig; | |
2872 desc.fOrigin = kTopLeft_GrSurfaceOrigin; | |
2873 desc.fSampleCnt = 1; | |
2874 desc.fStencilBits = 8; | |
2875 desc.fRenderTargetHandle = 0; | |
2876 | |
2877 skia::RefPtr<GrSurface> surface( | |
2878 skia::AdoptRef(gr_context_->wrapBackendRenderTarget(desc))); | |
2879 skia::RefPtr<SkDevice> device( | |
2880 skia::AdoptRef(SkGpuDevice::Create(surface.get()))); | |
2881 sk_canvas_ = skia::AdoptRef(new SkCanvas(device.get())); | |
2882 } | |
2883 | |
2884 void GLRenderer::ReinitializeGLState() { | |
2885 // Bind the common vertex attributes used for drawing all the layers. | |
2886 shared_geometry_->PrepareForDraw(); | |
2887 | |
2888 GLC(context_, context_->disable(GL_STENCIL_TEST)); | |
2889 GLC(context_, context_->disable(GL_DEPTH_TEST)); | |
2890 GLC(context_, context_->disable(GL_CULL_FACE)); | |
2891 GLC(context_, context_->colorMask(true, true, true, true)); | |
2892 GLC(context_, context_->enable(GL_BLEND)); | |
2893 blend_shadow_ = true; | |
2894 GLC(context_, context_->blendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA)); | |
2895 GLC(context_, context_->activeTexture(GL_TEXTURE0)); | |
2896 program_shadow_ = 0; | |
2897 | |
2898 // Make sure scissoring starts as disabled. | |
2899 is_scissor_enabled_ = false; | |
2900 GLC(context_, context_->disable(GL_SCISSOR_TEST)); | |
2901 } | |
2902 | |
2903 bool GLRenderer::CanUseGanesh() const { | |
2904 // Ganesh requires a stencil buffer. See ReinitializeGrCanvas implementation. | |
2905 return gr_context_ && context_->getContextAttributes().stencil; | |
2906 } | |
2907 | |
2802 bool GLRenderer::IsContextLost() { | 2908 bool GLRenderer::IsContextLost() { |
2803 return (context_->getGraphicsResetStatusARB() != GL_NO_ERROR); | 2909 return (context_->getGraphicsResetStatusARB() != GL_NO_ERROR); |
2804 } | 2910 } |
2805 | 2911 |
2806 } // namespace cc | 2912 } // namespace cc |
OLD | NEW |