| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 #include "platform/graphics/ExpensiveCanvasHeuristicParameters.h" | 37 #include "platform/graphics/ExpensiveCanvasHeuristicParameters.h" |
| 38 #include "platform/graphics/GraphicsLayer.h" | 38 #include "platform/graphics/GraphicsLayer.h" |
| 39 #include "platform/graphics/ImageBuffer.h" | 39 #include "platform/graphics/ImageBuffer.h" |
| 40 #include "platform/graphics/gpu/SharedContextRateLimiter.h" | 40 #include "platform/graphics/gpu/SharedContextRateLimiter.h" |
| 41 #include "platform/tracing/TraceEvent.h" | 41 #include "platform/tracing/TraceEvent.h" |
| 42 #include "public/platform/Platform.h" | 42 #include "public/platform/Platform.h" |
| 43 #include "public/platform/WebCompositorSupport.h" | 43 #include "public/platform/WebCompositorSupport.h" |
| 44 #include "public/platform/WebGraphicsContext3DProvider.h" | 44 #include "public/platform/WebGraphicsContext3DProvider.h" |
| 45 #include "public/platform/WebScheduler.h" | 45 #include "public/platform/WebScheduler.h" |
| 46 #include "public/platform/WebTraceLocation.h" | 46 #include "public/platform/WebTraceLocation.h" |
| 47 #include "skia/ext/cdl_canvas.h" |
| 48 #include "skia/ext/cdl_surface.h" |
| 47 #include "skia/ext/texture_handle.h" | 49 #include "skia/ext/texture_handle.h" |
| 48 #include "third_party/skia/include/core/SkData.h" | 50 #include "third_party/skia/include/core/SkData.h" |
| 49 #include "third_party/skia/include/core/SkPictureRecorder.h" | 51 #include "skia/ext/cdl_picture_recorder.h" |
| 50 #include "third_party/skia/include/core/SkSurface.h" | 52 #include "third_party/skia/include/core/SkSurface.h" |
| 51 #include "third_party/skia/include/gpu/GrContext.h" | 53 #include "third_party/skia/include/gpu/GrContext.h" |
| 52 #include "third_party/skia/include/gpu/gl/GrGLTypes.h" | 54 #include "third_party/skia/include/gpu/gl/GrGLTypes.h" |
| 53 #include "wtf/PtrUtil.h" | 55 #include "wtf/PtrUtil.h" |
| 54 #include <memory> | 56 #include <memory> |
| 55 | 57 |
| 56 namespace { | 58 namespace { |
| 57 enum { | 59 enum { |
| 58 InvalidMailboxIndex = -1, | 60 InvalidMailboxIndex = -1, |
| 59 MaxCanvasAnimationBacklog = 2, // Make sure the the GPU is never more than | 61 MaxCanvasAnimationBacklog = 2, // Make sure the the GPU is never more than |
| (...skipping 14 matching lines...) Expand all Loading... |
| 74 std::unique_ptr<gfx::GpuMemoryBuffer> m_gpuMemoryBuffer; | 76 std::unique_ptr<gfx::GpuMemoryBuffer> m_gpuMemoryBuffer; |
| 75 | 77 |
| 76 // The id of the CHROMIUM image. | 78 // The id of the CHROMIUM image. |
| 77 const GLuint m_imageId; | 79 const GLuint m_imageId; |
| 78 | 80 |
| 79 // The id of the texture bound to the CHROMIUM image. | 81 // The id of the texture bound to the CHROMIUM image. |
| 80 const GLuint m_textureId; | 82 const GLuint m_textureId; |
| 81 }; | 83 }; |
| 82 #endif // USE_IOSURFACE_FOR_2D_CANVAS | 84 #endif // USE_IOSURFACE_FOR_2D_CANVAS |
| 83 | 85 |
| 84 static sk_sp<SkSurface> createSkSurface(GrContext* gr, | 86 static sk_sp<CdlSurface> createSkSurface(GrContext* gr, |
| 85 const IntSize& size, | 87 const IntSize& size, |
| 86 int msaaSampleCount, | 88 int msaaSampleCount, |
| 87 OpacityMode opacityMode, | 89 OpacityMode opacityMode, |
| 88 sk_sp<SkColorSpace> colorSpace, | 90 sk_sp<SkColorSpace> colorSpace, |
| 89 SkColorType colorType, | 91 SkColorType colorType, |
| 90 bool* surfaceIsAccelerated) { | 92 bool* surfaceIsAccelerated) { |
| 91 if (gr) | 93 if (gr) |
| 92 gr->resetContext(); | 94 gr->resetContext(); |
| 93 | 95 |
| 94 SkAlphaType alphaType = | 96 SkAlphaType alphaType = |
| 95 (Opaque == opacityMode) ? kOpaque_SkAlphaType : kPremul_SkAlphaType; | 97 (Opaque == opacityMode) ? kOpaque_SkAlphaType : kPremul_SkAlphaType; |
| 96 SkImageInfo info = SkImageInfo::Make(size.width(), size.height(), colorType, | 98 SkImageInfo info = SkImageInfo::Make(size.width(), size.height(), colorType, |
| 97 alphaType, colorSpace); | 99 alphaType, colorSpace); |
| 98 SkSurfaceProps disableLCDProps(0, kUnknown_SkPixelGeometry); | 100 SkSurfaceProps disableLCDProps(0, kUnknown_SkPixelGeometry); |
| 99 sk_sp<SkSurface> surface; | 101 sk_sp<CdlSurface> surface; |
| 100 | 102 |
| 101 if (gr) { | 103 if (gr) { |
| 102 *surfaceIsAccelerated = true; | 104 *surfaceIsAccelerated = true; |
| 103 surface = SkSurface::MakeRenderTarget( | 105 surface = CdlSurface::MakeRenderTarget( |
| 104 gr, SkBudgeted::kNo, info, msaaSampleCount, | 106 gr, SkBudgeted::kNo, info, msaaSampleCount, |
| 105 Opaque == opacityMode ? 0 : &disableLCDProps); | 107 Opaque == opacityMode ? 0 : &disableLCDProps); |
| 106 } | 108 } |
| 107 | 109 |
| 108 if (!surface) { | 110 if (!surface) { |
| 109 *surfaceIsAccelerated = false; | 111 *surfaceIsAccelerated = false; |
| 110 surface = SkSurface::MakeRaster( | 112 surface = CdlSurface::MakeRaster( |
| 111 info, Opaque == opacityMode ? 0 : &disableLCDProps); | 113 info, Opaque == opacityMode ? 0 : &disableLCDProps); |
| 112 } | 114 } |
| 113 | 115 |
| 114 if (surface) { | 116 if (surface) { |
| 115 if (opacityMode == Opaque) { | 117 if (opacityMode == Opaque) { |
| 116 surface->getCanvas()->clear(SK_ColorBLACK); | 118 surface->getCanvas()->clear(SK_ColorBLACK); |
| 117 } else { | 119 } else { |
| 118 surface->getCanvas()->clear(SK_ColorTRANSPARENT); | 120 surface->getCanvas()->clear(SK_ColorTRANSPARENT); |
| 119 } | 121 } |
| 120 } | 122 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 #if USE_IOSURFACE_FOR_2D_CANVAS | 165 #if USE_IOSURFACE_FOR_2D_CANVAS |
| 164 clearCHROMIUMImageCache(); | 166 clearCHROMIUMImageCache(); |
| 165 #endif // USE_IOSURFACE_FOR_2D_CANVAS | 167 #endif // USE_IOSURFACE_FOR_2D_CANVAS |
| 166 | 168 |
| 167 m_layer.reset(); | 169 m_layer.reset(); |
| 168 DCHECK_EQ(0u, m_mailboxes.size()); | 170 DCHECK_EQ(0u, m_mailboxes.size()); |
| 169 } | 171 } |
| 170 | 172 |
| 171 void Canvas2DLayerBridge::startRecording() { | 173 void Canvas2DLayerBridge::startRecording() { |
| 172 DCHECK(m_isDeferralEnabled); | 174 DCHECK(m_isDeferralEnabled); |
| 173 m_recorder = wrapUnique(new SkPictureRecorder); | 175 m_recorder = wrapUnique(new CdlPictureRecorder); |
| 174 SkCanvas* canvas = | 176 CdlCanvas* canvas = |
| 175 m_recorder->beginRecording(m_size.width(), m_size.height(), nullptr); | 177 m_recorder->beginRecording(m_size.width(), m_size.height(), nullptr); |
| 176 // Always save an initial frame, to support resetting the top level matrix | 178 // Always save an initial frame, to support resetting the top level matrix |
| 177 // and clip. | 179 // and clip. |
| 178 canvas->save(); | 180 canvas->save(); |
| 179 | 181 |
| 180 if (m_imageBuffer) { | 182 if (m_imageBuffer) { |
| 181 m_imageBuffer->resetCanvas(canvas); | 183 m_imageBuffer->resetCanvas(canvas); |
| 182 } | 184 } |
| 183 m_recordingPixelCount = 0; | 185 m_recordingPixelCount = 0; |
| 184 } | 186 } |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 return; | 495 return; |
| 494 } | 496 } |
| 495 | 497 |
| 496 if (!isAccelerated()) { | 498 if (!isAccelerated()) { |
| 497 m_logger->reportHibernationEvent( | 499 m_logger->reportHibernationEvent( |
| 498 HibernationAbortedDueToSwitchToUnacceleratedRendering); | 500 HibernationAbortedDueToSwitchToUnacceleratedRendering); |
| 499 return; | 501 return; |
| 500 } | 502 } |
| 501 | 503 |
| 502 TRACE_EVENT0("cc", "Canvas2DLayerBridge::hibernate"); | 504 TRACE_EVENT0("cc", "Canvas2DLayerBridge::hibernate"); |
| 503 sk_sp<SkSurface> tempHibernationSurface = | 505 sk_sp<CdlSurface> tempHibernationSurface = |
| 504 SkSurface::MakeRasterN32Premul(m_size.width(), m_size.height()); | 506 CdlSurface::MakeRasterN32Premul(m_size.width(), m_size.height()); |
| 505 if (!tempHibernationSurface) { | 507 if (!tempHibernationSurface) { |
| 506 m_logger->reportHibernationEvent(HibernationAbortedDueToAllocationFailure); | 508 m_logger->reportHibernationEvent(HibernationAbortedDueToAllocationFailure); |
| 507 return; | 509 return; |
| 508 } | 510 } |
| 509 // No HibernationEvent reported on success. This is on purppose to avoid | 511 // No HibernationEvent reported on success. This is on purppose to avoid |
| 510 // non-complementary stats. Each HibernationScheduled event is paired with | 512 // non-complementary stats. Each HibernationScheduled event is paired with |
| 511 // exactly one failure or exit event. | 513 // exactly one failure or exit event. |
| 512 flushRecordingOnly(); | 514 flushRecordingOnly(); |
| 513 // The following checks that the flush succeeded, which should always be the | 515 // The following checks that the flush succeeded, which should always be the |
| 514 // case because flushRecordingOnly should only fail it it fails to allocate | 516 // case because flushRecordingOnly should only fail it it fails to allocate |
| 515 // a surface, and we have an early exit at the top of this function for when | 517 // a surface, and we have an early exit at the top of this function for when |
| 516 // 'this' does not already have a surface. | 518 // 'this' does not already have a surface. |
| 517 DCHECK(!m_haveRecordedDrawCommands); | 519 DCHECK(!m_haveRecordedDrawCommands); |
| 518 SkPaint copyPaint; | 520 CdlPaint copyPaint; |
| 519 copyPaint.setBlendMode(SkBlendMode::kSrc); | 521 copyPaint.setBlendMode(SkBlendMode::kSrc); |
| 520 m_surface->draw(tempHibernationSurface->getCanvas(), 0, 0, | 522 m_surface->draw(tempHibernationSurface->getCanvas(), 0, 0, |
| 521 ©Paint); // GPU readback | 523 ©Paint); // GPU readback |
| 522 m_hibernationImage = tempHibernationSurface->makeImageSnapshot(); | 524 m_hibernationImage = tempHibernationSurface->makeImageSnapshot(); |
| 523 m_surface.reset(); // destroy the GPU-backed buffer | 525 m_surface.reset(); // destroy the GPU-backed buffer |
| 524 m_layer->clearTexture(); | 526 m_layer->clearTexture(); |
| 525 #if USE_IOSURFACE_FOR_2D_CANVAS | 527 #if USE_IOSURFACE_FOR_2D_CANVAS |
| 526 clearCHROMIUMImageCache(); | 528 clearCHROMIUMImageCache(); |
| 527 #endif // USE_IOSURFACE_FOR_2D_CANVAS | 529 #endif // USE_IOSURFACE_FOR_2D_CANVAS |
| 528 m_logger->didStartHibernating(); | 530 m_logger->didStartHibernating(); |
| 529 } | 531 } |
| 530 | 532 |
| 531 void Canvas2DLayerBridge::reportSurfaceCreationFailure() { | 533 void Canvas2DLayerBridge::reportSurfaceCreationFailure() { |
| 532 if (!m_surfaceCreationFailedAtLeastOnce) { | 534 if (!m_surfaceCreationFailedAtLeastOnce) { |
| 533 // Only count the failure once per instance so that the histogram may | 535 // Only count the failure once per instance so that the histogram may |
| 534 // reflect the proportion of Canvas2DLayerBridge instances with surface | 536 // reflect the proportion of Canvas2DLayerBridge instances with surface |
| 535 // allocation failures. | 537 // allocation failures. |
| 536 CanvasMetrics::countCanvasContextUsage( | 538 CanvasMetrics::countCanvasContextUsage( |
| 537 CanvasMetrics::GPUAccelerated2DCanvasSurfaceCreationFailed); | 539 CanvasMetrics::GPUAccelerated2DCanvasSurfaceCreationFailed); |
| 538 m_surfaceCreationFailedAtLeastOnce = true; | 540 m_surfaceCreationFailedAtLeastOnce = true; |
| 539 } | 541 } |
| 540 } | 542 } |
| 541 | 543 |
| 542 SkSurface* Canvas2DLayerBridge::getOrCreateSurface(AccelerationHint hint) { | 544 CdlSurface* Canvas2DLayerBridge::getOrCreateSurface(AccelerationHint hint) { |
| 543 if (m_surface) | 545 if (m_surface) |
| 544 return m_surface.get(); | 546 return m_surface.get(); |
| 545 | 547 |
| 546 if (m_layer && !isHibernating() && hint == PreferAcceleration && | 548 if (m_layer && !isHibernating() && hint == PreferAcceleration && |
| 547 m_accelerationMode != DisableAcceleration) { | 549 m_accelerationMode != DisableAcceleration) { |
| 548 return nullptr; // re-creation will happen through restore() | 550 return nullptr; // re-creation will happen through restore() |
| 549 } | 551 } |
| 550 | 552 |
| 551 bool wantAcceleration = shouldAccelerate(hint); | 553 bool wantAcceleration = shouldAccelerate(hint); |
| 552 if (CANVAS2D_BACKGROUND_RENDER_SWITCH_TO_CPU && isHidden() && | 554 if (CANVAS2D_BACKGROUND_RENDER_SWITCH_TO_CPU && isHidden() && |
| (...skipping 30 matching lines...) Expand all Loading... |
| 583 if (surfaceIsAccelerated) { | 585 if (surfaceIsAccelerated) { |
| 584 m_logger->reportHibernationEvent(HibernationEndedNormally); | 586 m_logger->reportHibernationEvent(HibernationEndedNormally); |
| 585 } else { | 587 } else { |
| 586 if (isHidden()) | 588 if (isHidden()) |
| 587 m_logger->reportHibernationEvent( | 589 m_logger->reportHibernationEvent( |
| 588 HibernationEndedWithSwitchToBackgroundRendering); | 590 HibernationEndedWithSwitchToBackgroundRendering); |
| 589 else | 591 else |
| 590 m_logger->reportHibernationEvent(HibernationEndedWithFallbackToSW); | 592 m_logger->reportHibernationEvent(HibernationEndedWithFallbackToSW); |
| 591 } | 593 } |
| 592 | 594 |
| 593 SkPaint copyPaint; | 595 CdlPaint copyPaint; |
| 594 copyPaint.setBlendMode(SkBlendMode::kSrc); | 596 copyPaint.setBlendMode(SkBlendMode::kSrc); |
| 595 m_surface->getCanvas()->drawImage(m_hibernationImage.get(), 0, 0, | 597 m_surface->getCanvas()->drawImage(m_hibernationImage.get(), 0, 0, |
| 596 ©Paint); | 598 ©Paint); |
| 597 m_hibernationImage.reset(); | 599 m_hibernationImage.reset(); |
| 598 | 600 |
| 599 if (m_imageBuffer) | 601 if (m_imageBuffer) |
| 600 m_imageBuffer->updateGPUMemoryUsage(); | 602 m_imageBuffer->updateGPUMemoryUsage(); |
| 601 | 603 |
| 602 if (m_imageBuffer && !m_isDeferralEnabled) | 604 if (m_imageBuffer && !m_isDeferralEnabled) |
| 603 m_imageBuffer->resetCanvas(m_surface->getCanvas()); | 605 m_imageBuffer->resetCanvas(m_surface->getCanvas()); |
| 604 } | 606 } |
| 605 | 607 |
| 606 return m_surface.get(); | 608 return m_surface.get(); |
| 607 } | 609 } |
| 608 | 610 |
| 609 SkCanvas* Canvas2DLayerBridge::canvas() { | 611 CdlCanvas* Canvas2DLayerBridge::canvas() { |
| 610 if (!m_isDeferralEnabled) { | 612 if (!m_isDeferralEnabled) { |
| 611 SkSurface* s = getOrCreateSurface(); | 613 CdlSurface* s = getOrCreateSurface(); |
| 612 return s ? s->getCanvas() : nullptr; | 614 return s ? s->getCanvas() : nullptr; |
| 613 } | 615 } |
| 614 return m_recorder->getRecordingCanvas(); | 616 return m_recorder->getRecordingCanvas(); |
| 615 } | 617 } |
| 616 | 618 |
| 617 void Canvas2DLayerBridge::disableDeferral(DisableDeferralReason reason) { | 619 void Canvas2DLayerBridge::disableDeferral(DisableDeferralReason reason) { |
| 618 // Disabling deferral is permanent: once triggered by disableDeferral() | 620 // Disabling deferral is permanent: once triggered by disableDeferral() |
| 619 // we stay in immediate mode indefinitely. This is a performance heuristic | 621 // we stay in immediate mode indefinitely. This is a performance heuristic |
| 620 // that significantly helps a number of use cases. The rationale is that if | 622 // that significantly helps a number of use cases. The rationale is that if |
| 621 // immediate rendering was needed once, it is likely to be needed at least | 623 // immediate rendering was needed once, it is likely to be needed at least |
| (...skipping 12 matching lines...) Expand all Loading... |
| 634 CanvasMetrics::countCanvasContextUsage( | 636 CanvasMetrics::countCanvasContextUsage( |
| 635 CanvasMetrics::GPUAccelerated2DCanvasDeferralDisabled); | 637 CanvasMetrics::GPUAccelerated2DCanvasDeferralDisabled); |
| 636 flushRecordingOnly(); | 638 flushRecordingOnly(); |
| 637 // Because we will be discarding the recorder, if the flush failed | 639 // Because we will be discarding the recorder, if the flush failed |
| 638 // content will be lost -> force m_haveRecordedDrawCommands to false | 640 // content will be lost -> force m_haveRecordedDrawCommands to false |
| 639 m_haveRecordedDrawCommands = false; | 641 m_haveRecordedDrawCommands = false; |
| 640 | 642 |
| 641 m_isDeferralEnabled = false; | 643 m_isDeferralEnabled = false; |
| 642 m_recorder.reset(); | 644 m_recorder.reset(); |
| 643 // install the current matrix/clip stack onto the immediate canvas | 645 // install the current matrix/clip stack onto the immediate canvas |
| 644 SkSurface* surface = getOrCreateSurface(); | 646 CdlSurface* surface = getOrCreateSurface(); |
| 645 if (m_imageBuffer && surface) | 647 if (m_imageBuffer && surface) |
| 646 m_imageBuffer->resetCanvas(surface->getCanvas()); | 648 m_imageBuffer->resetCanvas(surface->getCanvas()); |
| 647 } | 649 } |
| 648 | 650 |
| 649 void Canvas2DLayerBridge::setImageBuffer(ImageBuffer* imageBuffer) { | 651 void Canvas2DLayerBridge::setImageBuffer(ImageBuffer* imageBuffer) { |
| 650 m_imageBuffer = imageBuffer; | 652 m_imageBuffer = imageBuffer; |
| 651 if (m_imageBuffer && m_isDeferralEnabled) { | 653 if (m_imageBuffer && m_isDeferralEnabled) { |
| 652 m_imageBuffer->resetCanvas(m_recorder->getRecordingCanvas()); | 654 m_imageBuffer->resetCanvas(m_recorder->getRecordingCanvas()); |
| 653 } | 655 } |
| 654 } | 656 } |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 710 BLINK_FROM_HERE, WTF::bind(&hibernateWrapperForTesting, | 712 BLINK_FROM_HERE, WTF::bind(&hibernateWrapperForTesting, |
| 711 m_weakPtrFactory.createWeakPtr())); | 713 m_weakPtrFactory.createWeakPtr())); |
| 712 } else { | 714 } else { |
| 713 Platform::current()->currentThread()->scheduler()->postIdleTask( | 715 Platform::current()->currentThread()->scheduler()->postIdleTask( |
| 714 BLINK_FROM_HERE, | 716 BLINK_FROM_HERE, |
| 715 WTF::bind(&hibernateWrapper, m_weakPtrFactory.createWeakPtr())); | 717 WTF::bind(&hibernateWrapper, m_weakPtrFactory.createWeakPtr())); |
| 716 } | 718 } |
| 717 } | 719 } |
| 718 if (!isHidden() && m_softwareRenderingWhileHidden) { | 720 if (!isHidden() && m_softwareRenderingWhileHidden) { |
| 719 flushRecordingOnly(); | 721 flushRecordingOnly(); |
| 720 SkPaint copyPaint; | 722 CdlPaint copyPaint; |
| 721 copyPaint.setBlendMode(SkBlendMode::kSrc); | 723 copyPaint.setBlendMode(SkBlendMode::kSrc); |
| 722 | 724 |
| 723 sk_sp<SkSurface> oldSurface = std::move(m_surface); | 725 sk_sp<CdlSurface> oldSurface = std::move(m_surface); |
| 724 m_surface.reset(); | 726 m_surface.reset(); |
| 725 | 727 |
| 726 m_softwareRenderingWhileHidden = false; | 728 m_softwareRenderingWhileHidden = false; |
| 727 SkSurface* newSurface = | 729 CdlSurface* newSurface = |
| 728 getOrCreateSurface(PreferAccelerationAfterVisibilityChange); | 730 getOrCreateSurface(PreferAccelerationAfterVisibilityChange); |
| 729 if (newSurface) { | 731 if (newSurface) { |
| 730 if (oldSurface) | 732 if (oldSurface) |
| 731 oldSurface->draw(newSurface->getCanvas(), 0, 0, ©Paint); | 733 oldSurface->draw(newSurface->getCanvas(), 0, 0, ©Paint); |
| 732 if (m_imageBuffer && !m_isDeferralEnabled) { | 734 if (m_imageBuffer && !m_isDeferralEnabled) { |
| 733 m_imageBuffer->resetCanvas(m_surface->getCanvas()); | 735 m_imageBuffer->resetCanvas(m_surface->getCanvas()); |
| 734 } | 736 } |
| 735 } | 737 } |
| 736 } | 738 } |
| 737 if (!isHidden() && isHibernating()) { | 739 if (!isHidden() && isHibernating()) { |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 851 gpu::gles2::GLES2Interface* sharedGL = nullptr; | 853 gpu::gles2::GLES2Interface* sharedGL = nullptr; |
| 852 m_layer->clearTexture(); | 854 m_layer->clearTexture(); |
| 853 m_contextProvider = wrapUnique( | 855 m_contextProvider = wrapUnique( |
| 854 Platform::current()->createSharedOffscreenGraphicsContext3DProvider()); | 856 Platform::current()->createSharedOffscreenGraphicsContext3DProvider()); |
| 855 if (m_contextProvider) | 857 if (m_contextProvider) |
| 856 sharedGL = m_contextProvider->contextGL(); | 858 sharedGL = m_contextProvider->contextGL(); |
| 857 | 859 |
| 858 if (sharedGL && sharedGL->GetGraphicsResetStatusKHR() == GL_NO_ERROR) { | 860 if (sharedGL && sharedGL->GetGraphicsResetStatusKHR() == GL_NO_ERROR) { |
| 859 GrContext* grCtx = m_contextProvider->grContext(); | 861 GrContext* grCtx = m_contextProvider->grContext(); |
| 860 bool surfaceIsAccelerated; | 862 bool surfaceIsAccelerated; |
| 861 sk_sp<SkSurface> surface( | 863 sk_sp<CdlSurface> surface( |
| 862 createSkSurface(grCtx, m_size, m_msaaSampleCount, m_opacityMode, | 864 createSkSurface(grCtx, m_size, m_msaaSampleCount, m_opacityMode, |
| 863 m_colorSpace, m_colorType, &surfaceIsAccelerated)); | 865 m_colorSpace, m_colorType, &surfaceIsAccelerated)); |
| 864 | 866 |
| 865 if (!m_surface) | 867 if (!m_surface) |
| 866 reportSurfaceCreationFailure(); | 868 reportSurfaceCreationFailure(); |
| 867 | 869 |
| 868 // The current paradigm does not support switching from accelerated to | 870 // The current paradigm does not support switching from accelerated to |
| 869 // non-accelerated, which would be tricky due to changes to the layer tree, | 871 // non-accelerated, which would be tricky due to changes to the layer tree, |
| 870 // which can only happen at specific times during the document lifecycle. | 872 // which can only happen at specific times during the document lifecycle. |
| 871 // Therefore, we can only accept the restored surface if it is accelerated. | 873 // Therefore, we can only accept the restored surface if it is accelerated. |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1144 default; | 1146 default; |
| 1145 | 1147 |
| 1146 void Canvas2DLayerBridge::Logger::reportHibernationEvent( | 1148 void Canvas2DLayerBridge::Logger::reportHibernationEvent( |
| 1147 HibernationEvent event) { | 1149 HibernationEvent event) { |
| 1148 DEFINE_STATIC_LOCAL(EnumerationHistogram, hibernationHistogram, | 1150 DEFINE_STATIC_LOCAL(EnumerationHistogram, hibernationHistogram, |
| 1149 ("Canvas.HibernationEvents", HibernationEventCount)); | 1151 ("Canvas.HibernationEvents", HibernationEventCount)); |
| 1150 hibernationHistogram.count(event); | 1152 hibernationHistogram.count(event); |
| 1151 } | 1153 } |
| 1152 | 1154 |
| 1153 } // namespace blink | 1155 } // namespace blink |
| OLD | NEW |