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

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

Issue 14298018: This CL implements the first draft of Canvas 2D Context Attributes, aka getContext('2d', { alpha: f… (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased to ToT; test cleanup Created 7 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 | 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 26 matching lines...) Expand all
37 37
38 namespace WebKit { 38 namespace WebKit {
39 class WebGraphicsContext3D; 39 class WebGraphicsContext3D;
40 } 40 }
41 41
42 namespace WebCore { 42 namespace WebCore {
43 43
44 class Canvas2DLayerBridge : public WebKit::WebExternalTextureLayerClient, public SkDeferredCanvas::NotificationClient, public DoublyLinkedListNode<Canvas2DLayer Bridge> { 44 class Canvas2DLayerBridge : public WebKit::WebExternalTextureLayerClient, public SkDeferredCanvas::NotificationClient, public DoublyLinkedListNode<Canvas2DLayer Bridge> {
45 WTF_MAKE_NONCOPYABLE(Canvas2DLayerBridge); 45 WTF_MAKE_NONCOPYABLE(Canvas2DLayerBridge);
46 public: 46 public:
47 enum OpacityMode {
48 Opaque,
49 NonOpaque
50 };
51
47 enum ThreadMode { 52 enum ThreadMode {
48 SingleThread, 53 SingleThread,
49 Threaded 54 Threaded
50 }; 55 };
51 56
52 static PassOwnPtr<Canvas2DLayerBridge> create(PassRefPtr<GraphicsContext3D> context, SkDeferredCanvas* canvas, ThreadMode threading) 57 static PassOwnPtr<Canvas2DLayerBridge> create(PassRefPtr<GraphicsContext3D> context, SkDeferredCanvas* canvas, OpacityMode opacityMode, ThreadMode threading )
53 { 58 {
54 return adoptPtr(new Canvas2DLayerBridge(context, canvas, threading)); 59 return adoptPtr(new Canvas2DLayerBridge(context, canvas, opacityMode, th reading));
55 } 60 }
56 61
57 virtual ~Canvas2DLayerBridge(); 62 virtual ~Canvas2DLayerBridge();
58 63
59 // WebKit::WebExternalTextureLayerClient implementation. 64 // WebKit::WebExternalTextureLayerClient implementation.
60 virtual unsigned prepareTexture(WebKit::WebTextureUpdater&) OVERRIDE; 65 virtual unsigned prepareTexture(WebKit::WebTextureUpdater&) OVERRIDE;
61 virtual WebKit::WebGraphicsContext3D* context() OVERRIDE; 66 virtual WebKit::WebGraphicsContext3D* context() OVERRIDE;
62 virtual bool prepareMailbox(WebKit::WebExternalTextureMailbox*) OVERRIDE { r eturn false; } 67 virtual bool prepareMailbox(WebKit::WebExternalTextureMailbox*) OVERRIDE { r eturn false; }
63 virtual void mailboxReleased(const WebKit::WebExternalTextureMailbox&) OVERR IDE { } 68 virtual void mailboxReleased(const WebKit::WebExternalTextureMailbox&) OVERR IDE { }
64 69
65 // SkDeferredCanvas::NotificationClient implementation 70 // SkDeferredCanvas::NotificationClient implementation
66 virtual void prepareForDraw() OVERRIDE; 71 virtual void prepareForDraw() OVERRIDE;
67 virtual void storageAllocatedForRecordingChanged(size_t) OVERRIDE; 72 virtual void storageAllocatedForRecordingChanged(size_t) OVERRIDE;
68 virtual void flushedDrawCommands() OVERRIDE; 73 virtual void flushedDrawCommands() OVERRIDE;
69 virtual void skippedPendingDrawCommands() OVERRIDE; 74 virtual void skippedPendingDrawCommands() OVERRIDE;
70 75
71 // Methods used by Canvas2DLayerManager 76 // Methods used by Canvas2DLayerManager
72 virtual size_t freeMemoryIfPossible(size_t); // virtual for mocking 77 virtual size_t freeMemoryIfPossible(size_t); // virtual for mocking
73 virtual void flush(); // virtual for mocking 78 virtual void flush(); // virtual for mocking
74 virtual size_t storageAllocatedForRecording(); // virtual for faking 79 virtual size_t storageAllocatedForRecording(); // virtual for faking
75 size_t bytesAllocated() const {return m_bytesAllocated;} 80 size_t bytesAllocated() const {return m_bytesAllocated;}
76 void limitPendingFrames(); 81 void limitPendingFrames();
77 82
78 WebKit::WebLayer* layer(); 83 WebKit::WebLayer* layer();
79 void contextAcquired(); 84 void contextAcquired();
80 85
81 unsigned backBufferTexture(); 86 unsigned backBufferTexture();
82 87
83 protected: 88 protected:
84 Canvas2DLayerBridge(PassRefPtr<GraphicsContext3D>, SkDeferredCanvas* canvas, ThreadMode); 89 Canvas2DLayerBridge(PassRefPtr<GraphicsContext3D>, SkDeferredCanvas*, Opacit yMode, ThreadMode);
85 90
86 SkDeferredCanvas* m_canvas; 91 SkDeferredCanvas* m_canvas;
87 OwnPtr<WebKit::WebExternalTextureLayer> m_layer; 92 OwnPtr<WebKit::WebExternalTextureLayer> m_layer;
88 RefPtr<GraphicsContext3D> m_context; 93 RefPtr<GraphicsContext3D> m_context;
89 size_t m_bytesAllocated; 94 size_t m_bytesAllocated;
90 bool m_didRecordDrawCommand; 95 bool m_didRecordDrawCommand;
91 int m_framesPending; 96 int m_framesPending;
92 97
93 friend class WTF::DoublyLinkedListNode<Canvas2DLayerBridge>; 98 friend class WTF::DoublyLinkedListNode<Canvas2DLayerBridge>;
94 Canvas2DLayerBridge* m_next; 99 Canvas2DLayerBridge* m_next;
95 Canvas2DLayerBridge* m_prev; 100 Canvas2DLayerBridge* m_prev;
96 }; 101 };
97 102
98 } 103 }
99 104
100 #endif 105 #endif
OLDNEW
« no previous file with comments | « Source/core/platform/graphics/ImageBuffer.h ('k') | Source/core/platform/graphics/chromium/Canvas2DLayerBridge.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698