Ejemplo n.º 1
0
static void
CreateContext(PP_Instance instance, const struct PP_Size* size)
{
  if (isContextValid())
    return;

  Log("making gc\n");
  sprintf(LogBuffer, "size: %d, %d\n", (int)size->width, (int)size->height);
  Log(LogBuffer);
  pthread_mutex_lock(&image_mutex);
  gc = graphics_2d_->Create(instance, size, false);
  if (!isContextValid() /*graphics_2d_->IsGraphics2D(gc)*/) {
    Log("failed to create gc\n");
  }
  if (!instance_->BindGraphics(instance, gc)) {
    Log("couldn't bind gc\n");
  }

  Log("make image\n");
  image = image_data_->Create(instance, PP_IMAGEDATAFORMAT_BGRA_PREMUL,
				size,
				PP_FALSE);
  getDesc();
  {
    uint32_t *pixels = image_data_->Map(image);
    int i, j;
    for (j = 0; j < screenHeight; j++) {
      for (i = 0; i < screenWidth; i++) {
	pixels[j*(screenStride/4)+i] = (j<<24)+ (i<<8) + 0xFF;
      }
    }
    image_data_->Unmap(image);
  }
  pthread_mutex_unlock(&image_mutex);
}
Ejemplo n.º 2
0
static void 
DestroyContext(PP_Instance instance)
{
  Log(isContextValid() ? "destroy good\n" : "destroy bad\n");
  if (isContextValid()) {
    pthread_mutex_lock(&image_mutex);
    core_->ReleaseResource(gc);
    gc = 0;
    core_->ReleaseResource(image);
    image = 0;
    pthread_mutex_unlock(&image_mutex);
  }
}
Ejemplo n.º 3
0
IDBOpenDBRequest* IDBFactory::openInternal(ScriptState* scriptState,
                                           const String& name,
                                           int64_t version,
                                           ExceptionState& exceptionState) {
  IDBDatabase::recordApiCallsHistogram(IDBOpenCall);
  ASSERT(version >= 1 || version == IDBDatabaseMetadata::NoVersion);
  if (!isContextValid(scriptState->getExecutionContext()))
    return nullptr;
  if (!scriptState->getExecutionContext()
           ->getSecurityOrigin()
           ->canAccessDatabase()) {
    exceptionState.throwSecurityError(
        "access to the Indexed Database API is denied in this context.");
    return nullptr;
  }

  IDBDatabaseCallbacks* databaseCallbacks = IDBDatabaseCallbacks::create();
  int64_t transactionId = IDBDatabase::nextTransactionId();
  IDBOpenDBRequest* request = IDBOpenDBRequest::create(
      scriptState, databaseCallbacks, transactionId, version);

  if (!IndexedDBClient::from(scriptState->getExecutionContext())
           ->allowIndexedDB(scriptState->getExecutionContext(), name)) {
    request->onError(
        DOMException::create(UnknownError, permissionDeniedErrorMessage));
    return request;
  }

  Platform::current()->idbFactory()->open(
      name, version, transactionId, request->createWebCallbacks().release(),
      databaseCallbacks->createWebCallbacks().release(),
      WebSecurityOrigin(
          scriptState->getExecutionContext()->getSecurityOrigin()));
  return request;
}
Ejemplo n.º 4
0
IDBOpenDBRequest* IDBFactory::deleteDatabase(ScriptState* scriptState,
                                             const String& name,
                                             ExceptionState& exceptionState) {
  IDB_TRACE("IDBFactory::deleteDatabase");
  IDBDatabase::recordApiCallsHistogram(IDBDeleteDatabaseCall);
  if (!isContextValid(scriptState->getExecutionContext()))
    return nullptr;
  if (!scriptState->getExecutionContext()
           ->getSecurityOrigin()
           ->canAccessDatabase()) {
    exceptionState.throwSecurityError(
        "access to the Indexed Database API is denied in this context.");
    return nullptr;
  }

  IDBOpenDBRequest* request = IDBOpenDBRequest::create(
      scriptState, nullptr, 0, IDBDatabaseMetadata::DefaultVersion);

  if (!IndexedDBClient::from(scriptState->getExecutionContext())
           ->allowIndexedDB(scriptState->getExecutionContext(), name)) {
    request->onError(
        DOMException::create(UnknownError, permissionDeniedErrorMessage));
    return request;
  }

  Platform::current()->idbFactory()->deleteDatabase(
      name, request->createWebCallbacks().release(),
      WebSecurityOrigin(
          scriptState->getExecutionContext()->getSecurityOrigin()));
  return request;
}
Ejemplo n.º 5
0
IDBRequest* IDBFactory::getDatabaseNames(ScriptState* scriptState,
                                         ExceptionState& exceptionState) {
  IDB_TRACE("IDBFactory::getDatabaseNames");
  if (!isContextValid(scriptState->getExecutionContext()))
    return nullptr;
  if (!scriptState->getExecutionContext()
           ->getSecurityOrigin()
           ->canAccessDatabase()) {
    exceptionState.throwSecurityError(
        "access to the Indexed Database API is denied in this context.");
    return nullptr;
  }

  IDBRequest* request =
      IDBRequest::create(scriptState, IDBAny::createNull(), nullptr);

  if (!IndexedDBClient::from(scriptState->getExecutionContext())
           ->allowIndexedDB(scriptState->getExecutionContext(),
                            "Database Listing")) {
    request->onError(
        DOMException::create(UnknownError, permissionDeniedErrorMessage));
    return request;
  }

  Platform::current()->idbFactory()->getDatabaseNames(
      request->createWebCallbacks().release(),
      WebSecurityOrigin(
          scriptState->getExecutionContext()->getSecurityOrigin()));
  return request;
}
Ejemplo n.º 6
0
	MeshComponent::~MeshComponent()
	{
#ifndef NULLRENDERER
		if (isContextValid())
			getRendererSystem()->removeComponent(this);
#endif
	}
