OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/compiler_specific.h" | 5 #include "base/compiler_specific.h" |
6 #include "skia/ext/analysis_canvas.h" | 6 #include "skia/ext/analysis_canvas.h" |
7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 #include "third_party/skia/include/core/SkShader.h" | 8 #include "third_party/skia/include/core/SkShader.h" |
9 | 9 |
10 namespace { | 10 namespace { |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 canvas.translate(128, 128); | 172 canvas.translate(128, 128); |
173 color = SkColorSetARGB(255, 11, 22, 33); | 173 color = SkColorSetARGB(255, 11, 22, 33); |
174 paint.setColor(color); | 174 paint.setColor(color); |
175 paint.setXfermodeMode(SkXfermode::kSrcOver_Mode); | 175 paint.setXfermodeMode(SkXfermode::kSrcOver_Mode); |
176 canvas.drawRect(SkRect::MakeWH(255, 255), paint); | 176 canvas.drawRect(SkRect::MakeWH(255, 255), paint); |
177 | 177 |
178 EXPECT_TRUE(canvas.getColorIfSolid(&outputColor)); | 178 EXPECT_TRUE(canvas.getColorIfSolid(&outputColor)); |
179 EXPECT_NE(static_cast<SkColor>(SK_ColorTRANSPARENT), outputColor); | 179 EXPECT_NE(static_cast<SkColor>(SK_ColorTRANSPARENT), outputColor); |
180 EXPECT_EQ(color, outputColor); | 180 EXPECT_EQ(color, outputColor); |
181 | 181 |
182 // Paint with the same color, tile should remain solid. | |
183 canvas.rotate(50); | 182 canvas.rotate(50); |
184 canvas.drawRect(SkRect::MakeWH(255, 255), paint); | 183 canvas.drawRect(SkRect::MakeWH(255, 255), paint); |
185 | 184 |
186 EXPECT_TRUE(canvas.getColorIfSolid(&outputColor)); | |
187 EXPECT_EQ(color, outputColor); | |
188 | |
189 color = SkColorSetARGB(255, 12, 23, 34); | |
190 paint.setColor(color); | |
191 paint.setXfermodeMode(SkXfermode::kSrcOver_Mode); | |
192 canvas.drawRect(SkRect::MakeWH(255, 255), paint); | |
193 EXPECT_FALSE(canvas.getColorIfSolid(&outputColor)); | 185 EXPECT_FALSE(canvas.getColorIfSolid(&outputColor)); |
194 } | 186 } |
195 | 187 |
196 TEST(AnalysisCanvasTest, ClipPath) { | 188 TEST(AnalysisCanvasTest, ClipPath) { |
197 SkBitmap emptyBitmap; | 189 SkBitmap emptyBitmap; |
198 emptyBitmap.setConfig(SkBitmap::kNo_Config, 255, 255); | 190 emptyBitmap.setConfig(SkBitmap::kNo_Config, 255, 255); |
199 skia::AnalysisDevice device(emptyBitmap); | 191 skia::AnalysisDevice device(emptyBitmap); |
200 skia::AnalysisCanvas canvas(&device); | 192 skia::AnalysisCanvas canvas(&device); |
201 | 193 |
202 SkPath path; | 194 SkPath path; |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 canvas.drawText(text, byteLength, point.fX, point.fY, paint); | 396 canvas.drawText(text, byteLength, point.fX, point.fY, paint); |
405 // Analysis device does not do any clipping. | 397 // Analysis device does not do any clipping. |
406 // So even when text is outside the clip region, | 398 // So even when text is outside the clip region, |
407 // it is marked as having the text. | 399 // it is marked as having the text. |
408 // TODO(alokp): We may be able to do some trivial rejection. | 400 // TODO(alokp): We may be able to do some trivial rejection. |
409 EXPECT_TRUE(canvas.hasText()); | 401 EXPECT_TRUE(canvas.hasText()); |
410 } | 402 } |
411 } | 403 } |
412 | 404 |
413 } // namespace skia | 405 } // namespace skia |
OLD | NEW |