コード例 #1
0
ファイル: prjwnd.c プロジェクト: bencz/OrangeC
void DragTo(HTREEITEM dstItem, HTREEITEM srcItem)
{
    PROJECTITEM *srcData = GetItemInfo(srcItem);
    PROJECTITEM *dstData = GetItemInfo(dstItem);
    if (srcData && dstData && srcData->parent != dstData)
    {
        PROJECTITEM *p = dstData->parent;
        while(p)
            if (p == srcData)
                return;
            else
                p = p->parent;
        if (srcData->type == PJ_FOLDER || srcData->type == PJ_FILE)
        {
            if (dstData->type == PJ_FOLDER || dstData->type == PJ_PROJ)
            {
                PROJECTITEM **rmv = &srcData->parent->children;
                MarkChanged(srcData,FALSE);
                while (*rmv && *rmv != srcData)
                    rmv = &(*rmv)->next;
                if (*rmv)
                {
                    PROJECTITEM **ins = &dstData->children;
                    HTREEITEM pos = TVI_FIRST;
                    (*rmv) = (*rmv)->next;

                    TreeView_DeleteItem(prjTreeWindow, srcData->hTreeItem);
                    ResDeleteItem(srcData);
                    if (srcData->type == PJ_FILE)
                    {
                        while (*ins && (*ins)->type == PJ_FOLDER)
                        {
                            pos = (*ins)->hTreeItem;
                            ins = &(*ins)->next;
                        }
                    }
                    while (*ins && (*ins)->type == srcData->type && stricmp((*ins)->displayName, srcData->displayName) < 0)
                    {
                        pos = (*ins)->hTreeItem;
                        ins = &(*ins)->next;
                    }
                    srcData->parent = dstData;
                    srcData->next = NULL;
                    RecursiveCreateTree(dstData->hTreeItem, pos, srcData);
                    srcData->next = *ins;
                    *ins = srcData;
                    MarkChanged(srcData,FALSE);
                }
            }
        }
    }
}
コード例 #2
0
ファイル: DrawTargetSkia.cpp プロジェクト: cbrem/gecko-dev
void
DrawTargetSkia::MaskSurface(const Pattern &aSource,
                            SourceSurface *aMask,
                            Point aOffset,
                            const DrawOptions &aOptions)
{
  MarkChanged();
  AutoPaintSetup paint(mCanvas.get(), aOptions, aSource);

  SkPaint maskPaint;
  TempBitmap tmpBitmap;
  SetPaintPattern(maskPaint, SurfacePattern(aMask, ExtendMode::CLAMP), tmpBitmap);

  SkMatrix transform = maskPaint.getShader()->getLocalMatrix();
  transform.postTranslate(SkFloatToScalar(aOffset.x), SkFloatToScalar(aOffset.y));
  maskPaint.getShader()->setLocalMatrix(transform);

  SkLayerRasterizer *raster = new SkLayerRasterizer();
  raster->addLayer(maskPaint);
  SkSafeUnref(paint.mPaint.setRasterizer(raster));

  IntSize size = aMask->GetSize();
  Rect rect = Rect(aOffset.x, aOffset.y, size.width, size.height);
  mCanvas->drawRect(RectToSkRect(rect), paint.mPaint);
}
コード例 #3
0
ファイル: bb_sudoku.c プロジェクト: Aykut-/plb
/********************\ 
**  ProcessSingles  *********************************************\ 
**                                                              ** 
**    ProcessSingles takes a naked single and marks each cell   ** 
**    in the 3 associated groups as not allowing that number.   ** 
**    It also marks the groups as changed so we know to check   ** 
**    for hidden singles in that group.                         ** 
**                                                              ** 
**    This routines marks cells changed as each single is       ** 
**    processed.                                                ** 
**                                                              ** 
\****************************************************************/ 
static void ProcessSingles (void) 
{ int i, t, g, t2; 
register  unsigned int b; 

  for (i = 0; i < SingleCnt; i++) 
  { t = SinglePos[i];                     // Get local copy of position 
    b = SingleVal[i];                     // Get local copy of the value 

    if (Gp->Grid[t] == 0) continue;   // Check if we already processed this position 
    if (!(Gp->Grid[t] & b))           // Check for error conditions 
    { No_Sol = 1; SingleCnt = Changed = 0; return; } 
    SolGrid[t] = b; // Store the single in the solution grid 
    Gp->CellsLeft--;                  // mark one less empty space 
    Gp->Grid[t] = 0;                  // mark this position processed 

    for (g = 0; g < 3; g++)               // loop through all 3 groups 
      Gp->Grp[C2Grp[t][g]] |= b;      // mark the value as found in the group 
    for (g = 0; g < 20; g++)              // loop through each cell in the groups 
    { t2 = (int)In_Groups[t][g];          // get temp copy of position 
      if (Gp->Grid[t2] & b)           // check if removing a possibility 
      { Gp->Grid[t2] = Gp->Grid[t2] ^ b;    // remove possibility 
        if (Gp->Grid[t2] == 0)                  // check for error (no possibility) 
           { No_Sol = 1; SingleCnt = 0; Changed = 0; return; } 
        if (B2V[Gp->Grid[t2]])                  // Check if a naked single is found 
          PushSingle(t2, Gp->Grid[t2]); 
        MarkChanged(t2);                            // Mark groups as changed 
      } 
    } 
  } 
  SingleCnt = 0;                          // Clear the single count 
} 
コード例 #4
0
ファイル: DrawTargetSkia.cpp プロジェクト: cbrem/gecko-dev
void
DrawTargetSkia::CopySurface(SourceSurface *aSurface,
                            const IntRect& aSourceRect,
                            const IntPoint &aDestination)
{
  //TODO: We could just use writePixels() here if the sourceRect is the entire source

  if (aSurface->GetType() != SurfaceType::SKIA) {
    return;
  }

  MarkChanged();

  TempBitmap bitmap = GetBitmapForSurface(aSurface);

  mCanvas->save();
  mCanvas->resetMatrix();
  SkRect dest = IntRectToSkRect(IntRect(aDestination.x, aDestination.y, aSourceRect.width, aSourceRect.height)); 
  SkIRect source = IntRectToSkIRect(aSourceRect);
  mCanvas->clipRect(dest, SkRegion::kReplace_Op);
  SkPaint paint;

  if (mCanvas->getDevice()->config() == SkBitmap::kRGB_565_Config) {
    // Set the xfermode to SOURCE_OVER to workaround
    // http://code.google.com/p/skia/issues/detail?id=628
    // RGB565 is opaque so they're equivalent anyway
    paint.setXfermodeMode(SkXfermode::kSrcOver_Mode);
  } else {
    paint.setXfermodeMode(SkXfermode::kSrc_Mode);
  }

  mCanvas->drawBitmapRect(bitmap.mBitmap, &source, dest, &paint);
  mCanvas->restore();
}
コード例 #5
0
void
DrawTargetSkia::FillGlyphs(ScaledFont *aFont,
                           const GlyphBuffer &aBuffer,
                           const Pattern &aPattern,
                           const DrawOptions &aOptions,
                           const GlyphRenderingOptions*)
{
    if (aFont->GetType() != FONT_MAC &&
            aFont->GetType() != FONT_SKIA &&
            aFont->GetType() != FONT_GDI) {
        return;
    }

    MarkChanged();

    ScaledFontBase* skiaFont = static_cast<ScaledFontBase*>(aFont);

    AutoPaintSetup paint(mCanvas.get(), aOptions, aPattern);
    paint.mPaint.setTypeface(skiaFont->GetSkTypeface());
    paint.mPaint.setTextSize(SkFloatToScalar(skiaFont->mSize));
    paint.mPaint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);

    std::vector<uint16_t> indices;
    std::vector<SkPoint> offsets;
    indices.resize(aBuffer.mNumGlyphs);
    offsets.resize(aBuffer.mNumGlyphs);

    for (unsigned int i = 0; i < aBuffer.mNumGlyphs; i++) {
        indices[i] = aBuffer.mGlyphs[i].mIndex;
        offsets[i].fX = SkFloatToScalar(aBuffer.mGlyphs[i].mPosition.x);
        offsets[i].fY = SkFloatToScalar(aBuffer.mGlyphs[i].mPosition.y);
    }

    mCanvas->drawPosText(&indices.front(), aBuffer.mNumGlyphs*2, &offsets.front(), paint.mPaint);
}
コード例 #6
0
ファイル: DrawTargetSkia.cpp プロジェクト: cbrem/gecko-dev
void
DrawTargetSkia::DrawSurfaceWithShadow(SourceSurface *aSurface,
                                      const Point &aDest,
                                      const Color &aColor,
                                      const Point &aOffset,
                                      Float aSigma,
                                      CompositionOp aOperator)
{
  if (!(aSurface->GetType() == SurfaceType::SKIA || aSurface->GetType() == SurfaceType::DATA)) {
    return;
  }

  MarkChanged();

  mCanvas->save(SkCanvas::kMatrix_SaveFlag);
  mCanvas->resetMatrix();

  TempBitmap bitmap = GetBitmapForSurface(aSurface);

  SkPaint paint;

  SkImageFilter* filter = SkDropShadowImageFilter::Create(aOffset.x, aOffset.y,
                                                          aSigma, ColorToSkColor(aColor, 1.0));

  paint.setImageFilter(filter);
  paint.setXfermodeMode(GfxOpToSkiaOp(aOperator));

  mCanvas->drawBitmap(bitmap.mBitmap, aDest.x, aDest.y, &paint);
  mCanvas->restore();
}
コード例 #7
0
ファイル: WaveTrack.cpp プロジェクト: Kirushanr/audacity
bool WaveTrack::Copy(double t0, double t1, Track **dest)
{
   if (t1 < t0)
      return false;

   sampleCount s0, s1;

   TimeToSamplesClip(t0, &s0);
   TimeToSamplesClip(t1, &s1);

   WaveTrack *newTrack = new WaveTrack(mDirManager);
   newTrack->Init(*this);

   delete newTrack->mSequence;
   newTrack->mSequence = NULL;
   
   if (!mSequence->Copy(s0, s1, &newTrack->mSequence)) {
      // Error
      *dest = NULL;
      delete newTrack;
      return false;
   }

   newTrack->GetEnvelope()->CopyFrom(GetEnvelope(), t0, t1);

   *dest = newTrack;
   MarkChanged();
   return true;
}
コード例 #8
0
ファイル: WaveTrack.cpp プロジェクト: Kirushanr/audacity
bool WaveTrack::Cut(double t0, double t1, Track **dest)
{
   bool success;
   sampleCount s0, s1;
   WaveTrack *newTrack;

   if (t1 < t0)
      return false;

   TimeToSamplesClip(t0, &s0);
   TimeToSamplesClip(t1, &s1);

   newTrack = new WaveTrack(mDirManager);
   delete newTrack->mSequence;
   newTrack->mSequence = NULL;
   success = mSequence->Copy(s0, s1, &newTrack->mSequence);
   if (success)
      success = mSequence->Delete(s0, s1-s0);
   
   if (!success) {
      *dest = NULL;
      delete newTrack;
      return false;
   }

   newTrack->GetEnvelope()->CopyFrom(GetEnvelope(), t0, t1);
   mEnvelope->CollapseRegion(t0, t1);

   *dest = newTrack;
   MarkChanged();
   return true;
}
コード例 #9
0
ファイル: DrawTargetSkia.cpp プロジェクト: MYSHLIFE/gecko-dev
void
DrawTargetSkia::DrawSurface(SourceSurface *aSurface,
                            const Rect &aDest,
                            const Rect &aSource,
                            const DrawSurfaceOptions &aSurfOptions,
                            const DrawOptions &aOptions)
{
  if (!(aSurface->GetType() == SurfaceType::SKIA || aSurface->GetType() == SurfaceType::DATA)) {
    return;
  }

  if (aSource.IsEmpty()) {
    return;
  }

  MarkChanged();

  SkRect destRect = RectToSkRect(aDest);
  SkRect sourceRect = RectToSkRect(aSource);

  TempBitmap bitmap = GetBitmapForSurface(aSurface);
 
  AutoPaintSetup paint(mCanvas.get(), aOptions);
  if (aSurfOptions.mFilter == Filter::POINT) {
    paint.mPaint.setFilterBitmap(false);
  }

  mCanvas->drawBitmapRectToRect(bitmap.mBitmap, &sourceRect, destRect, &paint.mPaint);
}
コード例 #10
0
ファイル: WaveClip.cpp プロジェクト: tuanmasterit/audacity
bool WaveClip::SetSamples(samplePtr buffer, sampleFormat format,
                   sampleCount start, sampleCount len)
{
   bool bResult = mSequence->Set(buffer, format, start, len);
   MarkChanged();
   return bResult;
}
コード例 #11
0
void
DrawTargetSkia::MaskSurface(const Pattern &aSource,
                            SourceSurface *aMask,
                            Point aOffset,
                            const DrawOptions &aOptions)
{
  MarkChanged();
  AutoPaintSetup paint(mCanvas.get(), aOptions, aSource);

  TempBitmap bitmap = GetBitmapForSurface(aMask);
  if (bitmap.mBitmap.colorType() == kAlpha_8_SkColorType) {
    mCanvas->drawBitmap(bitmap.mBitmap, aOffset.x, aOffset.y, &paint.mPaint);
  } else {
    SkPaint maskPaint;
    TempBitmap tmpBitmap;
    SetPaintPattern(maskPaint, SurfacePattern(aMask, ExtendMode::CLAMP), tmpBitmap);

    SkMatrix transform = maskPaint.getShader()->getLocalMatrix();
    transform.postTranslate(SkFloatToScalar(aOffset.x), SkFloatToScalar(aOffset.y));
    maskPaint.getShader()->setLocalMatrix(transform);

    SkLayerRasterizer::Builder builder;
    builder.addLayer(maskPaint);
    SkAutoTUnref<SkRasterizer> raster(builder.detachRasterizer());
    paint.mPaint.setRasterizer(raster.get());

    IntSize size = aMask->GetSize();
    Rect rect = Rect(aOffset.x, aOffset.y, size.width, size.height);
    mCanvas->drawRect(RectToSkRect(rect), paint.mPaint);
  }
}
コード例 #12
0
void
DrawTargetSkia::Mask(const Pattern &aSource,
                     const Pattern &aMask,
                     const DrawOptions &aOptions)
{
    MarkChanged();
    AutoPaintSetup paint(mCanvas.get(), aOptions, aSource);

    SkPaint maskPaint;
    SetPaintPattern(maskPaint, aMask);

    SkLayerRasterizer *raster = new SkLayerRasterizer();
    raster->addLayer(maskPaint);
    SkSafeUnref(paint.mPaint.setRasterizer(raster));

    // Skia only uses the mask rasterizer when we are drawing a path/rect.
    // Take our destination bounds and convert them into user space to use
    // as the path to draw.
    SkPath path;
    path.addRect(SkRect::MakeWH(SkScalar(mSize.width), SkScalar(mSize.height)));

    Matrix temp = mTransform;
    temp.Invert();
    SkMatrix mat;
    GfxMatrixToSkiaMatrix(temp, mat);
    path.transform(mat);

    mCanvas->drawPath(path, paint.mPaint);
}
コード例 #13
0
void
DrawTargetSkia::DrawSurface(SourceSurface *aSurface,
                            const Rect &aDest,
                            const Rect &aSource,
                            const DrawSurfaceOptions &aSurfOptions,
                            const DrawOptions &aOptions)
{
    if (aSurface->GetType() != SURFACE_SKIA) {
        return;
    }

    if (aSource.IsEmpty()) {
        return;
    }

    MarkChanged();

    SkRect destRect = RectToSkRect(aDest);
    SkRect sourceRect = RectToSkRect(aSource);

    SkMatrix matrix;
    matrix.setRectToRect(sourceRect, destRect, SkMatrix::kFill_ScaleToFit);

    const SkBitmap& bitmap = static_cast<SourceSurfaceSkia*>(aSurface)->GetBitmap();

    AutoPaintSetup paint(mCanvas.get(), aOptions);
    SkShader *shader = SkShader::CreateBitmapShader(bitmap, SkShader::kClamp_TileMode, SkShader::kClamp_TileMode);
    shader->setLocalMatrix(matrix);
    SkSafeUnref(paint.mPaint.setShader(shader));
    if (aSurfOptions.mFilter != FILTER_LINEAR) {
        paint.mPaint.setFilterBitmap(false);
    }
    mCanvas->drawRect(destRect, paint.mPaint);
}
コード例 #14
0
static BOOL SoftwareDirectories_OnDelete(HWND hDlg)
{
    int     nCount;
    int     nSelect;
    int     nItem;
    HWND    hList = GetDlgItem(hDlg, IDC_DIR_LIST);
	BOOL res;

	g_bModifiedSoftwarePaths = TRUE;

    nItem = ListView_GetNextItem(hList, -1, LVNI_SELECTED | LVNI_ALL);

    if (nItem == -1)
        return FALSE;

    /* Don't delete "Append" placeholder. */
    if (nItem == ListView_GetItemCount(hList) - 1)
        return FALSE;

	res = ListView_DeleteItem(hList, nItem);

    nCount = ListView_GetItemCount(hList);
    if (nCount <= 1)
        return FALSE;

    /* If the last item was removed, select the item above. */
    if (nItem == nCount - 1)
        nSelect = nCount - 2;
    else
        nSelect = nItem;

    ListView_SetItemState(hList, nSelect, LVIS_FOCUSED | LVIS_SELECTED, LVIS_FOCUSED | LVIS_SELECTED);
	MarkChanged(hDlg);
	return TRUE;
}
コード例 #15
0
ファイル: WaveClip.cpp プロジェクト: tuanmasterit/audacity
void WaveClip::ConvertToSampleFormat(sampleFormat format)
{
   bool bChanged;
   bool bResult = mSequence->ConvertToSampleFormat(format, &bChanged);
   if (bResult && bChanged)
      MarkChanged();
   wxASSERT(bResult); // TODO: Throw an actual error.
}
コード例 #16
0
	void cTexturedQuadFactory::AddReference(cQuadInfo& info)
	{
		AKJ_ASSERT(info.mReferences >= 0);
		if(++info.mReferences == 1)
		{
			MarkChanged(info);
		}
	}
