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

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

Issue 2857923004: cc: Keep PaintImage in DrawImage. (Closed)
Patch Set: .. Created 3 years, 7 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/raster/raster_source.cc ('k') | cc/test/fake_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 #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 "cc/paint/paint_flags.h" 15 #include "cc/paint/paint_flags.h"
16 #include "third_party/skia/include/core/SkImage.h" 16 #include "third_party/skia/include/core/SkImage.h"
17 #include "third_party/skia/include/core/SkRefCnt.h" 17 #include "third_party/skia/include/core/SkRefCnt.h"
18 #include "ui/gfx/geometry/rect.h" 18 #include "ui/gfx/geometry/rect.h"
19 #include "ui/gfx/geometry/rect_f.h" 19 #include "ui/gfx/geometry/rect_f.h"
20 #include "ui/gfx/transform.h" 20 #include "ui/gfx/transform.h"
21 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(sk_sp<SkImage> image, 27 ImageData(PaintImage image,
28 const gfx::Point& point, 28 const gfx::Point& point,
29 const PaintFlags& flags); 29 const PaintFlags& flags);
30 ImageData(sk_sp<SkImage> image, 30 ImageData(PaintImage image,
31 const gfx::Transform& transform, 31 const gfx::Transform& transform,
32 const PaintFlags& flags); 32 const PaintFlags& flags);
33 ImageData(const ImageData& other); 33 ImageData(const ImageData& other);
34 ~ImageData(); 34 ~ImageData();
35 sk_sp<SkImage> image; 35 PaintImage image;
36 gfx::Point point; 36 gfx::Point point;
37 gfx::Transform transform; 37 gfx::Transform transform;
38 PaintFlags flags; 38 PaintFlags flags;
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(
46 PaintingControlSetting painting_control) override; 46 PaintingControlSetting painting_control) override;
47 bool FillsBoundsCompletely() const override; 47 bool FillsBoundsCompletely() const override;
48 size_t GetApproximateUnsharedMemoryUsage() const override; 48 size_t GetApproximateUnsharedMemoryUsage() const override;
49 49
50 void set_fill_with_nonsolid_color(bool nonsolid) { 50 void set_fill_with_nonsolid_color(bool nonsolid) {
51 fill_with_nonsolid_color_ = nonsolid; 51 fill_with_nonsolid_color_ = nonsolid;
52 } 52 }
53 53
54 void add_draw_rect(const gfx::Rect& rect, const PaintFlags& flags) { 54 void add_draw_rect(const gfx::Rect& rect, const PaintFlags& flags) {
55 draw_rects_.push_back(std::make_pair(gfx::RectF(rect), flags)); 55 draw_rects_.push_back(std::make_pair(gfx::RectF(rect), flags));
56 } 56 }
57 57
58 void add_draw_rectf(const gfx::RectF& rect, const PaintFlags& flags) { 58 void add_draw_rectf(const gfx::RectF& rect, const PaintFlags& flags) {
59 draw_rects_.push_back(std::make_pair(rect, flags)); 59 draw_rects_.push_back(std::make_pair(rect, flags));
60 } 60 }
61 61
62 void add_draw_image(sk_sp<SkImage> image, 62 void add_draw_image(sk_sp<SkImage> image,
63 const gfx::Point& point, 63 const gfx::Point& point,
64 const PaintFlags& flags) { 64 const PaintFlags& flags) {
65 add_draw_image(PaintImage(PaintImage::GetNextId(), std::move(image)), point,
66 flags);
67 }
68 void add_draw_image(PaintImage image,
69 const gfx::Point& point,
70 const PaintFlags& flags) {
65 ImageData data(std::move(image), point, flags); 71 ImageData data(std::move(image), point, flags);
66 draw_images_.push_back(data); 72 draw_images_.push_back(data);
67 } 73 }
68 74
69 void add_draw_image_with_transform(sk_sp<SkImage> image, 75 void add_draw_image_with_transform(sk_sp<SkImage> image,
70 const gfx::Transform& transform, 76 const gfx::Transform& transform,
71 const PaintFlags& flags) { 77 const PaintFlags& flags) {
72 ImageData data(std::move(image), transform, flags); 78 ImageData data(PaintImage(PaintImage::GetNextId(), std::move(image)),
79 transform, flags);
73 draw_images_.push_back(data); 80 draw_images_.push_back(data);
74 } 81 }
75 82
76 SkCanvas* last_canvas() const { return last_canvas_; } 83 SkCanvas* last_canvas() const { return last_canvas_; }
77 84
78 PaintingControlSetting last_painting_control() const { 85 PaintingControlSetting last_painting_control() const {
79 return last_painting_control_; 86 return last_painting_control_;
80 } 87 }
81 88
82 void set_reported_memory_usage(size_t reported_memory_usage) { 89 void set_reported_memory_usage(size_t reported_memory_usage) {
(...skipping 15 matching lines...) Expand all
98 SkCanvas* last_canvas_; 105 SkCanvas* last_canvas_;
99 PaintingControlSetting last_painting_control_; 106 PaintingControlSetting last_painting_control_;
100 size_t reported_memory_usage_; 107 size_t reported_memory_usage_;
101 gfx::Size bounds_; 108 gfx::Size bounds_;
102 bool bounds_set_; 109 bool bounds_set_;
103 }; 110 };
104 111
105 } // namespace cc 112 } // namespace cc
106 113
107 #endif // CC_TEST_FAKE_CONTENT_LAYER_CLIENT_H_ 114 #endif // CC_TEST_FAKE_CONTENT_LAYER_CLIENT_H_
OLDNEW
« no previous file with comments | « cc/raster/raster_source.cc ('k') | cc/test/fake_content_layer_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698