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

Unified 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, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | skia/ext/bitmap_platform_device_linux.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: skia/ext/bitmap_platform_device_data.h
diff --git a/skia/ext/bitmap_platform_device_data.h b/skia/ext/bitmap_platform_device_data.h
new file mode 100644
index 0000000000000000000000000000000000000000..36e0ad5cab69b15471b16deab9e931845fb7c561
--- /dev/null
+++ b/skia/ext/bitmap_platform_device_data.h
@@ -0,0 +1,106 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SKIA_EXT_BITMAP_PLATFORM_DEVICE_DATA_H_
+#define SKIA_EXT_BITMAP_PLATFORM_DEVICE_DATA_H_
+
+#include "skia/ext/bitmap_platform_device.h"
+
+namespace skia {
+
+class BitmapPlatformDevice::BitmapPlatformDeviceData :
+#if defined(WIN32) || defined(__APPLE__)
+ public SkRefCnt {
+#elif defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__)
+ // These objects are reference counted and own a Cairo surface. The surface
+ // is the backing store for a Skia bitmap and we reference count it so that
+ // we can copy BitmapPlatformDevice objects without having to copy all the
+ // image data.
+ public base::RefCounted<BitmapPlatformDeviceData> {
+#endif
+
+ public:
+#if defined(WIN32)
+ typedef HBITMAP PlatformContext;
+#elif defined(__APPLE__)
+ typedef CGContextRef PlatformContext;
+#elif defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__)
+ typedef cairo_t* PlatformContext;
+#endif
+
+#if defined(WIN32) || defined(__APPLE__)
+ explicit BitmapPlatformDeviceData(PlatformContext bitmap);
+#elif defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__)
+ explicit BitmapPlatformDeviceData(cairo_surface_t* surface);
+#endif
+
+#if defined(WIN32)
+ // Create/destroy hdc_, which is the memory DC for our bitmap data.
+ HDC GetBitmapDC();
+ void ReleaseBitmapDC();
+ bool IsBitmapDCCreated() const;
+#endif
+
+#if defined(__APPLE__)
+ void ReleaseBitmapContext() {
+ SkASSERT(bitmap_context_);
+ CGContextRelease(bitmap_context_);
+ bitmap_context_ = NULL;
+ }
+#endif // defined(__APPLE__)
+
+ // Sets the transform and clip operations. This will not update the CGContext,
+ // but will mark the config as dirty. The next call of LoadConfig will
+ // pick up these changes.
+ void SetMatrixClip(const SkMatrix& transform, const SkRegion& region);
+
+ // Loads the current transform and clip into the context. Can be called even
+ // when |bitmap_context_| is NULL (will be a NOP).
+ void LoadConfig();
+
+ const SkMatrix& transform() const {
+ return transform_;
+ }
+
+ PlatformContext bitmap_context() {
+ return bitmap_context_;
+ }
+
+ private:
+#if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__)
+ friend class base::RefCounted<BitmapPlatformDeviceData>;
+#endif
+ virtual ~BitmapPlatformDeviceData();
+
+ // Lazily-created graphics context used to draw into the bitmap.
+ PlatformContext bitmap_context_;
+
+#if defined(WIN32)
+ // Lazily-created DC used to draw into the bitmap, see GetBitmapDC().
+ HDC hdc_;
+#elif defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__)
+ cairo_surface_t *const surface_;
+#endif
+
+ // True when there is a transform or clip that has not been set to the
+ // context. The context is retrieved for every text operation, and the
+ // transform and clip do not change as much. We can save time by not loading
+ // the clip and transform for every one.
+ bool config_dirty_;
+
+ // Translation assigned to the context: we need to keep track of this
+ // separately so it can be updated even if the context isn't created yet.
+ SkMatrix transform_;
+
+ // The current clipping
+ SkRegion clip_region_;
+
+ // Disallow copy & assign.
+ BitmapPlatformDeviceData(const BitmapPlatformDeviceData&);
+ BitmapPlatformDeviceData& operator=(const BitmapPlatformDeviceData&);
+};
+
+} // namespace skia
+
+#endif // SKIA_EXT_BITMAP_PLATFORM_DEVICE_DATA_H_
« 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