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

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

Issue 7633040: CL removing inheritance of SkDevice from PlatformDevice. Flavours of PlatformDevice classes now ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 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 | Annotate | Revision Log
« no previous file with comments | « printing/pdf_metafile_skia.cc ('k') | 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
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef SKIA_EXT_BITMAP_PLATFORM_DEVICE_LINUX_H_ 5 #ifndef SKIA_EXT_BITMAP_PLATFORM_DEVICE_LINUX_H_
6 #define SKIA_EXT_BITMAP_PLATFORM_DEVICE_LINUX_H_ 6 #define SKIA_EXT_BITMAP_PLATFORM_DEVICE_LINUX_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/compiler_specific.h"
10 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
11 #include "skia/ext/platform_device_linux.h" 12 #include "skia/ext/platform_device.h"
12 13
13 typedef struct _cairo_surface cairo_surface_t; 14 typedef struct _cairo_surface cairo_surface_t;
14 15
15 // ----------------------------------------------------------------------------- 16 // -----------------------------------------------------------------------------
16 // Image byte ordering on Linux: 17 // Image byte ordering on Linux:
17 // 18 //
18 // Pixels are packed into 32-bit words these days. Even for 24-bit images, 19 // Pixels are packed into 32-bit words these days. Even for 24-bit images,
19 // often 8-bits will be left unused for alignment reasons. Thus, when you see 20 // often 8-bits will be left unused for alignment reasons. Thus, when you see
20 // ARGB as the byte order you have to wonder if that's in memory order or 21 // ARGB as the byte order you have to wonder if that's in memory order or
21 // little-endian order. Here I'll write A.R.G.B to specifiy the memory order. 22 // little-endian order. Here I'll write A.R.G.B to specifiy the memory order.
(...skipping 27 matching lines...) Expand all
49 // to store the backing buffer. This buffer is BGRA in memory (on little-endian 50 // to store the backing buffer. This buffer is BGRA in memory (on little-endian
50 // machines). 51 // machines).
51 // 52 //
52 // For now we are also using Cairo to paint to the Drawables so we provide an 53 // For now we are also using Cairo to paint to the Drawables so we provide an
53 // accessor for getting the surface. 54 // accessor for getting the surface.
54 // 55 //
55 // This is all quite ok for test_shell. In the future we will want to use 56 // This is all quite ok for test_shell. In the future we will want to use
56 // shared memory between the renderer and the main process at least. In this 57 // shared memory between the renderer and the main process at least. In this
57 // case we'll probably create the buffer from a precreated region of memory. 58 // case we'll probably create the buffer from a precreated region of memory.
58 // ----------------------------------------------------------------------------- 59 // -----------------------------------------------------------------------------
59 class BitmapPlatformDevice : public PlatformDevice { 60 class BitmapPlatformDevice : public PlatformDevice, public SkDevice {
60 // A reference counted cairo surface 61 // A reference counted cairo surface
61 class BitmapPlatformDeviceData; 62 class BitmapPlatformDeviceData;
62 63
63 public: 64 public:
64 // Create a BitmapPlatformDeviceLinux from an already constructed bitmap; 65 // Create a BitmapPlatformDeviceLinux from an already constructed bitmap;
65 // you should probably be using Create(). This may become private later if 66 // you should probably be using Create(). This may become private later if
66 // we ever have to share state between some native drawing UI and Skia, like 67 // we ever have to share state between some native drawing UI and Skia, like
67 // the Windows and Mac versions of this class do. 68 // the Windows and Mac versions of this class do.
68 // 69 //
69 // This object takes ownership of @data. 70 // This object takes ownership of @data.
70 BitmapPlatformDevice(const SkBitmap& other, BitmapPlatformDeviceData* data); 71 BitmapPlatformDevice(const SkBitmap& other, BitmapPlatformDeviceData* data);
71 virtual ~BitmapPlatformDevice(); 72 virtual ~BitmapPlatformDevice();
72 73
73 static BitmapPlatformDevice* Create(int width, int height, bool is_opaque); 74 static BitmapPlatformDevice* Create(int width, int height, bool is_opaque);
74 75
75 // This doesn't take ownership of |data| 76 // This doesn't take ownership of |data|
76 static BitmapPlatformDevice* Create(int width, int height, 77 static BitmapPlatformDevice* Create(int width, int height, bool is_opaque,
77 bool is_opaque, uint8_t* data); 78 uint8_t* data);
78 79
79 virtual void MakeOpaque(int x, int y, int width, int height); 80 virtual void MakeOpaque(int x, int y, int width, int height) OVERRIDE;
80 81
81 // Overridden from SkDevice: 82 // Overridden from SkDevice:
82 virtual void setMatrixClip(const SkMatrix& transform, const SkRegion& region, 83 virtual void setMatrixClip(const SkMatrix& transform, const SkRegion& region,
83 const SkClipStack&); 84 const SkClipStack&) OVERRIDE;
84 85
85 // Overridden from PlatformDevice: 86 // Overridden from PlatformDevice:
86 virtual cairo_t* BeginPlatformPaint(); 87 virtual cairo_t* BeginPlatformPaint() OVERRIDE;
88 virtual void DrawToNativeContext(PlatformSurface surface, int x, int y,
89 const PlatformRect* src_rect) OVERRIDE;
87 90
88 protected: 91 protected:
89 virtual SkDevice* onCreateCompatibleDevice(SkBitmap::Config, int width, 92 virtual SkDevice* onCreateCompatibleDevice(SkBitmap::Config, int width,
90 int height, bool isOpaque, 93 int height, bool isOpaque,
91 Usage usage); 94 Usage usage) OVERRIDE;
92 95
93 private: 96 private:
94 static BitmapPlatformDevice* Create(int width, int height, bool is_opaque, 97 static BitmapPlatformDevice* Create(int width, int height, bool is_opaque,
95 cairo_surface_t* surface); 98 cairo_surface_t* surface);
96 99
97 scoped_refptr<BitmapPlatformDeviceData> data_; 100 scoped_refptr<BitmapPlatformDeviceData> data_;
98 101
99 DISALLOW_COPY_AND_ASSIGN(BitmapPlatformDevice); 102 DISALLOW_COPY_AND_ASSIGN(BitmapPlatformDevice);
100 }; 103 };
101 104
102 } // namespace skia 105 } // namespace skia
103 106
104 #endif // SKIA_EXT_BITMAP_PLATFORM_DEVICE_LINUX_H_ 107 #endif // SKIA_EXT_BITMAP_PLATFORM_DEVICE_LINUX_H_
OLDNEW
« no previous file with comments | « printing/pdf_metafile_skia.cc ('k') | skia/ext/bitmap_platform_device_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698