Chromium Code Reviews| 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 |
| 290 bool always_clear = true; | |
| 274 #ifdef NDEBUG | 291 #ifdef NDEBUG |
| 275 if (frame->current_render_pass->has_transparent_background) | 292 always_clear = false; |
| 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 if (CanUseGanesh()) | |
| 297 clear_bits |= GL_STENCIL_BUFFER_BIT; | |
| 298 context_->clear(clear_bits); | |
| 299 } | |
| 278 } | 300 } |
| 279 | 301 |
| 280 void GLRenderer::BeginDrawingFrame(DrawingFrame* frame) { | 302 void GLRenderer::BeginDrawingFrame(DrawingFrame* frame) { |
| 281 // FIXME: Remove this once backbuffer is automatically recreated on first use | 303 // FIXME: Remove this once backbuffer is automatically recreated on first use |
| 282 EnsureBackbuffer(); | 304 EnsureBackbuffer(); |
| 283 | 305 |
| 284 if (ViewportSize().IsEmpty()) | 306 if (ViewportSize().IsEmpty()) |
| 285 return; | 307 return; |
| 286 | 308 |
| 287 TRACE_EVENT0("cc", "GLRenderer::DrawLayers"); | 309 TRACE_EVENT0("cc", "GLRenderer::DrawLayers"); |
| 288 if (is_viewport_changed_) { | 310 if (is_viewport_changed_) { |
| 289 // Only reshape when we know we are going to draw. Otherwise, the reshape | 311 // 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 | 312 // can leave the window at the wrong size if we never draw and the proper |
| 291 // viewport size is never set. | 313 // viewport size is never set. |
| 292 is_viewport_changed_ = false; | 314 is_viewport_changed_ = false; |
| 293 output_surface_->Reshape(gfx::Size(ViewportWidth(), ViewportHeight())); | 315 output_surface_->Reshape(gfx::Size(ViewportWidth(), ViewportHeight())); |
| 294 } | 316 } |
| 295 | 317 |
| 296 MakeContextCurrent(); | 318 MakeContextCurrent(); |
| 297 // Bind the common vertex attributes used for drawing all the layers. | |
| 298 shared_geometry_->PrepareForDraw(); | |
| 299 | 319 |
| 300 GLC(context_, context_->disable(GL_DEPTH_TEST)); | 320 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 } | 321 } |
| 309 | 322 |
| 310 void GLRenderer::DoNoOp() { | 323 void GLRenderer::DoNoOp() { |
| 311 GLC(context_, context_->bindFramebuffer(GL_FRAMEBUFFER, 0)); | 324 GLC(context_, context_->bindFramebuffer(GL_FRAMEBUFFER, 0)); |
| 312 GLC(context_, context_->flush()); | 325 GLC(context_, context_->flush()); |
| 313 } | 326 } |
| 314 | 327 |
| 315 void GLRenderer::DoDrawQuad(DrawingFrame* frame, const DrawQuad* quad) { | 328 void GLRenderer::DoDrawQuad(DrawingFrame* frame, const DrawQuad* quad) { |
| 316 DCHECK(quad->rect.Contains(quad->visible_rect)); | 329 DCHECK(quad->rect.Contains(quad->visible_rect)); |
| 317 if (quad->material != DrawQuad::TEXTURE_CONTENT) { | 330 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)); | 1474 Context()->uniform1i(program->fragment_shader().sampler_location(), 0)); |
| 1462 | 1475 |
| 1463 SetShaderOpacity(quad->opacity(), | 1476 SetShaderOpacity(quad->opacity(), |
| 1464 program->fragment_shader().alpha_location()); | 1477 program->fragment_shader().alpha_location()); |
| 1465 DrawQuadGeometry(frame, | 1478 DrawQuadGeometry(frame, |
| 1466 quad->quadTransform(), | 1479 quad->quadTransform(), |
| 1467 quad->rect, | 1480 quad->rect, |
| 1468 program->vertex_shader().matrix_location()); | 1481 program->vertex_shader().matrix_location()); |
| 1469 } | 1482 } |
| 1470 | 1483 |
| 1484 void GLRenderer::DrawPictureQuadDirectToBackbuffer( | |
| 1485 const DrawingFrame* frame, | |
| 1486 const PictureDrawQuad* quad) { | |
| 1487 DCHECK(CanUseGanesh()); | |
| 1488 | |
| 1489 // TODO(enne): Only do this if we've set some state since the last time | |
| 1490 // Ganesh drew anything. | |
| 1491 gr_context_->resetContext(); | |
| 1492 | |
| 1493 if (is_scissor_enabled_) { | |
| 1494 gfx::Rect flipped_scissor = scissor_rect_; | |
| 1495 flipped_scissor.set_y(ViewportHeight() - scissor_rect_.bottom()); | |
| 1496 sk_canvas_->clipRect(gfx::RectToSkRect(flipped_scissor), | |
| 1497 SkRegion::kReplace_Op); | |
| 1498 } else { | |
| 1499 sk_canvas_->clipRect(gfx::RectToSkRect(gfx::Rect(ViewportSize())), | |
| 1500 SkRegion::kReplace_Op); | |
| 1501 } | |
| 1502 | |
| 1503 gfx::Transform y_flip; | |
| 1504 y_flip.Scale3d(1.0, -1.0, 1.0); | |
| 1505 | |
| 1506 gfx::Transform contents_device_transform = frame->window_matrix * y_flip * | |
| 1507 frame->projection_matrix * quad->quadTransform(); | |
| 1508 contents_device_transform.Translate(quad->rect.x(), | |
| 1509 quad->rect.y()); | |
| 1510 contents_device_transform.FlattenTo2d(); | |
| 1511 SkMatrix sk_device_matrix; | |
| 1512 gfx::TransformToFlattenedSkMatrix(contents_device_transform, | |
| 1513 &sk_device_matrix); | |
| 1514 sk_canvas_->setMatrix(sk_device_matrix); | |
| 1515 | |
| 1516 quad->picture_pile->Raster( | |
| 1517 sk_canvas_.get(), quad->content_rect, quad->contents_scale, NULL); | |
| 1518 | |
| 1519 // Flush any drawing buffers that have been deferred. | |
| 1520 sk_canvas_->flush(); | |
| 1521 ReinitializeGLState(); | |
| 1522 } | |
| 1523 | |
| 1471 void GLRenderer::DrawPictureQuad(const DrawingFrame* frame, | 1524 void GLRenderer::DrawPictureQuad(const DrawingFrame* frame, |
| 1472 const PictureDrawQuad* quad) { | 1525 const PictureDrawQuad* quad) { |
| 1526 if (quad->draw_direct_to_backbuffer && CanUseGanesh()) { | |
| 1527 DrawPictureQuadDirectToBackbuffer(frame, quad); | |
| 1528 return; | |
| 1529 } | |
| 1530 | |
| 1473 if (on_demand_tile_raster_bitmap_.width() != quad->texture_size.width() || | 1531 if (on_demand_tile_raster_bitmap_.width() != quad->texture_size.width() || |
| 1474 on_demand_tile_raster_bitmap_.height() != quad->texture_size.height()) { | 1532 on_demand_tile_raster_bitmap_.height() != quad->texture_size.height()) { |
| 1475 on_demand_tile_raster_bitmap_.setConfig( | 1533 on_demand_tile_raster_bitmap_.setConfig( |
| 1476 SkBitmap::kARGB_8888_Config, | 1534 SkBitmap::kARGB_8888_Config, |
| 1477 quad->texture_size.width(), | 1535 quad->texture_size.width(), |
| 1478 quad->texture_size.height()); | 1536 quad->texture_size.height()); |
| 1479 on_demand_tile_raster_bitmap_.allocPixels(); | 1537 on_demand_tile_raster_bitmap_.allocPixels(); |
| 1480 | 1538 |
| 1481 if (on_demand_tile_raster_resource_id_) | 1539 if (on_demand_tile_raster_resource_id_) |
| 1482 resource_provider_->DeleteResource(on_demand_tile_raster_resource_id_); | 1540 resource_provider_->DeleteResource(on_demand_tile_raster_resource_id_); |
| 1483 | 1541 |
| 1484 on_demand_tile_raster_resource_id_ = resource_provider_->CreateGLTexture( | 1542 on_demand_tile_raster_resource_id_ = resource_provider_->CreateGLTexture( |
| 1485 quad->texture_size, | 1543 quad->texture_size, |
| 1486 GL_RGBA, | 1544 GL_RGBA, |
| 1487 GL_TEXTURE_POOL_UNMANAGED_CHROMIUM, | 1545 GL_TEXTURE_POOL_UNMANAGED_CHROMIUM, |
| 1488 ResourceProvider::TextureUsageAny); | 1546 ResourceProvider::TextureUsageAny); |
| 1489 } | 1547 } |
| 1490 | 1548 |
| 1491 SkDevice device(on_demand_tile_raster_bitmap_); | 1549 SkDevice device(on_demand_tile_raster_bitmap_); |
| 1492 SkCanvas canvas(&device); | 1550 SkCanvas canvas(&device); |
| 1493 | 1551 |
| 1494 quad->picture_pile->Raster(&canvas, quad->content_rect, quad->contents_scale, | 1552 quad->picture_pile->RasterToBitmap(&canvas, quad->content_rect, |
| 1495 NULL); | 1553 quad->contents_scale, NULL); |
| 1496 | 1554 |
| 1497 resource_provider_->SetPixels( | 1555 resource_provider_->SetPixels( |
| 1498 on_demand_tile_raster_resource_id_, | 1556 on_demand_tile_raster_resource_id_, |
| 1499 reinterpret_cast<uint8_t*>(on_demand_tile_raster_bitmap_.getPixels()), | 1557 reinterpret_cast<uint8_t*>(on_demand_tile_raster_bitmap_.getPixels()), |
| 1500 gfx::Rect(quad->texture_size), | 1558 gfx::Rect(quad->texture_size), |
| 1501 gfx::Rect(quad->texture_size), | 1559 gfx::Rect(quad->texture_size), |
| 1502 gfx::Vector2d()); | 1560 gfx::Vector2d()); |
| 1503 | 1561 |
| 1504 DrawContentQuad(frame, quad, on_demand_tile_raster_resource_id_); | 1562 DrawContentQuad(frame, quad, on_demand_tile_raster_resource_id_); |
| 1505 } | 1563 } |
| (...skipping 1286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2792 | 2850 |
| 2793 if (offscreen_framebuffer_id_) | 2851 if (offscreen_framebuffer_id_) |
| 2794 GLC(context_, context_->deleteFramebuffer(offscreen_framebuffer_id_)); | 2852 GLC(context_, context_->deleteFramebuffer(offscreen_framebuffer_id_)); |
| 2795 | 2853 |
| 2796 if (on_demand_tile_raster_resource_id_) | 2854 if (on_demand_tile_raster_resource_id_) |
| 2797 resource_provider_->DeleteResource(on_demand_tile_raster_resource_id_); | 2855 resource_provider_->DeleteResource(on_demand_tile_raster_resource_id_); |
| 2798 | 2856 |
| 2799 ReleaseRenderPassTextures(); | 2857 ReleaseRenderPassTextures(); |
| 2800 } | 2858 } |
| 2801 | 2859 |
| 2860 void GLRenderer::ReinitializeGrCanvas() { | |
| 2861 if (!CanUseGanesh()) | |
| 2862 return; | |
| 2863 | |
| 2864 GrBackendRenderTargetDesc desc; | |
| 2865 desc.fWidth = ViewportWidth(); | |
| 2866 desc.fHeight = ViewportHeight(); | |
| 2867 desc.fConfig = kRGBA_8888_GrPixelConfig; | |
| 2868 desc.fOrigin = kBottomLeft_GrSurfaceOrigin; | |
|
bsalomon
2013/05/13 19:49:15
As of skia r9113 (which should get rolled to chrom
| |
| 2869 desc.fSampleCnt = 1; | |
| 2870 desc.fStencilBits = 8; | |
| 2871 desc.fRenderTargetHandle = 0; | |
| 2872 | |
| 2873 SkAutoTUnref<GrSurface> surface( | |
| 2874 gr_context_->wrapBackendRenderTarget(desc)); | |
| 2875 SkAutoTUnref<SkDevice> device(SkGpuDevice::Create(surface)); | |
| 2876 sk_canvas_.reset(new SkCanvas(device.get())); | |
| 2877 } | |
| 2878 | |
| 2879 void GLRenderer::ReinitializeGLState() { | |
| 2880 // Bind the common vertex attributes used for drawing all the layers. | |
| 2881 shared_geometry_->PrepareForDraw(); | |
| 2882 | |
| 2883 GLC(context_, context_->disable(GL_STENCIL_TEST)); | |
| 2884 GLC(context_, context_->disable(GL_DEPTH_TEST)); | |
| 2885 GLC(context_, context_->disable(GL_CULL_FACE)); | |
| 2886 GLC(context_, context_->colorMask(true, true, true, true)); | |
| 2887 GLC(context_, context_->enable(GL_BLEND)); | |
| 2888 blend_shadow_ = true; | |
| 2889 GLC(context_, context_->blendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA)); | |
| 2890 GLC(context_, context_->activeTexture(GL_TEXTURE0)); | |
| 2891 program_shadow_ = 0; | |
| 2892 | |
| 2893 // Make sure scissoring starts as disabled. | |
| 2894 is_scissor_enabled_ = false; | |
| 2895 GLC(context_, context_->disable(GL_SCISSOR_TEST)); | |
| 2896 } | |
| 2897 | |
| 2898 bool GLRenderer::CanUseGanesh() const { | |
| 2899 return gr_context_ && context_->getContextAttributes().stencil; | |
| 2900 } | |
| 2901 | |
| 2802 bool GLRenderer::IsContextLost() { | 2902 bool GLRenderer::IsContextLost() { |
| 2803 return (context_->getGraphicsResetStatusARB() != GL_NO_ERROR); | 2903 return (context_->getGraphicsResetStatusARB() != GL_NO_ERROR); |
| 2804 } | 2904 } |
| 2805 | 2905 |
| 2806 } // namespace cc | 2906 } // namespace cc |
| OLD | NEW |