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

Side by Side Diff: skia/ext/analysis_canvas_unittest.cc

Issue 126343003: Revert of cc: Combine analysis and raster (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « skia/ext/analysis_canvas.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 {
11 11
12 void SolidColorFill(skia::AnalysisCanvas& canvas) { 12 void SolidColorFill(skia::AnalysisCanvas& canvas) {
13 canvas.clear(SkColorSetARGB(255, 255, 255, 255)); 13 canvas.clear(SkColorSetARGB(255, 255, 255, 255));
14 } 14 }
15 15
16 void TransparentFill(skia::AnalysisCanvas& canvas) { 16 void TransparentFill(skia::AnalysisCanvas& canvas) {
17 canvas.clear(SkColorSetARGB(0, 0, 0, 0)); 17 canvas.clear(SkColorSetARGB(0, 0, 0, 0));
18 } 18 }
19 19
20 } // namespace 20 } // namespace
21
22 namespace skia { 21 namespace skia {
23 22
24 TEST(AnalysisCanvasTest, EmptyCanvas) { 23 TEST(AnalysisCanvasTest, EmptyCanvas) {
25 SkBitmap emptyBitmap; 24 SkBitmap emptyBitmap;
26 emptyBitmap.setConfig(SkBitmap::kNo_Config, 255, 255); 25 emptyBitmap.setConfig(SkBitmap::kNo_Config, 255, 255);
27 skia::AnalysisDevice device(emptyBitmap); 26 skia::AnalysisDevice device(emptyBitmap);
28 skia::AnalysisCanvas canvas(&device); 27 skia::AnalysisCanvas canvas(&device);
29 28
30 SkColor color; 29 SkColor color;
31 EXPECT_TRUE(canvas.GetColorIfSolid(&color)); 30 EXPECT_TRUE(canvas.GetColorIfSolid(&color));
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 EXPECT_TRUE(canvas.HasText()); 335 EXPECT_TRUE(canvas.HasText());
337 } 336 }
338 { 337 {
339 // Test SkCanvas::drawTextOnPath. 338 // Test SkCanvas::drawTextOnPath.
340 skia::AnalysisDevice device(bitmap); 339 skia::AnalysisDevice device(bitmap);
341 skia::AnalysisCanvas canvas(&device); 340 skia::AnalysisCanvas canvas(&device);
342 canvas.drawTextOnPath(text, byteLength, path, NULL, paint); 341 canvas.drawTextOnPath(text, byteLength, path, NULL, paint);
343 EXPECT_TRUE(canvas.HasText()); 342 EXPECT_TRUE(canvas.HasText());
344 } 343 }
345 { 344 {
345 // Text under opaque rect.
346 skia::AnalysisDevice device(bitmap);
347 skia::AnalysisCanvas canvas(&device);
348 canvas.drawText(text, byteLength, point.fX, point.fY, paint);
349 EXPECT_TRUE(canvas.HasText());
350 canvas.drawRect(SkRect::MakeWH(width, height), paint);
351 EXPECT_FALSE(canvas.HasText());
352 }
353 {
346 // Text under translucent rect. 354 // Text under translucent rect.
347 skia::AnalysisDevice device(bitmap); 355 skia::AnalysisDevice device(bitmap);
348 skia::AnalysisCanvas canvas(&device); 356 skia::AnalysisCanvas canvas(&device);
349 canvas.drawText(text, byteLength, point.fX, point.fY, paint); 357 canvas.drawText(text, byteLength, point.fX, point.fY, paint);
350 EXPECT_TRUE(canvas.HasText()); 358 EXPECT_TRUE(canvas.HasText());
351 SkPaint translucentPaint; 359 SkPaint translucentPaint;
352 translucentPaint.setColor(0x88FFFFFF); 360 translucentPaint.setColor(0x88FFFFFF);
353 canvas.drawRect(SkRect::MakeWH(width, height), translucentPaint); 361 canvas.drawRect(SkRect::MakeWH(width, height), translucentPaint);
354 EXPECT_TRUE(canvas.HasText()); 362 EXPECT_TRUE(canvas.HasText());
355 } 363 }
356 { 364 {
365 // Text under rect in clear mode.
366 skia::AnalysisDevice device(bitmap);
367 skia::AnalysisCanvas canvas(&device);
368 canvas.drawText(text, byteLength, point.fX, point.fY, paint);
369 EXPECT_TRUE(canvas.HasText());
370 SkPaint clearModePaint;
371 clearModePaint.setXfermodeMode(SkXfermode::kClear_Mode);
372 canvas.drawRect(SkRect::MakeWH(width, height), clearModePaint);
373 EXPECT_FALSE(canvas.HasText());
374 }
375 {
357 // Clear. 376 // Clear.
358 skia::AnalysisDevice device(bitmap); 377 skia::AnalysisDevice device(bitmap);
359 skia::AnalysisCanvas canvas(&device); 378 skia::AnalysisCanvas canvas(&device);
360 canvas.drawText(text, byteLength, point.fX, point.fY, paint); 379 canvas.drawText(text, byteLength, point.fX, point.fY, paint);
361 EXPECT_TRUE(canvas.HasText()); 380 EXPECT_TRUE(canvas.HasText());
362 canvas.clear(SK_ColorGRAY); 381 canvas.clear(SK_ColorGRAY);
363 EXPECT_FALSE(canvas.HasText()); 382 EXPECT_FALSE(canvas.HasText());
364 } 383 }
365 { 384 {
366 // Text inside clip region. 385 // Text inside clip region.
(...skipping 11 matching lines...) Expand all
378 canvas.drawText(text, byteLength, point.fX, point.fY, paint); 397 canvas.drawText(text, byteLength, point.fX, point.fY, paint);
379 // Analysis device does not do any clipping. 398 // Analysis device does not do any clipping.
380 // So even when text is outside the clip region, 399 // So even when text is outside the clip region,
381 // it is marked as having the text. 400 // it is marked as having the text.
382 // TODO(alokp): We may be able to do some trivial rejection. 401 // TODO(alokp): We may be able to do some trivial rejection.
383 EXPECT_TRUE(canvas.HasText()); 402 EXPECT_TRUE(canvas.HasText());
384 } 403 }
385 } 404 }
386 405
387 } // namespace skia 406 } // namespace skia
OLDNEW
« no previous file with comments | « skia/ext/analysis_canvas.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698