| 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 "skia/ext/refptr.h" | 7 #include "skia/ext/refptr.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 #include "third_party/skia/include/core/SkPicture.h" | 9 #include "third_party/skia/include/core/SkPicture.h" |
| 10 #include "third_party/skia/include/core/SkPictureRecorder.h" | 10 #include "third_party/skia/include/core/SkPictureRecorder.h" |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 | 338 |
| 339 SkPaint paint; | 339 SkPaint paint; |
| 340 paint.setColor(SkColorSetARGB(255, 255, 255, 255)); | 340 paint.setColor(SkColorSetARGB(255, 255, 255, 255)); |
| 341 paint.setXfermodeMode(SkXfermode::kSrcOver_Mode); | 341 paint.setXfermodeMode(SkXfermode::kSrcOver_Mode); |
| 342 | 342 |
| 343 record_canvas->drawRect(SkRect::MakeWH(256, 256), paint); | 343 record_canvas->drawRect(SkRect::MakeWH(256, 256), paint); |
| 344 record_canvas->drawRect(SkRect::MakeWH(256, 256), paint); | 344 record_canvas->drawRect(SkRect::MakeWH(256, 256), paint); |
| 345 record_canvas->drawText( | 345 record_canvas->drawText( |
| 346 text.c_str(), text.length(), point.fX, point.fY, paint); | 346 text.c_str(), text.length(), point.fX, point.fY, paint); |
| 347 | 347 |
| 348 skia::RefPtr<SkPicture> picture = | 348 sk_sp<SkPicture> picture = recorder.finishRecordingAsPicture(); |
| 349 skia::AdoptRef(recorder.endRecordingAsPicture()); | |
| 350 | 349 |
| 351 // Draw the picture into the analysis canvas, using the canvas as a callback | 350 // Draw the picture into the analysis canvas, using the canvas as a callback |
| 352 // as well. | 351 // as well. |
| 353 skia::AnalysisCanvas canvas(256, 256); | 352 skia::AnalysisCanvas canvas(256, 256); |
| 354 picture->playback(&canvas, &canvas); | 353 picture->playback(&canvas, &canvas); |
| 355 | 354 |
| 356 // Ensure that canvas is not solid. | 355 // Ensure that canvas is not solid. |
| 357 SkColor output_color; | 356 SkColor output_color; |
| 358 EXPECT_FALSE(canvas.GetColorIfSolid(&output_color)); | 357 EXPECT_FALSE(canvas.GetColorIfSolid(&output_color)); |
| 359 | 358 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 386 EXPECT_FALSE(canvas.GetColorIfSolid(&outputColor)); | 385 EXPECT_FALSE(canvas.GetColorIfSolid(&outputColor)); |
| 387 | 386 |
| 388 canvas.restore(); | 387 canvas.restore(); |
| 389 EXPECT_FALSE(canvas.GetColorIfSolid(&outputColor)); | 388 EXPECT_FALSE(canvas.GetColorIfSolid(&outputColor)); |
| 390 | 389 |
| 391 SolidColorFill(canvas); | 390 SolidColorFill(canvas); |
| 392 EXPECT_FALSE(canvas.GetColorIfSolid(&outputColor)); | 391 EXPECT_FALSE(canvas.GetColorIfSolid(&outputColor)); |
| 393 } | 392 } |
| 394 | 393 |
| 395 } // namespace skia | 394 } // namespace skia |
| OLD | NEW |