| 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 30 matching lines...) Expand all Loading... |
| 41 #include "platform/graphics/gpu/SharedContextRateLimiter.h" | 41 #include "platform/graphics/gpu/SharedContextRateLimiter.h" |
| 42 #include "platform/graphics/paint/PaintCanvas.h" | 42 #include "platform/graphics/paint/PaintCanvas.h" |
| 43 #include "platform/instrumentation/tracing/TraceEvent.h" | 43 #include "platform/instrumentation/tracing/TraceEvent.h" |
| 44 #include "platform/wtf/PtrUtil.h" | 44 #include "platform/wtf/PtrUtil.h" |
| 45 #include "public/platform/Platform.h" | 45 #include "public/platform/Platform.h" |
| 46 #include "public/platform/WebCompositorSupport.h" | 46 #include "public/platform/WebCompositorSupport.h" |
| 47 #include "public/platform/WebGraphicsContext3DProvider.h" | 47 #include "public/platform/WebGraphicsContext3DProvider.h" |
| 48 #include "public/platform/WebScheduler.h" | 48 #include "public/platform/WebScheduler.h" |
| 49 #include "public/platform/WebTraceLocation.h" | 49 #include "public/platform/WebTraceLocation.h" |
| 50 #include "skia/ext/texture_handle.h" | 50 #include "skia/ext/texture_handle.h" |
| 51 #include "third_party/skia/include/core/SkColorSpaceXformCanvas.h" |
| 51 #include "third_party/skia/include/core/SkData.h" | 52 #include "third_party/skia/include/core/SkData.h" |
| 52 #include "third_party/skia/include/core/SkSurface.h" | 53 #include "third_party/skia/include/core/SkSurface.h" |
| 53 #include "third_party/skia/include/gpu/GrContext.h" | 54 #include "third_party/skia/include/gpu/GrContext.h" |
| 54 #include "third_party/skia/include/gpu/GrTexture.h" | 55 #include "third_party/skia/include/gpu/GrTexture.h" |
| 55 #include "third_party/skia/include/gpu/gl/GrGLTypes.h" | 56 #include "third_party/skia/include/gpu/gl/GrGLTypes.h" |
| 56 | 57 |
| 57 namespace { | 58 namespace { |
| 58 enum { | 59 enum { |
| 59 InvalidMailboxIndex = -1, | 60 InvalidMailboxIndex = -1, |
| 60 MaxCanvasAnimationBacklog = 2, // Make sure the the GPU is never more than | 61 MaxCanvasAnimationBacklog = 2, // Make sure the the GPU is never more than |
| (...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 772 if (rate_limiter_) | 773 if (rate_limiter_) |
| 773 rate_limiter_->Reset(); | 774 rate_limiter_->Reset(); |
| 774 } | 775 } |
| 775 } | 776 } |
| 776 | 777 |
| 777 void Canvas2DLayerBridge::FlushRecordingOnly() { | 778 void Canvas2DLayerBridge::FlushRecordingOnly() { |
| 778 DCHECK(!destruction_in_progress_); | 779 DCHECK(!destruction_in_progress_); |
| 779 | 780 |
| 780 if (have_recorded_draw_commands_ && GetOrCreateSurface()) { | 781 if (have_recorded_draw_commands_ && GetOrCreateSurface()) { |
| 781 TRACE_EVENT0("cc", "Canvas2DLayerBridge::flushRecordingOnly"); | 782 TRACE_EVENT0("cc", "Canvas2DLayerBridge::flushRecordingOnly"); |
| 782 recorder_->finishRecordingAsPicture()->playback( | 783 |
| 783 GetOrCreateSurface()->getCanvas()); | 784 // For legacy canvases, transform all input colors and images to the target |
| 785 // space using a SkCreateColorSpaceXformCanvas. This ensures blending will |
| 786 // be done using target space pixel values. |
| 787 SkCanvas* canvas = GetOrCreateSurface()->getCanvas(); |
| 788 std::unique_ptr<SkCanvas> color_transform_canvas; |
| 789 if (RuntimeEnabledFeatures::colorCorrectRenderingEnabled() && |
| 790 !sk_surfaces_use_color_space_) { |
| 791 color_transform_canvas = |
| 792 SkCreateColorSpaceXformCanvas(canvas, color_space_.ToSkColorSpace()); |
| 793 canvas = color_transform_canvas.get(); |
| 794 } |
| 795 |
| 796 recorder_->finishRecordingAsPicture()->playback(canvas); |
| 784 if (is_deferral_enabled_) | 797 if (is_deferral_enabled_) |
| 785 StartRecording(); | 798 StartRecording(); |
| 786 have_recorded_draw_commands_ = false; | 799 have_recorded_draw_commands_ = false; |
| 787 } | 800 } |
| 788 } | 801 } |
| 789 | 802 |
| 790 void Canvas2DLayerBridge::Flush() { | 803 void Canvas2DLayerBridge::Flush() { |
| 791 if (!did_draw_since_last_flush_) | 804 if (!did_draw_since_last_flush_) |
| 792 return; | 805 return; |
| 793 TRACE_EVENT0("cc", "Canvas2DLayerBridge::flush"); | 806 TRACE_EVENT0("cc", "Canvas2DLayerBridge::flush"); |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1117 default; | 1130 default; |
| 1118 | 1131 |
| 1119 void Canvas2DLayerBridge::Logger::ReportHibernationEvent( | 1132 void Canvas2DLayerBridge::Logger::ReportHibernationEvent( |
| 1120 HibernationEvent event) { | 1133 HibernationEvent event) { |
| 1121 DEFINE_STATIC_LOCAL(EnumerationHistogram, hibernation_histogram, | 1134 DEFINE_STATIC_LOCAL(EnumerationHistogram, hibernation_histogram, |
| 1122 ("Canvas.HibernationEvents", kHibernationEventCount)); | 1135 ("Canvas.HibernationEvents", kHibernationEventCount)); |
| 1123 hibernation_histogram.Count(event); | 1136 hibernation_histogram.Count(event); |
| 1124 } | 1137 } |
| 1125 | 1138 |
| 1126 } // namespace blink | 1139 } // namespace blink |
| OLD | NEW |