| 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 1143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1461 Context()->uniform1i(program->fragment_shader().sampler_location(), 0)); | 1479 Context()->uniform1i(program->fragment_shader().sampler_location(), 0)); |
| 1462 | 1480 |
| 1463 SetShaderOpacity(quad->opacity(), | 1481 SetShaderOpacity(quad->opacity(), |
| 1464 program->fragment_shader().alpha_location()); | 1482 program->fragment_shader().alpha_location()); |
| 1465 DrawQuadGeometry(frame, | 1483 DrawQuadGeometry(frame, |
| 1466 quad->quadTransform(), | 1484 quad->quadTransform(), |
| 1467 quad->rect, | 1485 quad->rect, |
| 1468 program->vertex_shader().matrix_location()); | 1486 program->vertex_shader().matrix_location()); |
| 1469 } | 1487 } |
| 1470 | 1488 |
| 1489 void GLRenderer::DrawPictureQuadDirectToBackbuffer( |
| 1490 const DrawingFrame* frame, |
| 1491 const PictureDrawQuad* quad) { |
| 1492 DCHECK(CanUseSkiaGPUBackend()); |
| 1493 DCHECK_EQ(quad->opacity(), 1.f) << "Need to composite to a bitmap or a " |
| 1494 "render surface for non-1 opacity quads"; |
| 1495 |
| 1496 // TODO(enne): This should be done more lazily / efficiently. |
| 1497 gr_context_->resetContext(); |
| 1498 |
| 1499 // Reset the canvas matrix to identity because the clip rect is in target |
| 1500 // space. |
| 1501 SkMatrix sk_identity; |
| 1502 sk_identity.setIdentity(); |
| 1503 sk_canvas_->setMatrix(sk_identity); |
| 1504 |
| 1505 if (is_scissor_enabled_) { |
| 1506 sk_canvas_->clipRect(gfx::RectToSkRect(scissor_rect_), |
| 1507 SkRegion::kReplace_Op); |
| 1508 } else { |
| 1509 sk_canvas_->clipRect(gfx::RectToSkRect(gfx::Rect(ViewportSize())), |
| 1510 SkRegion::kReplace_Op); |
| 1511 } |
| 1512 |
| 1513 gfx::Transform contents_device_transform = frame->window_matrix * |
| 1514 frame->projection_matrix * quad->quadTransform(); |
| 1515 contents_device_transform.Translate(quad->rect.x(), |
| 1516 quad->rect.y()); |
| 1517 contents_device_transform.FlattenTo2d(); |
| 1518 SkMatrix sk_device_matrix; |
| 1519 gfx::TransformToFlattenedSkMatrix(contents_device_transform, |
| 1520 &sk_device_matrix); |
| 1521 sk_canvas_->setMatrix(sk_device_matrix); |
| 1522 |
| 1523 quad->picture_pile->RasterDirect( |
| 1524 sk_canvas_.get(), quad->content_rect, quad->contents_scale, NULL); |
| 1525 |
| 1526 // Flush any drawing buffers that have been deferred. |
| 1527 sk_canvas_->flush(); |
| 1528 |
| 1529 // TODO(enne): This should be done more lazily / efficiently. |
| 1530 ReinitializeGLState(); |
| 1531 } |
| 1532 |
| 1471 void GLRenderer::DrawPictureQuad(const DrawingFrame* frame, | 1533 void GLRenderer::DrawPictureQuad(const DrawingFrame* frame, |
| 1472 const PictureDrawQuad* quad) { | 1534 const PictureDrawQuad* quad) { |
| 1535 if (quad->can_draw_direct_to_backbuffer && CanUseSkiaGPUBackend()) { |
| 1536 DrawPictureQuadDirectToBackbuffer(frame, quad); |
| 1537 return; |
| 1538 } |
| 1539 |
| 1473 if (on_demand_tile_raster_bitmap_.width() != quad->texture_size.width() || | 1540 if (on_demand_tile_raster_bitmap_.width() != quad->texture_size.width() || |
| 1474 on_demand_tile_raster_bitmap_.height() != quad->texture_size.height()) { | 1541 on_demand_tile_raster_bitmap_.height() != quad->texture_size.height()) { |
| 1475 on_demand_tile_raster_bitmap_.setConfig( | 1542 on_demand_tile_raster_bitmap_.setConfig( |
| 1476 SkBitmap::kARGB_8888_Config, | 1543 SkBitmap::kARGB_8888_Config, |
| 1477 quad->texture_size.width(), | 1544 quad->texture_size.width(), |
| 1478 quad->texture_size.height()); | 1545 quad->texture_size.height()); |
| 1479 on_demand_tile_raster_bitmap_.allocPixels(); | 1546 on_demand_tile_raster_bitmap_.allocPixels(); |
| 1480 | 1547 |
| 1481 if (on_demand_tile_raster_resource_id_) | 1548 if (on_demand_tile_raster_resource_id_) |
| 1482 resource_provider_->DeleteResource(on_demand_tile_raster_resource_id_); | 1549 resource_provider_->DeleteResource(on_demand_tile_raster_resource_id_); |
| 1483 | 1550 |
| 1484 on_demand_tile_raster_resource_id_ = resource_provider_->CreateGLTexture( | 1551 on_demand_tile_raster_resource_id_ = resource_provider_->CreateGLTexture( |
| 1485 quad->texture_size, | 1552 quad->texture_size, |
| 1486 GL_RGBA, | 1553 GL_RGBA, |
| 1487 GL_TEXTURE_POOL_UNMANAGED_CHROMIUM, | 1554 GL_TEXTURE_POOL_UNMANAGED_CHROMIUM, |
| 1488 ResourceProvider::TextureUsageAny); | 1555 ResourceProvider::TextureUsageAny); |
| 1489 } | 1556 } |
| 1490 | 1557 |
| 1491 SkDevice device(on_demand_tile_raster_bitmap_); | 1558 SkDevice device(on_demand_tile_raster_bitmap_); |
| 1492 SkCanvas canvas(&device); | 1559 SkCanvas canvas(&device); |
| 1493 | 1560 |
| 1494 quad->picture_pile->Raster(&canvas, quad->content_rect, quad->contents_scale, | 1561 quad->picture_pile->RasterToBitmap(&canvas, quad->content_rect, |
| 1495 NULL); | 1562 quad->contents_scale, NULL); |
| 1496 | 1563 |
| 1497 resource_provider_->SetPixels( | 1564 resource_provider_->SetPixels( |
| 1498 on_demand_tile_raster_resource_id_, | 1565 on_demand_tile_raster_resource_id_, |
| 1499 reinterpret_cast<uint8_t*>(on_demand_tile_raster_bitmap_.getPixels()), | 1566 reinterpret_cast<uint8_t*>(on_demand_tile_raster_bitmap_.getPixels()), |
| 1500 gfx::Rect(quad->texture_size), | 1567 gfx::Rect(quad->texture_size), |
| 1501 gfx::Rect(quad->texture_size), | 1568 gfx::Rect(quad->texture_size), |
| 1502 gfx::Vector2d()); | 1569 gfx::Vector2d()); |
| 1503 | 1570 |
| 1504 DrawContentQuad(frame, quad, on_demand_tile_raster_resource_id_); | 1571 DrawContentQuad(frame, quad, on_demand_tile_raster_resource_id_); |
| 1505 } | 1572 } |
| (...skipping 1286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2792 | 2859 |
| 2793 if (offscreen_framebuffer_id_) | 2860 if (offscreen_framebuffer_id_) |
| 2794 GLC(context_, context_->deleteFramebuffer(offscreen_framebuffer_id_)); | 2861 GLC(context_, context_->deleteFramebuffer(offscreen_framebuffer_id_)); |
| 2795 | 2862 |
| 2796 if (on_demand_tile_raster_resource_id_) | 2863 if (on_demand_tile_raster_resource_id_) |
| 2797 resource_provider_->DeleteResource(on_demand_tile_raster_resource_id_); | 2864 resource_provider_->DeleteResource(on_demand_tile_raster_resource_id_); |
| 2798 | 2865 |
| 2799 ReleaseRenderPassTextures(); | 2866 ReleaseRenderPassTextures(); |
| 2800 } | 2867 } |
| 2801 | 2868 |
| 2869 void GLRenderer::ReinitializeGrCanvas() { |
| 2870 if (!CanUseSkiaGPUBackend()) |
| 2871 return; |
| 2872 |
| 2873 GrBackendRenderTargetDesc desc; |
| 2874 desc.fWidth = ViewportWidth(); |
| 2875 desc.fHeight = ViewportHeight(); |
| 2876 desc.fConfig = kRGBA_8888_GrPixelConfig; |
| 2877 desc.fOrigin = kTopLeft_GrSurfaceOrigin; |
| 2878 desc.fSampleCnt = 1; |
| 2879 desc.fStencilBits = 8; |
| 2880 desc.fRenderTargetHandle = 0; |
| 2881 |
| 2882 skia::RefPtr<GrSurface> surface( |
| 2883 skia::AdoptRef(gr_context_->wrapBackendRenderTarget(desc))); |
| 2884 skia::RefPtr<SkDevice> device( |
| 2885 skia::AdoptRef(SkGpuDevice::Create(surface.get()))); |
| 2886 sk_canvas_ = skia::AdoptRef(new SkCanvas(device.get())); |
| 2887 } |
| 2888 |
| 2889 void GLRenderer::ReinitializeGLState() { |
| 2890 // Bind the common vertex attributes used for drawing all the layers. |
| 2891 shared_geometry_->PrepareForDraw(); |
| 2892 |
| 2893 GLC(context_, context_->disable(GL_STENCIL_TEST)); |
| 2894 GLC(context_, context_->disable(GL_DEPTH_TEST)); |
| 2895 GLC(context_, context_->disable(GL_CULL_FACE)); |
| 2896 GLC(context_, context_->colorMask(true, true, true, true)); |
| 2897 GLC(context_, context_->enable(GL_BLEND)); |
| 2898 blend_shadow_ = true; |
| 2899 GLC(context_, context_->blendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA)); |
| 2900 GLC(context_, context_->activeTexture(GL_TEXTURE0)); |
| 2901 program_shadow_ = 0; |
| 2902 |
| 2903 // Make sure scissoring starts as disabled. |
| 2904 is_scissor_enabled_ = false; |
| 2905 GLC(context_, context_->disable(GL_SCISSOR_TEST)); |
| 2906 } |
| 2907 |
| 2908 bool GLRenderer::CanUseSkiaGPUBackend() const { |
| 2909 // The Skia GPU backend requires a stencil buffer. See ReinitializeGrCanvas |
| 2910 // implementation. |
| 2911 return gr_context_ && context_->getContextAttributes().stencil; |
| 2912 } |
| 2913 |
| 2802 bool GLRenderer::IsContextLost() { | 2914 bool GLRenderer::IsContextLost() { |
| 2803 return (context_->getGraphicsResetStatusARB() != GL_NO_ERROR); | 2915 return (context_->getGraphicsResetStatusARB() != GL_NO_ERROR); |
| 2804 } | 2916 } |
| 2805 | 2917 |
| 2806 } // namespace cc | 2918 } // namespace cc |
| OLD | NEW |