Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Side by Side Diff: pdf/draw_utils.h

Issue 1533413002: Switch to standard integer types in pdf/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pdf/document_loader.cc ('k') | pdf/draw_utils.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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>
9
8 #include <vector> 10 #include <vector>
9 11
10 #include "base/basictypes.h"
11 #include "ppapi/cpp/image_data.h" 12 #include "ppapi/cpp/image_data.h"
12 #include "ppapi/cpp/rect.h" 13 #include "ppapi/cpp/rect.h"
13 14
14 namespace chrome_pdf { 15 namespace chrome_pdf {
15 16
16 const uint8 kOpaqueAlpha = 0xFF; 17 const uint8_t kOpaqueAlpha = 0xFF;
17 const uint8 kTransparentAlpha = 0x00; 18 const uint8_t kTransparentAlpha = 0x00;
18 19
19 void AlphaBlend(const pp::ImageData& src, const pp::Rect& src_rc, 20 void AlphaBlend(const pp::ImageData& src,
20 pp::ImageData* dest, const pp::Point& dest_origin, 21 const pp::Rect& src_rc,
21 uint8 alpha_adjustment); 22 pp::ImageData* dest,
23 const pp::Point& dest_origin,
24 uint8_t alpha_adjustment);
22 25
23 // Fill rectangle with gradient horizontally or vertically. Start is a color of 26 // Fill rectangle with gradient horizontally or vertically. Start is a color of
24 // top-left point of the rectangle, end color is a color of 27 // top-left point of the rectangle, end color is a color of
25 // top-right (horizontal==true) or bottom-left (horizontal==false) point. 28 // top-right (horizontal==true) or bottom-left (horizontal==false) point.
26 void GradientFill(pp::ImageData* image, 29 void GradientFill(pp::ImageData* image,
27 const pp::Rect& rc, 30 const pp::Rect& rc,
28 uint32 start_color, 31 uint32_t start_color,
29 uint32 end_color, 32 uint32_t end_color,
30 bool horizontal); 33 bool horizontal);
31 34
32 // Fill dirty rectangle with gradient, where gradient color set for corners of 35 // Fill dirty rectangle with gradient, where gradient color set for corners of
33 // gradient rectangle. Parts of the dirty rect outside of gradient rect will 36 // gradient rectangle. Parts of the dirty rect outside of gradient rect will
34 // be unchanged. 37 // be unchanged.
35 void GradientFill(pp::Instance* instance, 38 void GradientFill(pp::Instance* instance,
36 pp::ImageData* image, 39 pp::ImageData* image,
37 const pp::Rect& dirty_rc, 40 const pp::Rect& dirty_rc,
38 const pp::Rect& gradient_rc, 41 const pp::Rect& gradient_rc,
39 uint32 start_color, 42 uint32_t start_color,
40 uint32 end_color, 43 uint32_t end_color,
41 bool horizontal, 44 bool horizontal,
42 uint8 transparency); 45 uint8_t transparency);
43 46
44 // Copy one image into another. If stretch is true, the result occupy the entire 47 // Copy one image into another. If stretch is true, the result occupy the entire
45 // dest_rc. If stretch is false, dest_rc.point will be used as an origin of the 48 // dest_rc. If stretch is false, dest_rc.point will be used as an origin of the
46 // result image. Copy will ignore all pixels with transparent alpha from the 49 // result image. Copy will ignore all pixels with transparent alpha from the
47 // source image. 50 // source image.
48 void CopyImage(const pp::ImageData& src, const pp::Rect& src_rc, 51 void CopyImage(const pp::ImageData& src, const pp::Rect& src_rc,
49 pp::ImageData* dest, const pp::Rect& dest_rc, 52 pp::ImageData* dest, const pp::Rect& dest_rc,
50 bool stretch); 53 bool stretch);
51 54
52 // Fill in rectangle with specified color. 55 // Fill in rectangle with specified color.
53 void FillRect(pp::ImageData* image, const pp::Rect& rc, uint32 color); 56 void FillRect(pp::ImageData* image, const pp::Rect& rc, uint32_t color);
54 57
55 // Shadow Matrix contains matrix for shadow rendering. To reduce amount of 58 // Shadow Matrix contains matrix for shadow rendering. To reduce amount of
56 // calculations user may choose to cache matrix and reuse it if nothing changed. 59 // calculations user may choose to cache matrix and reuse it if nothing changed.
57 class ShadowMatrix { 60 class ShadowMatrix {
58 public: 61 public:
59 // Matrix parameters. 62 // Matrix parameters.
60 // depth - how big matrix should be. Shadow will go smoothly across the 63 // depth - how big matrix should be. Shadow will go smoothly across the
61 // entire matrix from black to background color. 64 // entire matrix from black to background color.
62 // If factor == 1, smoothing will be linear from 0 to the end (depth), 65 // If factor == 1, smoothing will be linear from 0 to the end (depth),
63 // if 0 < factor < 1, smoothing will drop faster near 0. 66 // if 0 < factor < 1, smoothing will drop faster near 0.
64 // if factor > 1, smoothing will drop faster near the end (depth). 67 // if factor > 1, smoothing will drop faster near the end (depth).
65 ShadowMatrix(uint32 depth, double factor, uint32 background); 68 ShadowMatrix(uint32_t depth, double factor, uint32_t background);
66 69
67 ~ShadowMatrix(); 70 ~ShadowMatrix();
68 71
69 uint32 GetValue(int32 x, int32 y) const { return matrix_[y * depth_ + x]; } 72 uint32_t GetValue(int32_t x, int32_t y) const {
73 return matrix_[y * depth_ + x];
74 }
70 75
71 uint32 depth() const { return depth_; } 76 uint32_t depth() const { return depth_; }
72 double factor() const { return factor_; } 77 double factor() const { return factor_; }
73 uint32 background() const { return background_; } 78 uint32_t background() const { return background_; }
74 79
75 private: 80 private:
76 uint32 depth_; 81 uint32_t depth_;
77 double factor_; 82 double factor_;
78 uint32 background_; 83 uint32_t background_;
79 std::vector<uint32> matrix_; 84 std::vector<uint32_t> matrix_;
80 }; 85 };
81 86
82 // Draw shadow on the image using provided ShadowMatrix. 87 // Draw shadow on the image using provided ShadowMatrix.
83 // shadow_rc - rectangle occupied by shadow 88 // shadow_rc - rectangle occupied by shadow
84 // object_rc - rectangle that drops the shadow 89 // object_rc - rectangle that drops the shadow
85 // clip_rc - clipping region 90 // clip_rc - clipping region
86 void DrawShadow(pp::ImageData* image, 91 void DrawShadow(pp::ImageData* image,
87 const pp::Rect& shadow_rc, 92 const pp::Rect& shadow_rc,
88 const pp::Rect& object_rc, 93 const pp::Rect& object_rc,
89 const pp::Rect& clip_rc, 94 const pp::Rect& clip_rc,
90 const ShadowMatrix& matrix); 95 const ShadowMatrix& matrix);
91 96
92 } // namespace chrome_pdf 97 } // namespace chrome_pdf
93 98
94 #endif // PDF_DRAW_UTILS_H_ 99 #endif // PDF_DRAW_UTILS_H_
OLDNEW
« no previous file with comments | « pdf/document_loader.cc ('k') | pdf/draw_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698