Skip to content

Commit

Permalink
Bug 1062066 (Part 2) - Add a Downscaler API to clear a row. r=tn
Browse files Browse the repository at this point in the history
  • Loading branch information
sethfowler committed Sep 9, 2015
1 parent ae4622a commit c3bb377
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
10 changes: 10 additions & 0 deletions image/Downscaler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,16 @@ GetFilterOffsetAndLength(UniquePtr<skia::ConvolutionFilter1D>& aFilter,
aFilterLengthOut);
}

void
Downscaler::ClearRow(uint32_t aStartingAtCol)
{
MOZ_ASSERT(int64_t(mOriginalSize.width) > int64_t(aStartingAtCol));
uint32_t bytesToClear = (mOriginalSize.width - aStartingAtCol)
* sizeof(uint32_t);
memset(mRowBuffer.get() + (aStartingAtCol * sizeof(uint32_t)),
0, bytesToClear);
}

void
Downscaler::CommitRow()
{
Expand Down
4 changes: 4 additions & 0 deletions image/Downscaler.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ class Downscaler
/// Retrieves the buffer into which the Decoder should write each row.
uint8_t* RowBuffer() { return mRowBuffer.get(); }

/// Clears the current row buffer (optionally starting at @aStartingAtCol).
void ClearRow(uint32_t aStartingAtCol = 0);

/// Signals that the decoder has finished writing a row into the row buffer.
void CommitRow();

Expand Down Expand Up @@ -150,6 +153,7 @@ class Downscaler
}

uint8_t* RowBuffer() { return nullptr; }
void ClearRow(uint32_t = 0);
void CommitRow() { }
bool HasInvalidation() const { return false; }
DownscalerInvalidRect TakeInvalidRect() { return DownscalerInvalidRect(); }
Expand Down

0 comments on commit c3bb377

Please sign in to comment.