Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / cc / test / fake_content_layer_client.h
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
3 // found in the LICENSE file.
4
5 #ifndef CC_TEST_FAKE_CONTENT_LAYER_CLIENT_H_
6 #define CC_TEST_FAKE_CONTENT_LAYER_CLIENT_H_
7
8 #include <utility>
9 #include <vector>
10
11 #include "base/compiler_specific.h"
12 #include "cc/layers/content_layer_client.h"
13 #include "third_party/skia/include/core/SkBitmap.h"
14 #include "third_party/skia/include/core/SkPaint.h"
15 #include "ui/gfx/rect.h"
16
17 namespace cc {
18
19 class FakeContentLayerClient : public ContentLayerClient {
20  public:
21   struct BitmapData {
22     SkBitmap bitmap;
23     gfx::Point point;
24     SkPaint paint;
25   };
26
27   FakeContentLayerClient();
28   virtual ~FakeContentLayerClient();
29
30   virtual void PaintContents(
31       SkCanvas* canvas,
32       const gfx::Rect& rect,
33       ContentLayerClient::GraphicsContextStatus gc_status) OVERRIDE;
34   virtual void DidChangeLayerCanUseLCDText() OVERRIDE {}
35   virtual bool FillsBoundsCompletely() const OVERRIDE;
36
37   void set_fill_with_nonsolid_color(bool nonsolid) {
38     fill_with_nonsolid_color_ = nonsolid;
39   }
40
41   void add_draw_rect(const gfx::RectF& rect, const SkPaint& paint) {
42     draw_rects_.push_back(std::make_pair(rect, paint));
43   }
44
45   void add_draw_bitmap(const SkBitmap& bitmap,
46                        const gfx::Point& point,
47                        const SkPaint& paint) {
48     BitmapData data;
49     data.bitmap = bitmap;
50     data.point = point;
51     data.paint = paint;
52     draw_bitmaps_.push_back(data);
53   }
54
55   SkCanvas* last_canvas() const { return last_canvas_; }
56
57   ContentLayerClient::GraphicsContextStatus last_context_status() const {
58     return last_context_status_;
59   }
60
61  private:
62   typedef std::vector<std::pair<gfx::RectF, SkPaint> > RectPaintVector;
63   typedef std::vector<BitmapData> BitmapVector;
64
65   bool fill_with_nonsolid_color_;
66   RectPaintVector draw_rects_;
67   BitmapVector draw_bitmaps_;
68   SkCanvas* last_canvas_;
69   ContentLayerClient::GraphicsContextStatus last_context_status_;
70 };
71
72 }  // namespace cc
73
74 #endif  // CC_TEST_FAKE_CONTENT_LAYER_CLIENT_H_