Skip to content

Commit

Permalink
[vr] Measure text render performance if rerendered every run
Browse files Browse the repository at this point in the history
This perf test rerenders the text texture for every run even though the
text did not change.

Change-Id: I58454a6698a2a71d082a4476a961d02991963ae3
Reviewed-on: https://chromium-review.googlesource.com/728717
Commit-Queue: Tibor Goldschwendt <[email protected]>
Reviewed-by: Christopher Grant <[email protected]>
Cr-Commit-Position: refs/heads/master@{#510439}
  • Loading branch information
Tibor Goldschwendt authored and Commit Bot committed Oct 20, 2017
1 parent f82653a commit 6f8cbe2
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
10 changes: 9 additions & 1 deletion chrome/browser/vr/elements/textured_element.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ namespace vr {

namespace {
static bool g_initialized_for_testing_ = false;
static bool g_rerender_if_not_dirty_for_testing_ = false;
}

TexturedElement::TexturedElement(int maximum_width)
Expand All @@ -36,8 +37,15 @@ void TexturedElement::SetInitializedForTesting() {
g_initialized_for_testing_ = true;
}

// static
void TexturedElement::SetRerenderIfNotDirtyForTesting() {
g_rerender_if_not_dirty_for_testing_ = true;
}

bool TexturedElement::UpdateTexture() {
if (!initialized_ || !GetTexture()->dirty() || !IsVisible())
if (!initialized_ ||
!(GetTexture()->dirty() || g_rerender_if_not_dirty_for_testing_) ||
!IsVisible())
return false;
sk_sp<SkSurface> surface = SkSurface::MakeRasterN32Premul(
texture_size_.width(), texture_size_.height());
Expand Down
1 change: 1 addition & 0 deletions chrome/browser/vr/elements/textured_element.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class TexturedElement : public UiElement {
const gfx::Transform& model_view_proj_matrix) const final;

static void SetInitializedForTesting();
static void SetRerenderIfNotDirtyForTesting();

protected:
virtual UiTexture* GetTexture() const = 0;
Expand Down
22 changes: 22 additions & 0 deletions chrome/browser/vr/text_perftest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,26 @@ TEST_F(TextPerfTest, RenderLoremIpsum700Chars) {
PrintResults("render_lorem_ipsum_700_chars");
}

TEST_F(TextPerfTest, RenderLoremIpsum100Chars_NoTextChange) {
base::string16 text = base::UTF8ToUTF16(kLoremIpsum100Chars);
text_element_->SetText(text);
TexturedElement::SetRerenderIfNotDirtyForTesting();
timer_.Reset();
for (size_t i = 0; i < kNumberOfRuns; i++) {
RenderAndLapTimer();
}
PrintResults("render_lorem_ipsum_100_chars_no_text_change");
}

TEST_F(TextPerfTest, RenderLoremIpsum700Chars_NoTextChange) {
base::string16 text = base::UTF8ToUTF16(kLoremIpsum700Chars);
text_element_->SetText(text);
TexturedElement::SetRerenderIfNotDirtyForTesting();
timer_.Reset();
for (size_t i = 0; i < kNumberOfRuns; i++) {
RenderAndLapTimer();
}
PrintResults("render_lorem_ipsum_700_chars_no_text_change");
}

} // namespace vr

0 comments on commit 6f8cbe2

Please sign in to comment.