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

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

Issue 2825183002: Plumb CanvasColorParams to canvas image classes (Closed)
Patch Set: Require both runtime flags Created 3 years, 8 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 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "platform/graphics/RecordingImageBufferSurface.h" 5 #include "platform/graphics/RecordingImageBufferSurface.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include "platform/Histogram.h" 8 #include "platform/Histogram.h"
9 #include "platform/graphics/CanvasMetrics.h" 9 #include "platform/graphics/CanvasMetrics.h"
10 #include "platform/graphics/ExpensiveCanvasHeuristicParameters.h" 10 #include "platform/graphics/ExpensiveCanvasHeuristicParameters.h"
11 #include "platform/graphics/GraphicsContext.h" 11 #include "platform/graphics/GraphicsContext.h"
12 #include "platform/graphics/ImageBuffer.h" 12 #include "platform/graphics/ImageBuffer.h"
13 #include "platform/graphics/paint/PaintRecorder.h" 13 #include "platform/graphics/paint/PaintRecorder.h"
14 #include "platform/wtf/PassRefPtr.h" 14 #include "platform/wtf/PassRefPtr.h"
15 #include "platform/wtf/PtrUtil.h" 15 #include "platform/wtf/PtrUtil.h"
16 16
17 namespace blink { 17 namespace blink {
18 18
19 RecordingImageBufferSurface::RecordingImageBufferSurface( 19 RecordingImageBufferSurface::RecordingImageBufferSurface(
20 const IntSize& size, 20 const IntSize& size,
21 std::unique_ptr<RecordingImageBufferFallbackSurfaceFactory> 21 std::unique_ptr<RecordingImageBufferFallbackSurfaceFactory>
22 fallback_factory, 22 fallback_factory,
23 OpacityMode opacity_mode, 23 OpacityMode opacity_mode,
24 sk_sp<SkColorSpace> color_space, 24 const CanvasColorParams& color_params)
25 SkColorType color_type) 25 : ImageBufferSurface(size, opacity_mode, color_params),
26 : ImageBufferSurface(size,
27 opacity_mode,
28 std::move(color_space),
29 color_type),
30 image_buffer_(0), 26 image_buffer_(0),
31 current_frame_pixel_count_(0), 27 current_frame_pixel_count_(0),
32 previous_frame_pixel_count_(0), 28 previous_frame_pixel_count_(0),
33 frame_was_cleared_(true), 29 frame_was_cleared_(true),
34 did_record_draw_commands_in_current_frame_(false), 30 did_record_draw_commands_in_current_frame_(false),
35 current_frame_has_expensive_op_(false), 31 current_frame_has_expensive_op_(false),
36 previous_frame_has_expensive_op_(false), 32 previous_frame_has_expensive_op_(false),
37 fallback_factory_(std::move(fallback_factory)) { 33 fallback_factory_(std::move(fallback_factory)) {
38 InitializeCurrentFrame(); 34 InitializeCurrentFrame();
39 } 35 }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 DCHECK(!current_frame_); 86 DCHECK(!current_frame_);
91 return; 87 return;
92 } 88 }
93 89
94 DEFINE_THREAD_SAFE_STATIC_LOCAL( 90 DEFINE_THREAD_SAFE_STATIC_LOCAL(
95 EnumerationHistogram, canvas_fallback_histogram, 91 EnumerationHistogram, canvas_fallback_histogram,
96 new EnumerationHistogram("Canvas.DisplayListFallbackReason", 92 new EnumerationHistogram("Canvas.DisplayListFallbackReason",
97 kFallbackReasonCount)); 93 kFallbackReasonCount));
98 canvas_fallback_histogram.Count(reason); 94 canvas_fallback_histogram.Count(reason);
99 95
100 fallback_surface_ = fallback_factory_->CreateSurface( 96 fallback_surface_ = fallback_factory_->CreateSurface(size(), GetOpacityMode(),
101 size(), GetOpacityMode(), ColorSpace(), ColorType()); 97 color_params());
102 fallback_surface_->SetImageBuffer(image_buffer_); 98 fallback_surface_->SetImageBuffer(image_buffer_);
103 99
104 if (previous_frame_) { 100 if (previous_frame_) {
105 fallback_surface_->Canvas()->PlaybackPaintRecord(previous_frame_); 101 fallback_surface_->Canvas()->PlaybackPaintRecord(previous_frame_);
106 previous_frame_.reset(); 102 previous_frame_.reset();
107 } 103 }
108 104
109 if (current_frame_) { 105 if (current_frame_) {
110 sk_sp<PaintRecord> record = current_frame_->finishRecordingAsPicture(); 106 sk_sp<PaintRecord> record = current_frame_->finishRecordingAsPicture();
111 if (record) 107 if (record)
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 } 406 }
411 407
412 void RecordingImageBufferSurface::SetIsHidden(bool hidden) { 408 void RecordingImageBufferSurface::SetIsHidden(bool hidden) {
413 if (fallback_surface_) 409 if (fallback_surface_)
414 fallback_surface_->SetIsHidden(hidden); 410 fallback_surface_->SetIsHidden(hidden);
415 else 411 else
416 ImageBufferSurface::SetIsHidden(hidden); 412 ImageBufferSurface::SetIsHidden(hidden);
417 } 413 }
418 414
419 } // namespace blink 415 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698