Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(167)

Side by Side Diff: third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.cpp

Issue 2640983002: Rename paint data structures (Closed)
Patch Set: Clean up comments, fix mac build Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 20 matching lines...) Expand all
31 #include "gpu/command_buffer/client/gles2_interface.h" 31 #include "gpu/command_buffer/client/gles2_interface.h"
32 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h" 32 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h"
33 #include "platform/Histogram.h" 33 #include "platform/Histogram.h"
34 #include "platform/RuntimeEnabledFeatures.h" 34 #include "platform/RuntimeEnabledFeatures.h"
35 #include "platform/WebTaskRunner.h" 35 #include "platform/WebTaskRunner.h"
36 #include "platform/graphics/CanvasMetrics.h" 36 #include "platform/graphics/CanvasMetrics.h"
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/graphics/paint/PaintCanvas.h"
42 #include "platform/graphics/paint/PaintSurface.h"
41 #include "platform/instrumentation/tracing/TraceEvent.h" 43 #include "platform/instrumentation/tracing/TraceEvent.h"
42 #include "public/platform/Platform.h" 44 #include "public/platform/Platform.h"
43 #include "public/platform/WebCompositorSupport.h" 45 #include "public/platform/WebCompositorSupport.h"
44 #include "public/platform/WebGraphicsContext3DProvider.h" 46 #include "public/platform/WebGraphicsContext3DProvider.h"
45 #include "public/platform/WebScheduler.h" 47 #include "public/platform/WebScheduler.h"
46 #include "public/platform/WebTraceLocation.h" 48 #include "public/platform/WebTraceLocation.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"
50 #include "third_party/skia/include/core/SkSurface.h"
51 #include "third_party/skia/include/gpu/GrContext.h" 51 #include "third_party/skia/include/gpu/GrContext.h"
52 #include "third_party/skia/include/gpu/gl/GrGLTypes.h" 52 #include "third_party/skia/include/gpu/gl/GrGLTypes.h"
53 #include "wtf/PtrUtil.h" 53 #include "wtf/PtrUtil.h"
54 #include <memory> 54 #include <memory>
55 55
56 namespace { 56 namespace {
57 enum { 57 enum {
58 InvalidMailboxIndex = -1, 58 InvalidMailboxIndex = -1,
59 MaxCanvasAnimationBacklog = 2, // Make sure the the GPU is never more than 59 MaxCanvasAnimationBacklog = 2, // Make sure the the GPU is never more than
60 // two animation frames behind. 60 // two animation frames behind.
(...skipping 13 matching lines...) Expand all
74 std::unique_ptr<gfx::GpuMemoryBuffer> m_gpuMemoryBuffer; 74 std::unique_ptr<gfx::GpuMemoryBuffer> m_gpuMemoryBuffer;
75 75
76 // The id of the CHROMIUM image. 76 // The id of the CHROMIUM image.
77 const GLuint m_imageId; 77 const GLuint m_imageId;
78 78
79 // The id of the texture bound to the CHROMIUM image. 79 // The id of the texture bound to the CHROMIUM image.
80 const GLuint m_textureId; 80 const GLuint m_textureId;
81 }; 81 };
82 #endif // USE_IOSURFACE_FOR_2D_CANVAS 82 #endif // USE_IOSURFACE_FOR_2D_CANVAS
83 83
84 static sk_sp<SkSurface> createSkSurface(GrContext* gr, 84 static sk_sp<PaintSurface> createSkSurface(GrContext* gr,
danakj 2017/01/20 23:34:15 I feel like this should stay SkSurface and we shou
enne (OOO) 2017/01/24 01:51:28 Going to punt on this for now, given vmiura's comm
85 const IntSize& size, 85 const IntSize& size,
86 int msaaSampleCount, 86 int msaaSampleCount,
87 OpacityMode opacityMode, 87 OpacityMode opacityMode,
88 sk_sp<SkColorSpace> colorSpace, 88 sk_sp<SkColorSpace> colorSpace,
89 SkColorType colorType, 89 SkColorType colorType,
90 bool* surfaceIsAccelerated) { 90 bool* surfaceIsAccelerated) {
91 if (gr) 91 if (gr)
92 gr->resetContext(); 92 gr->resetContext();
93 93
94 SkAlphaType alphaType = 94 SkAlphaType alphaType =
95 (Opaque == opacityMode) ? kOpaque_SkAlphaType : kPremul_SkAlphaType; 95 (Opaque == opacityMode) ? kOpaque_SkAlphaType : kPremul_SkAlphaType;
96 SkImageInfo info = SkImageInfo::Make(size.width(), size.height(), colorType, 96 SkImageInfo info = SkImageInfo::Make(size.width(), size.height(), colorType,
97 alphaType, colorSpace); 97 alphaType, colorSpace);
98 SkSurfaceProps disableLCDProps(0, kUnknown_SkPixelGeometry); 98 SkSurfaceProps disableLCDProps(0, kUnknown_SkPixelGeometry);
99 sk_sp<SkSurface> surface; 99 sk_sp<PaintSurface> surface;
100 100
101 if (gr) { 101 if (gr) {
102 *surfaceIsAccelerated = true; 102 *surfaceIsAccelerated = true;
103 surface = SkSurface::MakeRenderTarget( 103 surface = PaintSurface::MakeRenderTarget(
104 gr, SkBudgeted::kNo, info, msaaSampleCount, 104 gr, SkBudgeted::kNo, info, msaaSampleCount,
105 Opaque == opacityMode ? 0 : &disableLCDProps); 105 Opaque == opacityMode ? 0 : &disableLCDProps);
106 } 106 }
107 107
108 if (!surface) { 108 if (!surface) {
109 *surfaceIsAccelerated = false; 109 *surfaceIsAccelerated = false;
110 surface = SkSurface::MakeRaster( 110 surface = PaintSurface::MakeRaster(
111 info, Opaque == opacityMode ? 0 : &disableLCDProps); 111 info, Opaque == opacityMode ? 0 : &disableLCDProps);
112 } 112 }
113 113
114 if (surface) { 114 if (surface) {
115 if (opacityMode == Opaque) { 115 if (opacityMode == Opaque) {
116 surface->getCanvas()->clear(SK_ColorBLACK); 116 surface->getCanvas()->clear(SK_ColorBLACK);
117 } else { 117 } else {
118 surface->getCanvas()->clear(SK_ColorTRANSPARENT); 118 surface->getCanvas()->clear(SK_ColorTRANSPARENT);
119 } 119 }
120 } 120 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 #if USE_IOSURFACE_FOR_2D_CANVAS 163 #if USE_IOSURFACE_FOR_2D_CANVAS
164 clearCHROMIUMImageCache(); 164 clearCHROMIUMImageCache();
165 #endif // USE_IOSURFACE_FOR_2D_CANVAS 165 #endif // USE_IOSURFACE_FOR_2D_CANVAS
166 166
167 m_layer.reset(); 167 m_layer.reset();
168 DCHECK_EQ(0u, m_mailboxes.size()); 168 DCHECK_EQ(0u, m_mailboxes.size());
169 } 169 }
170 170
171 void Canvas2DLayerBridge::startRecording() { 171 void Canvas2DLayerBridge::startRecording() {
172 DCHECK(m_isDeferralEnabled); 172 DCHECK(m_isDeferralEnabled);
173 m_recorder = WTF::wrapUnique(new SkPictureRecorder); 173 m_recorder = WTF::wrapUnique(new PaintRecorder);
174 SkCanvas* canvas = 174 PaintCanvas* canvas =
175 m_recorder->beginRecording(m_size.width(), m_size.height(), nullptr); 175 m_recorder->beginRecording(m_size.width(), m_size.height(), nullptr);
176 // Always save an initial frame, to support resetting the top level matrix 176 // Always save an initial frame, to support resetting the top level matrix
177 // and clip. 177 // and clip.
178 canvas->save(); 178 canvas->save();
179 179
180 if (m_imageBuffer) { 180 if (m_imageBuffer) {
181 m_imageBuffer->resetCanvas(canvas); 181 m_imageBuffer->resetCanvas(canvas);
182 } 182 }
183 m_recordingPixelCount = 0; 183 m_recordingPixelCount = 0;
184 } 184 }
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 return; 490 return;
491 } 491 }
492 492
493 if (!isAccelerated()) { 493 if (!isAccelerated()) {
494 m_logger->reportHibernationEvent( 494 m_logger->reportHibernationEvent(
495 HibernationAbortedDueToSwitchToUnacceleratedRendering); 495 HibernationAbortedDueToSwitchToUnacceleratedRendering);
496 return; 496 return;
497 } 497 }
498 498
499 TRACE_EVENT0("cc", "Canvas2DLayerBridge::hibernate"); 499 TRACE_EVENT0("cc", "Canvas2DLayerBridge::hibernate");
500 sk_sp<SkSurface> tempHibernationSurface = 500 sk_sp<PaintSurface> tempHibernationSurface =
501 SkSurface::MakeRasterN32Premul(m_size.width(), m_size.height()); 501 PaintSurface::MakeRasterN32Premul(m_size.width(), m_size.height());
502 if (!tempHibernationSurface) { 502 if (!tempHibernationSurface) {
503 m_logger->reportHibernationEvent(HibernationAbortedDueToAllocationFailure); 503 m_logger->reportHibernationEvent(HibernationAbortedDueToAllocationFailure);
504 return; 504 return;
505 } 505 }
506 // No HibernationEvent reported on success. This is on purppose to avoid 506 // No HibernationEvent reported on success. This is on purppose to avoid
507 // non-complementary stats. Each HibernationScheduled event is paired with 507 // non-complementary stats. Each HibernationScheduled event is paired with
508 // exactly one failure or exit event. 508 // exactly one failure or exit event.
509 flushRecordingOnly(); 509 flushRecordingOnly();
510 // The following checks that the flush succeeded, which should always be the 510 // The following checks that the flush succeeded, which should always be the
511 // case because flushRecordingOnly should only fail it it fails to allocate 511 // case because flushRecordingOnly should only fail it it fails to allocate
512 // a surface, and we have an early exit at the top of this function for when 512 // a surface, and we have an early exit at the top of this function for when
513 // 'this' does not already have a surface. 513 // 'this' does not already have a surface.
514 DCHECK(!m_haveRecordedDrawCommands); 514 DCHECK(!m_haveRecordedDrawCommands);
515 SkPaint copyPaint; 515 PaintFlags copyPaint;
516 copyPaint.setBlendMode(SkBlendMode::kSrc); 516 copyPaint.setBlendMode(SkBlendMode::kSrc);
517 m_surface->draw(tempHibernationSurface->getCanvas(), 0, 0, 517 m_surface->draw(tempHibernationSurface->getCanvas(), 0, 0,
518 &copyPaint); // GPU readback 518 &copyPaint); // GPU readback
519 m_hibernationImage = tempHibernationSurface->makeImageSnapshot(); 519 m_hibernationImage = tempHibernationSurface->makeImageSnapshot();
520 m_surface.reset(); // destroy the GPU-backed buffer 520 m_surface.reset(); // destroy the GPU-backed buffer
521 m_layer->clearTexture(); 521 m_layer->clearTexture();
522 #if USE_IOSURFACE_FOR_2D_CANVAS 522 #if USE_IOSURFACE_FOR_2D_CANVAS
523 clearCHROMIUMImageCache(); 523 clearCHROMIUMImageCache();
524 #endif // USE_IOSURFACE_FOR_2D_CANVAS 524 #endif // USE_IOSURFACE_FOR_2D_CANVAS
525 m_logger->didStartHibernating(); 525 m_logger->didStartHibernating();
526 } 526 }
527 527
528 void Canvas2DLayerBridge::reportSurfaceCreationFailure() { 528 void Canvas2DLayerBridge::reportSurfaceCreationFailure() {
529 if (!m_surfaceCreationFailedAtLeastOnce) { 529 if (!m_surfaceCreationFailedAtLeastOnce) {
530 // Only count the failure once per instance so that the histogram may 530 // Only count the failure once per instance so that the histogram may
531 // reflect the proportion of Canvas2DLayerBridge instances with surface 531 // reflect the proportion of Canvas2DLayerBridge instances with surface
532 // allocation failures. 532 // allocation failures.
533 CanvasMetrics::countCanvasContextUsage( 533 CanvasMetrics::countCanvasContextUsage(
534 CanvasMetrics::GPUAccelerated2DCanvasSurfaceCreationFailed); 534 CanvasMetrics::GPUAccelerated2DCanvasSurfaceCreationFailed);
535 m_surfaceCreationFailedAtLeastOnce = true; 535 m_surfaceCreationFailedAtLeastOnce = true;
536 } 536 }
537 } 537 }
538 538
539 SkSurface* Canvas2DLayerBridge::getOrCreateSurface(AccelerationHint hint) { 539 PaintSurface* Canvas2DLayerBridge::getOrCreateSurface(AccelerationHint hint) {
540 if (m_surface) 540 if (m_surface)
541 return m_surface.get(); 541 return m_surface.get();
542 542
543 if (m_layer && !isHibernating() && hint == PreferAcceleration && 543 if (m_layer && !isHibernating() && hint == PreferAcceleration &&
544 m_accelerationMode != DisableAcceleration) { 544 m_accelerationMode != DisableAcceleration) {
545 return nullptr; // re-creation will happen through restore() 545 return nullptr; // re-creation will happen through restore()
546 } 546 }
547 547
548 bool wantAcceleration = shouldAccelerate(hint); 548 bool wantAcceleration = shouldAccelerate(hint);
549 if (CANVAS2D_BACKGROUND_RENDER_SWITCH_TO_CPU && isHidden() && 549 if (CANVAS2D_BACKGROUND_RENDER_SWITCH_TO_CPU && isHidden() &&
(...skipping 30 matching lines...) Expand all
580 if (surfaceIsAccelerated) { 580 if (surfaceIsAccelerated) {
581 m_logger->reportHibernationEvent(HibernationEndedNormally); 581 m_logger->reportHibernationEvent(HibernationEndedNormally);
582 } else { 582 } else {
583 if (isHidden()) 583 if (isHidden())
584 m_logger->reportHibernationEvent( 584 m_logger->reportHibernationEvent(
585 HibernationEndedWithSwitchToBackgroundRendering); 585 HibernationEndedWithSwitchToBackgroundRendering);
586 else 586 else
587 m_logger->reportHibernationEvent(HibernationEndedWithFallbackToSW); 587 m_logger->reportHibernationEvent(HibernationEndedWithFallbackToSW);
588 } 588 }
589 589
590 SkPaint copyPaint; 590 PaintFlags copyPaint;
591 copyPaint.setBlendMode(SkBlendMode::kSrc); 591 copyPaint.setBlendMode(SkBlendMode::kSrc);
592 m_surface->getCanvas()->drawImage(m_hibernationImage.get(), 0, 0, 592 m_surface->getCanvas()->drawImage(m_hibernationImage.get(), 0, 0,
593 &copyPaint); 593 &copyPaint);
594 m_hibernationImage.reset(); 594 m_hibernationImage.reset();
595 595
596 if (m_imageBuffer) 596 if (m_imageBuffer)
597 m_imageBuffer->updateGPUMemoryUsage(); 597 m_imageBuffer->updateGPUMemoryUsage();
598 598
599 if (m_imageBuffer && !m_isDeferralEnabled) 599 if (m_imageBuffer && !m_isDeferralEnabled)
600 m_imageBuffer->resetCanvas(m_surface->getCanvas()); 600 m_imageBuffer->resetCanvas(m_surface->getCanvas());
601 } 601 }
602 602
603 return m_surface.get(); 603 return m_surface.get();
604 } 604 }
605 605
606 SkCanvas* Canvas2DLayerBridge::canvas() { 606 PaintCanvas* Canvas2DLayerBridge::canvas() {
607 if (!m_isDeferralEnabled) { 607 if (!m_isDeferralEnabled) {
608 SkSurface* s = getOrCreateSurface(); 608 PaintSurface* s = getOrCreateSurface();
609 return s ? s->getCanvas() : nullptr; 609 return s ? s->getCanvas() : nullptr;
610 } 610 }
611 return m_recorder->getRecordingCanvas(); 611 return m_recorder->getRecordingCanvas();
612 } 612 }
613 613
614 void Canvas2DLayerBridge::disableDeferral(DisableDeferralReason reason) { 614 void Canvas2DLayerBridge::disableDeferral(DisableDeferralReason reason) {
615 // Disabling deferral is permanent: once triggered by disableDeferral() 615 // Disabling deferral is permanent: once triggered by disableDeferral()
616 // we stay in immediate mode indefinitely. This is a performance heuristic 616 // we stay in immediate mode indefinitely. This is a performance heuristic
617 // that significantly helps a number of use cases. The rationale is that if 617 // that significantly helps a number of use cases. The rationale is that if
618 // immediate rendering was needed once, it is likely to be needed at least 618 // immediate rendering was needed once, it is likely to be needed at least
(...skipping 12 matching lines...) Expand all
631 CanvasMetrics::countCanvasContextUsage( 631 CanvasMetrics::countCanvasContextUsage(
632 CanvasMetrics::GPUAccelerated2DCanvasDeferralDisabled); 632 CanvasMetrics::GPUAccelerated2DCanvasDeferralDisabled);
633 flushRecordingOnly(); 633 flushRecordingOnly();
634 // Because we will be discarding the recorder, if the flush failed 634 // Because we will be discarding the recorder, if the flush failed
635 // content will be lost -> force m_haveRecordedDrawCommands to false 635 // content will be lost -> force m_haveRecordedDrawCommands to false
636 m_haveRecordedDrawCommands = false; 636 m_haveRecordedDrawCommands = false;
637 637
638 m_isDeferralEnabled = false; 638 m_isDeferralEnabled = false;
639 m_recorder.reset(); 639 m_recorder.reset();
640 // install the current matrix/clip stack onto the immediate canvas 640 // install the current matrix/clip stack onto the immediate canvas
641 SkSurface* surface = getOrCreateSurface(); 641 PaintSurface* surface = getOrCreateSurface();
642 if (m_imageBuffer && surface) 642 if (m_imageBuffer && surface)
643 m_imageBuffer->resetCanvas(surface->getCanvas()); 643 m_imageBuffer->resetCanvas(surface->getCanvas());
644 } 644 }
645 645
646 void Canvas2DLayerBridge::setImageBuffer(ImageBuffer* imageBuffer) { 646 void Canvas2DLayerBridge::setImageBuffer(ImageBuffer* imageBuffer) {
647 m_imageBuffer = imageBuffer; 647 m_imageBuffer = imageBuffer;
648 if (m_imageBuffer && m_isDeferralEnabled) { 648 if (m_imageBuffer && m_isDeferralEnabled) {
649 m_imageBuffer->resetCanvas(m_recorder->getRecordingCanvas()); 649 m_imageBuffer->resetCanvas(m_recorder->getRecordingCanvas());
650 } 650 }
651 } 651 }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
707 BLINK_FROM_HERE, WTF::bind(&hibernateWrapperForTesting, 707 BLINK_FROM_HERE, WTF::bind(&hibernateWrapperForTesting,
708 m_weakPtrFactory.createWeakPtr())); 708 m_weakPtrFactory.createWeakPtr()));
709 } else { 709 } else {
710 Platform::current()->currentThread()->scheduler()->postIdleTask( 710 Platform::current()->currentThread()->scheduler()->postIdleTask(
711 BLINK_FROM_HERE, 711 BLINK_FROM_HERE,
712 WTF::bind(&hibernateWrapper, m_weakPtrFactory.createWeakPtr())); 712 WTF::bind(&hibernateWrapper, m_weakPtrFactory.createWeakPtr()));
713 } 713 }
714 } 714 }
715 if (!isHidden() && m_softwareRenderingWhileHidden) { 715 if (!isHidden() && m_softwareRenderingWhileHidden) {
716 flushRecordingOnly(); 716 flushRecordingOnly();
717 SkPaint copyPaint; 717 PaintFlags copyPaint;
718 copyPaint.setBlendMode(SkBlendMode::kSrc); 718 copyPaint.setBlendMode(SkBlendMode::kSrc);
719 719
720 sk_sp<SkSurface> oldSurface = std::move(m_surface); 720 sk_sp<PaintSurface> oldSurface = std::move(m_surface);
721 m_surface.reset(); 721 m_surface.reset();
722 722
723 m_softwareRenderingWhileHidden = false; 723 m_softwareRenderingWhileHidden = false;
724 SkSurface* newSurface = 724 PaintSurface* newSurface =
725 getOrCreateSurface(PreferAccelerationAfterVisibilityChange); 725 getOrCreateSurface(PreferAccelerationAfterVisibilityChange);
726 if (newSurface) { 726 if (newSurface) {
727 if (oldSurface) 727 if (oldSurface)
728 oldSurface->draw(newSurface->getCanvas(), 0, 0, &copyPaint); 728 oldSurface->draw(newSurface->getCanvas(), 0, 0, &copyPaint);
729 if (m_imageBuffer && !m_isDeferralEnabled) { 729 if (m_imageBuffer && !m_isDeferralEnabled) {
730 m_imageBuffer->resetCanvas(m_surface->getCanvas()); 730 m_imageBuffer->resetCanvas(m_surface->getCanvas());
731 } 731 }
732 } 732 }
733 } 733 }
734 if (!isHidden() && isHibernating()) { 734 if (!isHidden() && isHibernating()) {
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
853 gpu::gles2::GLES2Interface* sharedGL = nullptr; 853 gpu::gles2::GLES2Interface* sharedGL = nullptr;
854 m_layer->clearTexture(); 854 m_layer->clearTexture();
855 m_contextProvider = WTF::wrapUnique( 855 m_contextProvider = WTF::wrapUnique(
856 Platform::current()->createSharedOffscreenGraphicsContext3DProvider()); 856 Platform::current()->createSharedOffscreenGraphicsContext3DProvider());
857 if (m_contextProvider) 857 if (m_contextProvider)
858 sharedGL = m_contextProvider->contextGL(); 858 sharedGL = m_contextProvider->contextGL();
859 859
860 if (sharedGL && sharedGL->GetGraphicsResetStatusKHR() == GL_NO_ERROR) { 860 if (sharedGL && sharedGL->GetGraphicsResetStatusKHR() == GL_NO_ERROR) {
861 GrContext* grCtx = m_contextProvider->grContext(); 861 GrContext* grCtx = m_contextProvider->grContext();
862 bool surfaceIsAccelerated; 862 bool surfaceIsAccelerated;
863 sk_sp<SkSurface> surface( 863 sk_sp<PaintSurface> surface(
864 createSkSurface(grCtx, m_size, m_msaaSampleCount, m_opacityMode, 864 createSkSurface(grCtx, m_size, m_msaaSampleCount, m_opacityMode,
865 m_colorSpace, m_colorType, &surfaceIsAccelerated)); 865 m_colorSpace, m_colorType, &surfaceIsAccelerated));
866 866
867 if (!m_surface) 867 if (!m_surface)
868 reportSurfaceCreationFailure(); 868 reportSurfaceCreationFailure();
869 869
870 // The current paradigm does not support switching from accelerated to 870 // The current paradigm does not support switching from accelerated to
871 // 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,
872 // which can only happen at specific times during the document lifecycle. 872 // which can only happen at specific times during the document lifecycle.
873 // 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 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
1149 default; 1149 default;
1150 1150
1151 void Canvas2DLayerBridge::Logger::reportHibernationEvent( 1151 void Canvas2DLayerBridge::Logger::reportHibernationEvent(
1152 HibernationEvent event) { 1152 HibernationEvent event) {
1153 DEFINE_STATIC_LOCAL(EnumerationHistogram, hibernationHistogram, 1153 DEFINE_STATIC_LOCAL(EnumerationHistogram, hibernationHistogram,
1154 ("Canvas.HibernationEvents", HibernationEventCount)); 1154 ("Canvas.HibernationEvents", HibernationEventCount));
1155 hibernationHistogram.count(event); 1155 hibernationHistogram.count(event);
1156 } 1156 }
1157 1157
1158 } // namespace blink 1158 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698