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

Unified Diff: tests/SerializationTest.cpp

Issue 2043393002: Refactoring of GPU NormalMap handling out into its own class (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: Fixed SK_API flags, got rid of NormalMapSource::Make Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/ports/SkGlobalInitialization_default.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/SerializationTest.cpp
diff --git a/tests/SerializationTest.cpp b/tests/SerializationTest.cpp
index 9e9b221cd287800c74dd8c19cde24c1273092610..e4e1a7acd7b0e0f1a408362ca846ccaadfac55ca 100644
--- a/tests/SerializationTest.cpp
+++ b/tests/SerializationTest.cpp
@@ -5,13 +5,14 @@
* found in the LICENSE file.
*/
-#include "SkAnnotationKeys.h"
#include "Resources.h"
+#include "SkAnnotationKeys.h"
#include "SkCanvas.h"
#include "SkFixed.h"
#include "SkFontDescriptor.h"
#include "SkImage.h"
#include "SkImageSource.h"
+#include "SkLightingShader.h"
#include "SkMallocPixelRef.h"
#include "SkOSFile.h"
#include "SkPictureRecorder.h"
@@ -21,6 +22,7 @@
#include "SkWriteBuffer.h"
#include "SkValidatingReadBuffer.h"
#include "SkXfermodeImageFilter.h"
+#include "sk_tool_utils.h"
#include "Test.h"
static const uint32_t kArraySize = 64;
@@ -182,8 +184,8 @@ static T* TestFlattenableSerialization(T* testObj, bool shouldSucceed,
size_t bytesWritten = writer.bytesWritten();
REPORTER_ASSERT(reporter, SkAlign4(bytesWritten) == bytesWritten);
+ SkASSERT(bytesWritten <= 4096);
unsigned char dataWritten[4096];
- SkASSERT(bytesWritten <= sizeof(dataWritten));
writer.writeToMemory(dataWritten);
// Make sure this fails when it should (test with smaller size, but still multiple of 4)
@@ -546,6 +548,43 @@ DEF_TEST(Serialization, reporter) {
}
TestPictureTypefaceSerialization(reporter);
+
+ // Test SkLightingShader/NormalMapSource serialization
+ {
+ const int kTexSize = 2;
+
+ SkLights::Builder builder;
+
+ builder.add(SkLights::Light(SkColor3f::Make(1.0f, 1.0f, 1.0f),
+ SkVector3::Make(1.0f, 0.0f, 0.0f)));
+ builder.add(SkLights::Light(SkColor3f::Make(0.2f, 0.2f, 0.2f)));
+
+ sk_sp<SkLights> fLights = builder.finish();
+
+ SkBitmap diffuse = sk_tool_utils::create_checkerboard_bitmap(
+ kTexSize, kTexSize,
+ sk_tool_utils::color_to_565(0x0),
+ sk_tool_utils::color_to_565(0xFF804020),
+ 8);
+
+ SkRect bitmapBounds = SkRect::MakeIWH(diffuse.width(), diffuse.height());
+
+ SkMatrix matrix;
+ SkRect r = SkRect::MakeWH(SkIntToScalar(kTexSize), SkIntToScalar(kTexSize));
+ matrix.setRectToRect(bitmapBounds, r, SkMatrix::kFill_ScaleToFit);
+
+ SkVector invNormRotation = { SkScalarSqrt(0.3f), SkScalarSqrt(0.7f) };
+ SkBitmap normals;
+ normals.allocN32Pixels(kTexSize, kTexSize);
+
+ sk_tool_utils::create_frustum_normal_map(&normals, SkIRect::MakeWH(kTexSize, kTexSize));
+ sk_sp<SkShader> lightingShader = SkLightingShader::Make(diffuse, normals, fLights,
+ invNormRotation, &matrix, &matrix);
+
+ SkAutoTUnref<SkShader>(TestFlattenableSerialization(lightingShader.get(), true, reporter));
+ // TODO test equality?
+
+ }
}
///////////////////////////////////////////////////////////////////////////////////////////////////
« no previous file with comments | « src/ports/SkGlobalInitialization_default.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698