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

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

Issue 104023007: Refactoring ImageBuffer to decouple it from Canvas2DLayerBridge (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: mac+win build fix Created 7 years 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 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 13 matching lines...) Expand all
24 */ 24 */
25 25
26 #ifndef Canvas2DLayerBridge_h 26 #ifndef Canvas2DLayerBridge_h
27 #define Canvas2DLayerBridge_h 27 #define Canvas2DLayerBridge_h
28 28
29 #include "SkDeferredCanvas.h" 29 #include "SkDeferredCanvas.h"
30 #include "SkImage.h" 30 #include "SkImage.h"
31 #include "platform/PlatformExport.h" 31 #include "platform/PlatformExport.h"
32 #include "platform/geometry/IntSize.h" 32 #include "platform/geometry/IntSize.h"
33 #include "platform/graphics/GraphicsContext3D.h" 33 #include "platform/graphics/GraphicsContext3D.h"
34 #include "platform/graphics/ImageBufferSurface.h"
34 #include "public/platform/WebExternalTextureLayer.h" 35 #include "public/platform/WebExternalTextureLayer.h"
35 #include "public/platform/WebExternalTextureLayerClient.h" 36 #include "public/platform/WebExternalTextureLayerClient.h"
36 #include "public/platform/WebExternalTextureMailbox.h" 37 #include "public/platform/WebExternalTextureMailbox.h"
37 #include "wtf/DoublyLinkedList.h" 38 #include "wtf/DoublyLinkedList.h"
38 #include "wtf/PassOwnPtr.h" 39 #include "wtf/PassOwnPtr.h"
40 #include "wtf/RefCounted.h"
39 #include "wtf/RefPtr.h" 41 #include "wtf/RefPtr.h"
40 42
41 namespace blink { 43 namespace blink {
42 class WebGraphicsContext3D; 44 class WebGraphicsContext3D;
43 } 45 }
44 46
45 namespace WebCore { 47 namespace WebCore {
46 48
47 class Canvas2DLayerBridge; 49 class Canvas2DLayerBridge : public blink::WebExternalTextureLayerClient, public SkDeferredCanvas::NotificationClient, public DoublyLinkedListNode<Canvas2DLayerB ridge>, public RefCounted<Canvas2DLayerBridge> {
48 class PassCanvas2DLayerBridgePtr;
49
50 class PLATFORM_EXPORT Canvas2DLayerBridgePtr {
51 public:
52 Canvas2DLayerBridgePtr() { }
53 Canvas2DLayerBridgePtr(const PassRefPtr<Canvas2DLayerBridge>& ptr) { m_ptr = ptr; }
54 ~Canvas2DLayerBridgePtr() { clear(); }
55 Canvas2DLayerBridge* operator->() const { return m_ptr.get(); }
56 Canvas2DLayerBridgePtr& operator=(const PassRefPtr<Canvas2DLayerBridge>&);
57 Canvas2DLayerBridge* get() const { return m_ptr.get(); }
58 operator bool () const { return m_ptr; }
59 void clear();
60 PassRefPtr<Canvas2DLayerBridge> release() WARN_UNUSED_RETURN { return m_ptr. release(); }
61 private:
62 RefPtr<Canvas2DLayerBridge> m_ptr;
63 };
64
65 class PLATFORM_EXPORT Canvas2DLayerBridge : public blink::WebExternalTextureLaye rClient, public SkDeferredCanvas::NotificationClient, public DoublyLinkedListNod e<Canvas2DLayerBridge>, public RefCounted<Canvas2DLayerBridge> {
66 WTF_MAKE_NONCOPYABLE(Canvas2DLayerBridge); 50 WTF_MAKE_NONCOPYABLE(Canvas2DLayerBridge);
67 public: 51 public:
68 enum OpacityMode { 52 static PassRefPtr<Canvas2DLayerBridge> create(const IntSize&, OpacityMode, i nt msaaSampleCount);
69 Opaque,
70 NonOpaque
71 };
72
73 static PassRefPtr<Canvas2DLayerBridge> create(PassRefPtr<GraphicsContext3D>, const IntSize&, OpacityMode, int msaaSampleCount);
74
75 virtual ~Canvas2DLayerBridge(); 53 virtual ~Canvas2DLayerBridge();
76 54
77 // blink::WebExternalTextureLayerClient implementation. 55 // blink::WebExternalTextureLayerClient implementation.
78 virtual blink::WebGraphicsContext3D* context() OVERRIDE; 56 virtual blink::WebGraphicsContext3D* context() OVERRIDE;
79 virtual bool prepareMailbox(blink::WebExternalTextureMailbox*, blink::WebExt ernalBitmap*) OVERRIDE; 57 virtual bool prepareMailbox(blink::WebExternalTextureMailbox*, blink::WebExt ernalBitmap*) OVERRIDE;
80 virtual void mailboxReleased(const blink::WebExternalTextureMailbox&) OVERRI DE; 58 virtual void mailboxReleased(const blink::WebExternalTextureMailbox&) OVERRI DE;
81 59
82 // SkDeferredCanvas::NotificationClient implementation 60 // SkDeferredCanvas::NotificationClient implementation
83 virtual void prepareForDraw() OVERRIDE; 61 virtual void prepareForDraw() OVERRIDE;
84 virtual void storageAllocatedForRecordingChanged(size_t) OVERRIDE; 62 virtual void storageAllocatedForRecordingChanged(size_t) OVERRIDE;
85 virtual void flushedDrawCommands() OVERRIDE; 63 virtual void flushedDrawCommands() OVERRIDE;
86 virtual void skippedPendingDrawCommands() OVERRIDE; 64 virtual void skippedPendingDrawCommands() OVERRIDE;
87 65
66 // ImageBufferSurface implementation
67 void aboutToUse();
68 SkCanvas* canvas() const { return m_canvas.get(); }
69 bool isValid();
70 blink::WebLayer* layer() const;
71 Platform3DObject getBackingTexture();
72 bool isAccelerated() const { return true; }
73
88 // Methods used by Canvas2DLayerManager 74 // Methods used by Canvas2DLayerManager
89 virtual size_t freeMemoryIfPossible(size_t); // virtual for mocking 75 virtual size_t freeMemoryIfPossible(size_t); // virtual for mocking
90 virtual void flush(); // virtual for mocking 76 virtual void flush(); // virtual for mocking
91 virtual size_t storageAllocatedForRecording(); // virtual for faking 77 virtual size_t storageAllocatedForRecording(); // virtual for faking
92 size_t bytesAllocated() const {return m_bytesAllocated;} 78 size_t bytesAllocated() const {return m_bytesAllocated;}
93 void limitPendingFrames(); 79 void limitPendingFrames();
94 80
95 blink::WebLayer* layer(); 81 void destroy();
96 void contextAcquired();
97 PassRefPtr<SkCanvas> getCanvas() { return PassRefPtr<SkCanvas>(m_canvas); }
98
99 unsigned backBufferTexture();
100
101 bool isValid();
102 82
103 protected: 83 protected:
104 void destroy(); 84 Canvas2DLayerBridge(PassRefPtr<GraphicsContext3D>, PassOwnPtr<SkDeferredCanv as>, int, OpacityMode);
105 friend class Canvas2DLayerBridgePtr;
106 Canvas2DLayerBridge(PassRefPtr<GraphicsContext3D>, PassRefPtr<SkDeferredCanv as>, int, OpacityMode);
107 void setRateLimitingEnabled(bool); 85 void setRateLimitingEnabled(bool);
108 86
109 RefPtr<SkDeferredCanvas> m_canvas; 87 OwnPtr<SkDeferredCanvas> m_canvas;
110 OwnPtr<blink::WebExternalTextureLayer> m_layer; 88 OwnPtr<blink::WebExternalTextureLayer> m_layer;
111 RefPtr<GraphicsContext3D> m_context; 89 RefPtr<GraphicsContext3D> m_context;
112 int m_msaaSampleCount; 90 int m_msaaSampleCount;
113 size_t m_bytesAllocated; 91 size_t m_bytesAllocated;
114 bool m_didRecordDrawCommand; 92 bool m_didRecordDrawCommand;
115 bool m_surfaceIsValid; 93 bool m_surfaceIsValid;
116 int m_framesPending; 94 int m_framesPending;
117 bool m_destructionInProgress; 95 bool m_destructionInProgress;
118 bool m_rateLimitingEnabled; 96 bool m_rateLimitingEnabled;
119 97
(...skipping 16 matching lines...) Expand all
136 MailboxInfo(const MailboxInfo&); 114 MailboxInfo(const MailboxInfo&);
137 MailboxInfo() {} 115 MailboxInfo() {}
138 }; 116 };
139 MailboxInfo* createMailboxInfo(); 117 MailboxInfo* createMailboxInfo();
140 118
141 uint32_t m_lastImageId; 119 uint32_t m_lastImageId;
142 Vector<MailboxInfo> m_mailboxes; 120 Vector<MailboxInfo> m_mailboxes;
143 }; 121 };
144 } 122 }
145 #endif 123 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698