Ejemplo n.º 1
0
	TextureRegion::TextureRegion(TextureAtlas *pTextureAtlas,float x1,float y1,float x2,float y2)
	{
		mTexture=pTextureAtlas;
		Region(x1,y1,x2,y2);
	
		if(!pTextureAtlas)
			Log::Warning("TxTextureRegion::TxTextureRegion: Texture Atlas - null");
	}
Ejemplo n.º 2
0
Region CCTiledLayerImpl::visibleContentOpaqueRegion() const
{
    if (m_skipsDraw)
        return Region();
    if (opaque())
        return visibleContentRect();
    return m_tiler->opaqueRegionInContentRect(visibleContentRect());
}
Ejemplo n.º 3
0
Regions Content::LayoutForPointInRegion(Point p, const Region& rgn) const
{
	Region layoutRgn = Region(rgn.Origin() + p, frame.Dimensions());

	Regions rgns;
	rgns.push_back(layoutRgn);
	return rgns;
}
Ejemplo n.º 4
0
void TextureMapperLayer::computeOverlapRegions(Region& overlapRegion, Region& nonOverlapRegion, ResolveSelfOverlapMode mode)
{
    if (!m_state.visible || !m_state.contentsVisible)
        return;

    FloatRect boundingRect;
    if (m_backingStore || m_state.masksToBounds || m_state.maskLayer || hasFilters())
        boundingRect = layerRect();
    else if (m_contentsLayer || m_state.solidColor.alpha())
        boundingRect = m_state.contentsRect;

    if (m_currentFilters.hasOutsets()) {
        FilterOutsets outsets = m_currentFilters.outsets();
        IntRect unfilteredTargetRect(boundingRect);
        boundingRect.move(std::max(0, -outsets.left()), std::max(0, -outsets.top()));
        boundingRect.expand(outsets.left() + outsets.right(), outsets.top() + outsets.bottom());
        boundingRect.unite(unfilteredTargetRect);
    }

    TransformationMatrix replicaMatrix;
    if (m_state.replicaLayer) {
        replicaMatrix = replicaTransform();
        boundingRect.unite(replicaMatrix.mapRect(boundingRect));
    }

    boundingRect = m_currentTransform.combined().mapRect(boundingRect);

    // Count all masks and filters as overlap layers.
    if (hasFilters() || m_state.maskLayer || (m_state.replicaLayer && m_state.replicaLayer->m_state.maskLayer)) {
        Region newOverlapRegion(enclosingIntRect(boundingRect));
        nonOverlapRegion.subtract(newOverlapRegion);
        overlapRegion.unite(newOverlapRegion);
        return;
    }

    Region newOverlapRegion;
    Region newNonOverlapRegion(enclosingIntRect(boundingRect));

    if (!m_state.masksToBounds) {
        for (auto* child : m_children)
            child->computeOverlapRegions(newOverlapRegion, newNonOverlapRegion, ResolveSelfOverlapIfNeeded);
    }

    if (m_state.replicaLayer) {
        newOverlapRegion.unite(replicaMatrix.mapRect(newOverlapRegion.bounds()));
        Region replicaRegion(replicaMatrix.mapRect(newNonOverlapRegion.bounds()));
        resolveOverlaps(replicaRegion, newOverlapRegion, newNonOverlapRegion);
    }

    if ((mode != ResolveSelfOverlapAlways) && shouldBlend()) {
        newNonOverlapRegion.unite(newOverlapRegion);
        newOverlapRegion = Region();
    }

    overlapRegion.unite(newOverlapRegion);
    resolveOverlaps(newNonOverlapRegion, overlapRegion, nonOverlapRegion);
}
static Rect reduce(const Rect& win, const Region& exclude) {
    if (CC_LIKELY(exclude.isEmpty())) {
        return win;
    }
    if (exclude.isRect()) {
        return win.reduce(exclude.getBounds());
    }
    return Region(win).subtract(exclude).getBounds();
}
Ejemplo n.º 6
0
Group::Group(unsigned int genus) {
	//center = cen;
	halfRegionWidth = _DRAW_WIDTH/(2*genus);
	for (unsigned int i = 0; i < genus; i++) {
		trans.push_back(vec2((-1 + .1 + (halfRegionWidth) + i*(_DRAW_WIDTH/(genus))), 0.0));
	}
	Region n = Region(genus, trans);
	baseRegion = n;
}
Ejemplo n.º 7
0
void RasterShapeIntervals::getIncludedIntervals(int y1, int y2, SegmentList& result) const
{
    ASSERT(y2 >= y1);

    IntRect lineRect(bounds().x(), y1, bounds().width(), y2 - y1);
    Region lineRegion(lineRect);
    lineRegion.intersect(m_region);
    if (lineRegion.isEmpty())
        return;

    const Vector<IntRect>& lineRects = lineRegion.rects();
    ASSERT(lineRects.size() > 0);

    Region segmentsRegion(lineRect);
    Region intervalsRegion;

    // The loop below uses Regions to compute the intersection of the horizontal
    // shape intervals that fall within the line's box.
    int currentLineY = lineRects[0].y();
    int currentLineMaxY = lineRects[0].maxY();
    for (unsigned i = 0; i < lineRects.size(); ++i) {
        int lineY = lineRects[i].y();
        ASSERT(lineY >= currentLineY);
        if (lineY > currentLineMaxY) {
            // We've encountered a vertical gap in lineRects, there are no included intervals.
            return;
        }
        if (lineY > currentLineY) {
            currentLineY = lineY;
            currentLineMaxY = lineRects[i].maxY();
            segmentsRegion.intersect(intervalsRegion);
            intervalsRegion = Region();
        } else
            currentLineMaxY = std::max<int>(currentLineMaxY, lineRects[i].maxY());
        intervalsRegion.unite(Region(alignedRect(lineRects[i], y1, y2)));
    }
    if (!intervalsRegion.isEmpty())
        segmentsRegion.intersect(intervalsRegion);

    const Vector<IntRect>& segmentRects = segmentsRegion.rects();
    for (unsigned i = 0; i < segmentRects.size(); ++i)
        result.append(LineSegment(segmentRects[i].x(), segmentRects[i].maxX()));
}
Ejemplo n.º 8
0
void CCOcclusionTrackerBase<LayerType, RenderSurfaceType>::finishedTargetRenderSurface(const LayerType* owningLayer, const RenderSurfaceType* finishedTarget)
{
    // FIXME: Remove the owningLayer parameter when we can get all the info from the surface.
    ASSERT(owningLayer->renderSurface() == finishedTarget);

    // Make sure we know about the target surface.
    enterTargetRenderSurface(finishedTarget);

    // If the occlusion within the surface can not be applied to things outside of the surface's subtree, then clear the occlusion here so it won't be used.
    if (owningLayer->maskLayer() || !surfaceOpacityKnown(finishedTarget) || finishedTarget->drawOpacity() < 1 || finishedTarget->filters().hasFilterThatAffectsOpacity()) {
        m_stack.last().occlusionInScreen = Region();
        m_stack.last().occlusionInTarget = Region();
    } else {
        if (!surfaceTransformsToTargetKnown(finishedTarget))
            m_stack.last().occlusionInTarget = Region();
        if (!surfaceTransformsToScreenKnown(finishedTarget))
            m_stack.last().occlusionInScreen = Region();
    }
}
Region ScrollingCoordinator::computeNonFastScrollableRegion(const Frame* frame, const IntPoint& frameLocation) const
{
#if ENABLE(IOS_TOUCH_EVENTS)
    // On iOS, we use nonFastScrollableRegion to represent the region covered by elements with touch event handlers.
    ASSERT(frame->isMainFrame());
    UNUSED_PARAM(frameLocation);

    Document* document = frame->document();
    if (!document)
        return Region();

    Vector<IntRect> touchRects;
    document->getTouchRects(touchRects);
    
    Region touchRegion;
    for (const auto& rect : touchRects)
        touchRegion.unite(rect);

    return touchRegion;
#else
    Region nonFastScrollableRegion;
    FrameView* frameView = frame->view();
    if (!frameView)
        return nonFastScrollableRegion;

    IntPoint offset = frameLocation;
    offset.moveBy(frameView->frameRect().location());
    offset.move(0, frameView->topContentInset());

    if (const FrameView::ScrollableAreaSet* scrollableAreas = frameView->scrollableAreas()) {
        for (FrameView::ScrollableAreaSet::const_iterator it = scrollableAreas->begin(), end = scrollableAreas->end(); it != end; ++it) {
            ScrollableArea* scrollableArea = *it;
            // Composited scrollable areas can be scrolled off the main thread.
            if (scrollableArea->usesCompositedScrolling())
                continue;
            IntRect box = scrollableArea->scrollableAreaBoundingBox();
            box.moveBy(offset);
            nonFastScrollableRegion.unite(box);
        }
    }

    for (const auto& child : frameView->children()) {
        if (!child->isPluginViewBase())
            continue;
        PluginViewBase* pluginViewBase = toPluginViewBase(child.get());
        if (pluginViewBase->wantsWheelEvents())
            nonFastScrollableRegion.unite(pluginViewBase->frameRect());
    }

    for (Frame* subframe = frame->tree().firstChild(); subframe; subframe = subframe->tree().nextSibling())
        nonFastScrollableRegion.unite(computeNonFastScrollableRegion(subframe, offset));

    return nonFastScrollableRegion;
#endif
}
Ejemplo n.º 10
0
List<Region> Map2d<Object>::collectregions() {
  int numrs=largest();
  List<Region> rs=List<Region>(numrs);
  for (int i=1;i<=numrs;i++)
    rs.add(Region(width,height));
  for (int i=0;i<width;i++)
  for (int j=0;j<height;j++)
    if (getpos(i,j)>0)
      rs.p2num(getpos(i,j))->list->add(Pixel(i,j));
  return rs;
}
Ejemplo n.º 11
0
END_TEST

