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

Side by Side Diff: pdf/draw_utils.h

Issue 294793003: Add the pdf plugin's source in src\pdf. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: review comments and sync past DEPS roll to fix gyp Created 6 years, 7 months 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 | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef PDF_DRAW_UTILS_H_
6 #define PDF_DRAW_UTILS_H_
7
8 #include <vector>
9
10 #include "base/basictypes.h"
11 #include "ppapi/cpp/image_data.h"
12 #include "ppapi/cpp/rect.h"
13
14 namespace chrome_pdf {
15
16 const uint8 kOpaqueAlpha = 0xFF;
17 const uint8 kTransparentAlpha = 0x00;
18
19 bool AlphaBlend(const pp::ImageData& src, const pp::Rect& src_rc,
20 pp::ImageData* dest, const pp::Point& dest_origin,
21 uint8 alpha_adjustment);
22
23 // 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
25 // top-right (horizontal==true) or bottom-left (horizontal==false) point.
26 void GradientFill(pp::ImageData* image,
27 const pp::Rect& rc,
28 uint32 start_color,
29 uint32 end_color,
30 bool horizontal);
31
32 // 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
34 // be unchanged.
35 void GradientFill(pp::Instance* instance,
36 pp::ImageData* image,
37 const pp::Rect& dirty_rc,
38 const pp::Rect& gradient_rc,
39 uint32 start_color,
40 uint32 end_color,
41 bool horizontal,
42 uint8 transparency);
43
44 // 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
46 // result image. Copy will ignore all pixels with transparent alpha from the
47 // source image.
48 void CopyImage(const pp::ImageData& src, const pp::Rect& src_rc,
49 pp::ImageData* dest, const pp::Rect& dest_rc,
50 bool stretch);
51
52 // Fill in rectangle with specified color.
53 void FillRect(pp::ImageData* image, const pp::Rect& rc, uint32 color);
54
55 // 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.
57 class ShadowMatrix {
58 public:
59 // Matrix parameters.
60 // depth - how big matrix should be. Shadow will go smoothly across the
61 // entire matrix from black to background color.
62 // If factor == 1, smoothing will be linear from 0 to the end (depth),
63 // if 0 < factor < 1, smoothing will drop faster near 0.
64 // if factor > 1, smoothing will drop faster near the end (depth).
65 ShadowMatrix(uint32 depth, double factor, uint32 background);
66
67 ~ShadowMatrix();
68
69 uint32 GetValue(int32 x, int32 y) const { return matrix_[y * depth_ + x]; }
70
71 uint32 depth() const { return depth_; }
72 double factor() const { return factor_; }
73 uint32 background() const { return background_; }
74
75 private:
76 uint32 depth_;
77 double factor_;
78 uint32 background_;
79 std::vector<uint32> matrix_;
80 };
81
82 // Draw shadow on the image using provided ShadowMatrix.
83 // shadow_rc - rectangle occupied by shadow
84 // object_rc - rectangle that drops the shadow
85 // clip_rc - clipping region
86 void DrawShadow(pp::ImageData* image,
87 const pp::Rect& shadow_rc,
88 const pp::Rect& object_rc,
89 const pp::Rect& clip_rc,
90 const ShadowMatrix& matrix);
91
92 } // namespace chrome_pdf
93
94 #endif // PDF_DRAW_UTILS_H_
OLDNEW
« no previous file with comments | « pdf/document_loader.cc ('k') | pdf/draw_utils.cc » ('j') | pdf/pdf.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698