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

Side by Side Diff: cc/test/skia_common.cc

Issue 2640983002: Rename paint data structures (Closed)
Patch Set: DrawingDisplayItem Created 3 years, 10 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
« no previous file with comments | « cc/test/fake_scrollbar.cc ('k') | cc/test/solid_color_content_layer_client.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 "cc/test/skia_common.h" 5 #include "cc/test/skia_common.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "cc/paint/paint_canvas.h"
9 #include "cc/playback/display_item_list.h" 10 #include "cc/playback/display_item_list.h"
10 #include "third_party/skia/include/core/SkCanvas.h"
11 #include "third_party/skia/include/core/SkImageGenerator.h" 11 #include "third_party/skia/include/core/SkImageGenerator.h"
12 #include "third_party/skia/include/core/SkPixmap.h" 12 #include "third_party/skia/include/core/SkPixmap.h"
13 #include "ui/gfx/geometry/rect.h" 13 #include "ui/gfx/geometry/rect.h"
14 #include "ui/gfx/skia_util.h" 14 #include "ui/gfx/skia_util.h"
15 15
16 namespace cc { 16 namespace cc {
17 17
18 namespace { 18 namespace {
19 19
20 class TestImageGenerator : public SkImageGenerator { 20 class TestImageGenerator : public SkImageGenerator {
(...skipping 19 matching lines...) Expand all
40 40
41 } // anonymous namespace 41 } // anonymous namespace
42 42
43 void DrawDisplayList(unsigned char* buffer, 43 void DrawDisplayList(unsigned char* buffer,
44 const gfx::Rect& layer_rect, 44 const gfx::Rect& layer_rect,
45 scoped_refptr<const DisplayItemList> list) { 45 scoped_refptr<const DisplayItemList> list) {
46 SkImageInfo info = 46 SkImageInfo info =
47 SkImageInfo::MakeN32Premul(layer_rect.width(), layer_rect.height()); 47 SkImageInfo::MakeN32Premul(layer_rect.width(), layer_rect.height());
48 SkBitmap bitmap; 48 SkBitmap bitmap;
49 bitmap.installPixels(info, buffer, info.minRowBytes()); 49 bitmap.installPixels(info, buffer, info.minRowBytes());
50 SkCanvas canvas(bitmap); 50 PaintCanvas canvas(bitmap);
51 canvas.clipRect(gfx::RectToSkRect(layer_rect)); 51 canvas.clipRect(gfx::RectToSkRect(layer_rect));
52 list->Raster(&canvas, NULL, layer_rect, 1.0f); 52 list->Raster(&canvas, NULL, layer_rect, 1.0f);
53 } 53 }
54 54
55 bool AreDisplayListDrawingResultsSame(const gfx::Rect& layer_rect, 55 bool AreDisplayListDrawingResultsSame(const gfx::Rect& layer_rect,
56 const DisplayItemList* list_a, 56 const DisplayItemList* list_a,
57 const DisplayItemList* list_b) { 57 const DisplayItemList* list_b) {
58 const size_t pixel_size = 4 * layer_rect.size().GetArea(); 58 const size_t pixel_size = 4 * layer_rect.size().GetArea();
59 59
60 std::unique_ptr<unsigned char[]> pixels_a(new unsigned char[pixel_size]); 60 std::unique_ptr<unsigned char[]> pixels_a(new unsigned char[pixel_size]);
61 std::unique_ptr<unsigned char[]> pixels_b(new unsigned char[pixel_size]); 61 std::unique_ptr<unsigned char[]> pixels_b(new unsigned char[pixel_size]);
62 memset(pixels_a.get(), 0, pixel_size); 62 memset(pixels_a.get(), 0, pixel_size);
63 memset(pixels_b.get(), 0, pixel_size); 63 memset(pixels_b.get(), 0, pixel_size);
64 DrawDisplayList(pixels_a.get(), layer_rect, list_a); 64 DrawDisplayList(pixels_a.get(), layer_rect, list_a);
65 DrawDisplayList(pixels_b.get(), layer_rect, list_b); 65 DrawDisplayList(pixels_b.get(), layer_rect, list_b);
66 66
67 return !memcmp(pixels_a.get(), pixels_b.get(), pixel_size); 67 return !memcmp(pixels_a.get(), pixels_b.get(), pixel_size);
68 } 68 }
69 69
70 sk_sp<SkImage> CreateDiscardableImage(const gfx::Size& size) { 70 sk_sp<SkImage> CreateDiscardableImage(const gfx::Size& size) {
71 return SkImage::MakeFromGenerator(new TestImageGenerator( 71 return SkImage::MakeFromGenerator(new TestImageGenerator(
72 SkImageInfo::MakeN32Premul(size.width(), size.height()))); 72 SkImageInfo::MakeN32Premul(size.width(), size.height())));
73 } 73 }
74 74
75 } // namespace cc 75 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/fake_scrollbar.cc ('k') | cc/test/solid_color_content_layer_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698