BEGIN_TEST(viewInsideRegion1) 
{
Region r1 = Region(1,2,3,4);
r1.
v.addRegion(r1);
WIN_ASSERT_TRUE(v.clickableRegions.get(r1).isInsideRegion(2,3));


}
Ejemplo n.º 12
0
int EQS_D2D::Coefs( ELEM*    elem,
                    PROJECT* project,
                    double** estifm,
                    double*  force )
{
  if( isFS(elem->flag, ELEM::kDry)  ||  isFS(elem->flag, ELEM::kBound) )  return 0;

  Region( elem, project, estifm, force );

  return 1;
}
Ejemplo n.º 13
0
END_TEST

BEGIN_TEST(viewInsideRegion2) 
{
Region r1 = Region(1,2,3,4);
r1.
v.addRegion(r1);
WIN_ASSERT_FALSSE(v.cickableRegions.get(r1).isInsideRegion(12,13);


}
Ejemplo n.º 14
0
END_TEST


BEGIN_TEST(addRegion1) 
{
Region r1 = Region(1,2,3,4);
v.addRegion(r1);
WIN_ASSERT_EQUAL(v.clickableRegions.exists(), r1); 


}
Ejemplo n.º 15
0
void LayerBase::drawForSreenShot()
{
    //Dont draw External-only layers
    if (isLayerExternalOnly(getLayer())) {
        return;
    }
    const DisplayHardware& hw(graphicPlane(0).displayHardware());
    setFiltering(true);
    onDraw( Region(hw.bounds()) );
    setFiltering(false);
}
Ejemplo n.º 16
0
void TextureMapperLayer::paintUsingOverlapRegions(const TextureMapperPaintOptions& options)
{
    Region overlapRegion;
    Region nonOverlapRegion;
    computeOverlapRegions(overlapRegion, nonOverlapRegion, ResolveSelfOverlapAlways);
    if (overlapRegion.isEmpty()) {
        paintSelfAndChildrenWithReplica(options);
        return;
    }

    // Having both overlap and non-overlap regions carries some overhead. Avoid it if the overlap area
    // is big anyway.
    if (overlapRegion.bounds().size().area() > nonOverlapRegion.bounds().size().area()) {
        overlapRegion.unite(nonOverlapRegion);
        nonOverlapRegion = Region();
    }

    nonOverlapRegion.translate(options.offset);
    Vector<IntRect> rects = nonOverlapRegion.rects();

    for (size_t i = 0; i < rects.size(); ++i) {
        IntRect rect = rects[i];
        if (!rect.intersects(options.textureMapper->clipBounds()))
            continue;

        options.textureMapper->beginClip(TransformationMatrix(), rects[i]);
        paintSelfAndChildrenWithReplica(options);
        options.textureMapper->endClip();
    }

    rects = overlapRegion.rects();
    static const size_t OverlapRegionConsolidationThreshold = 4;
    if (nonOverlapRegion.isEmpty() && rects.size() > OverlapRegionConsolidationThreshold) {
        rects.clear();
        rects.append(overlapRegion.bounds());
    }

    IntSize maxTextureSize = options.textureMapper->maxTextureSize();
    IntRect adjustedClipBounds(options.textureMapper->clipBounds());
    adjustedClipBounds.move(-options.offset);
    for (size_t i = 0; i < rects.size(); ++i) {
        IntRect rect = rects[i];
        for (int x = rect.x(); x < rect.maxX(); x += maxTextureSize.width()) {
            for (int y = rect.y(); y < rect.maxY(); y += maxTextureSize.height()) {
                IntRect tileRect(IntPoint(x, y), maxTextureSize);
                tileRect.intersect(rect);
                if (!tileRect.intersects(adjustedClipBounds))
                    continue;

                paintWithIntermediateSurface(options, tileRect);
            }
        }
    }
}
Ejemplo n.º 17
0
BOOL Manipulator::IsInClient(CPoint pt)
{
	CRect rc = Region(pt);
	if(rc.top>0&&rc.left>0)
	{
		return TRUE;
	}
	else
	{
		return FALSE;
	}
}
Ejemplo n.º 18
0
std::vector<Region> Region::subdivide()
{
	std::vector<Region> out;
	out.reserve(4);

	for (int i = 0; i < 2; i++) {
		for (int z = 0; z < 2; z++) {
			out.push_back(Region(image, threshold, start_x + (i * (size_x / 2)), start_y + (z * (size_y / 2)), (size_x / 2), (size_y / 2)) );
		}
	}
	return out;
}
Ejemplo n.º 19
0
/** Draws the Control on the Output Display */
void TextEdit::DrawInternal(Region& rgn)
{
	ieWord yOff = FontPosY;
	if (Back) {
		core->GetVideoDriver()->BlitSprite( Back, rgn.x, rgn.y, true );
		if (yOff) yOff += Back->Height;
	}
	if (!font)
		return;

	// FIXME: we should clip text to the background right?
	//The aligning of textedit fields is done by absolute positioning (FontPosX, FontPosY)
	if (hasFocus) {
		font->Print( Region( rgn.x + FontPosX, rgn.y - yOff, rgn.w, rgn.h ), Buffer,
				palette, Alignment,
				true, NULL, Cursor, CurPos );
	} else {
		font->Print( Region( rgn.x + FontPosX, rgn.y - yOff, rgn.w, rgn.h ), Buffer,
				palette, Alignment, true );
	}
}
Ejemplo n.º 20
0
Region Region::partition(enum partition p, double x, double y) {
	double centerX, centerY, width, height;
	double w = (this->width / 2.0);
	double h = (this->height / 2.0);
	double dx = x - this->x;
	double dy = y - this->y;
	
	if ( this->contain(x, y) ) {
		switch (p) {
			case kNEPartition:
			width = w - dx;
			height = h - dy;
			centerX = x + (width / 2.0);
			centerY = y + (height / 2.0);
			break;
			case kNWPartition:
			width = w + dx;
			height = h + dy;
			centerX = x - (width / 2.0);
			centerY = y + (height / 2.0);
			break;
			case kSEPartition:
			width = w - dx;
			height = h + dy;
			centerX = x + (width / 2.0);
			centerY = y - (height / 2.0);
			break;
			case kSWPartition:
			width = w + dx;
			height = h + dy;
			centerX = x - (width / 2.0);
			centerY = y - (height / 2.0);
			break;
		}
	} else {
		return Region(0,0,-1,-1);
	}
	
	return Region(centerX, centerY, width, height);
}
Ejemplo n.º 21
0
int rtree_insert_test() {
    ISpatialIndex *rtree;
	try {
        // Create a new storage manager with the provided base name and a 4K page size.
        //std::string baseName = "rtree";
        //IStorageManager* diskfile = StorageManager::createNewDiskStorageManager(baseName, 4096);
        memfile = StorageManager::createNewMemoryStorageManager();

        //StorageManager::IBuffer* file = StorageManager::createNewRandomEvictionsBuffer(*memfile, 100, false);
        // applies a main memory random buffer on top of the persistent storage manager
        // (LRU buffer, etc can be created the same way).

        // Create a new, empty, RTree with dimensionality 2, minimum load 70%, using "file" as
        // the StorageManager and the RSTAR splitting policy.
        id_type indexIdentifier;
        rtree = RTree::createNewRTree(*memfile, 0.7, 100, 100, MAX_DIM_NUM, SpatialIndex::RTree::RV_RSTAR, indexIdentifier);

        id_type id;
		uint32_t op;
		double x1, x2, y1, y2, z1, z2;
		double plow[3], phigh[3];

        std::ifstream fin("/root/mbj/data/data");
		while (fin)
		{
			fin >> op >> id >> x1 >> y1 >> z1 >> x2 >> y2 >> z2;
			if (! fin.good()) continue; // skip newlines, etc.

			if (op == RTREE_INSERT)
			{
				plow[0] = x1; plow[1] = y1; plow[2] = z1;
				phigh[0] = x2; phigh[1] = y2; phigh[2] = z2;

				Region r = Region(plow, phigh, 3);

				std::ostringstream os;
				os << r;
				std::string data = os.str();

				rtree->insertData(data.size() + 1, reinterpret_cast<const byte*>(data.c_str()), r, id);

			}
		}

    } catch (Tools::Exception& e) {
		std::cerr << "******ERROR******" << std::endl;
		std::string s = e.what();
		std::cerr << s << std::endl;
		return FALSE;
	}
    return TRUE;
}
Ejemplo n.º 22
0
int rtree_query(double plow[], double phigh[], ISpatialIndex *rtree) {
    if(rtree == NULL) {
        return FALSE;
    }

    uint32_t queryType = 0;
    MyVisitor vis;
	try {

        if (queryType == 0) {
            // this will find all data that intersect with the query range.
            Region r = Region(plow, phigh, MAX_DIM_NUM);
            rtree->intersectsWithQuery(r, vis);
            vis.printData();
        } else if (queryType == 1) {
            // this will find the 10 nearest neighbors.
            Point p = Point(plow, MAX_DIM_NUM);
            rtree->nearestNeighborQuery(10, p, vis);
        } else if(queryType == 2) {
            Region r = Region(plow, phigh, MAX_DIM_NUM);
            rtree->selfJoinQuery(r, vis);
        } else {
            // this will find all data that is contained by the query range.
            Region r = Region(plow, phigh, MAX_DIM_NUM);
            rtree->containsWhatQuery(r, vis);
        }

    } catch (Tools::Exception& e) {
		std::cerr << "******ERROR******" << std::endl;
		std::string s = e.what();
		std::cerr << s << std::endl;
		return FALSE;
    } catch (...) { cerr << "******ERROR******" << endl;
		cerr << "other exception" << endl;
		return FALSE;
	}
    return vis.getNumberOfData();
}
Ejemplo n.º 23
0
Region RegionFactory::
        operator()(const Reference& ref) const
{
    Position a, b;
    // For integers 'i': "2 to the power of 'i'" == powf(2.f, i) == ldexpf(1.f, i)
    Position blockSize( block_size_.texels_per_row () * ldexpf(1.f,ref.log2_samples_size[0]),
                        block_size_.texels_per_column () * ldexpf(1.f,ref.log2_samples_size[1]));
    a.time = blockSize.time * ref.block_index[0];
    a.scale = blockSize.scale * ref.block_index[1];
    b.time = a.time + blockSize.time;
    b.scale = a.scale + blockSize.scale;

    return Region(a,b);
}
Region RegionBuilder::build(size_t address, size_t base, size_t length, size_t /* INOUT */ &additionalContribution) {
   Region::bitfield_t const ONE = 1;
   Region::bitfield_t const ALL_ONE = ~((Region::bitfield_t)0);
   size_t const wordLength = sizeof(size_t)*8UL;
   
   //
   // Calculate the lowest bits of the mask (base mask relative to address 0).
   // That is, the part of the mask due to the stride determined by the mask.
   //
   size_t lowMask;
   
   if (base != 1) {
      // Find where the skiped bits begin
      lowMask = base - 1;
      size_t maskLowest1;
      for (maskLowest1 = 0; maskLowest1 <= wordLength-1UL; maskLowest1++) {
         if (lowMask & (ONE << maskLowest1)) {
            break;
         }
      }
      
      
      // Mark the following bits
      lowMask = lowMask | ((ONE << maskLowest1) - 1);
      lowMask = ~lowMask;
   } else {
      lowMask = ALL_ONE;
   }
   
   size_t lastAddress = address + (length-1)*base + additionalContribution;
   
   additionalContribution = additionalContribution + (length-1UL)*base;
   
   size_t highMask=0;
   for (int bit=wordLength-1; bit >= 0; bit--) {
      size_t bitSelector = ONE << bit;
      if ((address & bitSelector) == (lastAddress & bitSelector)) {
         highMask |= bitSelector;
      } else {
         break;
      }
   }
   highMask = ~highMask;
   
   size_t mask = ~(lowMask & highMask);
   
   address = address & mask;
   
   return Region(address, mask);
}
Ejemplo n.º 25
0
TEST(CoreTests, ImageOutOfBounds) {
    Image<char> * image = new Image<char>(10,10);
    // Getters
    EXPECT_THROW(image->get(-1), OutOfBoundsException);
    EXPECT_THROW(image->get(10*10), OutOfBoundsException);
    EXPECT_THROW(image->get(-1, 4), OutOfBoundsException);
    EXPECT_THROW(image->get(-1,-10), OutOfBoundsException);
    EXPECT_THROW(image->get(10, 0), OutOfBoundsException);
    EXPECT_THROW(image->get(2, 200), OutOfBoundsException);
    EXPECT_THROW(image->get(int2(-1, 4)), OutOfBoundsException);
    EXPECT_THROW(image->get(int2(0, 200)), OutOfBoundsException);
    EXPECT_THROW(image->get(Region(11, 11)), OutOfBoundsException);

    // Setters
    EXPECT_THROW(image->set(-1, 1), OutOfBoundsException);
    EXPECT_THROW(image->set(10*10, 1), OutOfBoundsException);
    EXPECT_THROW(image->set(-1, 4, 1), OutOfBoundsException);
    EXPECT_THROW(image->set(-1,-10, 1), OutOfBoundsException);
    EXPECT_THROW(image->set(10, 0, 1), OutOfBoundsException);
    EXPECT_THROW(image->set(2, 200, 1), OutOfBoundsException);
    EXPECT_THROW(image->set(int2(-1, 4), 1), OutOfBoundsException);
    EXPECT_THROW(image->set(int2(0, 200), 1), OutOfBoundsException);
    EXPECT_THROW(image->set(Region(11, 11), 1), OutOfBoundsException);
}
Ejemplo n.º 26
0
Region * Planet::CreateMoonRegion( MoonID iMoonID, const RegionCoords & vRegionCoords )
{
    Assert( iMoonID < m_iMoonCount );
    RegionMap * pMap = m_arrMoons[iMoonID];

    if ( pMap->Contains(vRegionCoords) )
        return (*pMap)[vRegionCoords];

    BlockWorldFn->SelectMemory( TEXT("Regions") );
    Region * pRegion = New Region( this, iMoonID, vRegionCoords );
    BlockWorldFn->UnSelectMemory();

    Bool bInserted = pMap->Insert( vRegionCoords, pRegion );
    Assert( bInserted );

    return pRegion;
}
Ejemplo n.º 27
0
float offness(Polygon2d p) {
      Region r=Region(p,oi->width,oi->height);
      r.makelist();
      V2d v=V2d(0,0);
      int cnt=0;
      for (int i=1;i<=r.list->len;i++) {
        int x=r.list->num(i).x;
        int y=r.list->num(i).y;
        if (angs->inmap(x,y)) {
          v=v+mag->pos[x][y]*V2d::rotate(V2d(1,0),angs->pos[x][y]);
          cnt++;
        }
      }
      float offness=v.mod()/(float)cnt;
      printf("Quad has offness %f count %i area %f\n",offness,cnt,p.area());
      return offness;
}
status_t SurfaceTexture::convert(sp<GraphicBuffer> &srcBuf, sp<GraphicBuffer> &dstBuf) {
    copybit_image_t dstImg;
    dstImg.w = dstBuf->getWidth();
    dstImg.h = dstBuf->getHeight();
    dstImg.format = dstBuf->getPixelFormat();
    dstImg.handle = (native_handle_t*) dstBuf->getNativeBuffer()->handle;

    copybit_image_t srcImg;
    srcImg.w = srcBuf->getWidth();
    srcImg.h = srcBuf->getHeight();
    srcImg.format = srcBuf->getPixelFormat();
    srcImg.base = NULL;
    srcImg.handle = (native_handle_t*) srcBuf->getNativeBuffer()->handle;

    copybit_rect_t dstCrop;
    dstCrop.l = 0;
    dstCrop.t = 0;
    dstCrop.r = dstBuf->getWidth();
    dstCrop.b = dstBuf->getHeight();

    copybit_rect_t srcCrop;
    srcCrop.l = 0;
    srcCrop.t = 0;
    srcCrop.r = srcBuf->getWidth();
    srcCrop.b = srcBuf->getHeight();

    region_iterator clip(Region(Rect(dstCrop.r, dstCrop.b)));
    mBlitEngine->set_parameter(mBlitEngine, COPYBIT_TRANSFORM, 0);
    mBlitEngine->set_parameter(mBlitEngine, COPYBIT_PLANE_ALPHA, 0xFF);
    mBlitEngine->set_parameter(mBlitEngine, COPYBIT_DITHER, COPYBIT_ENABLE);

    int err = mBlitEngine->stretch(
            mBlitEngine, &dstImg, &srcImg, &dstCrop, &srcCrop, &clip);
    if (err != 0) {
        ALOGE("Error: Blit stretch operation failed, retry once (err:%d)", err);
        // TODO: Bad boy doing hacks here, blit stretch operation should be completely fixed.
        int err = mBlitEngine->stretch(
            mBlitEngine, &dstImg, &srcImg, &dstCrop, &srcCrop, &clip);
        if (err != 0) {
            ALOGE("Error: Blit stretch operation failed (err:%d)", err);
            return UNKNOWN_ERROR;
        }
    }
    return OK;
}
Ejemplo n.º 29
0
void Region::computeMoments(std::vector<Region> &region, const RegionSet &decomposition) {
	// (2P)
	std::vector<Interval> rle = decomposition.rle;
	Interval I;

	for (unsigned int i = 0; i < rle.size(); ++i){
		I = rle[i];
		if (region.size() == I.region){
			region.push_back(Region());
		}
		region[I.region].integral   += I.xHi - I.xLo + 1;
		region[I.region].integralX  += (I.xHi * (I.xHi + 1) - I.xLo * (I.xLo - 1)) * .5;
		region[I.region].integralY  += (I.xHi - I.xLo + 1) * I.y;
		region[I.region].integralXX += (std::pow(I.xHi + .5, 3) - std::pow(I.xLo - .5, 3)) / 3.0;
		region[I.region].integralXY += (I.xHi * (I.xHi + 1) - I.xLo * (I.xLo - 1)) * I.y * .5;
		region[I.region].integralYY += (I.xHi - I.xLo + 1) * (I.y * I.y + 1.0 / 12.0);
	}
}
Ejemplo n.º 30
0
void Content::Draw(Point p) const
{
	Size s(frame.Dimensions());
	s.h = (s.h <= 0) ? CONTENT_MAX_SIZE: s.h;
	s.w = (s.w <= 0) ? CONTENT_MAX_SIZE: s.w;

#if DEBUG_TEXT
	Region drawRgn(p, s);
	core->GetVideoDriver()->DrawRect(drawRgn, ColorGreen, true);
#endif
	// FIXME: passing around a screen offset is clumsy.
	// there should be a way to have the video dirver draw relative to a given rect
	// we *almost* have this functionality, but it is tied to the gamecontrol viewport at the moment

	// this is the root of the drawing so region and point are both at 0,0
	Point origin;
	DrawContentsInRegions(LayoutForPointInRegion(origin, Region(origin, s)), p);
}