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 PDF_DRAW_UTILS_H_ | 5 #ifndef PDF_DRAW_UTILS_H_ |
6 #define PDF_DRAW_UTILS_H_ | 6 #define PDF_DRAW_UTILS_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "ppapi/cpp/image_data.h" | 12 #include "ppapi/cpp/image_data.h" |
13 #include "ppapi/cpp/rect.h" | 13 #include "ppapi/cpp/rect.h" |
14 | 14 |
15 namespace chrome_pdf { | 15 namespace chrome_pdf { |
16 | 16 |
17 const uint8_t kOpaqueAlpha = 0xFF; | 17 const uint8_t kOpaqueAlpha = 0xFF; |
18 const uint8_t kTransparentAlpha = 0x00; | 18 const uint8_t kTransparentAlpha = 0x00; |
19 | 19 |
20 void AlphaBlend(const pp::ImageData& src, | |
21 const pp::Rect& src_rc, | |
22 pp::ImageData* dest, | |
23 const pp::Point& dest_origin, | |
24 uint8_t alpha_adjustment); | |
25 | |
26 // Fill rectangle with gradient horizontally or vertically. Start is a color of | |
27 // top-left point of the rectangle, end color is a color of | |
28 // top-right (horizontal==true) or bottom-left (horizontal==false) point. | |
29 void GradientFill(pp::ImageData* image, | |
30 const pp::Rect& rc, | |
31 uint32_t start_color, | |
32 uint32_t end_color, | |
33 bool horizontal); | |
34 | |
35 // Fill dirty rectangle with gradient, where gradient color set for corners of | |
36 // gradient rectangle. Parts of the dirty rect outside of gradient rect will | |
37 // be unchanged. | |
38 void GradientFill(pp::Instance* instance, | |
39 pp::ImageData* image, | |
40 const pp::Rect& dirty_rc, | |
41 const pp::Rect& gradient_rc, | |
42 uint32_t start_color, | |
43 uint32_t end_color, | |
44 bool horizontal, | |
45 uint8_t transparency); | |
46 | |
47 // Copy one image into another. If stretch is true, the result occupy the entire | |
48 // dest_rc. If stretch is false, dest_rc.point will be used as an origin of the | |
49 // result image. Copy will ignore all pixels with transparent alpha from the | |
50 // source image. | |
51 void CopyImage(const pp::ImageData& src, const pp::Rect& src_rc, | |
52 pp::ImageData* dest, const pp::Rect& dest_rc, | |
53 bool stretch); | |
54 | |
55 // Fill in rectangle with specified color. | |
56 void FillRect(pp::ImageData* image, const pp::Rect& rc, uint32_t color); | |
57 | |
58 // Shadow Matrix contains matrix for shadow rendering. To reduce amount of | 20 // Shadow Matrix contains matrix for shadow rendering. To reduce amount of |
59 // calculations user may choose to cache matrix and reuse it if nothing changed. | 21 // calculations user may choose to cache matrix and reuse it if nothing changed. |
60 class ShadowMatrix { | 22 class ShadowMatrix { |
61 public: | 23 public: |
62 // Matrix parameters. | 24 // Matrix parameters. |
63 // depth - how big matrix should be. Shadow will go smoothly across the | 25 // depth - how big matrix should be. Shadow will go smoothly across the |
64 // entire matrix from black to background color. | 26 // entire matrix from black to background color. |
65 // If factor == 1, smoothing will be linear from 0 to the end (depth), | 27 // If factor == 1, smoothing will be linear from 0 to the end (depth), |
66 // if 0 < factor < 1, smoothing will drop faster near 0. | 28 // if 0 < factor < 1, smoothing will drop faster near 0. |
67 // if factor > 1, smoothing will drop faster near the end (depth). | 29 // if factor > 1, smoothing will drop faster near the end (depth). |
(...skipping 22 matching lines...) Expand all Loading... |
90 // clip_rc - clipping region | 52 // clip_rc - clipping region |
91 void DrawShadow(pp::ImageData* image, | 53 void DrawShadow(pp::ImageData* image, |
92 const pp::Rect& shadow_rc, | 54 const pp::Rect& shadow_rc, |
93 const pp::Rect& object_rc, | 55 const pp::Rect& object_rc, |
94 const pp::Rect& clip_rc, | 56 const pp::Rect& clip_rc, |
95 const ShadowMatrix& matrix); | 57 const ShadowMatrix& matrix); |
96 | 58 |
97 } // namespace chrome_pdf | 59 } // namespace chrome_pdf |
98 | 60 |
99 #endif // PDF_DRAW_UTILS_H_ | 61 #endif // PDF_DRAW_UTILS_H_ |
OLD | NEW |