speedup base
This commit is contained in:
parent
729b84f2ca
commit
4a0f0063a0
10 changed files with 1212 additions and 238 deletions
|
@ -9,10 +9,24 @@
|
|||
#include "atom/common/node_includes.h"
|
||||
#include "content/public/browser/render_widget_host.h"
|
||||
|
||||
#include <iostream>
|
||||
#include "content/browser/compositor/image_transport_factory.h"
|
||||
#include "cc/surfaces/surface_manager.h"
|
||||
#include "cc/surfaces/surface.h"
|
||||
#include "cc/output/copy_output_request.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
namespace api {
|
||||
|
||||
FrameSubscriberRenderWidgetHostView::FrameSubscriberRenderWidgetHostView() {
|
||||
std::cout << "FrameSubscriberRenderWidgetHostView" << std::endl;
|
||||
}
|
||||
|
||||
FrameSubscriberRenderWidgetHostView::~FrameSubscriberRenderWidgetHostView() {
|
||||
std::cout << "~FrameSubscriberRenderWidgetHostView" << std::endl;
|
||||
}
|
||||
|
||||
FrameSubscriber::FrameSubscriber(v8::Isolate* isolate,
|
||||
content::RenderWidgetHostView* view,
|
||||
const FrameCaptureCallback& callback,
|
||||
|
@ -30,26 +44,51 @@ bool FrameSubscriber::ShouldCaptureFrame(
|
|||
scoped_refptr<media::VideoFrame>* storage,
|
||||
DeliverFrameCallback* callback) {
|
||||
const auto host = view_ ? view_->GetRenderWidgetHost() : nullptr;
|
||||
|
||||
if (!view_ || !host)
|
||||
return false;
|
||||
|
||||
if (dirty_rect.IsEmpty())
|
||||
return false;
|
||||
/*if (dirty_rect.IsEmpty())
|
||||
return false;*/
|
||||
|
||||
gfx::Rect rect = gfx::Rect(view_->GetVisibleViewportSize());
|
||||
if (only_dirty_)
|
||||
rect = dirty_rect;
|
||||
|
||||
host->CopyFromBackingStore(
|
||||
/*host->CopyFromBackingStore(
|
||||
rect,
|
||||
rect.size(),
|
||||
base::Bind(&FrameSubscriber::OnFrameDelivered,
|
||||
weak_factory_.GetWeakPtr(), callback_, rect),
|
||||
kBGRA_8888_SkColorType);
|
||||
kBGRA_8888_SkColorType);*/
|
||||
|
||||
const auto base = reinterpret_cast<content::RenderWidgetHostViewBase*>(
|
||||
view_);
|
||||
content::ImageTransportFactory* itf =
|
||||
content::ImageTransportFactory::GetInstance();
|
||||
cc::SurfaceManager* sfm = itf->GetSurfaceManager();
|
||||
cc::Surface* surface = sfm->GetSurfaceForId(base->SurfaceIdForTesting());
|
||||
|
||||
std::unique_ptr<cc::CopyOutputRequest> request =
|
||||
cc::CopyOutputRequest::CreateBitmapRequest(
|
||||
base::Bind(&FrameSubscriber::ReadbackResultAsBitmap,
|
||||
base::Unretained(this)));
|
||||
|
||||
surface->RequestCopyOfOutput(std::move(request));
|
||||
return false;
|
||||
}
|
||||
|
||||
void FrameSubscriber::ReadbackResultAsBitmap(
|
||||
std::unique_ptr<cc::CopyOutputResult> result) {
|
||||
std::unique_ptr<SkBitmap> bitmap = result->TakeBitmap();
|
||||
|
||||
SkAutoPixmapUnlock res;
|
||||
if (!bitmap->requestLock(&res))
|
||||
return;
|
||||
|
||||
std::cout << res.pixmap().addr() << std::endl;
|
||||
}
|
||||
|
||||
void FrameSubscriber::OnFrameDelivered(const FrameCaptureCallback& callback,
|
||||
const gfx::Rect& damage_rect,
|
||||
const SkBitmap& bitmap,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue