Commit 1a59b378 authored by Lei Zhang's avatar Lei Zhang Committed by Commit Bot

Clean up pdf/draw_utils/shadow.h.

Forward declare some classes and move bits not needed into the header
into shadow.cc.

Change-Id: I1b54966a2e1619be64951a58e6ac6ca0a8b705ee
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1696387
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: default avatarHenrique Nakashima <hnakashima@chromium.org>
Cr-Commit-Position: refs/heads/master@{#676464}
parent eaac3145
...@@ -6,14 +6,18 @@ ...@@ -6,14 +6,18 @@
#include <math.h> #include <math.h>
#include <stddef.h> #include <stddef.h>
#include <stdint.h>
#include <algorithm> #include <algorithm>
#include <vector>
#include "base/logging.h" #include "base/logging.h"
#include "base/numerics/safe_math.h" #include "ppapi/cpp/image_data.h"
#include "ppapi/cpp/rect.h"
namespace chrome_pdf { namespace chrome_pdf {
namespace draw_utils {
constexpr uint8_t kOpaqueAlpha = 0xFF;
constexpr uint8_t kTransparentAlpha = 0x00;
inline uint8_t GetBlue(const uint32_t& pixel) { inline uint8_t GetBlue(const uint32_t& pixel) {
return static_cast<uint8_t>(pixel & 0xFF); return static_cast<uint8_t>(pixel & 0xFF);
...@@ -169,4 +173,5 @@ void DrawShadow(pp::ImageData* image, ...@@ -169,4 +173,5 @@ void DrawShadow(pp::ImageData* image,
PaintShadow(image, rc.Intersect(clip_rc), shadow_rc, matrix); PaintShadow(image, rc.Intersect(clip_rc), shadow_rc, matrix);
} }
} // namespace draw_utils
} // namespace chrome_pdf } // namespace chrome_pdf
...@@ -9,13 +9,13 @@ ...@@ -9,13 +9,13 @@
#include <vector> #include <vector>
#include "ppapi/cpp/image_data.h" namespace pp {
#include "ppapi/cpp/rect.h" class ImageData;
class Rect;
} // namespace pp
namespace chrome_pdf { namespace chrome_pdf {
namespace draw_utils {
const uint8_t kOpaqueAlpha = 0xFF;
const uint8_t kTransparentAlpha = 0x00;
// Shadow Matrix contains matrix for shadow rendering. To reduce amount of // Shadow Matrix contains matrix for shadow rendering. To reduce amount of
// calculations user may choose to cache matrix and reuse it if nothing changed. // calculations user may choose to cache matrix and reuse it if nothing changed.
...@@ -52,6 +52,7 @@ void DrawShadow(pp::ImageData* image, ...@@ -52,6 +52,7 @@ void DrawShadow(pp::ImageData* image,
const pp::Rect& clip_rc, const pp::Rect& clip_rc,
const ShadowMatrix& matrix); const ShadowMatrix& matrix);
} // namespace draw_utils
} // namespace chrome_pdf } // namespace chrome_pdf
#endif // PDF_DRAW_UTILS_SHADOW_H_ #endif // PDF_DRAW_UTILS_SHADOW_H_
...@@ -3367,8 +3367,8 @@ void PDFiumEngine::DrawPageShadow(const pp::Rect& page_rc, ...@@ -3367,8 +3367,8 @@ void PDFiumEngine::DrawPageShadow(const pp::Rect& page_rc,
depth = static_cast<uint32_t>(depth * 1.5) + 1; depth = static_cast<uint32_t>(depth * 1.5) + 1;
// We need to check depth only to verify our copy of shadow matrix is correct. // We need to check depth only to verify our copy of shadow matrix is correct.
if (!page_shadow_.get() || page_shadow_->depth() != depth) { if (!page_shadow_ || page_shadow_->depth() != depth) {
page_shadow_ = std::make_unique<ShadowMatrix>( page_shadow_ = std::make_unique<draw_utils::ShadowMatrix>(
depth, factor, client_->GetBackgroundColor()); depth, factor, client_->GetBackgroundColor());
} }
......
...@@ -38,7 +38,10 @@ ...@@ -38,7 +38,10 @@
namespace chrome_pdf { namespace chrome_pdf {
class PDFiumDocument; class PDFiumDocument;
namespace draw_utils {
class ShadowMatrix; class ShadowMatrix;
}
class PDFiumEngine : public PDFEngine, class PDFiumEngine : public PDFEngine,
public DocumentLoader::Client, public DocumentLoader::Client,
...@@ -649,7 +652,7 @@ class PDFiumEngine : public PDFEngine, ...@@ -649,7 +652,7 @@ class PDFiumEngine : public PDFEngine,
base::TimeDelta progressive_paint_timeout_; base::TimeDelta progressive_paint_timeout_;
// Shadow matrix for generating the page shadow bitmap. // Shadow matrix for generating the page shadow bitmap.
std::unique_ptr<ShadowMatrix> page_shadow_; std::unique_ptr<draw_utils::ShadowMatrix> page_shadow_;
// While true, the document try to be opened and parsed after download each // While true, the document try to be opened and parsed after download each
// part. Else the document will be opened and parsed only on finish of // part. Else the document will be opened and parsed only on finish of
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment