Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ vars = {
# Three lines of non-changing comments so that
# the commit queue can handle CLs rolling code_coverage
# and whatever else without interference from each other.
'code_coverage_revision': 'a81032f8d6f57774af865e502c5661cf24780ca2',
'code_coverage_revision': '084f00efb99dc9a1726ed68cc2e05d25bc52802b',
# Three lines of non-changing comments so that
# the commit queue can handle CLs rolling cpu_features
# and whatever else without interference from each other.
Expand Down Expand Up @@ -228,7 +228,7 @@ vars = {
# Three lines of non-changing comments so that
# the commit queue can handle CLs rolling pdfium_tests
# and whatever else without interference from each other.
'pdfium_tests_revision': '86219637fec25a23f5f87252b3bd156ff9ca848e',
'pdfium_tests_revision': 'f7a1d03ba45e874b7d3cdf722959a2b8ba4dbfa5',
# Three lines of non-changing comments so that
# the commit queue can handle CLs rolling result_adapter_revision
# and whatever else without interference from each other.
Expand Down
3 changes: 2 additions & 1 deletion core/fpdfapi/page/cpdf_page.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,10 @@ class CPDF_Page final : public IPDF_Page, public CPDF_PageObjectHolder {
virtual ~RenderContextIface() = default;
};

class RenderContextClearer {
class [[maybe_unused, nodiscard]] RenderContextClearer {
public:
FX_STACK_ALLOCATED();

explicit RenderContextClearer(CPDF_Page* pPage);
~RenderContextClearer();

Expand Down
2 changes: 1 addition & 1 deletion core/fpdfapi/parser/cpdf_document.h
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ class CPDF_Document : public Observable,
private:
// EmbedPDF(measurement): see GetMeasureStorage().
std::unique_ptr<CPDF_MeasureStorage> measure_storage_;
class StockFontClearer {
class [[maybe_unused, nodiscard]] StockFontClearer {
public:
FX_STACK_ALLOCATED();

Expand Down
2 changes: 1 addition & 1 deletion core/fpdfapi/parser/cpdf_read_validator.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

class CPDF_ReadValidator final : public IFX_SeekableReadStream {
public:
class ScopedSession {
class [[maybe_unused, nodiscard]] ScopedSession {
public:
FX_STACK_ALLOCATED();

Expand Down
22 changes: 14 additions & 8 deletions core/fpdfapi/render/cpdf_rendershading.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,24 +139,30 @@ void DrawAxialShading(const RetainPtr<CFX_DIBitmap>& pBitmap,
float x_span = end_x - start_x;
float y_span = end_y - start_y;
float axis_len_square = (x_span * x_span) + (y_span * y_span);
if (axis_len_square == 0.0f) {
return;
}

std::array<FX_ARGB, kShadingSteps> shading_steps;
if (!GetShadingSteps(t_min, t_max, funcs, pCS, alpha, &shading_steps)) {
return;
}

CFX_Matrix matrix = mtObject2Bitmap.GetInverse();
const CFX_Matrix matrix = mtObject2Bitmap.GetInverse();
const float delta_num = (matrix.a * x_span) + (matrix.b * y_span);
const float delta_scale = delta_num / axis_len_square;
for (int row = 0; row < height; row++) {
auto dest_buf = pBitmap->GetWritableScanlineAs<uint32_t>(row).first(
static_cast<size_t>(width));
size_t column_counter = 0;
const CFX_PointF pos =
matrix.Transform(CFX_PointF(0.0f, static_cast<float>(row)));
const float num_0 =
((pos.x - start_x) * x_span) + ((pos.y - start_y) * y_span);
const float scale_0 = num_0 / axis_len_square;
float column = 0.0f;
for (auto& pix : dest_buf) {
const float column = static_cast<float>(column_counter++);
const CFX_PointF pos =
matrix.Transform(CFX_PointF(column, static_cast<float>(row)));
float scale =
(((pos.x - start_x) * x_span) + ((pos.y - start_y) * y_span)) /
axis_len_square;
const float scale = scale_0 + (column * delta_scale);
++column;
int index = static_cast<int32_t>(scale * (kShadingSteps - 1));
if (index < 0) {
if (!bStartExtend) {
Expand Down
2 changes: 1 addition & 1 deletion core/fpdfdoc/cpdf_formfield_unittest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace {

// Create and destroys the page module that is necessary when instantiating a
// CPDF_Document.
class ScopedCPDF_PageModule {
class [[maybe_unused, nodiscard]] ScopedCPDF_PageModule {
public:
FX_STACK_ALLOCATED();

Expand Down
2 changes: 1 addition & 1 deletion core/fxcrt/autonuller.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace fxcrt {

template <typename T>
class AutoNuller {
class [[maybe_unused, nodiscard]] AutoNuller {
public:
FX_STACK_ALLOCATED();

Expand Down
18 changes: 11 additions & 7 deletions core/fxcrt/autorestorer.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,39 @@
#ifndef CORE_FXCRT_AUTORESTORER_H_
#define CORE_FXCRT_AUTORESTORER_H_

#include <type_traits>
#include <utility>

#include "core/fxcrt/fx_memory.h"
#include "core/fxcrt/unowned_ptr.h"

namespace fxcrt {

template <typename T>
class AutoRestorer {
class [[maybe_unused, nodiscard]] AutoRestorer {
public:
FX_STACK_ALLOCATED();

explicit AutoRestorer(T* location)
: location_(location), old_value_(*location) {}

AutoRestorer(T* location, const T& new_value)
: location_(location), old_value_(*location) {
*location = new_value;
}
template <typename U>
requires std::is_assignable_v<T&, U>
AutoRestorer(T* location, U&& new_value)
: location_(location),
old_value_(std::exchange(*location, std::forward<U>(new_value))) {}

~AutoRestorer() {
if (location_) {
*location_ = old_value_;
*location_ = std::move(old_value_);
}
}

void AbandonRestoration() { location_ = nullptr; }

private:
UnownedPtr<T> location_;
const T old_value_;
T old_value_;
};

} // namespace fxcrt
Expand Down
Loading