| 1 |
/* |
| 2 |
* Copyright 2012 Google Inc. |
| 3 |
* |
| 4 |
* Use of this source code is governed by a BSD-style license that can be |
| 5 |
* found in the LICENSE file. |
| 6 |
*/ |
| 7 |
|
| 8 |
#ifndef SkSurface_Raster_DEFINED |
| 9 |
#define SkSurface_Raster_DEFINED |
| 10 |
|
| 11 |
#include "include/core/SkBitmap.h" |
| 12 |
#include "include/core/SkImageInfo.h" |
| 13 |
#include "include/core/SkRefCnt.h" |
| 14 |
#include "include/core/SkSamplingOptions.h" |
| 15 |
#include "include/core/SkScalar.h" |
| 16 |
#include "include/core/SkSurface.h" |
| 17 |
#include "src/image/SkSurface_Base.h" |
| 18 |
|
| 19 |
#include <cstring> |
| 20 |
|
| 21 |
class SkCanvas; |
| 22 |
class SkCapabilities; |
| 23 |
class SkImage; |
| 24 |
class SkPaint; |
| 25 |
class SkPixelRef; |
| 26 |
class SkPixmap; |
| 27 |
class SkRecorder; |
| 28 |
class SkSurfaceProps; |
| 29 |
struct SkIRect; |
| 30 |
|
| 31 |
namespace skcpu { class RecorderImpl; } |
| 32 |
|
| 33 |
class SkSurface_Raster : public SkSurface_Base { |
| 34 |
public: |
| 35 |
SkSurface_Raster(const SkImageInfo&, void*, size_t rb, |
| 36 |
void (*releaseProc)(void* pixels, void* context), void* context, |
| 37 |
const SkSurfaceProps*); |
| 38 |
SkSurface_Raster(const SkImageInfo& info, sk_sp<SkPixelRef>, const SkSurfaceProps*); |
| 39 |
|
| 40 |
SkSurface_Raster(skcpu::RecorderImpl* recorder, |
| 41 |
const SkImageInfo&, |
| 42 |
void* pixels, |
| 43 |
size_t rowBytes, |
| 44 |
SkSurfaces::PixelsReleaseProc releaseProc, |
| 45 |
void* context, |
| 46 |
const SkSurfaceProps*); |
| 47 |
SkSurface_Raster(skcpu::RecorderImpl* recorder, |
| 48 |
const SkImageInfo&, |
| 49 |
sk_sp<SkPixelRef>, |
| 50 |
const SkSurfaceProps*); |
| 51 |
|
| 52 |
// From SkSurface.h |
| 53 |
SkImageInfo imageInfo() const override { return fBitmap.info(); } |
| 54 |
|
| 55 |
// From SkSurface_Base.h |
| 56 |
SkSurface_Base::Type type() const override { return SkSurface_Base::Type::kRaster; } |
| 57 |
|
| 58 |
SkCanvas* onNewCanvas() override; |
| 59 |
sk_sp<SkSurface> onNewSurface(const SkImageInfo&) override; |
| 60 |
sk_sp<SkImage> onNewImageSnapshot(const SkIRect* subset) override; |
| 61 |
void onWritePixels(const SkPixmap&, int x, int y) override; |
| 62 |
void onDraw(SkCanvas*, SkScalar, SkScalar, const SkSamplingOptions&, const SkPaint*) override; |
| 63 |
bool onCopyOnWrite(ContentChangeMode) override; |
| 64 |
void onRestoreBackingMutability() override; |
| 65 |
sk_sp<const SkCapabilities> onCapabilities() override; |
| 66 |
SkRecorder* onGetBaseRecorder() const override; |
| 67 |
|
| 68 |
private: |
| 69 |
skcpu::RecorderImpl* fRecorder; |
| 70 |
SkBitmap fBitmap; |
| 71 |
bool fWeOwnThePixels; |
| 72 |
}; |
| 73 |
|
| 74 |
#endif |