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

Side by Side Diff: cc/test/fake_content_layer_client.h

Issue 1900953004: Switch DrawImage to sk_sp<> (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Florin's nit Created 4 years, 8 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
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 #ifndef CC_TEST_FAKE_CONTENT_LAYER_CLIENT_H_ 5 #ifndef CC_TEST_FAKE_CONTENT_LAYER_CLIENT_H_
6 #define CC_TEST_FAKE_CONTENT_LAYER_CLIENT_H_ 6 #define CC_TEST_FAKE_CONTENT_LAYER_CLIENT_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <utility> 10 #include <utility>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
14 #include "cc/layers/content_layer_client.h" 14 #include "cc/layers/content_layer_client.h"
15 #include "third_party/skia/include/core/SkImage.h"
15 #include "third_party/skia/include/core/SkPaint.h" 16 #include "third_party/skia/include/core/SkPaint.h"
17 #include "third_party/skia/include/core/SkRefCnt.h"
16 #include "ui/gfx/geometry/rect.h" 18 #include "ui/gfx/geometry/rect.h"
17 #include "ui/gfx/geometry/rect_f.h" 19 #include "ui/gfx/geometry/rect_f.h"
18 #include "ui/gfx/transform.h" 20 #include "ui/gfx/transform.h"
19 21
20 class SkImage;
21
22 namespace cc { 22 namespace cc {
23 23
24 class FakeContentLayerClient : public ContentLayerClient { 24 class FakeContentLayerClient : public ContentLayerClient {
25 public: 25 public:
26 struct ImageData { 26 struct ImageData {
27 ImageData(const SkImage* image, 27 ImageData(sk_sp<const SkImage> image,
28 const gfx::Point& point, 28 const gfx::Point& point,
29 const SkPaint& paint); 29 const SkPaint& paint);
30 ImageData(const SkImage* image, 30 ImageData(sk_sp<const SkImage> image,
31 const gfx::Transform& transform, 31 const gfx::Transform& transform,
32 const SkPaint& paint); 32 const SkPaint& paint);
33 ImageData(const ImageData& other); 33 ImageData(const ImageData& other);
34 ~ImageData(); 34 ~ImageData();
35 skia::RefPtr<const SkImage> image; 35 sk_sp<const SkImage> image;
36 gfx::Point point; 36 gfx::Point point;
37 gfx::Transform transform; 37 gfx::Transform transform;
38 SkPaint paint; 38 SkPaint paint;
39 }; 39 };
40 40
41 FakeContentLayerClient(); 41 FakeContentLayerClient();
42 ~FakeContentLayerClient() override; 42 ~FakeContentLayerClient() override;
43 43
44 gfx::Rect PaintableRegion() override; 44 gfx::Rect PaintableRegion() override;
45 scoped_refptr<DisplayItemList> PaintContentsToDisplayList( 45 scoped_refptr<DisplayItemList> PaintContentsToDisplayList(
(...skipping 10 matching lines...) Expand all
56 } 56 }
57 57
58 void add_draw_rect(const gfx::Rect& rect, const SkPaint& paint) { 58 void add_draw_rect(const gfx::Rect& rect, const SkPaint& paint) {
59 draw_rects_.push_back(std::make_pair(gfx::RectF(rect), paint)); 59 draw_rects_.push_back(std::make_pair(gfx::RectF(rect), paint));
60 } 60 }
61 61
62 void add_draw_rectf(const gfx::RectF& rect, const SkPaint& paint) { 62 void add_draw_rectf(const gfx::RectF& rect, const SkPaint& paint) {
63 draw_rects_.push_back(std::make_pair(rect, paint)); 63 draw_rects_.push_back(std::make_pair(rect, paint));
64 } 64 }
65 65
66 void add_draw_image(const SkImage* image, 66 void add_draw_image(sk_sp<const SkImage> image,
67 const gfx::Point& point, 67 const gfx::Point& point,
68 const SkPaint& paint) { 68 const SkPaint& paint) {
69 ImageData data(image, point, paint); 69 ImageData data(std::move(image), point, paint);
70 draw_images_.push_back(data); 70 draw_images_.push_back(data);
71 } 71 }
72 72
73 void add_draw_image_with_transform(const SkImage* image, 73 void add_draw_image_with_transform(sk_sp<const SkImage> image,
74 const gfx::Transform& transform, 74 const gfx::Transform& transform,
75 const SkPaint& paint) { 75 const SkPaint& paint) {
76 ImageData data(image, transform, paint); 76 ImageData data(std::move(image), transform, paint);
77 draw_images_.push_back(data); 77 draw_images_.push_back(data);
78 } 78 }
79 79
80 SkCanvas* last_canvas() const { return last_canvas_; } 80 SkCanvas* last_canvas() const { return last_canvas_; }
81 81
82 PaintingControlSetting last_painting_control() const { 82 PaintingControlSetting last_painting_control() const {
83 return last_painting_control_; 83 return last_painting_control_;
84 } 84 }
85 85
86 void set_reported_memory_usage(size_t reported_memory_usage) { 86 void set_reported_memory_usage(size_t reported_memory_usage) {
(...skipping 16 matching lines...) Expand all
103 SkCanvas* last_canvas_; 103 SkCanvas* last_canvas_;
104 PaintingControlSetting last_painting_control_; 104 PaintingControlSetting last_painting_control_;
105 size_t reported_memory_usage_; 105 size_t reported_memory_usage_;
106 gfx::Size bounds_; 106 gfx::Size bounds_;
107 bool bounds_set_; 107 bool bounds_set_;
108 }; 108 };
109 109
110 } // namespace cc 110 } // namespace cc
111 111
112 #endif // CC_TEST_FAKE_CONTENT_LAYER_CLIENT_H_ 112 #endif // CC_TEST_FAKE_CONTENT_LAYER_CLIENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698