flutter_flutter/engine/core/loader/CanvasImageDecoder.h
Eric Seidel 8f975399e1 Move image loading out of C++ into Dart
We already know how to talk to the network_service from Dart
via fetch.dart.  Might as well use that for Image loading
as well insetad of having ImageLoader do it.

As part of this I've renamed *ImageLoader to *ImageDecoder
and moved all the image loading logic into Dart.  This required
me to teach the idl system about mojo handles so that I could
pass the resulting MojoHandle from fetch.dart up through to
ImageDecoder.

R=abarth@chromium.org, jackson@google.com, hansmuller@google.com

Review URL: https://codereview.chromium.org/1173703002.
2015-06-09 12:14:13 -07:00

41 lines
1.4 KiB
C++

// SKY_ENGINE_CORE_PAINTING_CANVASIMAGE_H_
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef SKY_ENGINE_CORE_LOADER_CANVASIMAGELOADER_H_
#define SKY_ENGINE_CORE_LOADER_CANVASIMAGELOADER_H_
#include "mojo/common/data_pipe_drainer.h"
#include "sky/engine/core/loader/ImageDecoderCallback.h"
#include "sky/engine/platform/SharedBuffer.h"
#include "sky/engine/tonic/dart_wrappable.h"
#include "sky/engine/wtf/OwnPtr.h"
#include "sky/engine/wtf/text/AtomicString.h"
namespace blink {
class CanvasImageDecoder : public mojo::common::DataPipeDrainer::Client,
public RefCounted<CanvasImageDecoder>,
public DartWrappable {
DEFINE_WRAPPERTYPEINFO();
public:
static PassRefPtr<CanvasImageDecoder> create(mojo::ScopedDataPipeConsumerHandle handle, PassOwnPtr<ImageDecoderCallback> callback);
virtual ~CanvasImageDecoder();
// mojo::common::DataPipeDrainer::Client
void OnDataAvailable(const void*, size_t) override;
void OnDataComplete() override;
private:
CanvasImageDecoder(mojo::ScopedDataPipeConsumerHandle handle, PassOwnPtr<ImageDecoderCallback> callback);
OwnPtr<mojo::common::DataPipeDrainer> drainer_;
RefPtr<SharedBuffer> buffer_;
OwnPtr<ImageDecoderCallback> callback_;
};
} // namespace blink
#endif // SKY_ENGINE_CORE_LOADER_CANVASIMAGELOADER_H_