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.
5 #ifndef PDF_DRAW_UTILS_H_
6 #define PDF_DRAW_UTILS_H_
12 #include "ppapi/cpp/image_data.h"
13 #include "ppapi/cpp/rect.h"
15 namespace chrome_pdf {
17 const uint8_t kOpaqueAlpha = 0xFF;
18 const uint8_t kTransparentAlpha = 0x00;
20 // Shadow Matrix contains matrix for shadow rendering. To reduce amount of
21 // calculations user may choose to cache matrix and reuse it if nothing changed.
25 // depth - how big matrix should be. Shadow will go smoothly across the
26 // entire matrix from black to background color.
27 // If factor == 1, smoothing will be linear from 0 to the end (depth),
28 // if 0 < factor < 1, smoothing will drop faster near 0.
29 // if factor > 1, smoothing will drop faster near the end (depth).
30 ShadowMatrix(uint32_t depth, double factor, uint32_t background);
34 uint32_t GetValue(int32_t x, int32_t y) const {
35 return matrix_[y * depth_ + x];
38 uint32_t depth() const { return depth_; }
41 const uint32_t depth_;
42 std::vector<uint32_t> matrix_;
45 // Draw shadow on the image using provided ShadowMatrix.
46 // shadow_rc - rectangle occupied by shadow
47 // object_rc - rectangle that drops the shadow
48 // clip_rc - clipping region
49 void DrawShadow(pp::ImageData* image,
50 const pp::Rect& shadow_rc,
51 const pp::Rect& object_rc,
52 const pp::Rect& clip_rc,
53 const ShadowMatrix& matrix);
55 } // namespace chrome_pdf
57 #endif // PDF_DRAW_UTILS_H_