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

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

Issue 2833593002: Remove unneeded abstractions and simplify RecordingImageBufferSurface (Closed)
Patch Set: imagebuffersurface-cleanups: morefixcompile 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 #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 RecordingImageBufferSurfaceTest; 19 class UnacceleratedImageBufferSurface;
20
21 class RecordingImageBufferFallbackSurfaceFactory {
22 USING_FAST_MALLOC(RecordingImageBufferFallbackSurfaceFactory);
23 WTF_MAKE_NONCOPYABLE(RecordingImageBufferFallbackSurfaceFactory);
24
25 public:
26 virtual std::unique_ptr<ImageBufferSurface>
27 CreateSurface(const IntSize&, OpacityMode, const CanvasColorParams&) = 0;
28 virtual ~RecordingImageBufferFallbackSurfaceFactory() {}
29
30 protected:
31 RecordingImageBufferFallbackSurfaceFactory() {}
32 };
33 20
34 class PLATFORM_EXPORT RecordingImageBufferSurface : public ImageBufferSurface { 21 class PLATFORM_EXPORT RecordingImageBufferSurface : public ImageBufferSurface {
35 WTF_MAKE_NONCOPYABLE(RecordingImageBufferSurface); 22 WTF_MAKE_NONCOPYABLE(RecordingImageBufferSurface);
36 USING_FAST_MALLOC(RecordingImageBufferSurface); 23 USING_FAST_MALLOC(RecordingImageBufferSurface);
37 24
38 public: 25 public:
39 // If the fallbackFactory is null the buffer surface should only be used 26 // If the fallbackFactory is null the buffer surface should only be used
40 // for one frame and should not be used for any operations which need a 27 // for one frame and should not be used for any operations which need a
41 // raster surface, (i.e. writePixels). 28 // raster surface, (i.e. writePixels).
42 // Only #getRecord should be used to access the resulting frame. 29 // Only #getRecord should be used to access the resulting frame.
43 RecordingImageBufferSurface( 30 RecordingImageBufferSurface(
44 const IntSize&, 31 const IntSize&,
45 std::unique_ptr<RecordingImageBufferFallbackSurfaceFactory>
46 fallback_factory = nullptr,
47 OpacityMode = kNonOpaque, 32 OpacityMode = kNonOpaque,
48 const CanvasColorParams& = CanvasColorParams()); 33 const CanvasColorParams& = CanvasColorParams());
49 ~RecordingImageBufferSurface() override; 34 ~RecordingImageBufferSurface() override;
50 35
51 // Implementation of ImageBufferSurface interfaces 36 // Implementation of ImageBufferSurface interfaces
52 PaintCanvas* Canvas() override; 37 PaintCanvas* Canvas() override;
53 void DisableDeferral(DisableDeferralReason) override; 38 void DisableDeferral(DisableDeferralReason) override;
54 sk_sp<PaintRecord> GetRecord() override; 39 sk_sp<PaintRecord> GetRecord() override;
55 void Flush(FlushReason) override; 40 void Flush(FlushReason) override;
56 void DidDraw(const FloatRect&) override; 41 void DidDraw(const FloatRect&) override;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 kFallbackReasonSnapshotForWebGLTexImage2D = 24, 94 kFallbackReasonSnapshotForWebGLTexImage2D = 24,
110 kFallbackReasonSnapshotForWebGLTexSubImage2D = 25, 95 kFallbackReasonSnapshotForWebGLTexSubImage2D = 25,
111 kFallbackReasonSnapshotForWebGLTexImage3D = 26, 96 kFallbackReasonSnapshotForWebGLTexImage3D = 26,
112 kFallbackReasonSnapshotForWebGLTexSubImage3D = 27, 97 kFallbackReasonSnapshotForWebGLTexSubImage3D = 27,
113 kFallbackReasonSnapshotForCopyToClipboard = 28, 98 kFallbackReasonSnapshotForCopyToClipboard = 28,
114 kFallbackReasonSnapshotForCreateImageBitmap = 29, 99 kFallbackReasonSnapshotForCreateImageBitmap = 29,
115 kFallbackReasonCount, 100 kFallbackReasonCount,
116 }; 101 };
117 102
118 private: 103 private:
119 friend class RecordingImageBufferSurfaceTest; // for unit testing
120 void FallBackToRasterCanvas(FallbackReason); 104 void FallBackToRasterCanvas(FallbackReason);
121 void InitializeCurrentFrame(); 105 void InitializeCurrentFrame();
122 bool FinalizeFrameInternal(FallbackReason*); 106 bool FinalizeFrameInternal(FallbackReason*);
123 int ApproximateOpCount(); 107 int ApproximateOpCount();
124 108
125 std::unique_ptr<PaintRecorder> current_frame_; 109 std::unique_ptr<PaintRecorder> current_frame_;
126 sk_sp<PaintRecord> previous_frame_; 110 sk_sp<PaintRecord> previous_frame_;
127 std::unique_ptr<ImageBufferSurface> fallback_surface_; 111 std::unique_ptr<UnacceleratedImageBufferSurface> fallback_surface_;
128 ImageBuffer* image_buffer_; 112 ImageBuffer* image_buffer_;
129 int initial_save_count_; 113 int initial_save_count_;
130 int current_frame_pixel_count_; 114 int current_frame_pixel_count_;
131 int previous_frame_pixel_count_; 115 int previous_frame_pixel_count_;
132 bool frame_was_cleared_; 116 bool frame_was_cleared_;
133 bool did_record_draw_commands_in_current_frame_; 117 bool did_record_draw_commands_in_current_frame_;
134 bool current_frame_has_expensive_op_; 118 bool current_frame_has_expensive_op_;
135 bool previous_frame_has_expensive_op_; 119 bool previous_frame_has_expensive_op_;
136 std::unique_ptr<RecordingImageBufferFallbackSurfaceFactory> fallback_factory_;
137 }; 120 };
138 121
139 } // namespace blink 122 } // namespace blink
140 123
141 #endif 124 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698