Skia
2DGraphicsLibrary
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SkRasterHandleAllocator.h
1 /*
2  * Copyright 2016 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 SkRasterHandleAllocator_DEFINED
9 #define SkRasterHandleAllocator_DEFINED
10 
11 #include "SkImageInfo.h"
12 
13 class SkBitmap;
14 class SkCanvas;
15 class SkMatrix;
16 
37 public:
38  virtual ~SkRasterHandleAllocator() {}
39 
40  // The value that is returned to clients of the canvas that has this allocator installed.
41  typedef void* Handle;
42 
43  struct Rec {
44  // When the allocation goes out of scope, this proc is called to free everything associated
45  // with it: the pixels, the "handle", etc. This is passed the pixel address and fReleaseCtx.
46  void (*fReleaseProc)(void* pixels, void* ctx);
47  void* fReleaseCtx; // context passed to fReleaseProc
48  void* fPixels; // pixels for this allocation
49  size_t fRowBytes; // rowbytes for these pixels
50  Handle fHandle; // public handle returned by SkCanvas::accessTopRasterHandle()
51  };
52 
62  virtual bool allocHandle(const SkImageInfo&, Rec*) = 0;
63 
69  virtual void updateHandle(Handle, const SkMatrix&, const SkIRect&) = 0;
70 
78  static std::unique_ptr<SkCanvas> MakeCanvas(std::unique_ptr<SkRasterHandleAllocator>,
79  const SkImageInfo&, const Rec* rec = nullptr);
80 
81 private:
82  friend class SkBitmapDevice;
83 
84  Handle allocBitmap(const SkImageInfo&, SkBitmap*);
85 };
86 
87 #endif
A Canvas encapsulates all of the state about drawing into a device (bitmap).
Definition: SkCanvas.h:59
Describe an image's dimensions and pixel type.
Definition: SkImageInfo.h:181
The SkMatrix class holds a 3x3 matrix for transforming coordinates.
Definition: SkMatrix.h:28
The SkBitmap class specifies a raster bitmap.
Definition: SkBitmap.h:37
Definition: SkRasterHandleAllocator.h:43
If a client wants to control the allocation of raster layers in a canvas, it should subclass SkRaster...
Definition: SkRasterHandleAllocator.h:36
SkIRect holds four 32 bit integer coordinates for a rectangle.
Definition: SkRect.h:20