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

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

Issue 659873002: Making display list canvases fall back to gpu-accelerated when appropriate (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: response to comments Created 6 years, 2 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 | Annotate | Revision Log
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 "platform/graphics/ImageBufferSurface.h" 8 #include "platform/graphics/ImageBufferSurface.h"
9 #include "public/platform/WebThread.h" 9 #include "public/platform/WebThread.h"
10 #include "third_party/skia/include/core/SkCanvas.h" 10 #include "third_party/skia/include/core/SkCanvas.h"
11 #include "wtf/LinkedStack.h" 11 #include "wtf/LinkedStack.h"
12 #include "wtf/OwnPtr.h" 12 #include "wtf/OwnPtr.h"
13 #include "wtf/RefPtr.h" 13 #include "wtf/RefPtr.h"
14 14
15 class SkPicture; 15 class SkPicture;
16 class SkPictureRecorder; 16 class SkPictureRecorder;
17 class RecordingImageBufferSurfaceTest; 17 class RecordingImageBufferSurfaceTest;
18 18
19 namespace blink { 19 namespace blink {
20 20
21 class ImageBuffer; 21 class ImageBuffer;
22 22
23 class RecordingImageBufferFallbackSurfaceFactory {
24 public:
25 virtual PassOwnPtr<ImageBufferSurface> createSurface(const IntSize&, Opacity Mode) = 0;
26 virtual ~RecordingImageBufferFallbackSurfaceFactory() { }
27 };
28
23 class PLATFORM_EXPORT RecordingImageBufferSurface : public ImageBufferSurface { 29 class PLATFORM_EXPORT RecordingImageBufferSurface : public ImageBufferSurface {
24 WTF_MAKE_NONCOPYABLE(RecordingImageBufferSurface); WTF_MAKE_FAST_ALLOCATED; 30 WTF_MAKE_NONCOPYABLE(RecordingImageBufferSurface); WTF_MAKE_FAST_ALLOCATED;
25 public: 31 public:
26 RecordingImageBufferSurface(const IntSize&, OpacityMode = NonOpaque); 32 RecordingImageBufferSurface(const IntSize&, PassOwnPtr<RecordingImageBufferF allbackSurfaceFactory> fallbackFactory, OpacityMode = NonOpaque);
27 virtual ~RecordingImageBufferSurface(); 33 virtual ~RecordingImageBufferSurface();
28 34
29 // Implementation of ImageBufferSurface interfaces 35 // Implementation of ImageBufferSurface interfaces
30 virtual SkCanvas* canvas() const override; 36 virtual SkCanvas* canvas() const override;
31 virtual PassRefPtr<SkPicture> getPicture() override; 37 virtual PassRefPtr<SkPicture> getPicture() override;
32 virtual bool isValid() const override { return true; } 38 virtual bool isValid() const override { return true; }
33 virtual void willAccessPixels() override; 39 virtual void willAccessPixels() override;
34 virtual void finalizeFrame(const FloatRect&) override; 40 virtual void finalizeFrame(const FloatRect&) override;
35 virtual void didClearCanvas() override; 41 virtual void didClearCanvas() override;
36 virtual void setImageBuffer(ImageBuffer*) override; 42 virtual void setImageBuffer(ImageBuffer*) override;
37 43
44 // Passthroughs to fallback surface
45 virtual const SkBitmap& bitmap() override;
46 virtual bool restore() override;
47 virtual WebLayer* layer() const override;
48 virtual bool isAccelerated() const override;
49 virtual Platform3DObject getBackingTexture() const override;
50 virtual bool cachedBitmapEnabled() const override;
51 virtual const SkBitmap& cachedBitmap() const override;
52 virtual void invalidateCachedBitmap() override;
53 virtual void updateCachedBitmapIfNeeded() override;
54 virtual void setIsHidden(bool) override;
55
38 private: 56 private:
39 struct StateRec { 57 struct StateRec {
40 public: 58 public:
41 SkMatrix m_ctm; 59 SkMatrix m_ctm;
42 // FIXME: handle transferring non-rectangular clip to the new frame, crb ug.com/392614 60 // FIXME: handle transferring non-rectangular clip to the new frame, crb ug.com/392614
43 SkIRect m_clip; 61 SkIRect m_clip;
44 }; 62 };
45 typedef LinkedStack<StateRec> StateStack; 63 typedef LinkedStack<StateRec> StateStack;
46 friend class ::RecordingImageBufferSurfaceTest; // for unit testing 64 friend class ::RecordingImageBufferSurfaceTest; // for unit testing
47 void fallBackToRasterCanvas(); 65 void fallBackToRasterCanvas();
48 bool initializeCurrentFrame(); 66 bool initializeCurrentFrame();
49 bool finalizeFrameInternal(); 67 bool finalizeFrameInternal();
50 68
51 // saves current clip and transform matrix of canvas 69 // saves current clip and transform matrix of canvas
52 bool saveState(SkCanvas*, StateStack*); 70 bool saveState(SkCanvas*, StateStack*);
53 // we should make sure that we can transfer state in saveState 71 // we should make sure that we can transfer state in saveState
54 void setCurrentState(SkCanvas*, StateStack*); 72 void setCurrentState(SkCanvas*, StateStack*);
55 73
56 OwnPtr<SkPictureRecorder> m_currentFrame; 74 OwnPtr<SkPictureRecorder> m_currentFrame;
57 RefPtr<SkPicture> m_previousFrame; 75 RefPtr<SkPicture> m_previousFrame;
58 OwnPtr<SkCanvas> m_rasterCanvas; 76 OwnPtr<ImageBufferSurface> m_fallbackSurface;
59 ImageBuffer* m_imageBuffer; 77 ImageBuffer* m_imageBuffer;
60 int m_initialSaveCount; 78 int m_initialSaveCount;
61 bool m_frameWasCleared; 79 bool m_frameWasCleared;
80 OwnPtr<RecordingImageBufferFallbackSurfaceFactory> m_fallbackFactory;
62 }; 81 };
63 82
64 } // namespace blink 83 } // namespace blink
65 84
66 #endif 85 #endif
OLDNEW
« no previous file with comments | « Source/core/html/HTMLCanvasElement.cpp ('k') | Source/platform/graphics/RecordingImageBufferSurface.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698