Ejemplo n.º 7
0
PassRefPtr<IDBRequest> IDBFactory::getDatabaseNames(ScriptExecutionContext* context)
{
    if (!isContextValid(context))
        return 0;

    RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this), 0);
    m_backend->getDatabaseNames(request, context->securityOrigin(), context, getIndexedDBDatabasePath(context));
    return request;
}
Ejemplo n.º 8
0
	MeshComponent::MeshComponent(void *context)
		: Component(context)
		, wireframe(false)
		, textureScale(1.f)
	{
#ifndef NULLRENDERER
		if (isContextValid())
			getRendererSystem()->addComponent(this);
#endif
	}
Ejemplo n.º 9
0
	RigidBodyComponent::~RigidBodyComponent()
	{
		if(isContextValid())
			getPhysicSystem()->removeComponent(this);

		if (motionState != NULL)
			delete motionState;

		LOG_WARNING("Cleanup missing for PhysicComponent!");
		// TODO: CLEANUP MISSING
	}
Ejemplo n.º 10
0
PassRefPtr<IDBOpenDBRequest> IDBFactory::open(ScriptExecutionContext* context, const String& name, int64_t version, ExceptionCode& ec)
{
    if (name.isNull()) {
        ec = NATIVE_TYPE_ERR;
        return 0;
    }
    if (!isContextValid(context))
        return 0;

    RefPtr<IDBOpenDBRequest> request = IDBOpenDBRequest::create(context, IDBAny::create(this), version);
    m_backend->open(name, version, request, context->securityOrigin(), context, getIndexedDBDatabasePath(context));
    return request;
}
Ejemplo n.º 11
0
PassRefPtr<IDBVersionChangeRequest> IDBFactory::deleteDatabase(ScriptExecutionContext* context, const String& name, ExceptionCode& ec)
{
    if (name.isNull()) {
        ec = NATIVE_TYPE_ERR;
        return 0;
    }
    if (!isContextValid(context))
        return 0;

    RefPtr<IDBVersionChangeRequest> request = IDBVersionChangeRequest::create(context, IDBAny::createNull(), "");
    m_backend->deleteDatabase(name, request, context->securityOrigin(), context, getIndexedDBDatabasePath(context));
    return request;
}
Ejemplo n.º 12
0
PassRefPtr<IDBRequest> IDBFactory::getDatabaseNames(ScriptExecutionContext* context, ExceptionCode& ec)
{
    LOG(StorageAPI, "IDBFactory::getDatabaseNames");
    if (!isContextValid(context))
        return 0;
    if (!context->securityOrigin()->canAccessDatabase(context->topOrigin())) {
        ec = SECURITY_ERR;
        return 0;
    }

    RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this), 0);
    m_backend->getDatabaseNames(request, *(context->securityOrigin()), *(context->topOrigin()), context);
    return request;
}
Ejemplo n.º 13
0
static void
FlushPixelBuffer()
{
  struct PP_Point top_left;
  /*  struct PP_Rect src_left = NULL;*/
  top_left.x = 0;
  top_left.y = 0;
  if (!isContextValid() /*!(graphics_2d_->IsGraphics2D(gc))*/) {
    flush_pending = 0;
    return;
  }
  graphics_2d_->PaintImageData(gc, image, &top_left, NULL);
  flush_pending = 1;
  graphics_2d_->Flush(gc, CompletionCallback);
}
Ejemplo n.º 14
0
PassRefPtr<IDBOpenDBRequest> IDBFactory::deleteDatabase(ScriptExecutionContext* context, const String& name, ExceptionCode& ec)
{
    LOG(StorageAPI, "IDBFactory::deleteDatabase");
    if (name.isNull()) {
        ec = TypeError;
        return 0;
    }
    if (!isContextValid(context))
        return 0;
    if (!context->securityOrigin()->canAccessDatabase(context->topOrigin())) {
        ec = SECURITY_ERR;
        return 0;
    }

    RefPtr<IDBOpenDBRequest> request = IDBOpenDBRequest::create(context, 0, 0, 0, IndexedDB::VersionNullness::Null);
    m_backend->deleteDatabase(name, *context->securityOrigin(), *context->topOrigin(), request, context);
    return request;
}
Ejemplo n.º 15
0
static void
FlushPixelBufferInSync()
{
  struct PP_Point top_left;
  /*  struct PP_Rect src_left = NULL;*/
  top_left.x = 0;
  top_left.y = 0;
  Log("flush 1\n");
  if (!isContextValid() /*!(graphics_2d_->IsGraphics2D(gc))*/) {
    Log("flush 2\n");
    flush_pending = 0;
    return;
  }
  Log("flush 3\n");
  graphics_2d_->PaintImageData(gc, image, &top_left, NULL);
  flush_pending = 1;
  /*  CompletionCallback.func = NULL; */
  graphics_2d_->Flush(gc, CompletionCallback);
}
Ejemplo n.º 16
0
PassRefPtr<IDBOpenDBRequest> IDBFactory::openInternal(ScriptExecutionContext* context, const String& name, uint64_t version, IndexedDB::VersionNullness versionNullness, ExceptionCode& ec)
{
    ASSERT(version >= 1 || versionNullness == IndexedDB::VersionNullness::Null);
    if (name.isNull()) {
        ec = TypeError;
        return 0;
    }
    if (!isContextValid(context))
        return 0;
    if (!context->securityOrigin()->canAccessDatabase(context->topOrigin())) {
        ec = SECURITY_ERR;
        return 0;
    }

    RefPtr<IDBDatabaseCallbacks> databaseCallbacks = IDBDatabaseCallbacksImpl::create();
    int64_t transactionId = IDBDatabase::nextTransactionId();
    RefPtr<IDBOpenDBRequest> request = IDBOpenDBRequest::create(context, databaseCallbacks, transactionId, version, versionNullness);
    m_backend->open(name, version, transactionId, request, databaseCallbacks, *(context->securityOrigin()), *(context->topOrigin()));
    return request;
}
Ejemplo n.º 17
0
int32_t
ioShowDisplay(uint32_t *dispBits, int32_t width, int32_t height, int32_t depth, int32_t aL, int32_t aR, int32_t aT, int32_t aB)
{
  uint32_t *pixels;
  int i, j;
  if (toQuit) {
    pthread_exit(NULL);
  }
  pthread_mutex_lock(&image_mutex);
  if (isContextValid()) {
    pixels = image_data_->Map(image);
    for (j = 0; j < screenHeight; j++) {
      for (i = 0; i < screenWidth; i++) {
	pixels[j*(screenStride/4)+i] = dispBits[j*width+i];
      }
    }
    image_data_->Unmap(image);
    /*FlushPixelBuffer();*/
  }
  pthread_mutex_unlock(&image_mutex);
  return 0;
}
Ejemplo n.º 18
0
static sqInt display_ioShowDisplay(sqInt dispBitsIndex, sqInt width, sqInt height, sqInt depth,
				   sqInt affectedL, sqInt affectedR, sqInt affectedT, sqInt affectedB)
{
  uint32_t *dispBits= pointerForOop(dispBitsIndex);
  uint32_t *pixels;
  int i, j;
  if (toQuit) {
    pthread_exit(NULL);
  }
  pthread_mutex_lock(&image_mutex);
  if (isContextValid()) {
    pixels = image_data_->Map(image);
    for (j = 0; j < screenHeight; j++) {
      for (i = 0; i < screenWidth; i++) {
	pixels[j*(screenStride/4)+i] = dispBits[j*width+i];
      }
    }
    image_data_->Unmap(image);
  }
  pthread_mutex_unlock(&image_mutex);
  flush_display_requested = 1;
  return 0;
}