cc: Added inline to Tile::IsReadyToDraw
[chromium-blink-merge.git] / cc / output / copy_output_request.h
blob3f4d925ee16c2f9cf649e82baba3ec800c931e20
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
3 // found in the LICENSE file.
5 #ifndef CC_OUTPUT_COPY_OUTPUT_REQUEST_H_
6 #define CC_OUTPUT_COPY_OUTPUT_REQUEST_H_
8 #include "base/callback.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "cc/base/cc_export.h"
11 #include "ui/gfx/rect.h"
13 class SkBitmap;
15 namespace cc {
16 class CopyOutputResult;
17 class TextureMailbox;
19 class CC_EXPORT CopyOutputRequest {
20 public:
21 typedef base::Callback<void(scoped_ptr<CopyOutputResult> result)>
22 CopyOutputRequestCallback;
24 static scoped_ptr<CopyOutputRequest> CreateEmptyRequest() {
25 return make_scoped_ptr(new CopyOutputRequest);
27 static scoped_ptr<CopyOutputRequest> CreateRequest(
28 const CopyOutputRequestCallback& result_callback) {
29 return make_scoped_ptr(new CopyOutputRequest(false, result_callback));
31 static scoped_ptr<CopyOutputRequest> CreateBitmapRequest(
32 const CopyOutputRequestCallback& result_callback) {
33 return make_scoped_ptr(new CopyOutputRequest(true, result_callback));
35 static scoped_ptr<CopyOutputRequest> CreateRelayRequest(
36 const CopyOutputRequest& original_request,
37 const CopyOutputRequestCallback& result_callback) {
38 scoped_ptr<CopyOutputRequest> relay = CreateRequest(result_callback);
39 relay->force_bitmap_result_ = original_request.force_bitmap_result_;
40 relay->has_area_ = original_request.has_area_;
41 relay->area_ = original_request.area_;
42 return relay.Pass();
45 ~CopyOutputRequest();
47 bool IsEmpty() const { return result_callback_.is_null(); }
49 bool force_bitmap_result() const { return force_bitmap_result_; }
51 // By default copy requests copy the entire layer's subtree output. If an
52 // area is given, then the intersection of this rect (in layer space) with
53 // the layer's subtree output will be returned.
54 void set_area(gfx::Rect area) {
55 has_area_ = true;
56 area_ = area;
58 bool has_area() const { return has_area_; }
59 gfx::Rect area() const { return area_; }
61 void SendEmptyResult();
62 void SendBitmapResult(scoped_ptr<SkBitmap> bitmap);
63 void SendTextureResult(gfx::Size size,
64 scoped_ptr<TextureMailbox> texture_mailbox);
66 void SendResult(scoped_ptr<CopyOutputResult> result);
68 bool Equals(const CopyOutputRequest& other) const {
69 return result_callback_.Equals(other.result_callback_) &&
70 force_bitmap_result_ == other.force_bitmap_result_;
73 private:
74 CopyOutputRequest();
75 explicit CopyOutputRequest(bool force_bitmap_result,
76 const CopyOutputRequestCallback& result_callback);
78 bool force_bitmap_result_;
79 bool has_area_;
80 gfx::Rect area_;
81 CopyOutputRequestCallback result_callback_;
84 } // namespace cc
86 #endif // CC_OUTPUT_COPY_OUTPUT_REQUEST_H_