Merge "Reduce the exposure of the graphics headers."
This commit is contained in:
committed by
Android (Google) Code Review
commit
f46a4a1c48
@@ -110,6 +110,7 @@ cc_library_shared {
|
||||
"android_view_InputEventReceiver.cpp",
|
||||
"android_view_InputEventSender.cpp",
|
||||
"android_view_InputQueue.cpp",
|
||||
"android_view_FrameMetricsObserver.cpp",
|
||||
"android_view_KeyCharacterMap.cpp",
|
||||
"android_view_KeyEvent.cpp",
|
||||
"android_view_MotionEvent.cpp",
|
||||
@@ -424,9 +425,9 @@ cc_library_static {
|
||||
android: {
|
||||
srcs: [ // sources that depend on android only libraries
|
||||
"android/graphics/apex/android_canvas.cpp",
|
||||
"android/graphics/apex/renderthread.cpp",
|
||||
"android/graphics/apex/jni_runtime.cpp",
|
||||
|
||||
"android_view_FrameMetricsObserver.cpp",
|
||||
"android_view_TextureLayer.cpp",
|
||||
"android_view_ThreadedRenderer.cpp",
|
||||
"android/graphics/BitmapRegionDecoder.cpp",
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
#include "SkWebpEncoder.h"
|
||||
|
||||
#include "android_os_Parcel.h"
|
||||
#include "android_util_Binder.h"
|
||||
#include "android_nio_utils.h"
|
||||
#include "CreateJavaOutputStreamAdaptor.h"
|
||||
#include <hwui/Paint.h>
|
||||
|
||||
@@ -25,18 +25,13 @@
|
||||
#include "SkBitmapRegionDecoder.h"
|
||||
#include "SkCodec.h"
|
||||
#include "SkData.h"
|
||||
#include "SkUtils.h"
|
||||
#include "SkPixelRef.h"
|
||||
#include "SkStream.h"
|
||||
|
||||
#include "android_nio_utils.h"
|
||||
#include "android_util_Binder.h"
|
||||
#include "core_jni_helpers.h"
|
||||
|
||||
#include <HardwareBitmapUploader.h>
|
||||
#include <nativehelper/JNIHelp.h>
|
||||
#include <androidfw/Asset.h>
|
||||
#include <binder/Parcel.h>
|
||||
#include <jni.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "Utils.h"
|
||||
|
||||
#include <nativehelper/JNIHelp.h>
|
||||
#include <log/log.h>
|
||||
#include <memory>
|
||||
|
||||
static jmethodID gInputStream_readMethodID;
|
||||
|
||||
@@ -22,8 +22,6 @@
|
||||
#include <nativehelper/ScopedPrimitiveArray.h>
|
||||
#include <nativehelper/ScopedUtfChars.h>
|
||||
#include "SkTypeface.h"
|
||||
#include <android_runtime/android_util_AssetManager.h>
|
||||
#include <androidfw/AssetManager.h>
|
||||
#include <hwui/Typeface.h>
|
||||
#include <minikin/FontFamily.h>
|
||||
#include <minikin/SystemFonts.h>
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
#include "SkUtils.h"
|
||||
#include "SkData.h"
|
||||
|
||||
#include <log/log.h>
|
||||
|
||||
using namespace android;
|
||||
|
||||
AssetStreamAdaptor::AssetStreamAdaptor(Asset* asset)
|
||||
|
||||
@@ -19,8 +19,6 @@
|
||||
|
||||
#include "SkStream.h"
|
||||
|
||||
#include "android_util_Binder.h"
|
||||
|
||||
#include <jni.h>
|
||||
#include <androidfw/Asset.h>
|
||||
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (C) 2019 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef ANDROID_GRAPHICS_RENDERTHREAD_H
|
||||
#define ANDROID_GRAPHICS_RENDERTHREAD_H
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
/**
|
||||
* Dumps a textual representation of the graphics stats for this process.
|
||||
* @param fd The file descriptor that the available graphics stats will be appended to. The
|
||||
* function requires a valid fd, but does not persist or assume ownership of the fd
|
||||
* outside the scope of this function.
|
||||
*/
|
||||
void ARenderThread_dumpGraphicsMemory(int fd);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif // ANDROID_GRAPHICS_RENDERTHREAD_H
|
||||
25
core/jni/android/graphics/apex/renderthread.cpp
Normal file
25
core/jni/android/graphics/apex/renderthread.cpp
Normal file
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright (C) 2019 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "android/graphics/renderthread.h"
|
||||
|
||||
#include <renderthread/RenderProxy.h>
|
||||
|
||||
using namespace android;
|
||||
|
||||
void ARenderThread_dumpGraphicsMemory(int fd) {
|
||||
uirenderer::renderthread::RenderProxy::dumpGraphicsMemory(fd);
|
||||
}
|
||||
@@ -17,13 +17,11 @@
|
||||
#include "jni.h"
|
||||
#include <nativehelper/JNIHelp.h>
|
||||
|
||||
#include <minikin/Layout.h>
|
||||
#include <renderthread/RenderProxy.h>
|
||||
|
||||
#include "core_jni_helpers.h"
|
||||
#include <unistd.h>
|
||||
|
||||
#include <bionic/malloc.h>
|
||||
#include <android/graphics/renderthread.h>
|
||||
|
||||
namespace android {
|
||||
|
||||
@@ -35,7 +33,7 @@ static void android_app_ActivityThread_purgePendingResources(JNIEnv* env, jobjec
|
||||
static void
|
||||
android_app_ActivityThread_dumpGraphics(JNIEnv* env, jobject clazz, jobject javaFileDescriptor) {
|
||||
int fd = jniGetFDFromFileDescriptor(env, javaFileDescriptor);
|
||||
android::uirenderer::renderthread::RenderProxy::dumpGraphicsMemory(fd);
|
||||
ARenderThread_dumpGraphicsMemory(fd);
|
||||
}
|
||||
|
||||
static void android_app_ActivityThread_initZygoteChildHeapProfiling(JNIEnv* env, jobject clazz) {
|
||||
|
||||
@@ -396,9 +396,8 @@ static sp<ANativeWindow> getNativeWindow(JNIEnv* env, jobject surface) {
|
||||
}
|
||||
|
||||
static sp<ANativeWindow> getSurfaceTextureNativeWindow(JNIEnv* env, jobject thiz) {
|
||||
sp<SurfaceTexture> surfaceTexture(SurfaceTexture_getSurfaceTexture(env, thiz));
|
||||
sp<IGraphicBufferProducer> producer(SurfaceTexture_getProducer(env, thiz));
|
||||
sp<Surface> surfaceTextureClient(surfaceTexture != NULL ? new Surface(producer) : NULL);
|
||||
sp<Surface> surfaceTextureClient(producer != NULL ? new Surface(producer) : NULL);
|
||||
return surfaceTextureClient;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
#define LOG_TAG "OpenGLRenderer"
|
||||
|
||||
#include "jni.h"
|
||||
#include "GraphicsJNI.h"
|
||||
#include <nativehelper/JNIHelp.h>
|
||||
|
||||
#include "core_jni_helpers.h"
|
||||
@@ -27,12 +26,8 @@
|
||||
#include <gui/surfacetexture/surface_texture_platform.h>
|
||||
#include <gui/surfacetexture/SurfaceTexture.h>
|
||||
#include <hwui/Paint.h>
|
||||
|
||||
#include <SkMatrix.h>
|
||||
|
||||
#include <DeferredLayerUpdater.h>
|
||||
#include <Rect.h>
|
||||
#include <RenderNode.h>
|
||||
|
||||
namespace android {
|
||||
|
||||
|
||||
@@ -28,67 +28,6 @@
|
||||
|
||||
namespace android {
|
||||
|
||||
AssetStream::AssetStream(SkStream* stream)
|
||||
: mStream(stream), mPosition(0) {
|
||||
}
|
||||
|
||||
AssetStream::~AssetStream() {
|
||||
}
|
||||
|
||||
piex::Error AssetStream::GetData(
|
||||
const size_t offset, const size_t length, std::uint8_t* data) {
|
||||
// Seek first.
|
||||
if (mPosition != offset) {
|
||||
if (!mStream->seek(offset)) {
|
||||
return piex::Error::kFail;
|
||||
}
|
||||
}
|
||||
|
||||
// Read bytes.
|
||||
size_t size = mStream->read((void*)data, length);
|
||||
mPosition = offset + size;
|
||||
|
||||
return size == length ? piex::Error::kOk : piex::Error::kFail;
|
||||
}
|
||||
|
||||
BufferedStream::BufferedStream(SkStream* stream)
|
||||
: mStream(stream) {
|
||||
}
|
||||
|
||||
BufferedStream::~BufferedStream() {
|
||||
}
|
||||
|
||||
piex::Error BufferedStream::GetData(
|
||||
const size_t offset, const size_t length, std::uint8_t* data) {
|
||||
// Seek first.
|
||||
if (offset + length > mStreamBuffer.bytesWritten()) {
|
||||
size_t sizeToRead = offset + length - mStreamBuffer.bytesWritten();
|
||||
if (sizeToRead <= kMinSizeToRead) {
|
||||
sizeToRead = kMinSizeToRead;
|
||||
}
|
||||
|
||||
void* tempBuffer = malloc(sizeToRead);
|
||||
if (tempBuffer == NULL) {
|
||||
return piex::Error::kFail;
|
||||
}
|
||||
|
||||
size_t bytesRead = mStream->read(tempBuffer, sizeToRead);
|
||||
if (bytesRead != sizeToRead) {
|
||||
free(tempBuffer);
|
||||
return piex::Error::kFail;
|
||||
}
|
||||
mStreamBuffer.write(tempBuffer, bytesRead);
|
||||
free(tempBuffer);
|
||||
}
|
||||
|
||||
// Read bytes.
|
||||
if (mStreamBuffer.read((void*)data, offset, length)) {
|
||||
return piex::Error::kOk;
|
||||
} else {
|
||||
return piex::Error::kFail;
|
||||
}
|
||||
}
|
||||
|
||||
FileStream::FileStream(const int fd)
|
||||
: mPosition(0) {
|
||||
mFile = fdopen(fd, "r");
|
||||
|
||||
@@ -25,53 +25,9 @@
|
||||
#include <utils/KeyedVector.h>
|
||||
#include <utils/String8.h>
|
||||
#include <utils/StrongPointer.h>
|
||||
#include <SkStream.h>
|
||||
|
||||
|
||||
namespace android {
|
||||
|
||||
class AssetStream : public piex::StreamInterface {
|
||||
private:
|
||||
SkStream *mStream;
|
||||
size_t mPosition;
|
||||
|
||||
public:
|
||||
explicit AssetStream(SkStream* stream);
|
||||
~AssetStream();
|
||||
|
||||
// Reads 'length' amount of bytes from 'offset' to 'data'. The 'data' buffer
|
||||
// provided by the caller, guaranteed to be at least "length" bytes long.
|
||||
// On 'kOk' the 'data' pointer contains 'length' valid bytes beginning at
|
||||
// 'offset' bytes from the start of the stream.
|
||||
// Returns 'kFail' if 'offset' + 'length' exceeds the stream and does not
|
||||
// change the contents of 'data'.
|
||||
piex::Error GetData(
|
||||
const size_t offset, const size_t length, std::uint8_t* data) override;
|
||||
};
|
||||
|
||||
class BufferedStream : public piex::StreamInterface {
|
||||
private:
|
||||
SkStream *mStream;
|
||||
// Growable memory stream
|
||||
SkDynamicMemoryWStream mStreamBuffer;
|
||||
|
||||
// Minimum size to read on filling the buffer.
|
||||
const size_t kMinSizeToRead = 8192;
|
||||
|
||||
public:
|
||||
explicit BufferedStream(SkStream* stream);
|
||||
~BufferedStream();
|
||||
|
||||
// Reads 'length' amount of bytes from 'offset' to 'data'. The 'data' buffer
|
||||
// provided by the caller, guaranteed to be at least "length" bytes long.
|
||||
// On 'kOk' the 'data' pointer contains 'length' valid bytes beginning at
|
||||
// 'offset' bytes from the start of the stream.
|
||||
// Returns 'kFail' if 'offset' + 'length' exceeds the stream and does not
|
||||
// change the contents of 'data'.
|
||||
piex::Error GetData(
|
||||
const size_t offset, const size_t length, std::uint8_t* data) override;
|
||||
};
|
||||
|
||||
class FileStream : public piex::StreamInterface {
|
||||
private:
|
||||
FILE *mFile;
|
||||
|
||||
Reference in New Issue
Block a user