Roll src/third_party/WebKit d9c6159:8139f33 (svn 201974:201975)
[chromium-blink-merge.git] / skia / ext / bitmap_platform_device_skia.h
blob0e21929112a9d9d27efaeebbd621ae6b4181d9bb
1 // Copyright 2013 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.
5 #ifndef SKIA_EXT_BITMAP_PLATFORM_DEVICE_SKIA_H_
6 #define SKIA_EXT_BITMAP_PLATFORM_DEVICE_SKIA_H_
8 #include "base/compiler_specific.h"
9 #include "base/memory/ref_counted.h"
10 #include "skia/ext/platform_device.h"
12 namespace skia {
14 // -----------------------------------------------------------------------------
15 // For now we just use SkBitmap for SkBitmapDevice
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
19 // case we'll probably create the buffer from a precreated region of memory.
20 // -----------------------------------------------------------------------------
21 class BitmapPlatformDevice : public SkBitmapDevice, public PlatformDevice {
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.
26 static BitmapPlatformDevice* Create(int width, int height, bool is_opaque);
28 // This doesn't take ownership of |data|. If |data| is null, the bitmap
29 // is not initialized to 0.
30 static BitmapPlatformDevice* Create(int width, int height, bool is_opaque,
31 uint8_t* data);
33 // Create a BitmapPlatformDevice from an already constructed bitmap;
34 // you should probably be using Create(). This may become private later if
35 // we ever have to share state between some native drawing UI and Skia, like
36 // the Windows and Mac versions of this class do.
37 explicit BitmapPlatformDevice(const SkBitmap& other);
38 ~BitmapPlatformDevice() override;
40 PlatformSurface BeginPlatformPaint() override;
42 protected:
43 SkBaseDevice* onCreateDevice(const CreateInfo&, const SkPaint*) override;
45 private:
46 DISALLOW_COPY_AND_ASSIGN(BitmapPlatformDevice);
49 } // namespace skia
51 #endif // SKIA_EXT_BITMAP_PLATFORM_DEVICE_SKIA_H_