| OLD | NEW |
| 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_ANDROID_H_ | 5 #ifndef SKIA_EXT_BITMAP_PLATFORM_DEVICE_ANDROID_H_ |
| 6 #define SKIA_EXT_BITMAP_PLATFORM_DEVICE_ANDROID_H_ | 6 #define SKIA_EXT_BITMAP_PLATFORM_DEVICE_ANDROID_H_ |
| 7 | 7 |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "skia/ext/platform_device.h" | 10 #include "skia/ext/platform_device.h" |
| 11 | 11 |
| 12 namespace skia { | 12 namespace skia { |
| 13 | 13 |
| 14 // ----------------------------------------------------------------------------- | 14 // ----------------------------------------------------------------------------- |
| 15 // For now we just use SkBitmap for SkDevice | 15 // For now we just use SkBitmap for SkDevice |
| 16 // | 16 // |
| 17 // This is all quite ok for test_shell. In the future we will want to use | 17 // This is all quite ok for test_shell. In the future we will want to use |
| 18 // shared memory between the renderer and the main process at least. In this | 18 // shared memory between the renderer and the main process at least. In this |
| 19 // case we'll probably create the buffer from a precreated region of memory. | 19 // case we'll probably create the buffer from a precreated region of memory. |
| 20 // ----------------------------------------------------------------------------- | 20 // ----------------------------------------------------------------------------- |
| 21 class BitmapPlatformDevice : public PlatformDevice, public SkDevice { | 21 class BitmapPlatformDevice : public PlatformDevice, public SkDevice { |
| 22 public: | 22 public: |
| 23 // Construct a BitmapPlatformDevice. |is_opaque| should be set if the caller |
| 24 // knows the bitmap will be completely opaque and allows some optimizations. |
| 25 // The bitmap is not initialized. |
| 23 static BitmapPlatformDevice* Create(int width, int height, bool is_opaque); | 26 static BitmapPlatformDevice* Create(int width, int height, bool is_opaque); |
| 24 | 27 |
| 25 // This doesn't take ownership of |data| | 28 // Construct a BitmapPlatformDevice, as above. |
| 29 // If |is_opaque| is false, the bitmap is initialized to 0. |
| 30 static BitmapPlatformDevice* CreateAndClear(int width, int height, |
| 31 bool is_opaque); |
| 32 |
| 33 // This doesn't take ownership of |data|. If |data| is null, the bitmap |
| 34 // is not initialized to 0. |
| 26 static BitmapPlatformDevice* Create(int width, int height, bool is_opaque, | 35 static BitmapPlatformDevice* Create(int width, int height, bool is_opaque, |
| 27 uint8_t* data); | 36 uint8_t* data); |
| 28 | 37 |
| 29 // Create a BitmapPlatformDevice from an already constructed bitmap; | 38 // Create a BitmapPlatformDevice from an already constructed bitmap; |
| 30 // you should probably be using Create(). This may become private later if | 39 // you should probably be using Create(). This may become private later if |
| 31 // we ever have to share state between some native drawing UI and Skia, like | 40 // we ever have to share state between some native drawing UI and Skia, like |
| 32 // the Windows and Mac versions of this class do. | 41 // the Windows and Mac versions of this class do. |
| 33 explicit BitmapPlatformDevice(const SkBitmap& other); | 42 explicit BitmapPlatformDevice(const SkBitmap& other); |
| 34 virtual ~BitmapPlatformDevice(); | 43 virtual ~BitmapPlatformDevice(); |
| 35 | 44 |
| 36 virtual PlatformSurface BeginPlatformPaint() OVERRIDE; | 45 virtual PlatformSurface BeginPlatformPaint() OVERRIDE; |
| 37 virtual void DrawToNativeContext(PlatformSurface surface, int x, int y, | 46 virtual void DrawToNativeContext(PlatformSurface surface, int x, int y, |
| 38 const PlatformRect* src_rect) OVERRIDE; | 47 const PlatformRect* src_rect) OVERRIDE; |
| 39 | 48 |
| 40 protected: | 49 protected: |
| 41 virtual SkDevice* onCreateCompatibleDevice(SkBitmap::Config, int width, | 50 virtual SkDevice* onCreateCompatibleDevice(SkBitmap::Config, int width, |
| 42 int height, bool isOpaque, | 51 int height, bool isOpaque, |
| 43 Usage usage) OVERRIDE; | 52 Usage usage) OVERRIDE; |
| 44 | 53 |
| 45 private: | 54 private: |
| 46 DISALLOW_COPY_AND_ASSIGN(BitmapPlatformDevice); | 55 DISALLOW_COPY_AND_ASSIGN(BitmapPlatformDevice); |
| 47 }; | 56 }; |
| 48 | 57 |
| 49 } // namespace skia | 58 } // namespace skia |
| 50 | 59 |
| 51 #endif // SKIA_EXT_BITMAP_PLATFORM_DEVICE_ANDROID_H_ | 60 #endif // SKIA_EXT_BITMAP_PLATFORM_DEVICE_ANDROID_H_ |
| OLD | NEW |