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

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

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 #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 RecordingImageBufferSurfaceTest;
20 20
21 class RecordingImageBufferFallbackSurfaceFactory { 21 class RecordingImageBufferFallbackSurfaceFactory {
22 USING_FAST_MALLOC(RecordingImageBufferFallbackSurfaceFactory); 22 USING_FAST_MALLOC(RecordingImageBufferFallbackSurfaceFactory);
23 WTF_MAKE_NONCOPYABLE(RecordingImageBufferFallbackSurfaceFactory); 23 WTF_MAKE_NONCOPYABLE(RecordingImageBufferFallbackSurfaceFactory);
24 24
25 public: 25 public:
26 virtual std::unique_ptr<ImageBufferSurface> CreateSurface(const IntSize&, 26 virtual std::unique_ptr<ImageBufferSurface>
27 OpacityMode, 27 CreateSurface(const IntSize&, OpacityMode, const CanvasColorParams&) = 0;
28 sk_sp<SkColorSpace>,
29 SkColorType) = 0;
30 virtual ~RecordingImageBufferFallbackSurfaceFactory() {} 28 virtual ~RecordingImageBufferFallbackSurfaceFactory() {}
31 29
32 protected: 30 protected:
33 RecordingImageBufferFallbackSurfaceFactory() {} 31 RecordingImageBufferFallbackSurfaceFactory() {}
34 }; 32 };
35 33
36 class PLATFORM_EXPORT RecordingImageBufferSurface : public ImageBufferSurface { 34 class PLATFORM_EXPORT RecordingImageBufferSurface : public ImageBufferSurface {
37 WTF_MAKE_NONCOPYABLE(RecordingImageBufferSurface); 35 WTF_MAKE_NONCOPYABLE(RecordingImageBufferSurface);
38 USING_FAST_MALLOC(RecordingImageBufferSurface); 36 USING_FAST_MALLOC(RecordingImageBufferSurface);
39 37
40 public: 38 public:
41 // If the fallbackFactory is null the buffer surface should only be used 39 // If the fallbackFactory is null the buffer surface should only be used
42 // for one frame and should not be used for any operations which need a 40 // for one frame and should not be used for any operations which need a
43 // raster surface, (i.e. writePixels). 41 // raster surface, (i.e. writePixels).
44 // Only #getRecord should be used to access the resulting frame. 42 // Only #getRecord should be used to access the resulting frame.
45 RecordingImageBufferSurface( 43 RecordingImageBufferSurface(
46 const IntSize&, 44 const IntSize&,
47 std::unique_ptr<RecordingImageBufferFallbackSurfaceFactory> 45 std::unique_ptr<RecordingImageBufferFallbackSurfaceFactory>
48 fallback_factory = nullptr, 46 fallback_factory = nullptr,
49 OpacityMode = kNonOpaque, 47 OpacityMode = kNonOpaque,
50 sk_sp<SkColorSpace> = nullptr, 48 const CanvasColorParams& = CanvasColorParams());
51 SkColorType = kN32_SkColorType);
52 ~RecordingImageBufferSurface() override; 49 ~RecordingImageBufferSurface() override;
53 50
54 // Implementation of ImageBufferSurface interfaces 51 // Implementation of ImageBufferSurface interfaces
55 PaintCanvas* Canvas() override; 52 PaintCanvas* Canvas() override;
56 void DisableDeferral(DisableDeferralReason) override; 53 void DisableDeferral(DisableDeferralReason) override;
57 sk_sp<PaintRecord> GetRecord() override; 54 sk_sp<PaintRecord> GetRecord() override;
58 void Flush(FlushReason) override; 55 void Flush(FlushReason) override;
59 void DidDraw(const FloatRect&) override; 56 void DidDraw(const FloatRect&) override;
60 bool IsValid() const override { return true; } 57 bool IsValid() const override { return true; }
61 bool IsRecording() const override { return !fallback_surface_; } 58 bool IsRecording() const override { return !fallback_surface_; }
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 bool frame_was_cleared_; 132 bool frame_was_cleared_;
136 bool did_record_draw_commands_in_current_frame_; 133 bool did_record_draw_commands_in_current_frame_;
137 bool current_frame_has_expensive_op_; 134 bool current_frame_has_expensive_op_;
138 bool previous_frame_has_expensive_op_; 135 bool previous_frame_has_expensive_op_;
139 std::unique_ptr<RecordingImageBufferFallbackSurfaceFactory> fallback_factory_; 136 std::unique_ptr<RecordingImageBufferFallbackSurfaceFactory> fallback_factory_;
140 }; 137 };
141 138
142 } // namespace blink 139 } // namespace blink
143 140
144 #endif 141 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698