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

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

Issue 2840093002: Allow RecordingImageBufferSurface to prevent fallback. (Closed)
Patch Set: imagebuffer-fallback: missedone Created 3 years, 7 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 #ifndef RecordingImageBufferSurface_h 5 #ifndef RecordingImageBufferSurface_h
6 #define RecordingImageBufferSurface_h 6 #define RecordingImageBufferSurface_h
7 7
8 #include <memory> 8 #include <memory>
9 #include "platform/graphics/GraphicsContext.h" 9 #include "platform/graphics/GraphicsContext.h"
10 #include "platform/graphics/ImageBufferSurface.h" 10 #include "platform/graphics/ImageBufferSurface.h"
11 #include "platform/wtf/Allocator.h" 11 #include "platform/wtf/Allocator.h"
12 #include "platform/wtf/Noncopyable.h" 12 #include "platform/wtf/Noncopyable.h"
13 #include "public/platform/WebThread.h" 13 #include "public/platform/WebThread.h"
14 #include "third_party/skia/include/core/SkRefCnt.h" 14 #include "third_party/skia/include/core/SkRefCnt.h"
15 15
16 namespace blink { 16 namespace blink {
17 17
18 class ImageBuffer; 18 class ImageBuffer;
19 class UnacceleratedImageBufferSurface; 19 class UnacceleratedImageBufferSurface;
20 20
21 class PLATFORM_EXPORT RecordingImageBufferSurface : public ImageBufferSurface { 21 class PLATFORM_EXPORT RecordingImageBufferSurface : public ImageBufferSurface {
22 WTF_MAKE_NONCOPYABLE(RecordingImageBufferSurface); 22 WTF_MAKE_NONCOPYABLE(RecordingImageBufferSurface);
23 USING_FAST_MALLOC(RecordingImageBufferSurface); 23 USING_FAST_MALLOC(RecordingImageBufferSurface);
24 24
25 public: 25 public:
26 // If the fallbackFactory is null the buffer surface should only be used 26 enum AllowFallback : bool { kDisallowFallback, kAllowFallback };
27 // for one frame and should not be used for any operations which need a 27
28 // raster surface, (i.e. writePixels). 28 // If |AllowFallback| is kDisallowFallback the buffer surface should only be
29 // Only #getRecord should be used to access the resulting frame. 29 // used for one frame and should not be used for any operations which need a
30 RecordingImageBufferSurface( 30 // raster surface, (i.e. WritePixels()).
31 const IntSize&, 31 // Only GetRecord() should be used to access the resulting frame.
32 OpacityMode = kNonOpaque, 32 RecordingImageBufferSurface(const IntSize&,
33 const CanvasColorParams& = CanvasColorParams()); 33 AllowFallback,
34 OpacityMode = kNonOpaque,
35 const CanvasColorParams& = CanvasColorParams());
34 ~RecordingImageBufferSurface() override; 36 ~RecordingImageBufferSurface() override;
35 37
36 // Implementation of ImageBufferSurface interfaces 38 // Implementation of ImageBufferSurface interfaces
37 PaintCanvas* Canvas() override; 39 PaintCanvas* Canvas() override;
38 void DisableDeferral(DisableDeferralReason) override; 40 void DisableDeferral(DisableDeferralReason) override;
39 sk_sp<PaintRecord> GetRecord() override; 41 sk_sp<PaintRecord> GetRecord() override;
40 void Flush(FlushReason) override; 42 void Flush(FlushReason) override;
41 void DidDraw(const FloatRect&) override; 43 void DidDraw(const FloatRect&) override;
42 bool IsValid() const override { return true; } 44 bool IsValid() const override { return true; }
43 bool IsRecording() const override { return !fallback_surface_; } 45 bool IsRecording() const override { return !fallback_surface_; }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 kFallbackReasonSnapshotForCreateImageBitmap = 29, 101 kFallbackReasonSnapshotForCreateImageBitmap = 29,
100 kFallbackReasonCount, 102 kFallbackReasonCount,
101 }; 103 };
102 104
103 private: 105 private:
104 void FallBackToRasterCanvas(FallbackReason); 106 void FallBackToRasterCanvas(FallbackReason);
105 void InitializeCurrentFrame(); 107 void InitializeCurrentFrame();
106 bool FinalizeFrameInternal(FallbackReason*); 108 bool FinalizeFrameInternal(FallbackReason*);
107 int ApproximateOpCount(); 109 int ApproximateOpCount();
108 110
111 const AllowFallback allow_fallback_;
109 std::unique_ptr<PaintRecorder> current_frame_; 112 std::unique_ptr<PaintRecorder> current_frame_;
110 sk_sp<PaintRecord> previous_frame_; 113 sk_sp<PaintRecord> previous_frame_;
111 std::unique_ptr<UnacceleratedImageBufferSurface> fallback_surface_; 114 std::unique_ptr<UnacceleratedImageBufferSurface> fallback_surface_;
112 ImageBuffer* image_buffer_; 115 ImageBuffer* image_buffer_;
113 int initial_save_count_; 116 int initial_save_count_;
114 int current_frame_pixel_count_; 117 int current_frame_pixel_count_;
115 int previous_frame_pixel_count_; 118 int previous_frame_pixel_count_;
116 bool frame_was_cleared_; 119 bool frame_was_cleared_;
117 bool did_record_draw_commands_in_current_frame_; 120 bool did_record_draw_commands_in_current_frame_;
118 bool current_frame_has_expensive_op_; 121 bool current_frame_has_expensive_op_;
119 bool previous_frame_has_expensive_op_; 122 bool previous_frame_has_expensive_op_;
120 }; 123 };
121 124
122 } // namespace blink 125 } // namespace blink
123 126
124 #endif 127 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698