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

Side by Side Diff: skia/ext/bitmap_platform_device_data.h

Issue 3212009: Move BitmapPlatformDeviceData into its own header file. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: add to gyp Created 10 years, 3 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
« no previous file with comments | « no previous file | skia/ext/bitmap_platform_device_linux.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2010 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 SKIA_EXT_BITMAP_PLATFORM_DEVICE_DATA_H_
6 #define SKIA_EXT_BITMAP_PLATFORM_DEVICE_DATA_H_
7
8 #include "skia/ext/bitmap_platform_device.h"
9
10 namespace skia {
11
12 class BitmapPlatformDevice::BitmapPlatformDeviceData :
13 #if defined(WIN32) || defined(__APPLE__)
14 public SkRefCnt {
15 #elif defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__)
16 // These objects are reference counted and own a Cairo surface. The surface
17 // is the backing store for a Skia bitmap and we reference count it so that
18 // we can copy BitmapPlatformDevice objects without having to copy all the
19 // image data.
20 public base::RefCounted<BitmapPlatformDeviceData> {
21 #endif
22
23 public:
24 #if defined(WIN32)
25 typedef HBITMAP PlatformContext;
26 #elif defined(__APPLE__)
27 typedef CGContextRef PlatformContext;
28 #elif defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__)
29 typedef cairo_t* PlatformContext;
30 #endif
31
32 #if defined(WIN32) || defined(__APPLE__)
33 explicit BitmapPlatformDeviceData(PlatformContext bitmap);
34 #elif defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__)
35 explicit BitmapPlatformDeviceData(cairo_surface_t* surface);
36 #endif
37
38 #if defined(WIN32)
39 // Create/destroy hdc_, which is the memory DC for our bitmap data.
40 HDC GetBitmapDC();
41 void ReleaseBitmapDC();
42 bool IsBitmapDCCreated() const;
43 #endif
44
45 #if defined(__APPLE__)
46 void ReleaseBitmapContext() {
47 SkASSERT(bitmap_context_);
48 CGContextRelease(bitmap_context_);
49 bitmap_context_ = NULL;
50 }
51 #endif // defined(__APPLE__)
52
53 // Sets the transform and clip operations. This will not update the CGContext,
54 // but will mark the config as dirty. The next call of LoadConfig will
55 // pick up these changes.
56 void SetMatrixClip(const SkMatrix& transform, const SkRegion& region);
57
58 // Loads the current transform and clip into the context. Can be called even
59 // when |bitmap_context_| is NULL (will be a NOP).
60 void LoadConfig();
61
62 const SkMatrix& transform() const {
63 return transform_;
64 }
65
66 PlatformContext bitmap_context() {
67 return bitmap_context_;
68 }
69
70 private:
71 #if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__)
72 friend class base::RefCounted<BitmapPlatformDeviceData>;
73 #endif
74 virtual ~BitmapPlatformDeviceData();
75
76 // Lazily-created graphics context used to draw into the bitmap.
77 PlatformContext bitmap_context_;
78
79 #if defined(WIN32)
80 // Lazily-created DC used to draw into the bitmap, see GetBitmapDC().
81 HDC hdc_;
82 #elif defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__)
83 cairo_surface_t *const surface_;
84 #endif
85
86 // True when there is a transform or clip that has not been set to the
87 // context. The context is retrieved for every text operation, and the
88 // transform and clip do not change as much. We can save time by not loading
89 // the clip and transform for every one.
90 bool config_dirty_;
91
92 // Translation assigned to the context: we need to keep track of this
93 // separately so it can be updated even if the context isn't created yet.
94 SkMatrix transform_;
95
96 // The current clipping
97 SkRegion clip_region_;
98
99 // Disallow copy & assign.
100 BitmapPlatformDeviceData(const BitmapPlatformDeviceData&);
101 BitmapPlatformDeviceData& operator=(const BitmapPlatformDeviceData&);
102 };
103
104 } // namespace skia
105
106 #endif // SKIA_EXT_BITMAP_PLATFORM_DEVICE_DATA_H_
OLDNEW
« no previous file with comments | « no previous file | skia/ext/bitmap_platform_device_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698