Line data Source code
1 : /*
2 : * Copyright 2017 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 SkThreadedBMPDevice_DEFINED
9 : #define SkThreadedBMPDevice_DEFINED
10 :
11 : #include "SkDraw.h"
12 : #include "SkBitmapDevice.h"
13 :
14 : ///////////////////////////////////////////////////////////////////////////////
15 0 : class SkThreadedBMPDevice : public SkBitmapDevice {
16 : public:
17 : SkThreadedBMPDevice(const SkBitmap& bitmap, int threads);
18 :
19 : protected:
20 : void drawPaint(const SkPaint& paint) override;
21 : void drawPoints(SkCanvas::PointMode mode, size_t count,
22 : const SkPoint[], const SkPaint& paint) override;
23 : void drawRect(const SkRect& r, const SkPaint& paint) override;
24 : void drawRRect(const SkRRect& rr, const SkPaint& paint) override;
25 :
26 : void drawPath(const SkPath&, const SkPaint&, const SkMatrix* prePathMatrix,
27 : bool pathIsMutable) override;
28 : void drawBitmap(const SkBitmap&, const SkMatrix&, const SkPaint&) override;
29 : void drawSprite(const SkBitmap&, int x, int y, const SkPaint&) override;
30 :
31 : void drawText(const void* text, size_t len, SkScalar x, SkScalar y,
32 : const SkPaint&) override;
33 : void drawPosText(const void* text, size_t len, const SkScalar pos[],
34 : int scalarsPerPos, const SkPoint& offset, const SkPaint& paint) override;
35 : void drawVertices(const SkVertices*, SkBlendMode, const SkPaint&) override;
36 : void drawDevice(SkBaseDevice*, int x, int y, const SkPaint&) override;
37 :
38 : void flush() override;
39 :
40 : private:
41 0 : struct DrawElement {
42 : SkIRect fDrawBounds;
43 : std::function<void(const SkIRect& threadBounds)> fDrawFn;
44 : };
45 :
46 : struct DrawState;
47 :
48 : SkIRect transformDrawBounds(const SkRect& drawBounds) const;
49 :
50 : const int fThreadCnt;
51 : SkTArray<SkIRect> fThreadBounds;
52 : SkTArray<DrawElement> fQueue;
53 :
54 : typedef SkBitmapDevice INHERITED;
55 : };
56 :
57 : #endif // SkThreadedBMPDevice_DEFINED
|