Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(198)

Side by Side Diff: cc/resources/texture_compressor_etc1_unittest.cc

Issue 1096703002: Reland: Add ETC1 powered SSE encoder for tile texture compression (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reland: Change ia32 to x86 in Build.gn Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 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.
4
5 #include "cc/resources/texture_compressor.h"
6
7 #include "cc/base/util.h"
8 #include "testing/gtest/include/gtest/gtest.h"
9
10 namespace cc {
11 namespace {
12
13 const int kImageWidth = 256;
14 const int kImageHeight = 256;
15 const int kImageChannels = 4;
16 const int kImageSizeInBytes = kImageWidth * kImageHeight * kImageChannels;
17
18 TEST(TextureCompressorETC1Test, Compress256x256Ratio) {
19 scoped_ptr<TextureCompressor> compressor =
20 TextureCompressor::Create(TextureCompressor::kFormatETC1);
21 uint8_t src[kImageSizeInBytes];
22 uint8_t dst[kImageSizeInBytes];
23 const unsigned int kImagePoison = 0xDEADBEEF;
24
25 // Poison destination bytes so we can see how much has been
26 // overwritten by compression algorithm.
27 uint32_t* dst_32 = reinterpret_cast<uint32_t*>(dst);
28 for (int i = 0; i < kImageWidth * kImageHeight; i++) {
29 dst_32[i] = kImagePoison;
30 }
31
32 // Generate test texture.
33 for (int i = 0; i < kImageSizeInBytes; i++) {
34 src[i] = i % 256;
35 }
36
37 compressor->Compress(src, dst, kImageWidth, kImageHeight,
38 TextureCompressor::kQualityLow);
39
40 int compressed_size = 0;
41 for (compressed_size = 0; compressed_size < kImageWidth * kImageHeight;
42 compressed_size++) {
43 if (dst_32[compressed_size] == kImagePoison) {
44 // Represents size in bytes of the compressed block.
45 compressed_size = compressed_size * 4;
46 break;
47 }
48 }
49
50 // Check if compression ratio is 8:1 for RGBA or BGRA images, after discarding
51 // alpha channel.
52 EXPECT_EQ(kImageSizeInBytes, compressed_size * 8);
53 }
54
55 } // namespace
56 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698