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 REMOTING_CLIENT_JNI_JNI_FRAME_CONSUMER_H_
6 #define REMOTING_CLIENT_JNI_JNI_FRAME_CONSUMER_H_
8 #include "remoting/client/frame_consumer.h"
10 #include "base/compiler_specific.h"
17 class ChromotingJniRuntime
;
20 // FrameConsumer implementation that draws onto a JNI direct byte buffer.
21 class JniFrameConsumer
: public FrameConsumer
{
23 // The instance does not take ownership of |jni_runtime|.
24 explicit JniFrameConsumer(ChromotingJniRuntime
* jni_runtime
);
26 virtual ~JniFrameConsumer();
28 // This must be called once before the producer's source size is set.
29 void set_frame_producer(FrameProducer
* producer
);
31 // FrameConsumer implementation.
32 virtual void ApplyBuffer(const SkISize
& view_size
,
33 const SkIRect
& clip_area
,
34 webrtc::DesktopFrame
* buffer
,
35 const SkRegion
& region
) OVERRIDE
;
36 virtual void ReturnBuffer(webrtc::DesktopFrame
* buffer
) OVERRIDE
;
37 virtual void SetSourceSize(const SkISize
& source_size
,
38 const SkIPoint
& dpi
) OVERRIDE
;
41 // Variables are to be used from the display thread.
43 // Used to obtain task runner references and make calls to Java methods.
44 ChromotingJniRuntime
* jni_runtime_
;
46 // Whether we're currently in the constructor, and should deallocate the
47 // buffer instead of passing it back to the producer.
50 FrameProducer
* frame_producer_
;
54 // If |provide_buffer_|, allocates a new buffer of |view_size_|, informs
55 // Java about it, and tells the producer to draw onto it. Otherwise, no-op.
56 void AllocateBuffer();
58 DISALLOW_COPY_AND_ASSIGN(JniFrameConsumer
);
61 } // namespace remoting