コード例 #17
0
ファイル: WaveClip.cpp プロジェクト: tuanmasterit/audacity
bool WaveClip::Clear(double t0, double t1)
{
   sampleCount s0, s1;

   TimeToSamplesClip(t0, &s0);
   TimeToSamplesClip(t1, &s1);

   if (GetSequence()->Delete(s0, s1-s0))
   {
      // msmeyer
      //
      // Delete all cutlines that are within the given area, if any.
      //
      // Note that when cutlines are active, two functions are used:
      // Clear() and ClearAndAddCutLine(). ClearAndAddCutLine() is called
      // whenever the user directly calls a command that removes some audio, e.g.
      // "Cut" or "Clear" from the menu. This command takes care about recursive
      // preserving of cutlines within clips. Clear() is called when internal
      // operations want to remove audio. In the latter case, it is the right
      // thing to just remove all cutlines within the area.
      //
      double clip_t0 = t0;
      double clip_t1 = t1;
      if (clip_t0 < GetStartTime())
         clip_t0 = GetStartTime();
      if (clip_t1 > GetEndTime())
         clip_t1 = GetEndTime();

      WaveClipList::compatibility_iterator nextIt;

      for (WaveClipList::compatibility_iterator it = mCutLines.GetFirst(); it; it=nextIt)
      {
         nextIt = it->GetNext();
         WaveClip* clip = it->GetData();
         double cutlinePosition = mOffset + clip->GetOffset();
         if (cutlinePosition >= t0 && cutlinePosition <= t1)
         {
            // This cutline is within the area, delete it
            delete clip;
            mCutLines.DeleteNode(it);
         } else
         if (cutlinePosition >= t1)
         {
            clip->Offset(clip_t0-clip_t1);
         }
      }

      // Collapse envelope
      GetEnvelope()->CollapseRegion(t0, t1);
      if (t0 < GetStartTime())
         Offset(-(GetStartTime() - t0));

      MarkChanged();
      return true;
   }

   return false;
}
コード例 #18
0
ファイル: DrawTargetSkia.cpp プロジェクト: cbrem/gecko-dev
void
DrawTargetSkia::FillGlyphs(ScaledFont *aFont,
                           const GlyphBuffer &aBuffer,
                           const Pattern &aPattern,
                           const DrawOptions &aOptions,
                           const GlyphRenderingOptions *aRenderingOptions)
{
  if (aFont->GetType() != FontType::MAC &&
      aFont->GetType() != FontType::SKIA &&
      aFont->GetType() != FontType::GDI) {
    return;
  }

  MarkChanged();

  ScaledFontBase* skiaFont = static_cast<ScaledFontBase*>(aFont);

  AutoPaintSetup paint(mCanvas.get(), aOptions, aPattern);
  paint.mPaint.setTypeface(skiaFont->GetSkTypeface());
  paint.mPaint.setTextSize(SkFloatToScalar(skiaFont->mSize));
  paint.mPaint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);

  if (aRenderingOptions && aRenderingOptions->GetType() == FontType::CAIRO) {
    switch (static_cast<const GlyphRenderingOptionsCairo*>(aRenderingOptions)->GetHinting()) {
      case FontHinting::NONE:
        paint.mPaint.setHinting(SkPaint::kNo_Hinting);
        break;
      case FontHinting::LIGHT:
        paint.mPaint.setHinting(SkPaint::kSlight_Hinting);
        break;
      case FontHinting::NORMAL:
        paint.mPaint.setHinting(SkPaint::kNormal_Hinting);
        break;
      case FontHinting::FULL:
        paint.mPaint.setHinting(SkPaint::kFull_Hinting);
        break;
    }

    if (static_cast<const GlyphRenderingOptionsCairo*>(aRenderingOptions)->GetAutoHinting()) {
      paint.mPaint.setAutohinted(true);
    }
  } else {
    paint.mPaint.setHinting(SkPaint::kNormal_Hinting);
  }

  std::vector<uint16_t> indices;
  std::vector<SkPoint> offsets;
  indices.resize(aBuffer.mNumGlyphs);
  offsets.resize(aBuffer.mNumGlyphs);

  for (unsigned int i = 0; i < aBuffer.mNumGlyphs; i++) {
    indices[i] = aBuffer.mGlyphs[i].mIndex;
    offsets[i].fX = SkFloatToScalar(aBuffer.mGlyphs[i].mPosition.x);
    offsets[i].fY = SkFloatToScalar(aBuffer.mGlyphs[i].mPosition.y);
  }

  mCanvas->drawPosText(&indices.front(), aBuffer.mNumGlyphs*2, &offsets.front(), paint.mPaint);
}
コード例 #19
0
void
DrawTargetD2D1::ClearRect(const Rect &aRect)
{
  MarkChanged();

  mDC->PushAxisAlignedClip(D2DRect(aRect), D2D1_ANTIALIAS_MODE_PER_PRIMITIVE);
  mDC->Clear();
  mDC->PopAxisAlignedClip();
}
コード例 #20
0
ファイル: WaveClip.cpp プロジェクト: tuanmasterit/audacity
bool WaveClip::Paste(double t0, WaveClip* other)
{
   WaveClip* pastedClip;

   bool clipNeedsResampling = other->mRate != mRate;

   if (clipNeedsResampling)
   {
      // The other clip's rate is different to our's, so resample
      pastedClip = new WaveClip(*other, mSequence->GetDirManager());
      if (!pastedClip->Resample(mRate))
      {
         delete pastedClip;
         return false;
      }
   } else
   {
      // No resampling needed, just use original clip without making a copy
      pastedClip = other;
   }

   sampleCount s0;
   TimeToSamplesClip(t0, &s0);

   // Force sample formats to match.
   if (pastedClip->mSequence->GetSampleFormat() != mSequence->GetSampleFormat())
      pastedClip->ConvertToSampleFormat(mSequence->GetSampleFormat());

   bool result = false;
   if (mSequence->Paste(s0, pastedClip->mSequence))
   {
      MarkChanged();
      mEnvelope->Paste((double)s0/mRate + mOffset, pastedClip->mEnvelope);
      mEnvelope->RemoveUnneededPoints();
      OffsetCutLines(t0, pastedClip->GetEndTime() - pastedClip->GetStartTime());
      
      // Paste cut lines contained in pasted clip
      for (WaveClipList::compatibility_iterator it = pastedClip->mCutLines.GetFirst(); it; it=it->GetNext())
      {
         WaveClip* cutline = it->GetData();
         WaveClip* newCutLine = new WaveClip(*cutline,
                                             mSequence->GetDirManager());
         newCutLine->Offset(t0 - mOffset);
         mCutLines.Append(newCutLine);
      }
      
      result = true;
   }
   
   if (clipNeedsResampling)
   {
      // Clip was constructed as a copy, so delete it
      delete pastedClip;
   }

   return result;
}
コード例 #21
0
void
DrawTargetSkia::CopySurface(SourceSurface *aSurface,
                            const IntRect& aSourceRect,
                            const IntPoint &aDestination)
{
  //TODO: We could just use writePixels() here if the sourceRect is the entire source

  if (aSurface->GetType() != SurfaceType::SKIA && aSurface->GetType() != SurfaceType::DATA) {
    return;
  }

  MarkChanged();

  TempBitmap bitmap = GetBitmapForSurface(aSurface);

  // This is a fast path that is disabled for now to mimimize risk
  if (false && !bitmap.mBitmap.getTexture() && mCanvas->getDevice()->config() == bitmap.mBitmap.config()) {
	SkBitmap bm(bitmap.mBitmap);
	bm.lockPixels();
	if (bm.getPixels()) {
	  SkImageInfo info = bm.info();
	  info.fWidth = aSourceRect.width;
	  info.fHeight = aSourceRect.height;
	  uint8_t* pixels = static_cast<uint8_t*>(bm.getPixels());
	  // adjust pixels for the source offset
	  pixels += aSourceRect.x + aSourceRect.y*bm.rowBytes();
	  mCanvas->writePixels(info, pixels, bm.rowBytes(), aDestination.x, aDestination.y);
	  return;
	}
  }

  mCanvas->save();
  mCanvas->resetMatrix();
  SkRect dest = IntRectToSkRect(IntRect(aDestination.x, aDestination.y, aSourceRect.width, aSourceRect.height)); 
  SkIRect source = IntRectToSkIRect(aSourceRect);
  mCanvas->clipRect(dest, SkRegion::kReplace_Op);
  SkPaint paint;

  if (mCanvas->getDevice()->config() == SkBitmap::kRGB_565_Config) {
    // Set the xfermode to SOURCE_OVER to workaround
    // http://code.google.com/p/skia/issues/detail?id=628
    // RGB565 is opaque so they're equivalent anyway
    paint.setXfermodeMode(SkXfermode::kSrcOver_Mode);
  } else {
    paint.setXfermodeMode(SkXfermode::kSrc_Mode);
  }
  // drawBitmapRect with A8 bitmaps ends up doing a mask operation
  // so we need to clear before
  if (bitmap.mBitmap.config() == SkBitmap::kA8_Config) {
    SkPaint clearPaint;
    clearPaint.setColor(SkColorSetARGB(0, 0, 0, 0));
    clearPaint.setXfermodeMode(SkXfermode::kSrc_Mode);
    mCanvas->drawPaint(clearPaint);
  }
  mCanvas->drawBitmapRect(bitmap.mBitmap, &source, dest, &paint);
  mCanvas->restore();
}
コード例 #22
0
ファイル: WaveTrack.cpp プロジェクト: Kirushanr/audacity
bool WaveTrack::AppendAlias(wxString fName, sampleCount start,
                            sampleCount len, int channel)
{
   MarkChanged();
   bool ret=mSequence->AppendAlias(fName, start, len, channel);
   if(ret==true)
      mEnvelope->SetTrackLen(mSequence->GetNumSamples() / mRate);

   return ret;
}
コード例 #23
0
ファイル: WaveClip.cpp プロジェクト: tuanmasterit/audacity
bool WaveClip::AppendCoded(wxString fName, sampleCount start,
                            sampleCount len, int channel, int decodeType)
{
   bool result = mSequence->AppendCoded(fName, start, len, channel, decodeType);
   if (result)
   {
      UpdateEnvelopeTrackLen();
      MarkChanged();
   }
   return result;
}
コード例 #24
0
ファイル: DrawTargetSkia.cpp プロジェクト: cbrem/gecko-dev
void
DrawTargetSkia::FillRect(const Rect &aRect,
                         const Pattern &aPattern,
                         const DrawOptions &aOptions)
{
  MarkChanged();
  SkRect rect = RectToSkRect(aRect);
  AutoPaintSetup paint(mCanvas.get(), aOptions, aPattern, &aRect);

  mCanvas->drawRect(rect, paint.mPaint);
}
コード例 #25
0
ファイル: WaveClip.cpp プロジェクト: tuanmasterit/audacity
bool WaveClip::AppendAlias(wxString fName, sampleCount start,
                            sampleCount len, int channel,bool useOD)
{
   bool result = mSequence->AppendAlias(fName, start, len, channel,useOD);
   if (result)
   {
      UpdateEnvelopeTrackLen();
      MarkChanged();
   }
   return result;
}
コード例 #26
0
ファイル: DrawTargetSkia.cpp プロジェクト: cbrem/gecko-dev
void
DrawTargetSkia::ClearRect(const Rect &aRect)
{
  MarkChanged();
  SkPaint paint;
  mCanvas->save();
  mCanvas->clipRect(RectToSkRect(aRect), SkRegion::kIntersect_Op, true);
  paint.setColor(SkColorSetARGB(0, 0, 0, 0));
  paint.setXfermodeMode(SkXfermode::kSrc_Mode);
  mCanvas->drawPaint(paint);
  mCanvas->restore();
}
コード例 #27
0
ファイル: WaveTrack.cpp プロジェクト: Kirushanr/audacity
bool WaveTrack::Silence(double t0, double t1)
{
   sampleCount s0, s1;

   if (t1 < t0)
      return false;

   TimeToSamplesClip(t0, &s0);
   TimeToSamplesClip(t1, &s1);

   MarkChanged();
   return mSequence->SetSilence(s0, s1-s0);
}
コード例 #28
0
ファイル: WaveClip.cpp プロジェクト: tuanmasterit/audacity
bool WaveClip::Append(samplePtr buffer, sampleFormat format,
                      sampleCount len, unsigned int stride /* = 1 */,
                      XMLWriter* blockFileLog /*=NULL*/)
{
   //wxLogDebug(wxT("Append: len=%i"), len);
   
   sampleCount maxBlockSize = mSequence->GetMaxBlockSize();
   sampleCount blockSize = mSequence->GetIdealAppendLen();
   sampleFormat seqFormat = mSequence->GetSampleFormat();

   if (!mAppendBuffer)
      mAppendBuffer = NewSamples(maxBlockSize, seqFormat);

   for(;;) {
      if (mAppendBufferLen >= blockSize) {
         bool success =
            mSequence->Append(mAppendBuffer, seqFormat, blockSize,
                              blockFileLog);
         if (!success)
            return false;
         memmove(mAppendBuffer,
                 mAppendBuffer + blockSize * SAMPLE_SIZE(seqFormat),
                 (mAppendBufferLen - blockSize) * SAMPLE_SIZE(seqFormat));
         mAppendBufferLen -= blockSize;
         blockSize = mSequence->GetIdealAppendLen();
      }

      if (len == 0)
         break;

      int toCopy = maxBlockSize - mAppendBufferLen;
      if (toCopy > len)
         toCopy = len;

      CopySamples(buffer, format,
                  mAppendBuffer + mAppendBufferLen * SAMPLE_SIZE(seqFormat),
                  seqFormat,
                  toCopy,
                  true, // high quality
                  stride);

      mAppendBufferLen += toCopy;
      buffer += toCopy * SAMPLE_SIZE(format) * stride;
      len -= toCopy;
   }

   UpdateEnvelopeTrackLen();
   MarkChanged();

   return true;
}
コード例 #29
0
ファイル: bb_sudoku.c プロジェクト: Aykut-/plb
/************************\ 
**  ProcessInitSingles  *****************************************\ 
**                                                              ** 
**    ProcessInitSingles takes a naked single and marks each    ** 
**    cell in the 3 associated groups as not allowing that      ** 
**    number.  It also marks the groups as changed so we know   ** 
**    to check for hidden singles in that group.                ** 
**                                                              ** 
**    This routines marks all the groups first, then marks the  ** 
**    cells for each changed groups.                            ** 
**                                                              ** 
\****************************************************************/ 
static void ProcessInitSingles (void) 
{ register unsigned char const *ucp; 
  register int i, t, g, t2, j; 
  unsigned int b; 
      
   while (SingleCnt > 2)  { 
      for (i = 0; i < SingleCnt; i++){ 
         t = SinglePos[i];                     // Get local copy of position 
         b = SingleVal[i];                     // Get local copy of the value 

         if (Gp->Grid[t] == 0) continue;   // Check if we already processed this position 
         if (!(Gp->Grid[t] & b)) {          // Check for error conditions 
            No_Sol = 1; SingleCnt = Changed = 0; 
            return; 
         }  
         SolGrid[t] = b; // Store the single in the solution grid 
         Gp->CellsLeft--;                  // mark one less empty space 
         Gp->Grid[t] = 0;                  // mark this position processed 
         ucp = C2Grp[t]; 
         for (g = 0; g < 3; g++) {              // loop through all 3 groups 
            if (Gp->Grp[*(ucp++)] & b) { 
               No_Sol = 1; SingleCnt = Changed = 0; 
               return; 
            }  
            Gp->Grp[C2Grp[t][g]] |= b;      // mark the value as found in the group 
            SingleGroup[C2Grp[t][g]]  = 1; 
         } 
      } 

      SingleCnt = 0; 
      for (i = 0; i < 27; i++) 
         if (SingleGroup[i]) { 
            SingleGroup[i] = 0; 
            for (j = 0; j < 9; j++) { 
               t2 = Group[i][j];                 // get temp copy of position 
               b = Gp->Grp[i]; 
               if (Gp->Grid[t2] & b) {        // check if removing a possibility 
                  Gp->Grid[t2] = Gp->Grid[t2] & ~b;   // remove possibility 
                  if (Gp->Grid[t2] == 0) {                 // check for error (no possibility) 
                     No_Sol = 1; SingleCnt = 0; Changed = 0; 
                     return; 
                  }  
                  if (B2V[Gp->Grid[t2]])                  // Check if a naked single is found 
                  PushSingle(t2, Gp->Grid[t2]);          
                  MarkChanged(t2);                            // Mark groups as changed 
               } 
            } 
         } 
   } 
} 
コード例 #30
0
ファイル: DrawTargetSkia.cpp プロジェクト: cbrem/gecko-dev
void
DrawTargetSkia::StrokeRect(const Rect &aRect,
                           const Pattern &aPattern,
                           const StrokeOptions &aStrokeOptions,
                           const DrawOptions &aOptions)
{
  MarkChanged();
  AutoPaintSetup paint(mCanvas.get(), aOptions, aPattern);
  if (!StrokeOptionsToPaint(paint.mPaint, aStrokeOptions)) {
    return;
  }

  mCanvas->drawRect(RectToSkRect(aRect), paint.mPaint);
}