OLD | NEW |
| (Empty) |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef WEBKIT_PLUGINS_NPAPI_QUICKDRAW_DRAWING_MANAGER_MAC_H_ | |
6 #define WEBKIT_PLUGINS_NPAPI_QUICKDRAW_DRAWING_MANAGER_MAC_H_ | |
7 | |
8 #ifndef NP_NO_QUICKDRAW | |
9 | |
10 #import <Carbon/Carbon.h> | |
11 | |
12 #include "ui/gfx/rect.h" | |
13 | |
14 namespace webkit { | |
15 namespace npapi { | |
16 | |
17 // Plugin helper class encapsulating the details of capturing what a QuickDraw | |
18 // drawing model plugin draws, then drawing it into a CGContext. | |
19 class QuickDrawDrawingManager { | |
20 public: | |
21 QuickDrawDrawingManager(); | |
22 ~QuickDrawDrawingManager(); | |
23 | |
24 // Sets the context that the plugin bits should be copied into when | |
25 // UpdateContext is called. This object does not retain |context|, so the | |
26 // caller must call SetTargetContext again if the context changes. | |
27 void SetTargetContext(CGContextRef context, const gfx::Size& plugin_size); | |
28 | |
29 // Sets the window that is used by the plugin. This object does not own the | |
30 // window, so the caler must call SetPluginWindow again if the window changes. | |
31 void SetPluginWindow(WindowRef window); | |
32 | |
33 // Updates the target context with the current plugin bits. | |
34 void UpdateContext(); | |
35 | |
36 // Returns the port that the plugin should draw into. This returned port is | |
37 // only valid until the next call to SetPluginWindow. | |
38 CGrafPtr port() { return current_port_; } | |
39 | |
40 // Makes the QuickDraw port current; should be called before calls where the | |
41 // plugin might draw. | |
42 void MakePortCurrent(); | |
43 | |
44 private: | |
45 // Scrapes the contents of the window into the given context. | |
46 static void ScrapeWindow(WindowRef window, CGContextRef target_context, | |
47 const gfx::Size& plugin_size); | |
48 | |
49 WindowRef plugin_window_; // Weak reference. | |
50 CGContextRef target_context_; // Weak reference. | |
51 gfx::Size plugin_size_; | |
52 CGrafPtr current_port_; | |
53 }; | |
54 | |
55 } // namespace npapi | |
56 } // namespace webkit | |
57 | |
58 #endif // !NP_NO_QUICKDRAW | |
59 | |
60 #endif // WEBKIT_PLUGINS_NPAPI_QUICKDRAW_DRAWING_MANAGER_MAC_H_ | |
OLD | NEW |